Paged.The open publishing system
The technical handbook
Module commands

Paged Docs

Module commands

The typed commands the built-in modules offer — one id and one argument schema, run the same way from a script, an extension and the Node command line.

Tier: IntermediateIntermediateIIreferenceDraft

Reviewed against engine v0.74.2

What the editor's panels do, as commands with typed arguments.

In short Every built-in module contributes typed commands — an id, an argument schema and a result — to the host's object model. The editor's own panels and menus run them, and so can three other callers, with the same checks and the same undo steps:

CallerHow
A scriptJSON.parse(await paged.invoke(id, args)); paged.commands(owner?) lists them.
An extensionawait host.objects.invoke(id, args); host.objects.commands() lists them.
The Node command linepaged invoke <doc> <id> '<json>'; paged commands [doc] --owner <pluginId> lists them.

The commands on these pages are on main and ship with the next release. A module's commands exist only where its bundle is loaded: the editor loads every built-in module; the Node command line loads the bundles named with --plugins (in a checkout of paged-media/paged the modules are workspace packages; they are not published on npm). The engine's Rust command line has no plugin host, so a module command is out of its reach, and a script run there (paged script) has no host for paged.invoke.

Ids and arguments

A command id is the module's plugin id and the command's name:

ModuleIds
paged.drawmedia.paged.draw.command.<name>
paged.imagemedia.paged.image.command.<name>
paged.sheetmedia.paged.sheet.command.<name>
paged.datamedia.paged.data.<name>
paged.docmedia.paged.doc.command.<name>
paged.slidemedia.paged.slide.<name>
paged.publishmedia.paged.publish.<name>

The engine's own operations are typed commands too (core.<op>), one per catalog operation. paged commands --text prints each command's arguments (targets: list of ref to frame (JSON), widths: list of length …); give lengths as numbers in points. A field with a default may be left out. Arguments are checked against the schema before the command runs, so a misspelled field or a wrong type is refused with the field's path.

Objects are named by address, the same grammar paged get and paged.set take: textFrame:u12, page:#1, plugin:media.paged.sheet/workbook/main.

Bytes

A file going in (an image, a workbook, a deck) is an argument of kind bytes. JSON cannot carry bytes, so the Node command line reads them from a file:

paged invoke book.paged media.paged.sheet.command.importXlsx '{"bytes":"@book.xlsx"}'
paged invoke book.paged media.paged.sheet.command.importXlsx '{"bytes":{"$file":"book.xlsx"}}'
paged invoke book.paged media.paged.sheet.command.importXlsx '{"bytes":{"base64":"UEsDB…"}}'

A command that answers bytes (an exported file) is written with --result-out <file>: the result itself, or its one bytes field. An extension passes and receives a Uint8Array.

Results, refusals and undo

paged invoke prints { command, applied, result, saved, wrote } and, unless --no-save or -o says otherwise, writes the document back. A refused command — its arguments do not fit, or what it acts on cannot take it — prints { applied: false, error } and exits 1; in a script or an extension the promise rejects with the message, which starts with a code such as invalidValue: or failed:.

Each command that changes the document is one undo step unless its page says otherwise, and the template policy applies: a filler session may run only what the template permits.

Example: the same command three ways

In a script
const r = JSON.parse(await paged.invoke('media.paged.draw.command.widthProfile', {
  targets: ['polygon:u1f'],
  widths: [0, 8, 0],
}));
console.log(r.outlined);   // 1
In an extension
await host.objects.invoke('media.paged.draw.command.widthProfile', {
  targets: ['polygon:u1f'],
  widths: [0, 8, 0],
});
From the command line
paged-node invoke drawing.paged media.paged.draw.command.widthProfile \
  '{"targets":["polygon:u1f"],"widths":[0,8,0]}' --plugins=@paged-media/draw

On this page