@pptx-editor. dev/ core/ automation
Functions (4)
createAutomationHostfunctionSource ↗
Build a host over a port.
declare function createAutomationHost(composition: AutomationHostComposition): AutomationHost;createServerAutomationHostfunctionSource ↗
Open .pptx bytes as a headless host. Never throws for a malformed file.
declare function createServerAutomationHost(bytes: Uint8Array, options?: ServerAutomationOptions): {
readonly ok: true;
readonly host: AutomationHost;
} | {
readonly ok: false;
readonly error: ServerAutomationRejection;
};createStoreAutomationHostfunctionSource ↗
A host over a store: the server host's composition, and the base of the editor's.
declare function createStoreAutomationHost(store: PptxDocumentStore, options?: StoreAutomationOptions): AutomationHost;storeAutomationPortfunctionSource ↗
A port over a store this host owns or shares. New part names never reuse a name the store has held, so a name in the history always means one part.
declare function storeAutomationPort(store: PptxDocumentStore, options?: StoreAutomationOptions): AutomationDocumentPort;Interfaces (51)
AutomationAdjustmentsReadinterfaceSource ↗
The adjust values of a preset geometry (a:prstGeom/a:avLst, ECMA-376 Part 1, 20.1.9.5), in the order the preset defines them. A length is a fraction of the shape size (the guide value / 100 000); an angle is in degrees (the guide value / 60 000).
interface AutomationAdjustmentsRead| Member | Type | Summary |
|---|---|---|
| preset | string | `a:prstGeom/@prst`. |
| values | readonly number[] |
AutomationBackgroundFillReadinterfaceSource ↗
The fill of a background (p:bg, ECMA-376 Part 1, 19.3.1.1): the own one of the part, or the one it shows from the layout or master. Colors are #RRGGBB; transparency is 0 to 1.
interface AutomationBackgroundFillRead| Member | Type | Summary |
|---|---|---|
| backgroundColor | string | null | |
| color | string | null | The solid color. |
| foregroundColor | string | null | The pattern colors (`a:fgClr`, `a:bgClr`). |
| gradientType | string | null | The gradient shading: `linear` (`a:lin`), `circle`, `rect`, or `shape` (`a:path/@path`), or `shadeToTitle` (`p:bgPr/@shadeToTitle`). |
| pattern | string | null | The pattern preset (`ST_PresetPatternVal`). |
| transparency | number | null | The transparency of a solid color (`a:alpha`) or a picture (`a:alphaModFix`). |
| type | 'solid' | 'gradient' | 'pattern' | 'picture' | 'unsupported' | `solid`, `gradient`, `pattern`, `picture`, or `unsupported` (`a:noFill`, `a:grpFill`). |
AutomationBackgroundReadinterfaceSource ↗
The background of a slide, a layout, or a master.
interface AutomationBackgroundRead| Member | Type | Summary |
|---|---|---|
| fill | AutomationBackgroundFillRead | |
| followsMaster | boolean | The part has no own `p:bg`, so it shows the background of its layout or master. |
AutomationBatchRequestinterfaceSource ↗
One ordered batch, and the revision it was planned against.
interface AutomationBatchRequest| Member | Type | Summary |
|---|---|---|
| expectedRevision? | number | Refuse the whole batch unless the host is at this revision. |
| historyGroup? | string | Batches that carry the same group, one after the other, are one undo step in a host that keeps an undo history. A client sends one group for the batches of one sync that it splits. A host without a history ignores it. |
| operations | readonly AutomationOperation[] |
AutomationBatchResponseinterfaceSource ↗
A verdict, one result per operation in request order, and the revision afterwards.
interface AutomationBatchResponse| Member | Type | Summary |
|---|---|---|
| changed | boolean | Whether the batch moved the presentation. |
| ok | boolean | True only when every operation succeeded and the commands committed. |
| results | readonly AutomationOperationResult[] | |
| revision | number | The host's revision after the batch. Unchanged when nothing committed. |
AutomationBindingReadinterfaceSource ↗
One binding of the host: an id that names a shape. Bindings are never file content.
interface AutomationBindingRead| Member | Type | Summary |
|---|---|---|
| id | string | |
| type | 'shape' | What the binding names. Only `shape`. |
AutomationBoxinterfaceSource ↗
A box in points. Each field is optional on writes.
interface AutomationBox| Member | Type | Summary |
|---|---|---|
| height? | number | |
| left? | number | |
| top? | number | |
| width? | number |
AutomationCapabilitiesinterfaceSource ↗
What a host supports, fixed at construction and frozen.
A headless host reports selection false: it has no reader to select for, and refuses the selection operations rather than inventing a selection.
interface AutomationCapabilities| Member | Type | Summary |
|---|---|---|
| autofit | boolean | Text writes re-fit text bodies by their autofit rules (a text measurer is present). |
| document | boolean | Reading and editing the presentation. Every operation but the selection ones needs it. |
| events | boolean | Change notification through [AutomationHost.subscribe](AutomationHost.subscribe). |
| images | boolean | Pictures of slides and shapes through [AutomationHost.renderImage](AutomationHost.renderImage). Drawing needs a DOM and a canvas, so only a browser host reports it. |
| save | boolean | Serializing the current presentation back to `.pptx` bytes. |
| selection | boolean | A reader's slide, shape, or text selection exists and can be read and set. |
AutomationCellAddressinterfaceSource ↗
A table cell whose text body a text operation addresses instead of the shape's own: the cell at this grid position, or the anchor of the merged block that covers it.
interface AutomationCellAddress| Member | Type | Summary |
|---|---|---|
| column | number | |
| row | number |
AutomationCellMarginsWriteinterfaceSource ↗
Cell margins a write sets, in points. Null removes one, back to its default.
interface AutomationCellMarginsWrite| Member | Type | Summary |
|---|---|---|
| bottom? | number | null | |
| left? | number | null | |
| right? | number | null | |
| top? | number | null |
AutomationChangeEventinterfaceSource ↗
The presentation moved. Coarse on purpose: a consumer reads again what it needs.
interface AutomationChangeEvent| Member | Type | Summary |
|---|---|---|
| revision | number |
AutomationCustomPropertyReadinterfaceSource ↗
One custom document property (docProps/custom.xml, ECMA-376 Part 1, 22.3). A Date is an ISO 8601 text in UTC.
interface AutomationCustomPropertyRead| Member | Type | Summary |
|---|---|---|
| key | string | |
| type | 'String' | 'Number' | 'Boolean' | 'Date' | |
| value | string | number | boolean |
AutomationCustomXmlPartReadinterfaceSource ↗
One custom XML part (ECMA-376 Part 1, 22.5): its item id and the namespace of its root.
interface AutomationCustomXmlPartRead| Member | Type | Summary |
|---|---|---|
| id | string | `ds:itemID`, braced and upper case. |
| namespaceUri | string | The namespace URI of the root element, or an empty string. |
AutomationDocumentPortinterfaceSource ↗
What a host needs from the document it acts on.
interface AutomationDocumentPort| Member | Type | Summary |
|---|---|---|
| apply | | Commit ops as one transaction. A port with an undo history makes consecutive commits of one `historyGroup` a single undo step. |
| batch | | A working batch over `pkg` that keeps new part names unique for this document. |
| collaborating | | True while the document is in a collaboration room. A table structure edit then marks the table, as the editor's own table commands do, so a save repairs the merge markup that a concurrent edit of a peer leaves. |
| committed | | Called once after a batch that changed the document has committed and moved the selection. A browser port records the selection after the batch for redo. |
| currentPackage | | The committed package, or null while there is none (an editor between mounts). |
| dispose | | Release the port. |
| document | | Which document the port holds now, for a port that can change it (an editor that loads another presentation). A change forgets every handle, so an object of the previous document never addresses an object of the new one that has the same id. |
| measurer | | The measurer text writes re-fit with, when the host has one. |
| renderImage | | A PNG picture of a slide or of one shape of it, from the committed package, for a host with the `images` capability. Rejects with a `CommandRefusal` when it cannot draw. |
| revision | | Monotonic revision of the document. |
| save | | The document as `.pptx` bytes, or null when there is none. |
| selection? | AutomationSelectionPort | The reader's selection, for a browser host. |
| subscribe | | Change notification for commits by anyone. |
| wholeDocument | | Make the whole document ready for a reader of every part, as `save` does: a deck that is still opening opens the rest now. False when the document cannot be read whole (a slide did not parse). A port without it is always whole. |
AutomationErrorinterfaceSource ↗
One refused operation. Plain data, not an Error: it crosses transports.
code is the stable part. detail is for logs and for the object model's diagnostic code; the object model never copies it into a message, because a store rejection reason would become documented API the moment somebody matched on it.
interface AutomationError| Member | Type | Summary |
|---|---|---|
| code | AutomationErrorCode | |
| detail? | string | Machine-ish specifics: the store's rejection reason, the bad argument's name. |
| message | string | Human-readable, for a log. Never parsed. |
AutomationFillReadinterfaceSource ↗
A shape fill. Colors are #RRGGBB; transparency is 0 to 1.
interface AutomationFillRead| Member | Type | Summary |
|---|---|---|
| foregroundColor | string | null | |
| transparency | number | null | |
| type | string | `noFill`, `solid`, `gradient`, `pattern`, `pictureAndTexture`, or `slideBackground`. |
AutomationFontReadinterfaceSource ↗
The effective font of a text range. A field the runs disagree on is null.
interface AutomationFontRead| Member | Type | Summary |
|---|---|---|
| allCaps | boolean | null | |
| bold | boolean | null | |
| color | string | null | |
| doubleStrikethrough | boolean | null | |
| italic | boolean | null | |
| name | string | null | |
| size | number | null | |
| smallCaps | boolean | null | |
| strikethrough | boolean | null | |
| subscript | boolean | null | |
| superscript | boolean | null | |
| underline | string | null | `a:rPr/@u`, `none` without an underline. |
AutomationFontWriteinterfaceSource ↗
Font properties a write sets.
interface AutomationFontWrite| Member | Type | Summary |
|---|---|---|
| allCaps? | boolean | |
| bold? | boolean | |
| color? | string | |
| doubleStrikethrough? | boolean | |
| italic? | boolean | |
| name? | string | |
| size? | number | Points. |
| smallCaps? | boolean | |
| strikethrough? | boolean | |
| subscript? | boolean | |
| superscript? | boolean | |
| underline? | string | `ST_TextUnderlineType`. |
AutomationHandleinterfaceSource ↗
A stable reference to one presentation object, valid for the life of its host.
interface AutomationHandle<K extends AutomationObjectKind = AutomationObjectKind>| Member | Type | Summary |
|---|---|---|
| kind | K | |
| ref | AutomationHandleRef |
AutomationHostinterfaceSource ↗
The protocol both hosts implement.
A batch is one revision, one undo step, and one transaction. Operations run in order, so a read sees the writes before it in the same batch. If any operation is refused, nothing is written.
interface AutomationHost| Member | Type | Summary |
|---|---|---|
| capabilities | AutomationCapabilities | |
| dispose | | Release everything this host holds. Idempotent; every later call fails `disposed`. |
| execute | | Run one ordered batch. |
| renderImage | | A PNG picture of a slide or a shape, drawn from the current presentation. A host without the `images` capability answers `unsupported-capability`. |
| revision | | Monotonic revision of the presentation this host acts on. |
| save | | The current presentation as `.pptx` bytes, through the normalizing writer. |
| subscribe | | Change notification. Returns an unsubscribe that is safe to call more than once. |
AutomationHostCompositioninterfaceSource ↗
The port and the capabilities a host claims.
interface AutomationHostComposition| Member | Type | Summary |
|---|---|---|
| capabilities | AutomationCapabilities | |
| port | AutomationDocumentPort |
AutomationHyperlinkReadinterfaceSource ↗
One hyperlink of a slide.
interface AutomationHyperlinkRead| Member | Type | Summary |
|---|---|---|
| address | string | null | |
| length | number | null | |
| screenTip | string | null | |
| shape | AutomationHandle<'shape'> | |
| start | number | null | For a text link: the range it covers in the shape's text. |
| type | 'textRange' | 'shape' | `textRange` or `shape`: what carries the link. |
AutomationImageRequestinterfaceSource ↗
What [AutomationHost.renderImage](AutomationHost.renderImage) draws.
interface AutomationImageRequest| Member | Type | Summary |
|---|---|---|
| height? | number | The height of that box. Absent sizes: the picture has its own size. |
| target | AutomationHandle | A slide, or a shape on a slide, as a `prepareImage` operation answered it. |
| width? | number | The width of the box the picture fits into, in pixels, keeping its aspect ratio. |
AutomationImageTargetinterfaceSource ↗
What the port draws (AutomationDocumentPort.renderImage): a slide, or one shape of it.
interface AutomationImageTarget| Member | Type | Summary |
|---|---|---|
| height? | number | The height of that box. |
| shapeNodeId? | string | The tree node id of the shape; absent for the whole slide. |
| slideIndex | number | The index of the slide in the presentation. |
| width? | number | The width of the box the picture fits into, in pixels, keeping its aspect ratio. |
AutomationInsertSlidesOptionsinterfaceSource ↗
Options of a slide import (Office.js InsertSlideOptions).
interface AutomationInsertSlidesOptions| Member | Type | Summary |
|---|---|---|
| formatting? | 'keepSource' | 'useDestinationTheme' | Keep the source layouts, masters, and themes (default), or use this presentation's. |
| sourceSlideIds? | readonly string[] | The source slides, by slide id, in the order they go in. Absent: every slide. |
| targetSlideId? | string | The slide the new slides follow, by id. Absent: they go first. |
AutomationLayoutReadinterfaceSource ↗
A layout or master.
interface AutomationLayoutRead| Member | Type | Summary |
|---|---|---|
| id | string | `p:sldLayoutId/@id` or `p:sldMasterId/@id`, as a string. |
| master | AutomationHandle<'slideMaster'> | null | |
| name | string | |
| type | string | null | For a layout: `p:sldLayout/@type` (`cust` when absent). Null for a master. |
AutomationLineReadinterfaceSource ↗
A shape outline. The weight is in points.
interface AutomationLineRead| Member | Type | Summary |
|---|---|---|
| color | string | null | |
| dashStyle | string | null | The `a:prstDash/@val` value, or null. |
| style | string | null | The compound line (`a:ln/@cmpd`). |
| transparency | number | null | |
| visible | boolean | |
| weight | number | null |
AutomationLineWriteinterfaceSource ↗
Outline properties a write sets.
interface AutomationLineWrite| Member | Type | Summary |
|---|---|---|
| color? | string | |
| dashStyle? | string | `ST_PresetLineDashVal`. |
| style? | string | `ST_CompoundLine`. |
| transparency? | number | |
| visible? | boolean | |
| weight? | number | Points. |
AutomationParagraphReadinterfaceSource ↗
The effective paragraph format of a text range. A field the paragraphs disagree on is null.
interface AutomationParagraphRead| Member | Type | Summary |
|---|---|---|
| alignment | string | null | `a:pPr/@algn`: `l`, `ctr`, `r`, `just`, `justLow`, `dist`, or `thaiDist`. |
| bulletStyle | string | null | The autonumber scheme (`ST_TextAutonumberScheme`) when numbered. |
| bulletType | string | null | `none`, `char`, or `autonum`. |
| bulletVisible | boolean | null | |
| indentLevel | number | null | 1-based list level (`a:pPr/@lvl` + 1). |
AutomationParagraphWriteinterfaceSource ↗
Paragraph properties a write sets.
interface AutomationParagraphWrite| Member | Type | Summary |
|---|---|---|
| alignment? | string | `ST_TextAlignType`. |
| bulletStyle? | string | |
| bulletType? | 'none' | 'char' | 'autonum' | `autonum` with a scheme, or `char`. |
| bulletVisible? | boolean | |
| indentLevel? | number | 1-based list level, 1 to 9. |
AutomationPlaceholderReadinterfaceSource ↗
ST_PlaceholderType read as the object model names it.
interface AutomationPlaceholderRead| Member | Type | Summary |
|---|---|---|
| containedType | string | null | What the shape holds now: its own kind, as `AutomationShapeRead.type` spells it. |
| type | string | The `p:ph/@type` value (`obj` when absent, ECMA-376 Part 1, 19.7.10). |
AutomationPresentationReadinterfaceSource ↗
The presentation. Lengths in points.
interface AutomationPresentationRead| Member | Type | Summary |
|---|---|---|
| id | string | A stable id for the open presentation in this host. |
| slideHeight | number | |
| slideWidth | number | |
| title | string | The core properties title. |
AutomationPropertiesReadinterfaceSource ↗
The core and extended document properties.
interface AutomationPropertiesRead| Member | Type | Summary |
|---|---|---|
| author | string | |
| category | string | |
| comments | string | |
| company | string | |
| creationDate | string | null | |
| keywords | string | |
| lastAuthor | string | |
| manager | string | |
| revisionNumber | number | |
| subject | string | |
| title | string |
AutomationPropertiesWriteinterfaceSource ↗
Document properties a write sets.
interface AutomationPropertiesWrite| Member | Type | Summary |
|---|---|---|
| author? | string | |
| category? | string | |
| comments? | string | |
| company? | string | |
| keywords? | string | |
| manager? | string | |
| revisionNumber? | number | |
| subject? | string | |
| title? | string |
AutomationResultRefinterfaceSource ↗
The object an earlier operation of the same batch answered with, by its index.
How one batch adds a slide and then writes to it: the slide has no handle until the add runs, so the write names the add's result instead. A reference to an operation that answered null (getSlide with orNull) makes a read answer null and a write fail with invalid-handle.
interface AutomationResultRef| Member | Type | Summary |
|---|---|---|
| result | number |
AutomationSelectionPortinterfaceSource ↗
A reader's selection, as the browser host's port reports and sets it.
interface AutomationSelectionPort| Member | Type | Summary |
|---|---|---|
| read | | The selected slides (`p:sldId/@id`), the selected shapes, and the selected text. |
| selectShapes | | |
| selectSlides | | |
| selectText | |
AutomationSelectionReadinterfaceSource ↗
A reader's selection (browser host).
interface AutomationSelectionRead| Member | Type | Summary |
|---|---|---|
| shapes | readonly AutomationHandle<'shape'>[] | |
| slides | readonly AutomationHandle<'slide'>[] | |
| text | {
readonly shape: AutomationHandle<'shape'>;
readonly start: number;
readonly length: number;
} | null | The selected text: a shape and a range of its text, or null. |
AutomationShapeReadinterfaceSource ↗
One shape, as plain values. Lengths in points, the rotation in degrees.
interface AutomationShapeRead| Member | Type | Summary |
|---|---|---|
| altTextDescription | string | |
| altTextTitle | string | |
| geometry | string | null | The preset geometry (`a:prstGeom/@prst`), or null. |
| hasTextFrame | boolean | Whether the shape can hold text (`p:txBody`). |
| height | number | |
| id | string | `p:cNvPr/@id` as a string. |
| isDecorative | boolean | The decorative flag of the `a16:decorative` extension. |
| left | number | |
| level | number | Group depth: 0 for a top-level shape. |
| name | string | |
| parentGroup | AutomationHandle<'shape'> | null | |
| placeholder | AutomationPlaceholderRead | null | |
| rotation | number | |
| top | number | |
| type | string | `geometricShape`, `line`, `textBox`, `placeholder`, `image`, `group`, `table`, `chart`, `diagram` (a `dgm:` frame), `media`, `ole`, `freeform`, or `unsupported`. |
| visible | boolean | |
| width | number | |
| zOrderPosition | number | Position in the owner's z-order, from 0 at the back. |
AutomationShapeWriteinterfaceSource ↗
Shape properties a write sets.
interface AutomationShapeWrite extends AutomationBox| Member | Type | Summary |
|---|---|---|
| altTextDescription? | string | |
| altTextTitle? | string | |
| isDecorative? | boolean | |
| name? | string | |
| rotation? | number | |
| visible? | boolean |
AutomationSlideReadinterfaceSource ↗
A slide.
interface AutomationSlideRead| Member | Type | Summary |
|---|---|---|
| id | string | `p:sldId/@id`, as a string. |
| index | number | |
| layout | AutomationHandle<'slideLayout'> | null | |
| master | AutomationHandle<'slideMaster'> | null |
AutomationTableCellFormatReadinterfaceSource ↗
The borders and margins of one table cell (a:tcPr, ECMA-376 Part 1, 21.1.3.17). A border reads as the cell shows it: its own line, else the table style's on a slide. Margins in points.
interface AutomationTableCellFormatRead| Member | Type | Summary |
|---|---|---|
| borders | {
readonly left: AutomationLineRead;
readonly right: AutomationLineRead;
readonly top: AutomationLineRead;
readonly bottom: AutomationLineRead;
readonly diagonalDown: AutomationLineRead;
readonly diagonalUp: AutomationLineRead;
} | |
| margins | {
readonly left: number;
readonly right: number;
readonly top: number;
readonly bottom: number;
} |
AutomationTableCellReadinterfaceSource ↗
One cell of a table, at its grid position.
interface AutomationTableCellRead| Member | Type | Summary |
|---|---|---|
| anchor | string | `ST_TextAnchoringType` of the cell (`a:tcPr/@anchor`, default `t`). |
| anchorCenter | boolean | `a:tcPr/@anchorCtr`. |
| columnCount | number | |
| columnIndex | number | |
| rowCount | number | The rows and columns the cell spans. |
| rowIndex | number | |
| text | string |
AutomationTableReadinterfaceSource ↗
A table's grid and values. Widths and heights in points.
interface AutomationTableRead| Member | Type | Summary |
|---|---|---|
| columnCount | number | |
| columnWidths | readonly number[] | |
| mergedAreas | readonly {
readonly rowIndex: number;
readonly columnIndex: number;
readonly rowCount: number;
readonly columnCount: number;
}[] | Merged areas, top-left cell first. |
| rowCount | number | |
| rowHeights | readonly number[] | |
| style | {
readonly styleId: string | null;
readonly styleName: string | null;
readonly firstRow: boolean;
readonly lastRow: boolean;
readonly firstColumn: boolean;
readonly lastColumn: boolean;
readonly bandedRows: boolean;
readonly bandedColumns: boolean;
} | `a:tblPr` flags and the style id. |
| values | readonly (readonly string[])[] |
AutomationTableStyleWriteinterfaceSource ↗
Table style options (a:tblPr flags, ECMA-376 Part 1, 21.1.3.15) and the style a write sets.
interface AutomationTableStyleWrite| Member | Type | Summary |
|---|---|---|
| bandedColumns? | boolean | |
| bandedRows? | boolean | |
| firstColumn? | boolean | |
| firstRow? | boolean | |
| lastColumn? | boolean | |
| lastRow? | boolean | |
| styleName? | string | null | The style by its `styleName`: one the presentation defines in `ppt/tableStyles.xml`, or the built-in default. Null removes the style choice. |
AutomationTaginterfaceSource ↗
One key and value of a tag list (p:tagLst).
interface AutomationTag| Member | Type | Summary |
|---|---|---|
| key | string | |
| value | string |
AutomationTextFrameReadinterfaceSource ↗
A text body's frame. Margins in points.
interface AutomationTextFrameRead| Member | Type | Summary |
|---|---|---|
| autoSize | 'none' | 'normal' | 'shape' | `none`, `normal` (`a:normAutofit`), or `shape` (`a:spAutoFit`). |
| bottomMargin | number | |
| hasText | boolean | |
| leftMargin | number | |
| rightMargin | number | |
| topMargin | number | |
| verticalAlignment | string | `a:bodyPr/@anchor`, with `anchorCtr` (`ctr` + centered reads as `ctrCentered`). |
| wordWrap | boolean |
AutomationTextFrameWriteinterfaceSource ↗
Text frame properties a write sets. Margins in points.
interface AutomationTextFrameWrite| Member | Type | Summary |
|---|---|---|
| autoSize? | 'none' | 'normal' | 'shape' | |
| bottomMargin? | number | |
| leftMargin? | number | |
| rightMargin? | number | |
| topMargin? | number | |
| verticalAlignment? | string | `t`, `ctr`, `b`, or with a centered column `tCentered`, `ctrCentered`, `bCentered`. |
| wordWrap? | boolean |
AutomationTextRunReadinterfaceSource ↗
One run of a text body with its effective character format.
interface AutomationTextRunRead| Member | Type | Summary |
|---|---|---|
| font | AutomationFontRead | |
| text | string | The run text; a paragraph break reads as `\r` and a line break as `\v`. |
AutomationTextSpaninterfaceSource ↗
A stretch of a shape's text: a UTF-16 start and length. Absent means the whole text.
interface AutomationTextSpan| Member | Type | Summary |
|---|---|---|
| length | number | |
| start | number |
ServerAutomationOptionsinterfaceSource ↗
Options for a host over bytes.
interface ServerAutomationOptions extends StoreAutomationOptions| Member | Type | Summary |
|---|---|---|
| limits? | ZipLimits | Zip limits for the bounded reader. |
StoreAutomationOptionsinterfaceSource ↗
How a store host commits and measures.
interface StoreAutomationOptions| Member | Type | Summary |
|---|---|---|
| collaborating? | boolean | The store is shared with a collaboration room. A table structure edit then marks the table, as the editor's table commands do in a room. Default `false`. |
| label? | string | The label of each committed transaction (undo history). Default `automation`. |
| measurer? | TextMeasurer | The measurer text writes re-fit with (ECMA-376 Part 1, 21.1.2.1). Without one, a text write keeps the shape's size and font scale as they are. |
| renderImage? | (target: AutomationImageTarget) => Promise<Uint8Array> | Draws a PNG picture of a slide, or of one shape of it, from the committed package. With it, the host claims the `images` capability and `getImageAsBase64` works; without it, a picture request refuses with `unsupported-capability`. This lane has no layout or paint, so the caller supplies the drawing: `@pptx-editor.dev/editor-api` builds it from the editor's own paint and a rasterizer (`createServer({ rasterize })`). Rejects with a `CommandRefusal` when it cannot draw. |
Type aliases (18)
AutomationBackgroundWritetypeSource ↗
A background write (p:cSld/p:bg, ECMA-376 Part 1, 19.3.1.1). A fill write gives the part an own p:bgPr; a field it leaves out keeps the current value, or takes the default.
type AutomationBackgroundWrite =
/** Remove the own `p:bg`: show the background of the layout or master. */
{
readonly kind: 'follow';
}
/** Copy the background the part shows into an own `p:bg`. */
| {
readonly kind: 'own';
}
/** `showMasterSp`: hide or show the shapes of the level above. */
| {
readonly kind: 'graphicsHidden';
readonly hidden: boolean;
} | {
readonly kind: 'solid';
readonly color?: string;
readonly transparency?: number;
}
/** The gradient shading: `linear`, or an `a:path` of `circle`, `rect`, or `shape`. */
| {
readonly kind: 'gradient';
readonly gradientType?: 'linear' | 'circle' | 'rect' | 'shape';
} | {
readonly kind: 'pattern';
readonly pattern?: string;
readonly foregroundColor?: string;
readonly backgroundColor?: string;
}
/** A stretched picture from PNG, JPEG, or GIF bytes in base64, or the current picture. */
| {
readonly kind: 'picture';
readonly base64?: string;
readonly transparency?: number;
};AutomationCellBorderSidetypeSource ↗
A line of a table cell: an edge, or a diagonal (a:lnTlToBr down, a:lnBlToTr up).
type AutomationCellBorderSide = 'left' | 'right' | 'top' | 'bottom' | 'diagonalDown' | 'diagonalUp';AutomationCustomPropertyWritetypeSource ↗
A custom property value a write sets. A Date is an ISO 8601 text.
type AutomationCustomPropertyWrite = {
readonly type: 'String';
readonly value: string;
} | {
readonly type: 'Number';
readonly value: number;
} | {
readonly type: 'Boolean';
readonly value: boolean;
} | {
readonly type: 'Date';
readonly value: string;
};AutomationErrorCodetypeSource ↗
Why an operation was refused, as a value to branch on.
Distinguishable on purpose: the object model maps each code to a different error, and a caller that retries stale-revision must not retry invalid-handle.
type AutomationErrorCode =
/** Nothing was applied: `expectedRevision` did not match the host's revision. */
'stale-revision'
/** A handle this host never minted, one of another kind, or one whose object is gone. */
| 'invalid-handle'
/** An argument outside its range: an index, an offset, a length, a size. */
| 'invalid-argument'
/** The operation needs a capability this host reports false. */
| 'unsupported-capability'
/** The host has been disposed. Every later call fails this way. */
| 'disposed'
/** The store refused the transaction; nothing was applied. */
| 'transaction-refused'
/** The operation is not one this protocol version defines. */
| 'unknown-operation'
/** The target holds content this operation does not edit (a chart, a diagram, a picture). */
| 'unsupported-content'
/** A lookup by key or index found nothing, and the caller did not ask for null. */
| 'item-not-found'
/** The host is live but holds no presentation right now (an editor between mounts). */
| 'document-unavailable';AutomationFillWritetypeSource ↗
A fill write. Colors are #RRGGBB or a preset color name; transparency is 0 to 1.
type AutomationFillWrite = {
readonly kind: 'solid';
readonly color: string;
readonly transparency?: number;
} | {
readonly kind: 'clear';
}
/** Change the transparency of the current solid fill. */
| {
readonly kind: 'transparency';
readonly transparency: number;
}
/** A picture fill (`a:blipFill`) from PNG, JPEG, or GIF bytes in base64, stretched. */
| {
readonly kind: 'image';
readonly base64: string;
};AutomationHandleReftypeSource ↗
An opaque host-minted name for a presentation object.
Branded so a consumer cannot invent one. Its content is meaningless outside the host that minted it: each host draws a random token when it starts and stamps it into every ref, so a ref passed to another host, even one open on the same bytes, is invalid-handle.
type AutomationHandleRef = string & {
readonly [AUTOMATION_HANDLE_BRAND]: 'handle';
};AutomationImageResulttypeSource ↗
A PNG picture as base64, or why it could not be drawn.
type AutomationImageResult = {
readonly ok: true;
readonly base64: string;
} | {
readonly ok: false;
readonly error: AutomationError;
};AutomationItemKeytypeSource ↗
How a collection item is found: by position, or by the id the object model shows.
type AutomationItemKey = {
readonly index: number;
} | {
readonly id: string;
};AutomationNewShapetypeSource ↗
What a new shape is.
type AutomationNewShape =
/** A preset geometry (`ST_ShapeType`, ECMA-376 Part 1, 20.1.10.56). */
{
readonly kind: 'geometric';
readonly geometry: string;
}
/** A connector: `straight`, `elbow`, or `curve`. */
| {
readonly kind: 'line';
readonly connector: 'straight' | 'elbow' | 'curve';
} | {
readonly kind: 'textBox';
readonly text: string;
} | {
readonly kind: 'table';
readonly rows: number;
readonly columns: number;
readonly values?: readonly (readonly string[])[];
};AutomationObjectKindtypeSource ↗
What kind of presentation object a handle names.
type AutomationObjectKind = 'presentation' | 'slide' | 'slideLayout' | 'slideMaster' | 'shape';AutomationOperationtypeSource ↗
Every operation a host understands.
type AutomationOperation = {
readonly op: 'getPresentation';
} | {
readonly op: 'readPresentation';
} | {
readonly op: 'setPageSetup';
readonly slideWidth?: number;
readonly slideHeight?: number;
} | {
readonly op: 'getProperties';
} | {
readonly op: 'setProperties';
readonly properties: AutomationPropertiesWrite;
} | {
readonly op: 'readCustomProperties';
readonly owner: AutomationRef;
} | {
readonly op: 'setCustomProperty';
readonly owner: AutomationRef;
readonly key: string;
readonly value: AutomationCustomPropertyWrite;
} | {
readonly op: 'deleteCustomProperty';
readonly owner: AutomationRef;
readonly key: string;
} | {
readonly op: 'deleteCustomProperties';
readonly owner: AutomationRef;
} | {
readonly op: 'listCustomXmlParts';
readonly owner: AutomationRef;
readonly namespaceUri?: string;
} | {
readonly op: 'readCustomXml';
readonly owner: AutomationRef;
readonly id: string;
} | {
readonly op: 'addCustomXmlPart';
readonly owner: AutomationRef;
readonly xml: string;
readonly id?: string;
} | {
readonly op: 'setCustomXml';
readonly owner: AutomationRef;
readonly id: string;
readonly xml: string;
} | {
readonly op: 'deleteCustomXmlPart';
readonly owner: AutomationRef;
readonly id: string;
} | {
readonly op: 'listSlides';
} | {
readonly op: 'getSlide';
readonly key: AutomationItemKey;
readonly orNull?: boolean;
} | {
readonly op: 'readSlide';
readonly slide: AutomationRef;
} | {
readonly op: 'addSlide';
readonly index?: number;
readonly layout?: AutomationRef;
readonly master?: AutomationRef;
readonly layoutId?: string;
readonly masterId?: string;
} | {
readonly op: 'getSlideLayout';
readonly slide: AutomationRef;
} | {
readonly op: 'getSlideMaster';
readonly owner: AutomationRef;
} | {
readonly op: 'deleteSlide';
readonly slide: AutomationRef;
} | {
readonly op: 'moveSlide';
readonly slide: AutomationRef;
readonly index: number;
} | {
readonly op: 'applyLayout';
readonly slide: AutomationRef;
readonly layout: AutomationRef;
} | {
readonly op: 'exportSlides';
readonly slides: readonly AutomationRef[];
} | {
readonly op: 'prepareImage';
readonly target: AutomationRef;
readonly width?: number;
readonly height?: number;
} | {
readonly op: 'insertSlides';
readonly base64: string;
readonly options?: AutomationInsertSlidesOptions;
} | {
readonly op: 'listHyperlinks';
readonly slide: AutomationRef;
} | {
readonly op: 'listBindings';
readonly owner: AutomationRef;
} | {
readonly op: 'addBinding';
readonly owner: AutomationRef;
readonly shape: AutomationRef;
readonly id: string;
} | {
readonly op: 'addBindingFromSelection';
readonly owner: AutomationRef;
readonly id: string;
} | {
readonly op: 'deleteBinding';
readonly owner: AutomationRef;
readonly id: string;
} | {
readonly op: 'getBindingShape';
readonly owner: AutomationRef;
readonly id: string;
} | {
readonly op: 'listMasters';
} | {
readonly op: 'getMaster';
readonly key: AutomationItemKey;
readonly orNull?: boolean;
} | {
readonly op: 'readMaster';
readonly master: AutomationRef;
} | {
readonly op: 'listLayouts';
readonly master: AutomationRef;
} | {
readonly op: 'getLayout';
readonly master: AutomationRef;
readonly key: AutomationItemKey;
readonly orNull?: boolean;
} | {
readonly op: 'readLayout';
readonly layout: AutomationRef;
} | {
readonly op: 'listShapes';
readonly container: AutomationRef;
readonly orNull?: boolean;
} | {
readonly op: 'getShape';
readonly container: AutomationRef;
readonly key: AutomationItemKey;
readonly orNull?: boolean;
} | {
readonly op: 'readShape';
readonly shape: AutomationRef;
readonly group?: boolean;
readonly orNull?: boolean;
} | {
readonly op: 'addShape';
readonly container: AutomationRef;
readonly shape: AutomationNewShape;
readonly box?: AutomationBox;
} | {
readonly op: 'deleteShape';
readonly shape: AutomationRef;
} | {
readonly op: 'setShape';
readonly shape: AutomationRef;
readonly props: AutomationShapeWrite;
} | {
readonly op: 'setZOrder';
readonly shape: AutomationRef;
readonly position: AutomationZOrder;
} | {
readonly op: 'group';
readonly shapes: readonly AutomationRef[];
} | {
readonly op: 'ungroup';
readonly group: AutomationRef;
} | {
readonly op: 'getParentGroup';
readonly shape: AutomationRef;
readonly orNull?: boolean;
} | {
readonly op: 'setShapeHyperlink';
readonly shape: AutomationRef;
readonly address: string | null;
readonly screenTip?: string;
} | {
readonly op: 'parentOf';
readonly shape: AutomationRef;
readonly kind: 'slide' | 'slideLayout' | 'slideMaster';
readonly orNull?: boolean;
} | {
readonly op: 'readFill';
readonly shape: AutomationRef;
readonly cell?: AutomationCellAddress;
} | {
readonly op: 'setFill';
readonly shape: AutomationRef;
readonly fill: AutomationFillWrite;
readonly cell?: AutomationCellAddress;
} | {
readonly op: 'readBackground';
readonly owner: AutomationRef;
} | {
readonly op: 'setBackground';
readonly owner: AutomationRef;
readonly background: AutomationBackgroundWrite;
}
/** A color of the theme's `a:clrScheme`: `dk1`, `lt1`, … `accent6`, `hlink`, `folHlink`. */
| {
readonly op: 'readThemeColor';
readonly owner: AutomationRef;
readonly slot: string;
} | {
readonly op: 'setThemeColor';
readonly owner: AutomationRef;
readonly slot: string;
readonly color: string;
} | {
readonly op: 'readLine';
readonly shape: AutomationRef;
} | {
readonly op: 'setLine';
readonly shape: AutomationRef;
readonly line: AutomationLineWrite;
} | {
readonly op: 'readTextFrame';
readonly shape: AutomationRef;
readonly orNull?: boolean;
} | {
readonly op: 'setTextFrame';
readonly shape: AutomationRef;
readonly props: AutomationTextFrameWrite;
} | {
readonly op: 'readText';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly cell?: AutomationCellAddress;
readonly orNull?: boolean;
} | {
readonly op: 'setText';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly text: string;
readonly cell?: AutomationCellAddress;
} | {
readonly op: 'readFont';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly cell?: AutomationCellAddress;
readonly orNull?: boolean;
} | {
readonly op: 'readTextRuns';
readonly shape: AutomationRef;
readonly cell?: AutomationCellAddress;
} | {
readonly op: 'setFont';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly font: AutomationFontWrite;
readonly cell?: AutomationCellAddress;
} | {
readonly op: 'readParagraph';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly cell?: AutomationCellAddress;
readonly orNull?: boolean;
} | {
readonly op: 'setParagraph';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly paragraph: AutomationParagraphWrite;
readonly cell?: AutomationCellAddress;
} | {
readonly op: 'setHyperlink';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
readonly address: string | null;
readonly screenTip?: string;
} | {
readonly op: 'listTextHyperlinks';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
} | {
readonly op: 'readTags';
readonly owner: AutomationRef;
} | {
readonly op: 'setTag';
readonly owner: AutomationRef;
readonly key: string;
readonly value: string;
} | {
readonly op: 'deleteTag';
readonly owner: AutomationRef;
readonly key: string;
} | {
readonly op: 'readTable';
readonly shape: AutomationRef;
} | {
readonly op: 'readTableCell';
readonly shape: AutomationRef;
readonly row: number;
readonly column: number;
} | {
readonly op: 'setTableCell';
readonly shape: AutomationRef;
readonly row: number;
readonly column: number;
readonly text: string;
} | {
readonly op: 'insertTableRows';
readonly shape: AutomationRef;
readonly index?: number;
readonly count: number;
} | {
readonly op: 'insertTableColumns';
readonly shape: AutomationRef;
readonly index?: number;
readonly count: number;
} | {
readonly op: 'deleteTableRows';
readonly shape: AutomationRef;
readonly index: number;
readonly count: number;
} | {
readonly op: 'deleteTableColumns';
readonly shape: AutomationRef;
readonly index: number;
readonly count: number;
} | {
readonly op: 'mergeTableCells';
readonly shape: AutomationRef;
readonly row: number;
readonly column: number;
readonly rowCount: number;
readonly columnCount: number;
} | {
readonly op: 'setTableCellAnchor';
readonly shape: AutomationRef;
readonly row: number;
readonly column: number;
readonly anchor: string;
readonly anchorCenter: boolean;
} | {
readonly op: 'splitTableCell';
readonly shape: AutomationRef;
readonly row: number;
readonly column: number;
readonly rowCount: number;
readonly columnCount: number;
} | {
readonly op: 'resizeTableCell';
readonly shape: AutomationRef;
readonly row: number;
readonly column: number;
readonly rowCount: number;
readonly columnCount: number;
} | {
readonly op: 'clearTable';
readonly shape: AutomationRef;
readonly text: boolean;
readonly format: boolean;
} | {
readonly op: 'readTableCellFormat';
readonly shape: AutomationRef;
readonly cell: AutomationCellAddress;
} | {
readonly op: 'setTableCellBorder';
readonly shape: AutomationRef;
readonly cell: AutomationCellAddress;
readonly side: AutomationCellBorderSide;
readonly line: AutomationLineWrite;
} | {
readonly op: 'setTableCellMargins';
readonly shape: AutomationRef;
readonly cell: AutomationCellAddress;
readonly margins: AutomationCellMarginsWrite;
} | {
readonly op: 'setTableStyle';
readonly shape: AutomationRef;
readonly style: AutomationTableStyleWrite;
} | {
readonly op: 'readAdjustments';
readonly shape: AutomationRef;
} | {
readonly op: 'setAdjustment';
readonly shape: AutomationRef;
readonly index: number;
readonly value: number;
} | {
readonly op: 'setTableSize';
readonly shape: AutomationRef;
readonly target: 'row' | 'column';
readonly index: number;
readonly size: number;
} | {
readonly op: 'readSelection';
} | {
readonly op: 'selectSlides';
readonly slides: readonly AutomationRef[];
} | {
readonly op: 'selectShapes';
readonly shapes: readonly AutomationRef[];
} | {
readonly op: 'selectText';
readonly shape: AutomationRef;
readonly span?: AutomationTextSpan;
};AutomationOperationResulttypeSource ↗
One operation's outcome.
skipped is what makes an atomic batch honest. When a batch fails, every operation other than the failing one reports skipped, including reads and the operations before it: reporting those as ok would describe a state that was never published.
type AutomationOperationResult = {
readonly status: 'ok';
readonly value: AutomationValue;
} | {
readonly status: 'error';
readonly error: AutomationError;
} | {
readonly status: 'skipped';
};AutomationReftypeSource ↗
A handle, or the handle an earlier operation of the batch answered with.
type AutomationRef = AutomationHandle | AutomationResultRef;AutomationSaveResulttypeSource ↗
.pptx bytes, or why they could not be produced.
type AutomationSaveResult = {
readonly ok: true;
readonly bytes: Uint8Array;
} | {
readonly ok: false;
readonly error: AutomationError;
};AutomationUnsubscribetypeSource ↗
What a subscription returns. Calling it twice is safe.
type AutomationUnsubscribe = () => void;AutomationValuetypeSource ↗
What an operation answered with.
type AutomationValue = {
readonly kind: 'handle';
readonly handle: AutomationHandle;
} | {
readonly kind: 'handles';
readonly handles: readonly AutomationHandle[];
}
/** A lookup that found nothing, asked for with `orNull`. */
| {
readonly kind: 'null';
} | {
readonly kind: 'text';
readonly text: string;
} | {
readonly kind: 'number';
readonly value: number;
} | {
readonly kind: 'flag';
readonly value: boolean;
}
/** `.pptx` bytes as base64: an exported slide. */
| {
readonly kind: 'base64';
readonly base64: string;
} | {
readonly kind: 'presentation';
readonly presentation: AutomationPresentationRead;
} | {
readonly kind: 'slide';
readonly slide: AutomationSlideRead;
} | {
readonly kind: 'layout';
readonly layout: AutomationLayoutRead;
} | {
readonly kind: 'shape';
readonly shape: AutomationShapeRead;
} | {
readonly kind: 'fill';
readonly fill: AutomationFillRead;
} | {
readonly kind: 'background';
readonly background: AutomationBackgroundRead;
} | {
readonly kind: 'line';
readonly line: AutomationLineRead;
} | {
readonly kind: 'textFrame';
readonly textFrame: AutomationTextFrameRead;
} | {
readonly kind: 'font';
readonly font: AutomationFontRead;
} | {
readonly kind: 'textRuns';
readonly runs: readonly AutomationTextRunRead[];
} | {
readonly kind: 'paragraph';
readonly paragraph: AutomationParagraphRead;
} | {
readonly kind: 'tags';
readonly tags: readonly AutomationTag[];
} | {
readonly kind: 'properties';
readonly properties: AutomationPropertiesRead;
} | {
readonly kind: 'customProperties';
readonly properties: readonly AutomationCustomPropertyRead[];
} | {
readonly kind: 'customXmlParts';
readonly parts: readonly AutomationCustomXmlPartRead[];
} | {
readonly kind: 'table';
readonly table: AutomationTableRead;
} | {
readonly kind: 'tableCell';
readonly cell: AutomationTableCellRead;
} | {
readonly kind: 'tableCellFormat';
readonly format: AutomationTableCellFormatRead;
} | {
readonly kind: 'adjustments';
readonly adjustments: AutomationAdjustmentsRead;
} | {
readonly kind: 'hyperlinks';
readonly hyperlinks: readonly AutomationHyperlinkRead[];
} | {
readonly kind: 'bindings';
readonly bindings: readonly AutomationBindingRead[];
} | {
readonly kind: 'selection';
readonly selection: AutomationSelectionRead;
}
/** A command that committed. The effect is the response's revision. */
| {
readonly kind: 'applied';
};AutomationZOrdertypeSource ↗
ShapeZOrder moves.
type AutomationZOrder = 'bringForward' | 'bringToFront' | 'sendBackward' | 'sendToBack';ServerAutomationRejectiontypeSource ↗
Why bytes could not be opened.
type ServerAutomationRejection = PackageRejection | {
readonly reason: 'empty';
};Variables (2)
AUTOMATION_COMMANDSconstSource ↗
The operations that write. Every other operation only reads.
AUTOMATION_COMMANDS: ReadonlySet<AutomationOperation['op']>MAX_BATCH_OPERATIONSconstSource ↗
The most operations one batch may carry.
MAX_BATCH_OPERATIONS = 10000