@docx-editor.dev/editor-api 2.33.0 → 2.35.0-canary.20261102190412.sha-b9a04a3

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, ReviewDiagnosticCode, ReviewOperation } 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;
@@ -1373,12 +1404,11 @@ declare class Range extends ModelObject implements PromisedItem {
1373
1404
  /** The paragraphs this range covers, in reading order. */
1374
1405
  get paragraphs(): ParagraphCollection;
1375
1406
  /**
1376
- * The paragraph style, by the name a reader sees in the styles gallery.
1377
- *
1378
- * Reading answers the name every paragraph this range covers agrees on, and `null` where they do not or
1379
- * where the document names no style. Writing applies it to all of them, and a name the document
1380
- * does not already define is refused rather than created — a minted style would report itself
1381
- * 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.
1382
1412
  */
1383
1413
  get style(): string;
1384
1414
  set style(value: string);
@@ -1586,6 +1616,7 @@ declare class Range extends ModelObject implements PromisedItem {
1586
1616
  * `editor.exec({ type: 'replaceMatch', match, text })` on a match from `editor.findMatches`.
1587
1617
  * In suggesting mode it records a tracked replacement as the editor's author.
1588
1618
  *
1619
+ * You can load the returned range in the same sync. Editing it needs a sync first.
1589
1620
  * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/tracked-replacement | Replace as a tracked change}
1590
1621
  */
1591
1622
  insertText(text: string, insertLocation: InsertLocation | 'Replace' | 'Start' | 'End' | 'Before' | 'After'): Range;
@@ -1664,18 +1695,21 @@ declare class Range extends ModelObject implements PromisedItem {
1664
1695
  */
1665
1696
  insertInlinePictureFromBase64(base64EncodedImage: string, insertLocation: InsertLocation | 'Before' | 'After' | 'Start' | 'End' | 'Replace'): InlinePicture;
1666
1697
  /**
1667
- * Line, page, and next-page section breaks are supported; other break types refuse at sync.
1668
- * TrackMineOnly records a line break as a tracked insertion. Page and section breaks refuse
1669
- * 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.
1670
1701
  */
1671
1702
  insertBreak(breakType: BreakType | 'Page' | 'SectionNext' | 'Next' | 'Line' | 'SectionContinuous' | 'SectionEven' | 'SectionOdd', insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After'): void;
1672
1703
  /**
1673
1704
  * Insert a rectangular table before or after this range.
1674
- * 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.
1675
1706
  * Sync before configuring the returned table. Nested table authoring refuses.
1676
1707
  */
1677
1708
  insertTable(rowCount: number, columnCount: number, insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After', values?: string[][]): Table;
1678
- /** 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
+ */
1679
1713
  insertParagraph(paragraphText: string, insertLocation: InsertLocation.before | InsertLocation.after | 'Before' | 'After'): Paragraph;
1680
1714
  /**
1681
1715
  * Put the reader's selection on this range and navigate the editor viewport to it.
@@ -2066,9 +2100,18 @@ declare class Paragraph extends ModelObject implements PromisedItem {
2066
2100
  /**
2067
2101
  * The paragraph style, by the name a reader sees in the styles gallery.
2068
2102
  *
2069
- * `null` where the document names none. A name it does not already define is refused rather than
2070
- * created, and the write rides the same `w:pPr` rewrite the alignment and indent members do — so
2071
- * 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.
2072
2115
  */
2073
2116
  get style(): string;
2074
2117
  set style(value: string);
@@ -2193,9 +2236,20 @@ declare class Paragraph extends ModelObject implements PromisedItem {
2193
2236
  *
2194
2237
  * `\n`, `\r`, and `\r\n` in `text` start new paragraphs, tracked with `TrackMineOnly`. See
2195
2238
  * `Range.insertText` for the rules.
2239
+ *
2240
+ * You can load the returned range in the same sync. Editing it needs a sync first.
2196
2241
  */
2197
2242
  insertText(text: string, insertLocation: InsertLocation.replace | InsertLocation.start | InsertLocation.end | 'Replace' | 'Start' | 'End'): Range;
2198
- /** 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
+ */
2199
2253
  insertParagraph(paragraphText: string, insertLocation: 'Before' | 'After'): Paragraph;
2200
2254
  /**
2201
2255
  * Break this paragraph at every occurrence of any delimiter.
@@ -2204,6 +2258,10 @@ declare class Paragraph extends ModelObject implements PromisedItem {
2204
2258
  * this paragraph's identity — so a caller can read back what each piece became without having to
2205
2259
  * work out which of them is the original. The collection is filled by the split itself: there is
2206
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.
2207
2265
  */
2208
2266
  split(delimiters: string[], trimDelimiters?: boolean, trimSpacing?: boolean): RangeCollection;
2209
2267
  /** @internal Plan the read this object's `load(...)` asked for. */
@@ -2483,6 +2541,156 @@ declare class SectionCollection extends HandleCollection<Section> {
2483
2541
  protected promised(label: string, nullable: boolean): Section & PromisedItem;
2484
2542
  }
2485
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
+
2486
2694
  /**
2487
2695
  * The document: the root every other object is reached from.
2488
2696
  *
@@ -2544,6 +2752,27 @@ declare class Document extends ModelObject {
2544
2752
  removeDocumentInformation(removeDocInfoType: 'Comments' | 'Revisions' | 'Versions' | 'RemovePersonalInformation' | 'EmailHeader' | 'RoutingSlip' | 'SendForReview' | 'DocumentProperties' | 'Template' | 'DocumentWorkspace' | 'InkAnnotations' | 'DocumentServerProperties' | 'DocumentManagementPolicy' | 'ContentType' | 'TaskpaneWebExtensions' | 'AtMentions' | 'DocumentTasks' | 'DocumentIntelligence' | 'CommentReactions' | 'All'): void;
2545
2753
  /** Core document metadata. Reads require load; writes commit at sync. */
2546
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;
2547
2776
  /** The main story's paragraphs, in reading order. */
2548
2777
  get paragraphs(): ParagraphCollection;
2549
2778
  /** The document's sections, in document order. */
@@ -3249,7 +3478,11 @@ interface RuntimeSession {
3249
3478
  * `sync()` commits all queued commands in one atomic transaction. Supported read-derived
3250
3479
  * proxy dependencies can require additional read-only transport calls before that commit.
3251
3480
  * These reads and the final write share one revision; a concurrent change refuses the sync.
3252
- * 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.
3253
3486
  *
3254
3487
  * Conditional writes come from the same place. A context that has READ from the document
3255
3488
  * remembers the revision it read at, and a later batch that writes goes out conditional on it,
@@ -3630,9 +3863,14 @@ declare class Body extends ModelObject {
3630
3863
  * The paragraph style, by the name a reader sees in the styles gallery.
3631
3864
  *
3632
3865
  * Reading answers the name every paragraph in the story agrees on, and `null` where they do not or
3633
- * where the document names no style. Writing applies it to all of them, and a name the document
3634
- * does not already define is refused rather than created — a minted style would report itself
3635
- * 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.
3636
3874
  */
3637
3875
  get style(): string;
3638
3876
  set style(value: string);
@@ -3667,10 +3905,21 @@ declare class Body extends ModelObject {
3667
3905
  *
3668
3906
  * `\n`, `\r`, and `\r\n` in `text` start new paragraphs, tracked with `TrackMineOnly` at
3669
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.
3670
3910
  */
3671
3911
  insertText(text: string, insertLocation: InsertLocation.replace | InsertLocation.start | InsertLocation.end | 'Replace' | 'Start' | 'End'): Range;
3672
- /** 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
+ */
3673
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;
3674
3923
  /** @internal Plan the read this object's `load(...)` asked for. */
3675
3924
  protected onLoad(request: ResolvedLoadOptions): void;
3676
3925
  /** Fields within this body. */
@@ -3940,5 +4189,5 @@ interface CreateServerOptions {
3940
4189
  /** Options for {@link createCollaborative}. @public */
3941
4190
  type CreateCollaborativeOptions = CreateServerOptions;
3942
4191
 
3943
- 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 };
3944
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 };