@docx-editor.dev/editor-api 2.32.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { AutomationHandle, AutomationSpan, AutomationOperation, AutomationValue, AutomationSpanRef, RevisionBatchResult, RevisionAuthorResult, DiagnosticCode, HistoryGroup, AutomationHost, AutomationCapabilities, AutomationPaginationOptions, ByteSizeBucket, DocumentOpenDiagnosticCode, DocumentPartKind, DiagnosticErrorName, EditDiagnosticCode } from '@docx-editor.dev/core/automation';
1
+ import { AutomationHandle, AutomationSpan, AutomationOperation, AutomationValue, AutomationSpanRef, RevisionBatchResult, RevisionAuthorResult, AutomationStyleRead, DiagnosticCode, HistoryGroup, AutomationHost, AutomationCapabilities, AutomationPaginationOptions, ByteSizeBucket, DocumentOpenDiagnosticCode, DocumentPartKind, DiagnosticErrorName, EditDiagnosticCode, ReviewDiagnosticCode, ReviewOperation } from '@docx-editor.dev/core/automation';
2
2
  import { CollaborationModuleContribution } from '@docx-editor.dev/core/collaboration';
3
3
 
4
4
  /**
@@ -65,6 +65,11 @@ declare class ObjectPath {
65
65
  /** A path that is whatever its owner's path is, under its own name. */
66
66
  static derived(label: string, parent: ObjectPath): ObjectPath;
67
67
  get state(): ObjectPathState;
68
+ /**
69
+ * The path this one shares its fate with, followed to the end: itself when it has no owner.
70
+ * `range.font` and `range.paragraphs` have the range as their origin.
71
+ */
72
+ get origin(): ObjectPath;
68
73
  get isAddressable(): boolean;
69
74
  get isPending(): boolean;
70
75
  get isNull(): boolean;
@@ -114,6 +119,12 @@ interface QueuedAction {
114
119
  readonly sort: ActionSort;
115
120
  /** Paths that must resolve before this action can be planned. */
116
121
  readonly dependencies?: readonly ObjectPath[];
122
+ /**
123
+ * Paths a write names in its answer: the range an insertion wrote, the paragraph it created.
124
+ * A read in the same sync on one of these, or on a path derived from one, is answered after
125
+ * the writes, because the object has no value before them.
126
+ */
127
+ readonly produces?: readonly ObjectPath[];
117
128
  /** A scalar load on an OrNullObject proxy is skipped if its lookup resolves null. */
118
129
  readonly nullableLoad?: ObjectPath;
119
130
  /** The consumer-facing name of what this action is for, for errors. Never a handle. */
@@ -126,8 +137,11 @@ interface QueuedAction {
126
137
  /**
127
138
  * The answer queues reads for the same sync: a listing whose items load properties named
128
139
  * with `items/`. A sync that writes sends such a listing, and those reads, before its writes.
140
+ *
141
+ * A function is asked when the sync takes the action: a collection load that a later load in
142
+ * the same sync joins can start naming item properties after it was queued.
129
143
  */
130
- readonly continues?: boolean;
144
+ readonly continues?: boolean | (() => boolean);
131
145
  /** Detach coalesced setters when sync captures this action, before asynchronous reads. */
132
146
  capture?(): void;
133
147
  /** Release coalesced state when a batch completes or is discarded. */
@@ -188,6 +202,13 @@ declare abstract class ModelObject extends ClientObject {
188
202
  protected commandDiscarding(name: string, plan: () => AutomationOperation): void;
189
203
  /** Queue a command whose answer names something the caller keeps. */
190
204
  protected commandAnswering(label: string, plan: () => AutomationOperation, settle: (value: AutomationValue) => void, dispose?: () => void): void;
205
+ /**
206
+ * Queue a command whose answer names `created`, the object this call returns.
207
+ *
208
+ * A read on `created` queued before the same `sync()` is answered after the writes, on the
209
+ * revision they produce. A write on `created` still needs a sync first.
210
+ */
211
+ protected commandCreating(created: ModelObject, label: string, plan: () => AutomationOperation, settle: (value: AutomationValue) => void, dispose?: () => void): void;
191
212
  /** Queue a read whose answer is hydrated by the caller. */
192
213
  protected read(label: string, plan: () => AutomationOperation, settle: (value: AutomationValue) => void): void;
193
214
  /** The properties a load asked for, refusing any name this object does not have. */
@@ -622,7 +643,13 @@ declare class Table extends ModelObject implements PromisedItem {
622
643
  */
623
644
  get values(): string[][];
624
645
  set values(value: string[][]);
625
- /** Table style display name. Writes must name an existing table style in the document. */
646
+ /**
647
+ * The table style, by its display name. Writes must name a table style the document defines: list
648
+ * the names with `context.document.getStyles()` and assign the `nameLocal` of a style whose `type`
649
+ * is `Table`; paragraph, character, and list names are refused. A read answers the name that
650
+ * writes back to the same style, or an empty string where the table has no style or no name of
651
+ * its style writes back to it.
652
+ */
626
653
  get style(): string;
627
654
  set style(value: string);
628
655
  /** Number of consecutive leading rows repeated as table headers. */
@@ -658,9 +685,12 @@ declare class Table extends ModelObject implements PromisedItem {
658
685
  * cell can lie further left. The rectangle grows to whole merged cells; a cell that crosses
659
686
  * its edge, or a rectangle of one cell, refuses with `InvalidArgument` and the diagnostic
660
687
  * code `edit.table-merge-not-rectangle`. The merged cell keeps every non-empty cell's content
661
- * in reading order. Edits to the returned cell can share the sync. A pending cell revision
662
- * refuses with `NotImplemented`; tracking modes refuse with `NotSupported`, because a merge
663
- * has no tracked form.
688
+ * in reading order. The returned cell's `value`, `shadingColor`, and `verticalAlignment` can
689
+ * share the sync; a text edit in the table refuses with `ConflictingChanges` until a sync,
690
+ * because the merge moves paragraphs between cells. With tracking off, a pending cell revision
691
+ * refuses with `NotImplemented`. `TrackMineOnly` merges only inside the author's own
692
+ * proposed table, whose insertion the new shape joins; any other table refuses with
693
+ * `NotSupported` and `edit.tracked-structure-unsupported`.
664
694
  */
665
695
  mergeCells(topRow: number, firstCell: number, bottomRow: number, lastCell: number): TableCell;
666
696
  /** Delete this table and its contents through the canonical document transaction. */
@@ -722,7 +752,8 @@ declare class TableCell extends ModelObject implements PromisedItem {
722
752
  * from 1 to 63. A cell merged over several rows splits only into a divisor of them; a
723
753
  * one-row cell adds rows to the table. Counts the cell cannot take, such as columns narrower
724
754
  * than the minimum width, refuse with `InvalidArgument` and the diagnostic code
725
- * `edit.table-split-unsupported`. Tracking modes refuse with `NotSupported`.
755
+ * `edit.table-split-unsupported`. `TrackMineOnly` splits only inside the author's own
756
+ * proposed table, as `Table.mergeCells` does; any other table refuses with `NotSupported`.
726
757
  */
727
758
  split(rowCount: number, columnCount: number): void;
728
759
  protected onLoad(request: ResolvedLoadOptions): void;
@@ -989,10 +1020,11 @@ declare class ClientResult<T> {
989
1020
  * Word's own names for a kind of change.
990
1021
  *
991
1022
  * The WHOLE upstream vocabulary, because a declaration says what a caller may be handed and a caller
992
- * switching on it should not have to be told which subset this engine happens to produce. Seven of
993
- * these actually occur as published objects — insert, delete, replace, the two property kinds and
994
- * the two move halves. Structural cards whose exact Word subtype this API cannot name are omitted
995
- * from `items`; collection-wide decisions still resolve every store-resolvable revision. See
1023
+ * switching on it should not have to be told which subset this engine happens to produce. Nine of
1024
+ * these occur as published objects: Insert, Delete, Property, MovedFrom, MovedTo, CellInsertion,
1025
+ * CellDeletion, CellMerge and ParagraphNumber. A structural card with no single type, such as
1026
+ * table grid history, is omitted from `items`; collection-wide decisions still resolve every
1027
+ * store-resolvable revision. See
996
1028
  * `compat/manifest.json`.
997
1029
  */
998
1030
  type RevisionType = 'None' | 'Insert' | 'Delete' | 'Property' | 'ParagraphNumber' | 'DisplayField' | 'Reconcile' | 'Conflict' | 'Style' | 'Replace' | 'ParagraphProperty' | 'TableProperty' | 'SectionProperty' | 'StyleDefinition' | 'MovedFrom' | 'MovedTo' | 'CellInsertion' | 'CellDeletion' | 'CellMerge' | 'CellSplit' | 'ConflictInsert' | 'ConflictDelete';
@@ -1134,11 +1166,12 @@ declare class CommentCollection extends HandleCollection<Comment> {
1134
1166
  protected promised(label: string, nullable: boolean): Comment & PromisedItem;
1135
1167
  }
1136
1168
  /**
1137
- * One tracked change, published when this API can name its Word subtype.
1169
+ * One tracked change.
1138
1170
  *
1139
- * Structural cards whose exact Word subtype cannot be typed — a row, a cell, a section, the table
1140
- * grid — are omitted from the collection rather than shipped as objects with an unpublishable
1141
- * `type`. That listing is not the collection decision set: see {@link RevisionCollection}.
1171
+ * A row is listed as `Insert` or `Delete`, and a cell or tracked numbering by its own type. A
1172
+ * structural card with no single type, such as table grid history, is omitted rather than
1173
+ * shipped with an unpublishable `type`. That listing is not the collection decision set: see
1174
+ * {@link RevisionCollection}.
1142
1175
  *
1143
1176
  * @public
1144
1177
  */
@@ -1159,10 +1192,19 @@ declare class Revision extends ModelObject implements PromisedItem {
1159
1192
  get date(): Date | null;
1160
1193
  /** What kind of change it is, by Word's own name for it. */
1161
1194
  get type(): RevisionType;
1162
- /** The words the change covers. */
1195
+ /** The words the change covers. Each read returns the same proxy, so a load on it is kept. */
1163
1196
  get range(): Range;
1164
1197
  /**
1165
- * Keep the change, resolving every site that carries its identity in one transaction.
1198
+ * Keep the change, in one transaction, with every part of it: both halves of a move or a cell
1199
+ * merge, and the changes inside content it removes, such as another author's insertion in a
1200
+ * deleted row. Rejecting a formatting change restores the earlier properties, so another
1201
+ * author's change inside the replaced properties, such as tracked numbering, goes with it.
1202
+ *
1203
+ * After a sync resolves this change, another call on the same object fails with
1204
+ * `InvalidObjectPath`, because the change is gone. Within one sync, a decision on a change an
1205
+ * earlier decision removed is skipped. Read `debugInfo.innerError.code` on a refusal, such as
1206
+ * `review.retained-structure` for a row that must stay to keep a nested table, or
1207
+ * `review.locked-content` and `review.bound-content` for a change a content control keeps.
1166
1208
  *
1167
1209
  * In a React or Vue host with the review module, use `useReview().accept` from
1168
1210
  * `@docx-editor.dev/pro/react` or `@docx-editor.dev/pro/vue` for a review UI.
@@ -1171,7 +1213,7 @@ declare class Revision extends ModelObject implements PromisedItem {
1171
1213
  */
1172
1214
  accept(): void;
1173
1215
  /**
1174
- * Undo the change, likewise in one transaction.
1216
+ * Undo the change, likewise in one transaction and with the same rules as {@link Revision.accept}.
1175
1217
  *
1176
1218
  * In a React or Vue host with the review module, use `useReview().reject` for a review UI.
1177
1219
  */
@@ -1202,9 +1244,9 @@ interface RevisionAuthorOptions {
1202
1244
  /**
1203
1245
  * The tracked changes on a document, story or range, as of the batch that loaded them.
1204
1246
  *
1205
- * `items` omits structural cards whose Word subtype this API cannot name; see {@link Revision}.
1247
+ * `items` omits a structural card with no single revision type; see {@link Revision}.
1206
1248
  * On a story's collection, `acceptAll` / `rejectAll` still resolve every store-resolvable
1207
- * revision in the story and refuse atomically if any `readOnly` or otherwise unsupported
1249
+ * revision in the story and refuse atomically if any read-only or otherwise unsupported
1208
1250
  * revision remains. On {@link Range.revisions} and `getReviewItemRevisions`, they resolve the
1209
1251
  * changes the range overlaps or the key names, and `resolve` and `setAuthor` refuse with
1210
1252
  * `NotSupported`.
@@ -1214,7 +1256,7 @@ interface RevisionAuthorOptions {
1214
1256
  declare class RevisionCollection extends HandleCollection<Revision> {
1215
1257
  #private;
1216
1258
  /** @internal The pending decisions of one story. */
1217
- static of(context: RequestContext, label: string, owner: ObjectPath, body: AutomationHandle): RevisionCollection;
1259
+ static of(context: RequestContext, label: string, owner: ObjectPath, body: () => AutomationHandle): RevisionCollection;
1218
1260
  /** @internal The pending decisions a range overlaps, read from the range at plan time. */
1219
1261
  static inSpan(context: RequestContext, label: string, owner: ObjectPath, span: () => AutomationSpanRef): RevisionCollection;
1220
1262
  /** @internal The pending decisions one review-queue key names. */
@@ -1223,10 +1265,11 @@ declare class RevisionCollection extends HandleCollection<Revision> {
1223
1265
  /**
1224
1266
  * Keep every change in this story, as ONE decision and one undo unit.
1225
1267
  *
1226
- * Resolves every store-resolvable revision in the story, including complete tracked rows
1227
- * omitted from `items`. Refuses the sync outright where any `readOnly` or otherwise
1228
- * unsupported revision remains, rather than reporting the story as reviewed while pending
1229
- * changes remain.
1268
+ * Resolves every store-resolvable revision in the story, including history omitted from
1269
+ * `items`. Refuses the sync outright where any read-only or otherwise unsupported revision
1270
+ * remains, a row must stay to keep a nested table (`review.retained-structure`), or a content
1271
+ * control keeps a change (`review.locked-content`, `review.bound-content`), rather
1272
+ * than reporting the story as reviewed while pending changes remain.
1230
1273
  *
1231
1274
  * On a collection from {@link Range.revisions}, resolves every change the range overlaps at
1232
1275
  * sync time, structural changes absent from `items` included. A change the range covers in
@@ -1241,7 +1284,10 @@ declare class RevisionCollection extends HandleCollection<Revision> {
1241
1284
  rejectAll(): void;
1242
1285
  /**
1243
1286
  * Resolve eligible revisions in this story and report skipped decisions after sync.
1244
- * Omit revisions to include unsupported and structural decisions absent from items.
1287
+ * Omit revisions to include unsupported decisions and history absent from items. Named
1288
+ * revisions resolve as single `accept()` or `reject()` calls on them would, except that a
1289
+ * row kept for a nested table is reported as `retained-structure` while the other named
1290
+ * changes resolve, where a single call refuses whole.
1245
1291
  * Pass an empty array to select nothing. Duplicate objects resolve once; stale targets
1246
1292
  * are reported as unknown-revision. This must be the only write in its sync batch.
1247
1293
  * Unlike acceptAll/rejectAll, unsupported decisions do not block independent changes.
@@ -1253,7 +1299,8 @@ declare class RevisionCollection extends HandleCollection<Revision> {
1253
1299
  * const result = context.document.revisions.resolve('accept');
1254
1300
  * await context.sync();
1255
1301
  * console.log(result.value.resolved.length, result.value.remaining);
1256
- * for (const skipped of result.value.skipped) console.log(skipped.reason);
1302
+ * for (const skipped of result.value.skipped)
1303
+ * console.log(skipped.reason, skipped.detail ?? '');
1257
1304
  * ```
1258
1305
  */
1259
1306
  resolve(action: 'accept' | 'reject', revisions?: readonly Revision[]): ClientResult<RevisionBatchResult>;
@@ -1357,12 +1404,11 @@ declare class Range extends ModelObject implements PromisedItem {
1357
1404
  /** The paragraphs this range covers, in reading order. */
1358
1405
  get paragraphs(): ParagraphCollection;
1359
1406
  /**
1360
- * The paragraph style, by the name a reader sees in the styles gallery.
1361
- *
1362
- * Reading answers the name every paragraph this range covers agrees on, and `null` where they do not or
1363
- * where the document names no style. Writing applies it to all of them, and a name the document
1364
- * does not already define is refused rather than created — a minted style would report itself
1365
- * applied while the text stayed exactly as it looked.
1407
+ * The paragraph style of the paragraphs this range covers, by name. A read answers the name they
1408
+ * all agree on, which always writes back to the same style, or `null` where there is no such
1409
+ * name. A write applies a style the document defines and never creates one: list the names with
1410
+ * `context.document.getStyles()` and assign the `nameLocal` of a `Paragraph` style; character,
1411
+ * table, and list names are refused.
1366
1412
  */
1367
1413
  get style(): string;
1368
1414
  set style(value: string);
@@ -1570,6 +1616,7 @@ declare class Range extends ModelObject implements PromisedItem {
1570
1616
  * `editor.exec({ type: 'replaceMatch', match, text })` on a match from `editor.findMatches`.
1571
1617
  * In suggesting mode it records a tracked replacement as the editor's author.
1572
1618
  *
1619
+ * You can load the returned range in the same sync. Editing it needs a sync first.
1573
1620
  * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/tracked-replacement | Replace as a tracked change}
1574
1621
  */
1575
1622
  insertText(text: string, insertLocation: InsertLocation | 'Replace' | 'Start' | 'End' | 'Before' | 'After'): Range;
@@ -1648,18 +1695,21 @@ declare class Range extends ModelObject implements PromisedItem {
1648
1695
  */
1649
1696
  insertInlinePictureFromBase64(base64EncodedImage: string, insertLocation: InsertLocation | 'Before' | 'After' | 'Start' | 'End' | 'Replace'): InlinePicture;
1650
1697
  /**
1651
- * Line, page, and next-page section breaks are supported; other break types refuse at sync.
1652
- * TrackMineOnly records a line break as a tracked insertion. Page and section breaks refuse
1653
- * while tracking.
1698
+ * Line, page, and next-page section breaks are supported; other types refuse at sync. With
1699
+ * `TrackMineOnly`, each is a tracked insertion that reject removes. A tracked `SectionNext`
1700
+ * refuses with `NotSupported` where the next section does not start on a new page.
1654
1701
  */
1655
1702
  insertBreak(breakType: BreakType | 'Page' | 'SectionNext' | 'Next' | 'Line' | 'SectionContinuous' | 'SectionEven' | 'SectionOdd', insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After'): void;
1656
1703
  /**
1657
1704
  * Insert a rectangular table before or after this range.
1658
- * TrackMineOnly records native row/cell insertions, including initial values.
1705
+ * TrackMineOnly marks rows, cell marks, and values inserted; when a paragraph splits, see the guide.
1659
1706
  * Sync before configuring the returned table. Nested table authoring refuses.
1660
1707
  */
1661
1708
  insertTable(rowCount: number, columnCount: number, insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After', values?: string[][]): Table;
1662
- /** Add a paragraph before or after the one this range starts or ends in. */
1709
+ /**
1710
+ * Add a paragraph before or after the one this range starts or ends in.
1711
+ * You can load the returned paragraph in the same sync. Editing it needs a sync first.
1712
+ */
1663
1713
  insertParagraph(paragraphText: string, insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After'): Paragraph;
1664
1714
  /**
1665
1715
  * Put the reader's selection on this range and navigate the editor viewport to it.
@@ -2050,9 +2100,18 @@ declare class Paragraph extends ModelObject implements PromisedItem {
2050
2100
  /**
2051
2101
  * The paragraph style, by the name a reader sees in the styles gallery.
2052
2102
  *
2053
- * `null` where the document names none. A name it does not already define is refused rather than
2054
- * created, and the write rides the same `w:pPr` rewrite the alignment and indent members do — so
2055
- * applying a style and adjusting a spacing in one sync is one write rather than a refusal.
2103
+ * A read answers the style's `nameLocal` as the styles part writes it, such as `heading 1`, and
2104
+ * any name read writes back to the same style. `null` where the document names none, where the
2105
+ * paragraph's style has the same name as an earlier paragraph style (assigning that name applies
2106
+ * the earlier style), and where its name is one a write refuses, such as a blank name. A name it does
2107
+ * not already define is refused rather than created; list the defined names with
2108
+ * `context.document.getStyles()` and assign the `nameLocal` of a style whose `type` is
2109
+ * `Paragraph`. A refused name rejects the sync with `InvalidArgument`, and
2110
+ * `debugInfo.innerError.code` is `edit.style-not-defined` (or `edit.no-styles-defined` when the
2111
+ * document has no styles part). To apply a built-in style by its enum value, as
2112
+ * `styleBuiltIn` does elsewhere, find its name with `getStyles()` and assign it here. The write
2113
+ * rides the same `w:pPr` rewrite the alignment and indent members do — so applying a style and
2114
+ * adjusting a spacing in one sync is one write rather than a refusal.
2056
2115
  */
2057
2116
  get style(): string;
2058
2117
  set style(value: string);
@@ -2177,9 +2236,20 @@ declare class Paragraph extends ModelObject implements PromisedItem {
2177
2236
  *
2178
2237
  * `\n`, `\r`, and `\r\n` in `text` start new paragraphs, tracked with `TrackMineOnly`. See
2179
2238
  * `Range.insertText` for the rules.
2239
+ *
2240
+ * You can load the returned range in the same sync. Editing it needs a sync first.
2180
2241
  */
2181
2242
  insertText(text: string, insertLocation: InsertLocation.replace | InsertLocation.start | InsertLocation.end | 'Replace' | 'Start' | 'End'): Range;
2182
- /** Add a paragraph beside this one. Answers the new paragraph. */
2243
+ /**
2244
+ * Insert a rectangular table before or after this paragraph.
2245
+ * TrackMineOnly marks rows, cell marks, and values inserted, as `Range.insertTable` does.
2246
+ * Sync before configuring the returned table. A table inside a table cell refuses.
2247
+ */
2248
+ insertTable(rowCount: number, columnCount: number, insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After', values?: string[][]): Table;
2249
+ /**
2250
+ * Add a paragraph beside this one. Answers the new paragraph.
2251
+ * You can load the returned paragraph in the same sync. Editing it needs a sync first.
2252
+ */
2183
2253
  insertParagraph(paragraphText: string, insertLocation: 'Before' | 'After'): Paragraph;
2184
2254
  /**
2185
2255
  * Break this paragraph at every occurrence of any delimiter.
@@ -2188,6 +2258,10 @@ declare class Paragraph extends ModelObject implements PromisedItem {
2188
2258
  * this paragraph's identity — so a caller can read back what each piece became without having to
2189
2259
  * work out which of them is the original. The collection is filled by the split itself: there is
2190
2260
  * no second read, because a second read would describe the document the split had already made.
2261
+ *
2262
+ * With `TrackMineOnly`, each new paragraph mark is a tracked insertion, and reject joins the
2263
+ * pieces again. A tracked split keeps its delimiters: `trimDelimiters` set to `true` refuses
2264
+ * with `NotSupported` when a delimiter is found, and nothing changes.
2191
2265
  */
2192
2266
  split(delimiters: string[], trimDelimiters?: boolean, trimSpacing?: boolean): RangeCollection;
2193
2267
  /** @internal Plan the read this object's `load(...)` asked for. */
@@ -2467,6 +2541,156 @@ declare class SectionCollection extends HandleCollection<Section> {
2467
2541
  protected promised(label: string, nullable: boolean): Section & PromisedItem;
2468
2542
  }
2469
2543
 
2544
+ /** The kind of a style. @public */
2545
+ declare enum StyleType {
2546
+ /** A character style. The paragraph `style` setters refuse its name. */
2547
+ character = "Character",
2548
+ /** A numbering style, which defines list formatting. The paragraph `style` setters refuse its name. */
2549
+ list = "List",
2550
+ /** A paragraph style, which `paragraph.style` accepts by its `nameLocal`. */
2551
+ paragraph = "Paragraph",
2552
+ /**
2553
+ * A table style. The paragraph `style` setters refuse its name; `Table.style` accepts its
2554
+ * `nameLocal`.
2555
+ */
2556
+ table = "Table"
2557
+ }
2558
+ /**
2559
+ * One style the document's styles part defines. Every property is read-only and needs a `load`
2560
+ * before it is read; `load()` with no arguments reads them all.
2561
+ *
2562
+ * `nameLocal` is the name the styles part declares. Only a style whose `type` is `Paragraph` can be
2563
+ * assigned to `paragraph.style`, `range.style`, or `body.style`; those setters refuse character,
2564
+ * table, and list style names. `Table.style` accepts the `nameLocal` of a listed table style.
2565
+ *
2566
+ * @example Offer the paragraph styles a reader would see
2567
+ * ```ts
2568
+ * const styles = context.document.getStyles();
2569
+ * styles.load('items/nameLocal,items/type,items/visibility,items/unhideWhenUsed,items/priority');
2570
+ * await context.sync();
2571
+ *
2572
+ * // Keep hidden styles that unhide once used, such as heading 2, so they can be applied too.
2573
+ * // Many styles share priority 99, so sort by name next for a stable order.
2574
+ * const choices = styles.items
2575
+ * .filter((style) => style.type === 'Paragraph' && (style.visibility || style.unhideWhenUsed))
2576
+ * .sort((a, b) => a.priority - b.priority || a.nameLocal.localeCompare(b.nameLocal))
2577
+ * .map((style) => style.nameLocal);
2578
+ * ```
2579
+ *
2580
+ * @public
2581
+ */
2582
+ declare class Style extends ModelObject {
2583
+ #private;
2584
+ /** @internal A member of a loaded collection. */
2585
+ static listed(context: RequestContext, label: string, owner: ObjectPath, style: AutomationStyleRead): Style;
2586
+ /** @internal A style a lookup is still looking for; a sync says whether it exists. */
2587
+ static promised(context: RequestContext, label: string): Style;
2588
+ private constructor();
2589
+ /**
2590
+ * The name the styles part declares. Assign it to `paragraph.style` only when `type` is
2591
+ * `Paragraph`; the paragraph `style` setters refuse other kinds. A built-in name reads as the part
2592
+ * writes it, such as `heading 1`, and the setters accept it that way. The setters and
2593
+ * `getByNameOrNullObject` compare names without case, so `Heading 1` finds `heading 1`; compare
2594
+ * names the same way rather than with `===`.
2595
+ */
2596
+ get nameLocal(): string;
2597
+ /**
2598
+ * The kind of style. A numbering style reads as `List`. Only `Paragraph` names are accepted by
2599
+ * the paragraph, range, and body `style` setters.
2600
+ */
2601
+ get type(): StyleType | 'Character' | 'List' | 'Paragraph' | 'Table';
2602
+ /** False when the styles part marks the style as custom. */
2603
+ get builtIn(): boolean;
2604
+ /**
2605
+ * The name of the style this one is based on: a listed style of the same kind. An empty string
2606
+ * when the style states none or names any other style. Read-only here.
2607
+ */
2608
+ get baseStyle(): string;
2609
+ /**
2610
+ * The name of the style for the paragraph after this one: always a listed paragraph style. A
2611
+ * paragraph style that states no next style names itself. An empty string for other kinds, and
2612
+ * where the next style it names is not a listed paragraph style. Read-only here.
2613
+ */
2614
+ get nextParagraphStyle(): string;
2615
+ /**
2616
+ * Whether the style is linked to its partner: a paragraph style to a listed character style, or a
2617
+ * character style to a listed paragraph style. Other kinds, and links to the same kind or to
2618
+ * itself, read false.
2619
+ */
2620
+ get linked(): boolean;
2621
+ /**
2622
+ * Whether the style shows as a recommended style. False when the styles part marks it
2623
+ * semi-hidden or hidden; true when it marks neither. Read-only here.
2624
+ */
2625
+ get visibility(): boolean;
2626
+ /**
2627
+ * The sort order of the style among recommended styles; lower comes first. 99 when the styles
2628
+ * part states no priority. Read-only here.
2629
+ */
2630
+ get priority(): number;
2631
+ /** Whether the style is in the quick style gallery. False when not stated. Read-only here. */
2632
+ get quickStyle(): boolean;
2633
+ /**
2634
+ * Whether a hidden style becomes visible once it is used. False when not stated. Read-only here.
2635
+ */
2636
+ get unhideWhenUsed(): boolean;
2637
+ /** @internal The lookup found this style. */
2638
+ hydrateFound(style: AutomationStyleRead): void;
2639
+ /** @internal The lookup found nothing. */
2640
+ hydrateNull(): void;
2641
+ /**
2642
+ * @internal The sync took the lookup. The properties awaiting it are its answer's to fill; a load
2643
+ * after this point queues its own read by id, so it is never left waiting on a sync that has
2644
+ * already been sent, or that fails.
2645
+ */
2646
+ lookupCaptured(): void;
2647
+ /** @internal The lookup's batch ended; later loads read by id. */
2648
+ lookupEnded(): void;
2649
+ /** @internal Record the selected properties from one listing entry. */
2650
+ hydrateProperties(style: AutomationStyleRead, selected: readonly string[]): void;
2651
+ /** @internal Plan the read this object's `load(...)` asked for. */
2652
+ protected onLoad(request: ResolvedLoadOptions): void;
2653
+ }
2654
+ /**
2655
+ * The styles a document defines, of every kind, in the order its styles part writes them, as of
2656
+ * the sync that loaded them.
2657
+ *
2658
+ * The listing holds paragraph, character, table, and list styles. The `paragraph.style`,
2659
+ * `range.style`, and `body.style` setters accept paragraph style names only; they refuse character,
2660
+ * table, and list names. Check `type` before assigning a `nameLocal`. Every listed paragraph style
2661
+ * applies through those setters. Styles with no name, an invalid name, or an unknown kind are not
2662
+ * listed. A document with no styles part lists none.
2663
+ *
2664
+ * `load()` with no arguments, or `load('items')`, reads every property of each style in the same
2665
+ * sync. Name `items/` paths to read fewer, such as `styles.load('items/nameLocal,items/type')`.
2666
+ *
2667
+ * @public
2668
+ */
2669
+ declare class StyleCollection extends ModelObject {
2670
+ #private;
2671
+ /** @internal The styles of the document `owner` names. */
2672
+ static of(context: RequestContext, label: string, owner: ObjectPath): StyleCollection;
2673
+ private constructor();
2674
+ /** The styles this collection was loaded with. `PropertyNotLoaded` before a synced load. */
2675
+ get items(): readonly Style[];
2676
+ /** The number of listed styles, of every kind, readable after the next sync. */
2677
+ getCount(): ClientResult<number>;
2678
+ /**
2679
+ * The style with this name, or an object that reports `isNullObject` after the sync. Reading
2680
+ * `isNullObject` needs no property load; properties loaded on the object before that sync are
2681
+ * answered by the same lookup.
2682
+ *
2683
+ * Names compare without case and surrounding spaces, the way the style setters compare them.
2684
+ * When one name belongs to styles of several kinds, the paragraph style is answered, because that
2685
+ * is the style the setters apply. Otherwise the first match in part order is answered.
2686
+ */
2687
+ getByNameOrNullObject(name: string): Style;
2688
+ /** @internal Collections accept `items/<property>` paths. */
2689
+ protected get loadsItemPaths(): boolean;
2690
+ /** @internal Plan the read this object's `load(...)` asked for. */
2691
+ protected onLoad(request: ResolvedLoadOptions): void;
2692
+ }
2693
+
2470
2694
  /**
2471
2695
  * The document: the root every other object is reached from.
2472
2696
  *
@@ -2528,6 +2752,27 @@ declare class Document extends ModelObject {
2528
2752
  removeDocumentInformation(removeDocInfoType: 'Comments' | 'Revisions' | 'Versions' | 'RemovePersonalInformation' | 'EmailHeader' | 'RoutingSlip' | 'SendForReview' | 'DocumentProperties' | 'Template' | 'DocumentWorkspace' | 'InkAnnotations' | 'DocumentServerProperties' | 'DocumentManagementPolicy' | 'ContentType' | 'TaskpaneWebExtensions' | 'AtMentions' | 'DocumentTasks' | 'DocumentIntelligence' | 'CommentReactions' | 'All'): void;
2529
2753
  /** Core document metadata. Reads require load; writes commit at sync. */
2530
2754
  get properties(): DocumentProperties;
2755
+ /**
2756
+ * The styles the document defines, of every kind, in the order its styles part writes them.
2757
+ * Each call answers a new collection; load it before reading `items`.
2758
+ *
2759
+ * The list includes character, table, and list styles. The `paragraph.style`, `range.style`,
2760
+ * and `body.style` setters accept paragraph style names only and refuse the other kinds, so
2761
+ * filter on `type === 'Paragraph'` before assigning a `nameLocal`.
2762
+ *
2763
+ * @example
2764
+ * ```ts
2765
+ * const styles = context.document.getStyles();
2766
+ * styles.load('items/nameLocal,items/type,items/visibility,items/unhideWhenUsed');
2767
+ * await context.sync();
2768
+ *
2769
+ * // Keep hidden styles that unhide once used, such as heading 2, so they can be applied too.
2770
+ * const names = styles.items
2771
+ * .filter((style) => style.type === 'Paragraph' && (style.visibility || style.unhideWhenUsed))
2772
+ * .map((style) => style.nameLocal);
2773
+ * ```
2774
+ */
2775
+ getStyles(): StyleCollection;
2531
2776
  /** The main story's paragraphs, in reading order. */
2532
2777
  get paragraphs(): ParagraphCollection;
2533
2778
  /** The document's sections, in document order. */
@@ -2539,8 +2784,8 @@ declare class Document extends ModelObject {
2539
2784
  /**
2540
2785
  * The tracked changes of the main-body story that this API can publish as typed objects.
2541
2786
  *
2542
- * Structural cards whose exact Word subtype cannot be named are omitted from `items`, and so
2543
- * are property changes that leave the resolved formatting unchanged.
2787
+ * A structural card with no single revision type is omitted from `items`, and so are property
2788
+ * changes that leave the resolved formatting unchanged.
2544
2789
  * `acceptAll` / `rejectAll` still resolve every store-resolvable revision in the main body
2545
2790
  * and refuse atomically if any `readOnly` or otherwise unsupported revision remains. Header,
2546
2791
  * footer, and note revisions live on those stories' own `Body.revisions` collections.
@@ -3233,7 +3478,11 @@ interface RuntimeSession {
3233
3478
  * `sync()` commits all queued commands in one atomic transaction. Supported read-derived
3234
3479
  * proxy dependencies can require additional read-only transport calls before that commit.
3235
3480
  * These reads and the final write share one revision; a concurrent change refuses the sync.
3236
- * Write-created proxies require a separate sync before dependent operations.
3481
+ * A read on an object that a write in the same sync returns (the range `insertText` wrote,
3482
+ * the paragraph `insertParagraph` created) is answered after that commit, on the revision it
3483
+ * produced. If that read fails, the writes stay applied and `sync()` rejects with the read's
3484
+ * error code, with `debugInfo.innerError.code` `edit.read-after-commit`: read again, and do not
3485
+ * apply the same edit again. A write on such an object requires a separate sync.
3237
3486
  *
3238
3487
  * Conditional writes come from the same place. A context that has READ from the document
3239
3488
  * remembers the revision it read at, and a later batch that writes goes out conditional on it,
@@ -3614,9 +3863,14 @@ declare class Body extends ModelObject {
3614
3863
  * The paragraph style, by the name a reader sees in the styles gallery.
3615
3864
  *
3616
3865
  * Reading answers the name every paragraph in the story agrees on, and `null` where they do not or
3617
- * where the document names no style. Writing applies it to all of them, and a name the document
3618
- * does not already define is refused rather than created — a minted style would report itself
3619
- * applied while the text stayed exactly as it looked.
3866
+ * where no paragraph style name writes back to their style. Writing applies it to all of them, and
3867
+ * a name the document does not already define is refused rather than created — a minted style
3868
+ * would report itself applied while the text stayed exactly as it looked.
3869
+ *
3870
+ * List the names you can write with `context.document.getStyles()`, and assign the `nameLocal`
3871
+ * of a style whose `type` is `Paragraph`; character, table, and list names are refused.
3872
+ * A name read is always one that writes back to the same style. `null` means there is no such
3873
+ * name: write a listed name instead.
3620
3874
  */
3621
3875
  get style(): string;
3622
3876
  set style(value: string);
@@ -3636,7 +3890,7 @@ declare class Body extends ModelObject {
3636
3890
  *
3637
3891
  * DocxEditor's own accessor: upstream reaches revisions from the document, and this story-scoped
3638
3892
  * collection is what makes a header's, footer's, or note's changes reachable at all. Recorded in
3639
- * `compat/manifest.json`. `items` may omit structural cards; collection-wide decisions still
3893
+ * `compat/manifest.json`. `items` may omit a structural card with no single type; collection-wide decisions still
3640
3894
  * resolve every store-resolvable revision in this story.
3641
3895
  */
3642
3896
  get revisions(): RevisionCollection;
@@ -3651,10 +3905,21 @@ declare class Body extends ModelObject {
3651
3905
  *
3652
3906
  * `\n`, `\r`, and `\r\n` in `text` start new paragraphs, tracked with `TrackMineOnly` at
3653
3907
  * `Start` and `End`. See `Range.insertText` for the rules.
3908
+ *
3909
+ * You can load the returned range in the same sync. Editing it needs a sync first.
3654
3910
  */
3655
3911
  insertText(text: string, insertLocation: InsertLocation.replace | InsertLocation.start | InsertLocation.end | 'Replace' | 'Start' | 'End'): Range;
3656
- /** Add a paragraph at the start or the end of the story. Answers the new paragraph. */
3912
+ /**
3913
+ * Add a paragraph at the start or the end of the story. Answers the new paragraph.
3914
+ * You can load the returned paragraph in the same sync. Editing it needs a sync first.
3915
+ */
3657
3916
  insertParagraph(paragraphText: string, insertLocation: InsertLocation.start | InsertLocation.end | 'Start' | 'End'): Paragraph;
3917
+ /**
3918
+ * Insert a rectangular table at the start or the end of this body.
3919
+ * TrackMineOnly marks rows, cell marks, and values inserted, as `Range.insertTable` does.
3920
+ * Sync before configuring the returned table. A table inside a table cell refuses.
3921
+ */
3922
+ insertTable(rowCount: number, columnCount: number, insertLocation: InsertLocation.start | InsertLocation.end | 'Start' | 'End', values?: string[][]): Table;
3658
3923
  /** @internal Plan the read this object's `load(...)` asked for. */
3659
3924
  protected onLoad(request: ResolvedLoadOptions): void;
3660
3925
  /** Fields within this body. */
@@ -3812,6 +4077,18 @@ type RuntimeDiagnostic = {
3812
4077
  readonly errorName?: DiagnosticErrorName;
3813
4078
  /** `automation` when `cause` is `exception`. */
3814
4079
  readonly stage?: 'automation';
4080
+ } | {
4081
+ /** A tracked-change decision the batch refused, with why and in what structure. */
4082
+ readonly kind: 'review.skipped';
4083
+ readonly code: ReviewDiagnosticCode;
4084
+ /** Always 1: a refused batch is one decision. */
4085
+ readonly count: number;
4086
+ readonly operation?: ReviewOperation;
4087
+ /**
4088
+ * The structure behind the skip, such as `paired-change` for the other half of a move,
4089
+ * or `nested-table` for a row kept for its nested table. See `diagnosticCauses()`.
4090
+ */
4091
+ readonly cause?: string;
3815
4092
  });
3816
4093
 
3817
4094
  /**
@@ -3912,5 +4189,5 @@ interface CreateServerOptions {
3912
4189
  /** Options for {@link createCollaborative}. @public */
3913
4190
  type CreateCollaborativeOptions = CreateServerOptions;
3914
4191
 
3915
- export { ListItem as $, Alignment as A, DocumentProperties as F, DocxEditorError as J, Field as P, FieldCollection as Q, FieldType as R, Font as T, InlinePicture as V, InlinePictureCollection as W, InsertLocation as X, List as Y, ListBullet as Z, ListCollection as _, ListNumbering as a0, NoteItem as a3, NoteItemCollection as a4, PageOrientation as a6, PageSetup as a7, Paragraph as a8, ShapeType as aA, Table as aB, TableCell as aC, TableCellCollection as aD, TableCollection as aE, TableRow as aF, TableRowCollection as aG, TrackedObjects as aH, UnderlineType as aI, VerticalAlignment as aJ, getReviewItemRange as aK, getReviewItemRangeOrNullObject as aL, getReviewItemRevisions as aM, isDocxEditorError as aN, ParagraphCollection as aa, Range as ae, RangeCollection as af, RangeLocation as ah, RemoveDocInfoType as ai, RequestContext as aj, Revision as ak, RevisionCollection as an, Section as au, SectionCollection as av, Shape as ay, ShapeCollection as az, Body as b, Bookmark as e, BookmarkCollection as f, BreakType as g, ChangeTrackingMode as h, ChangeTrackingVersion as i, ClientObject as j, ClientResult as k, Comment as l, CommentCollection as m, CommentReply as n, CommentReplyCollection as o, ContentControl as q, ContentControlCollection as r, ContentControlType as u, Document as w };
4192
+ export { ListItem as $, Alignment as A, DocumentProperties as F, DocxEditorError as J, Field as P, FieldCollection as Q, FieldType as R, Font as T, InlinePicture as V, InlinePictureCollection as W, InsertLocation as X, List as Y, ListBullet as Z, ListCollection as _, ListNumbering as a0, NoteItem as a3, NoteItemCollection as a4, PageOrientation as a6, PageSetup as a7, Paragraph as a8, ShapeType as aA, Style as aB, StyleCollection as aC, StyleType as aD, Table as aE, TableCell as aF, TableCellCollection as aG, TableCollection as aH, TableRow as aI, TableRowCollection as aJ, TrackedObjects as aK, UnderlineType as aL, VerticalAlignment as aM, getReviewItemRange as aN, getReviewItemRangeOrNullObject as aO, getReviewItemRevisions as aP, isDocxEditorError as aQ, ParagraphCollection as aa, Range as ae, RangeCollection as af, RangeLocation as ah, RemoveDocInfoType as ai, RequestContext as aj, Revision as ak, RevisionCollection as an, Section as au, SectionCollection as av, Shape as ay, ShapeCollection as az, Body as b, Bookmark as e, BookmarkCollection as f, BreakType as g, ChangeTrackingMode as h, ChangeTrackingVersion as i, ClientObject as j, ClientResult as k, Comment as l, CommentCollection as m, CommentReply as n, CommentReplyCollection as o, ContentControl as q, ContentControlCollection as r, ContentControlType as u, Document as w };
3916
4193
  export type { BesideLocation as B, CreateServerOptions as C, DocxEditorServerRuntime as D, DocumentPreviewStatus as E, DocumentXmlLimits as G, DocumentZipLimits as H, DocxEditorDebugInfo as I, DocxEditorErrorCode as K, DocxEditorErrorInit as L, DocxEditorInnerError as M, DocxEditorRuntime as N, EditorModule as O, FieldTypeLiteral as S, HeaderFooterType as U, CreateCollaborativeOptions as a, LoadOption as a1, LoadQueryOptions as a2, NoteItemType as a5, ParagraphAlignment as a9, ParagraphInsertTextLocation as ab, ParagraphReadingOrder as ac, PreviewCallback as ad, RangeInsertTextLocation as ag, RevisionAuthorOptions as al, RevisionAuthorSelection as am, RevisionTextView as ao, RevisionType as ap, RunCallback as aq, RunOptions as ar, RuntimeDiagnostic as as, SearchOptions as at, SelectionMode as aw, ServerPaginationOptions as ax, BodyInsertParagraphLocation as c, BodyInsertTextLocation as d, CommitPreviewOptions as p, ContentControlLockState as s, ContentControlSubtype as t, ContentControlValue as v, DocumentCapabilities as x, DocumentLimits as y, DocumentPreview as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docx-editor.dev/editor-api",
3
- "version": "2.32.0",
3
+ "version": "2.34.0",
4
4
  "description": "Document automation for DOCX: a batching object model that drives a document from a server or from an editor already open in a page",
5
5
  "sideEffects": false,
6
6
  "engines": {
@@ -92,6 +92,6 @@
92
92
  "access": "public"
93
93
  },
94
94
  "peerDependencies": {
95
- "@docx-editor.dev/core": "~2.32.0"
95
+ "@docx-editor.dev/core": "~2.34.0"
96
96
  }
97
97
  }