@docx-editor.dev/core 2.30.0 → 2.31.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.
Files changed (106) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.d.ts +16 -25
  3. package/dist/automation.js +1 -1
  4. package/dist/binding.cjs +1 -1
  5. package/dist/binding.d.ts +15 -16
  6. package/dist/binding.js +1 -1
  7. package/dist/bookmark-names-DDuAra_V.d.ts +37 -0
  8. package/dist/{chrome-print-BM3Js-6X.d.ts → chrome-print-BWvaVEhD.d.ts} +318 -33
  9. package/dist/chunk-243W4WW2.cjs +2 -0
  10. package/dist/{chunk-RJCQGJR7.js → chunk-2E2RPEKX.js} +1 -1
  11. package/dist/chunk-4S24UOPG.js +30 -0
  12. package/dist/chunk-5JPIEN54.cjs +3 -0
  13. package/dist/{chunk-KJRTNY2Q.cjs → chunk-5SO5QDMV.cjs} +1 -1
  14. package/dist/{chunk-WF7JZ755.cjs → chunk-6IDOVU6L.cjs} +1 -1
  15. package/dist/chunk-DBOOTED4.cjs +30 -0
  16. package/dist/chunk-EOTAXOJY.cjs +5 -0
  17. package/dist/chunk-FDAKJ2SJ.cjs +30 -0
  18. package/dist/chunk-FNNOJNGY.js +3 -0
  19. package/dist/chunk-FT33HRZP.js +5 -0
  20. package/dist/{chunk-HYASLE2G.cjs → chunk-HC6YNKUI.cjs} +1 -1
  21. package/dist/chunk-HZ66UCIS.js +2 -0
  22. package/dist/{chunk-5RRAZMBU.cjs → chunk-IBRBNT37.cjs} +1 -1
  23. package/dist/chunk-IVIN7X43.js +30 -0
  24. package/dist/chunk-LZY6B6IV.js +4 -0
  25. package/dist/chunk-MOYYRVFV.cjs +2 -0
  26. package/dist/{chunk-YZGUBCHP.js → chunk-N6B3BXCL.js} +1 -1
  27. package/dist/chunk-Q5K2GGNG.js +2 -0
  28. package/dist/chunk-R2XINWVE.js +7 -0
  29. package/dist/chunk-SUEXVBPR.js +1 -0
  30. package/dist/chunk-T2QQHG5C.js +18 -0
  31. package/dist/{chunk-T32MGBJS.js → chunk-VWIJKH4A.js} +1 -1
  32. package/dist/chunk-WO4V6PNS.cjs +18 -0
  33. package/dist/chunk-XMJKFURD.cjs +4 -0
  34. package/dist/{chunk-FLBEJC6X.cjs → chunk-XSTGE3NI.cjs} +1 -1
  35. package/dist/chunk-YQWMI6J5.cjs +7 -0
  36. package/dist/{chunk-WPDD2Y32.js → chunk-ZCJS7D7S.js} +1 -1
  37. package/dist/collaboration/replication.cjs +1 -1
  38. package/dist/collaboration/replication.d.ts +4 -5
  39. package/dist/collaboration/replication.js +1 -1
  40. package/dist/collaboration.d.ts +3 -4
  41. package/dist/contracts/document.d.ts +3 -3
  42. package/dist/contracts/editor.d.ts +8 -9
  43. package/dist/contracts/interaction.d.ts +2 -2
  44. package/dist/contracts/modules.d.ts +12 -13
  45. package/dist/contracts/types.d.ts +2 -2
  46. package/dist/{custom-node-writes-0v0Kgw1T.d.ts → custom-node-writes-TeUvMP13.d.ts} +2 -2
  47. package/dist/{diagnostic-context-CcAO4q1s.d.ts → diagnostic-context-DJ0P1uZE.d.ts} +3 -2
  48. package/dist/{diagnostic-hints-2Bke6H_w.d.ts → diagnostic-hints-C9JlLz1L.d.ts} +1 -1
  49. package/dist/{document-protection-8eyMWIJ0.d.ts → document-protection-C8x3P2J6.d.ts} +1 -1
  50. package/dist/{editor-DaEJd2so.d.ts → editor-B2ShlO23.d.ts} +292 -50
  51. package/dist/{editor-scope-7o9xweiJ.d.ts → editor-scope-C7ke1KJG.d.ts} +57 -4
  52. package/dist/editor.cjs +1 -1
  53. package/dist/editor.css +5 -3
  54. package/dist/editor.d.ts +602 -31
  55. package/dist/editor.js +1 -1
  56. package/dist/export.cjs +2 -2
  57. package/dist/export.d.ts +13 -14
  58. package/dist/export.js +2 -2
  59. package/dist/{font-resolver-CL9BVKZo.d.ts → font-resolver-CWh40DYp.d.ts} +1 -1
  60. package/dist/{headless-document-view-DZQN8Bnx.d.ts → headless-document-view-qOpaCF82.d.ts} +2 -2
  61. package/dist/index.cjs +1 -1
  62. package/dist/index.d.ts +22 -23
  63. package/dist/index.js +1 -1
  64. package/dist/{layout-shaping-cEnVrhWg.d.ts → layout-shaping-CWS3j0Xr.d.ts} +1 -1
  65. package/dist/layout.cjs +1 -1
  66. package/dist/layout.d.ts +87 -22
  67. package/dist/layout.js +1 -1
  68. package/dist/{note-properties-9FH8zAeG.d.ts → note-properties-QsKh24sM.d.ts} +1 -1
  69. package/dist/{omml-equation-DP2WpUbK.d.ts → omml-equation-BsLAa2lX.d.ts} +27 -9
  70. package/dist/output.cjs +1 -1
  71. package/dist/output.d.ts +20 -10
  72. package/dist/output.js +1 -1
  73. package/dist/{protocol-CZ1uUlPO.d.ts → protocol-COZJUKUY.d.ts} +94 -2
  74. package/dist/{review-paragraph-order-CqVelc5A.d.ts → review-paragraph-order-C_QbCKcH.d.ts} +1 -1
  75. package/dist/{semantic-cell-selection-Dr9yxFZt.d.ts → semantic-cell-selection-Cub9FDa8.d.ts} +2 -2
  76. package/dist/{semantic-interaction-Dc3pf3hr.d.ts → semantic-interaction-dApRIYpt.d.ts} +1 -1
  77. package/dist/{semantic-paint-Bz3FBAoH.d.ts → semantic-paint-DLzA8sjP.d.ts} +3 -3
  78. package/dist/{semantic-record-queries-Bx0pl6kL.d.ts → semantic-record-queries-3yp9o11g.d.ts} +1 -1
  79. package/dist/{semantic-records-CjcF26ZL.d.ts → semantic-records-B-akgRch.d.ts} +130 -87
  80. package/dist/store.cjs +1 -1
  81. package/dist/store.d.ts +48 -22
  82. package/dist/store.js +1 -1
  83. package/dist/{tree-package-store-DKhdEVym.d.ts → tree-package-store-B8l8DX3Z.d.ts} +675 -645
  84. package/dist/{tree-session-contract-CwnTEVLF.d.ts → tree-session-contract-DeLRqohz.d.ts} +26 -13
  85. package/dist/{types-barrel-CA0xB8kH.d.ts → types-barrel-CkF2JbU4.d.ts} +1146 -745
  86. package/package.json +2 -2
  87. package/dist/chunk-2PV5L5NJ.js +0 -5
  88. package/dist/chunk-5OTS2EJ7.js +0 -7
  89. package/dist/chunk-5P4223J4.cjs +0 -27
  90. package/dist/chunk-5SPITS5F.js +0 -18
  91. package/dist/chunk-7ATNKARV.js +0 -2
  92. package/dist/chunk-BGCUTKWE.cjs +0 -5
  93. package/dist/chunk-EBCXSH2W.js +0 -3
  94. package/dist/chunk-ERECKTIR.cjs +0 -2
  95. package/dist/chunk-JC47NRJC.cjs +0 -3
  96. package/dist/chunk-NKPUH3QJ.js +0 -1
  97. package/dist/chunk-PF5NJWS3.js +0 -2
  98. package/dist/chunk-PWTRJSES.cjs +0 -18
  99. package/dist/chunk-QFKGI242.cjs +0 -30
  100. package/dist/chunk-RPPV4S6T.cjs +0 -4
  101. package/dist/chunk-UM26GH5B.js +0 -30
  102. package/dist/chunk-VRCZBFLH.js +0 -27
  103. package/dist/chunk-WK5X2MMA.cjs +0 -7
  104. package/dist/chunk-YBMWBXST.cjs +0 -2
  105. package/dist/chunk-ZOS2PM4A.js +0 -4
  106. package/dist/image-resources-Bipz8toD.d.ts +0 -211
@@ -1,13 +1,12 @@
1
- import { q as ResolvedRevisionMarkup, a as ReviewDisplayMode } from './semantic-records-CjcF26ZL.js';
2
- import { t as DocAnchor, g as ReviewRevisionKind, c as ReviewCommentItem, b as ReviewRevisionItem, d as ReviewCustomItem, aJ as SourceCrop, Y as DrawingKind, a1 as ImageWrapTarget, _ as DrawingPositionInput, Z as DrawingLocks, r as ColorValue, x as ExecErrorCode, a5 as ParagraphFormatCommand, af as Watermark, E as ExecResult, n as ContentControlFilter, o as DocRange, k as RunFormatting, p as Revision, a7 as Rect, ab as SelectionPin, ae as Unsubscribe } from './types-barrel-CA0xB8kH.js';
3
- import { H as HistoryDiagnostic, V as ViewScope, b as HistoryGroup, a as EditorExecOptions, E as EditorScope } from './editor-scope-7o9xweiJ.js';
1
+ import { q as ResolvedRevisionMarkup, a as ReviewDisplayMode } from './semantic-records-B-akgRch.js';
2
+ import { t as DocAnchor, g as ReviewRevisionKind, c as ReviewCommentItem, b as ReviewRevisionItem, d as ReviewCustomItem, aT as SourceCrop, Y as DrawingKind, a2 as ImageWrapTarget, _ as DrawingPositionInput, Z as DrawingLocks, a1 as ImageResourceState, r as ColorValue, x as ExecErrorCode, a6 as ParagraphFormatCommand, af as SupportedImageMime, al as Watermark, E as ExecResult, an as WatermarkState, n as ContentControlFilter, o as DocRange, k as RunFormatting, p as Revision, a9 as Rect, ae as SelectionPin, ai as Unsubscribe } from './types-barrel-CkF2JbU4.js';
3
+ import { H as HistoryDiagnostic, V as ViewScope, b as HistoryGroup, a as EditorExecOptions, E as EditorScope, c as HistoryGroupOptions } from './editor-scope-C7ke1KJG.js';
4
+ import { C as CollaborationDiagnosticCode, c as CustomNodeDiagnosticCode, D as DiagnosticErrorName, F as FailureStage, B as ByteSizeBucket, b as CountBucket, f as DocumentOpenDiagnosticCode, a as DocumentPartKind, g as DocumentSaveDiagnosticCode, E as EditDiagnosticCode, j as ReviewDiagnosticCode, k as ReviewOperation, R as ReviewChangeKind, i as FormattingChangeKind, h as FontDiagnosticCode, H as HistoryDiagnosticCode, P as PerformanceDiagnosticCode } from './diagnostic-hints-C9JlLz1L.js';
4
5
  import { DocEdits, DocQueries, DocQueryResults, ContentControlSummary } from './contracts/document.js';
5
6
  import { InteractionOutcome } from './contracts/interaction.js';
6
- import { a as SemanticSelection, S as SemanticPosition } from './semantic-interaction-Dc3pf3hr.js';
7
- import { I as ImageResourceState, S as SupportedImageMime } from './image-resources-Bipz8toD.js';
8
- import { a as DocumentProtectionState } from './document-protection-8eyMWIJ0.js';
7
+ import { a as SemanticSelection, S as SemanticPosition } from './semantic-interaction-dApRIYpt.js';
8
+ import { a as DocumentProtectionState } from './document-protection-C8x3P2J6.js';
9
9
  import { C as CollaborationStatus } from './failure-NS2lsya4.js';
10
- import { C as CollaborationDiagnosticCode, c as CustomNodeDiagnosticCode, D as DiagnosticErrorName, F as FailureStage, B as ByteSizeBucket, b as CountBucket, f as DocumentOpenDiagnosticCode, a as DocumentPartKind, g as DocumentSaveDiagnosticCode, E as EditDiagnosticCode, j as ReviewDiagnosticCode, k as ReviewOperation, R as ReviewChangeKind, i as FormattingChangeKind, h as FontDiagnosticCode, H as HistoryDiagnosticCode, P as PerformanceDiagnosticCode } from './diagnostic-hints-2Bke6H_w.js';
11
10
 
12
11
  /**
13
12
  * When the review pane opens by itself.
@@ -50,7 +49,8 @@ type ReviewPaneOverflow = 'float' | 'shrinkPage' | 'scroll';
50
49
  * - `'balloons'`: the pane lists comments only, except comments that reply to a tracked
51
50
  * change: the change's balloon shows those. A tracked change opens in a balloon at its
52
51
  * text when the reader clicks it, or when Next Change, Previous Change, or
53
- * `setActiveReviewItem(key, { announce: true })` reaches it.
52
+ * `setActiveReviewItem(key, { announce: true })` reaches it. A replacement is one balloon.
53
+ * In both settings, Next Change and Previous Change stop on a replacement once.
54
54
  *
55
55
  * @public
56
56
  */
@@ -488,7 +488,11 @@ interface EditorEvents {
488
488
  revisionMarkupChange: (settings: ResolvedRevisionMarkup) => void;
489
489
  /** A document mutation committed, with the ids it touched. */
490
490
  change: (change: DocumentChange) => void;
491
- /** The selection or its derived formatting moved. */
491
+ /**
492
+ * Observable editor state moved without a document change: the selection or its derived
493
+ * formatting, the armed typing format, the open header or footer, or the collaboration
494
+ * session's status.
495
+ */
492
496
  selectionChange: (snapshot: EditorSnapshot) => void;
493
497
  error: (error: EditorError) => void;
494
498
  historyDiagnostic: (diagnostic: HistoryDiagnostic) => void;
@@ -527,7 +531,42 @@ interface EditorEvents {
527
531
  * ```
528
532
  */
529
533
  reviewItemReveal: (event: ReviewItemRevealEvent) => void;
534
+ /**
535
+ * The editor's pages are now in another document: it was attached for the first time, moved
536
+ * into another element or window, detached (`document` is `null`), or found its element
537
+ * moved to another window by the host. Custom chrome that listens on the editor's document
538
+ * or measures its window re-binds here.
539
+ *
540
+ * @example
541
+ * ```ts
542
+ * editor.on('hostChange', ({ document }) => {
543
+ * stopShortcuts?.();
544
+ * stopShortcuts = document ? listenForShortcuts(document) : undefined;
545
+ * });
546
+ * ```
547
+ */
548
+ hostChange: (event: EditorHostChange) => void;
530
549
  }
550
+ /**
551
+ * The payload of the `hostChange` event.
552
+ *
553
+ * @public
554
+ */
555
+ interface EditorHostChange {
556
+ /** The document the pages are mounted in now, or `null` while the editor is detached. */
557
+ readonly document: EditorHostDocument | null;
558
+ }
559
+ /**
560
+ * The DOM `Document`, wherever DOM types are loaded (every browser host).
561
+ *
562
+ * Read from `globalThis` rather than named, so this contract also compiles in the engine's
563
+ * DOM-free lanes and on servers, where it falls back to `object`.
564
+ *
565
+ * @public
566
+ */
567
+ type EditorHostDocument = typeof globalThis extends {
568
+ readonly document: infer D;
569
+ } ? D : object;
531
570
  /**
532
571
  * The payload of the `reviewItemReveal` event.
533
572
  *
@@ -535,17 +574,18 @@ interface EditorEvents {
535
574
  */
536
575
  interface ReviewItemRevealEvent {
537
576
  /**
538
- * The key of the review item to open, as `getReviewItems()` without `pairReplacements`
539
- * lists it. Next Change and Previous Change step through that unpaired queue, so for a
540
- * replacement this is the key of its deletion or its insertion. `setActiveReviewItem`
577
+ * The key of the review item to open, as `getReviewItems({ pairReplacements: false })`
578
+ * lists it, so for a replacement this is the key of its deletion or its insertion. Next
579
+ * Change and Previous Change stop once on a replacement and report its deletion's key,
580
+ * with the pair's key in {@link ReviewItemRevealEvent.pairKey}. `setActiveReviewItem`
541
581
  * reports the key it was given, so a call with a pair's key reports that key here and in
542
582
  * {@link ReviewItemRevealEvent.pairKey}.
543
583
  */
544
584
  readonly key: string;
545
585
  /**
546
- * The key that `getReviewItems({ pairReplacements: true })` gives the replacement this item
547
- * belongs to. Present only when the item is a paired replacement or one half of one. A
548
- * host that lists pairs opens `pairKey ?? key`.
586
+ * The key that `getReviewItems()` gives the replacement this item belongs to, since it
587
+ * pairs replacements by default. Present only when the item is a paired replacement or one
588
+ * half of one. A host that reads the default list opens `pairKey ?? key`.
549
589
  */
550
590
  readonly pairKey?: string;
551
591
  /**
@@ -897,7 +937,7 @@ interface EditorReviewHits {
897
937
  *
898
938
  * Filtering revision kinds is how a host hides structural cards it has no UI for,
899
939
  * `placement: false` skips the layout pass entirely when only metadata is wanted, and
900
- * `pairReplacements` lists a typed-over selection as one decision.
940
+ * `pairReplacements: false` lists a typed-over selection as its two halves.
901
941
  */
902
942
  interface ReviewItemQuery {
903
943
  /**
@@ -910,8 +950,12 @@ interface ReviewItemQuery {
910
950
  /** When false, skip layout geometry; metadata is unchanged and anchors are null. Default true. */
911
951
  readonly placement?: boolean;
912
952
  /**
913
- * When true, list a deletion and the insertion that directly follows it as one
914
- * `'replace'` item. Default false.
953
+ * Whether to list a deletion and the insertion that directly follows it as one
954
+ * `'replace'` item. Default true. Set it to false to list the deletion and the insertion as
955
+ * separate items, for example to accept or reject each half on its own.
956
+ *
957
+ * A host that steps through the list with `setActiveReviewItem` stops once on
958
+ * each replacement with the default, as Next Change does.
915
959
  *
916
960
  * Two revisions pair when they are next to each other among the queue's revisions, the
917
961
  * deletion comes first, both have the same author, nesting level and `readOnly` value, and
@@ -931,6 +975,43 @@ interface ReviewItemQuery {
931
975
  readonly pairReplacements?: boolean;
932
976
  }
933
977
 
978
+ /**
979
+ * The refused-open read model, split out of `editor.ts`.
980
+ *
981
+ * Re-exported from `editor.ts`, so consumers keep importing
982
+ * `@docx-editor.dev/core/contracts/editor`.
983
+ */
984
+
985
+ /**
986
+ * What a person can do about a document that did not open. It groups the open codes so a
987
+ * host can pick a message without listing every code:
988
+ *
989
+ * - `damaged`: the archive or its XML is broken. Saving the file again in a desktop editor
990
+ * can repair it.
991
+ * - `not-docx`: the bytes are not a `.docx` document, or hold no main document.
992
+ * - `too-large`: the file crosses a size, count or depth limit.
993
+ * - `blocked`: the file uses XML features that the editor refuses for security.
994
+ * - `unknown`: any other failure.
995
+ *
996
+ * @public
997
+ */
998
+ type DocumentOpenFailureReason = 'damaged' | 'not-docx' | 'too-large' | 'blocked' | 'unknown';
999
+ /**
1000
+ * A document the editor refused to open. It carries a stable code only, never the file's
1001
+ * content or name, so a host can show it, log it, or send it with a support request.
1002
+ *
1003
+ * Each refusal is a new object, so a host can compare it by reference to tell a second
1004
+ * refusal of the same file from the first.
1005
+ *
1006
+ * @public
1007
+ */
1008
+ interface DocumentOpenFailure {
1009
+ /** The stable open code, the same one the `document.open` diagnostic reports. */
1010
+ readonly code: DocumentOpenDiagnosticCode;
1011
+ /** The group of {@link DocumentOpenFailure.code} that picks the message. */
1012
+ readonly reason: DocumentOpenFailureReason;
1013
+ }
1014
+
934
1015
  /**
935
1016
  * How activating a review item places it in the viewport, and whether it announces the
936
1017
  * reveal.
@@ -1046,8 +1127,8 @@ interface ReviewRevisionPlacement extends ReviewItemPlacementBase {
1046
1127
  readonly revisionKind: ReviewRevisionKind;
1047
1128
  /**
1048
1129
  * The words a replacement decision removes when {@link revisionKind} is `'replace'`.
1049
- * The built-in reader lists separate deletion and insertion cards unless the query sets
1050
- * {@link ReviewItemQuery.pairReplacements}.
1130
+ * The built-in reader lists separate deletion and insertion cards when the query sets
1131
+ * {@link ReviewItemQuery.pairReplacements} to false.
1051
1132
  */
1052
1133
  readonly replacedText?: string;
1053
1134
  readonly item: ReviewRevisionItem;
@@ -1319,7 +1400,8 @@ interface EditorFormatPainterCommands {
1319
1400
  * direct paragraph properties as well.
1320
1401
  *
1321
1402
  * Non-mutating: the capture lives on the editor, not in the document, and it survives
1322
- * until the next capture or until the editor is detached.
1403
+ * until the next capture, a document load, or `destroy()`, including across a `detach()`
1404
+ * and a later `attach()`.
1323
1405
  */
1324
1406
  copyFormatting: Record<never, never>;
1325
1407
  /**
@@ -1450,6 +1532,110 @@ interface SelectedImageState {
1450
1532
  */
1451
1533
  type ImageContext = SelectedImageState;
1452
1534
 
1535
+ /**
1536
+ * Which kind of story a bookmark is in: the main text, a header or footer, or a note.
1537
+ *
1538
+ * @public
1539
+ */
1540
+ type BookmarkStory = 'body' | 'headerFooter' | 'note';
1541
+ /**
1542
+ * Where a bookmark is, finer than {@link BookmarkStory}: the main text, a header, a footer, a
1543
+ * footnote or an endnote.
1544
+ *
1545
+ * @public
1546
+ */
1547
+ type BookmarkPlace = 'body' | 'header' | 'footer' | 'footnote' | 'endnote';
1548
+ /**
1549
+ * One bookmark, as the `bookmarks` query lists it.
1550
+ *
1551
+ * @public
1552
+ */
1553
+ interface BookmarkSummary {
1554
+ /** The name as the document writes it. Names compare without case. */
1555
+ readonly name: string;
1556
+ /** Whether the name starts with an underscore. Hidden bookmarks mark application targets. */
1557
+ readonly hidden: boolean;
1558
+ /** The story the bookmark starts in. */
1559
+ readonly story: BookmarkStory;
1560
+ /** The same story, telling a header from a footer and a footnote from an endnote. */
1561
+ readonly place: BookmarkPlace;
1562
+ /**
1563
+ * Position in document order: the main text first, then headers, footers and notes. Sort by
1564
+ * this value to list bookmarks by location.
1565
+ */
1566
+ readonly order: number;
1567
+ /** Whether the bookmark marks a point rather than a range of text. */
1568
+ readonly empty: boolean;
1569
+ /** Whether the start of the selection is inside the bookmark, edges included. */
1570
+ readonly atSelection: boolean;
1571
+ /**
1572
+ * How many other places carry the same name. Usually 0. Collaborators who add one name while
1573
+ * offline can leave copies; the list, Go To and links use this bookmark, the first in
1574
+ * document order. Adding the name again at this bookmark keeps it and removes the copies.
1575
+ */
1576
+ readonly duplicates: number;
1577
+ }
1578
+ /**
1579
+ * The bookmark commands an editor accepts.
1580
+ *
1581
+ * @public
1582
+ */
1583
+ interface EditorBookmarkCommands {
1584
+ /**
1585
+ * Bookmark the selection under `name`, or the caret position when the selection is
1586
+ * collapsed. A bookmark that already has the name, compared without case, moves here, also
1587
+ * from another story, in one undo step. Two collaborators who add one name offline both keep
1588
+ * their bookmark; every replica reads the first in document order until the next write of the
1589
+ * name, which replaces or removes both.
1590
+ * Refused with `invalidArgs` for a name that does not start with a letter, holds a
1591
+ * character other than a letter, a digit or an underscore, or has more than 40 characters.
1592
+ */
1593
+ insertBookmark: {
1594
+ name: string;
1595
+ };
1596
+ /**
1597
+ * Remove the bookmark with this name, compared without case, and any copies of it in other
1598
+ * places. The text stays.
1599
+ */
1600
+ deleteBookmark: {
1601
+ name: string;
1602
+ };
1603
+ /**
1604
+ * Keep the bookmark this name means, the first in document order, and remove its copies, in
1605
+ * one undo step. The selection does not move. Collaborators who add one name while offline
1606
+ * can leave copies; `BookmarkSummary.duplicates` counts them. Refused with `notFound` when no
1607
+ * bookmark has the name, and with `unsupported` when it has no copies.
1608
+ */
1609
+ keepFirstBookmark: {
1610
+ name: string;
1611
+ };
1612
+ /** Select the bookmark's text, or put the caret at a point bookmark, and scroll to it. */
1613
+ goToBookmark: {
1614
+ name: string;
1615
+ };
1616
+ /** Show or hide bracket marks at bookmarks. A view command: the document does not change. */
1617
+ toggleBookmarks: Record<never, never>;
1618
+ /**
1619
+ * Open the host's Go To UI, the Go to tab of `DocxEditor.Navigation`, the request its
1620
+ * shortcut (Ctrl+G, Cmd+Option+G on macOS) sends. Allowed in a read-only document. Refused
1621
+ * with `unsupported` while no host shows one. To jump without UI, run `goToBookmark`.
1622
+ *
1623
+ * `fromShortcut: true` asks as the shortcut does: also refused with `unsupported` when the
1624
+ * Go To UI turned its shortcut off (`GoToChromeHandlers.shortcut`). Chrome that forwards the
1625
+ * chord sends it, and a menu asks `can` with it before it shows the shortcut.
1626
+ */
1627
+ openGoTo: {
1628
+ readonly fromShortcut?: boolean;
1629
+ };
1630
+ /**
1631
+ * Open the Bookmark dialog the host registered, the same request the Insert menu and
1632
+ * Ctrl/Cmd+Shift+F5 send. Allowed in a read-only document, where Go To still works.
1633
+ * Refused with `unsupported` while no host shows a bookmark dialog, for example when the
1634
+ * `bookmark` popup is `false`.
1635
+ */
1636
+ openBookmarkDialog: Record<never, never>;
1637
+ }
1638
+
1453
1639
  /** Where the caret sits inside a table: its shape and current cell. */
1454
1640
  interface TableContext {
1455
1641
  readonly rows: number;
@@ -1682,6 +1868,11 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
1682
1868
  * Serialize the current document, finalizing pending text form values first.
1683
1869
  * Invalid input rejects with `EditorError.code === 'invalidArgs'` and remains editable.
1684
1870
  * Validation does not open a dialog. Other write refusals also reject the save.
1871
+ *
1872
+ * The bytes describe the document as it was when you called `save()`. The file is written
1873
+ * in short tasks, so input stays responsive while a long document saves, and edits made
1874
+ * meanwhile belong to the next save. Paragraphs and table rows unchanged since an earlier
1875
+ * save are not written again, so autosave after a small edit stays cheap.
1685
1876
  */
1686
1877
  save(): Promise<ArrayBuffer>;
1687
1878
  getDocumentHandle(): DocumentHandle;
@@ -1835,11 +2026,11 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
1835
2026
  setTableInteractionLabel(resolver: (key: 'table.insertRowBelow' | 'table.insertColumnRight') => string): void;
1836
2027
  /** Section page setup — size, orientation and margins — for the page-setup dialog. */
1837
2028
  getPageSetup(): PageSetup | null;
1838
- /** The document watermark, for the watermark dialog. */
1839
- getWatermark(): {
1840
- readonly kind: 'text' | 'image';
1841
- readonly text?: string;
1842
- } | null;
2029
+ /**
2030
+ * The watermark the document shows, read from the first section's headers; null when it
2031
+ * shows none. For a picture watermark's bytes, use `query({ type: 'watermark' })`.
2032
+ */
2033
+ getWatermark(): WatermarkState | null;
1843
2034
  /** Header/footer editing state: which region is being edited, if any. */
1844
2035
  getHeaderFooterState(): HeaderFooterState | null;
1845
2036
  /** Resolved and authored note properties for the caret section — properties dialog read-model. */
@@ -1932,8 +2123,25 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
1932
2123
  * Anchored to the RETAINED range when there is one, so a compose box that took focus does
1933
2124
  * not lose the words it is about — that is what retention exists for. Refused on a
1934
2125
  * collapsed caret: a comment with no range has nothing to point at, and Word writes none.
2126
+ *
2127
+ * A refused write names its cause, as every review write does: `code: 'locked'` with
2128
+ * `'the document is open for viewing'` in viewing or under read-only protection, and
2129
+ * `code: 'unsupported'` with the external refresh sentence or a collaboration reason token
2130
+ * such as `'collaboration-session-not-ready'` (wait for the session, then retry). Branch on
2131
+ * `diagnosticCodeOfRefusal(result.reason, result.code)`, not on the text.
2132
+ *
2133
+ * Pass `options.historyGroup` to make the comment part of a larger undo step, such as a
2134
+ * review decision that also resolves changes. See {@link HistoryGroupOptions}.
2135
+ *
2136
+ * @example
2137
+ * ```ts
2138
+ * editor.addComment('Counter-proposal: 45 days.', { historyGroup: decision });
2139
+ * editor.addComment('Approved.', 'Legal team', { historyGroup: decision });
2140
+ * ```
1935
2141
  */
1936
- addComment(text: string, author?: string): ExecResult;
2142
+ addComment(text: string, options?: HistoryGroupOptions): ExecResult;
2143
+ /** {@link addComment} with an author for this call, overriding the configured author. */
2144
+ addComment(text: string, author?: string, options?: HistoryGroupOptions): ExecResult;
1937
2145
  /**
1938
2146
  * Where a comment on the current selection would sit, in the same space as
1939
2147
  * {@link ReviewItemPlacement.anchorY}, or null when nothing is selected.
@@ -1969,16 +2177,15 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
1969
2177
  * caret that merely lands in a change leaves this `null`. Open a balloon or card for the
1970
2178
  * activated item, and highlight the caret-active one.
1971
2179
  *
1972
- * Pass the query you read items with, so the key matches theirs: with
1973
- * `pairReplacements: true`, a paired replacement reports the pair's key; without it, the
1974
- * key of the half the caret is in. The value changes with the selection, so read it again
1975
- * on `selectionChange`.
2180
+ * Pass the query you read items with, so the key matches theirs. By default a paired
2181
+ * replacement reports the pair's key; with `pairReplacements: false`, the key of the half
2182
+ * the caret is in. The value changes with the selection, so read it again on
2183
+ * `selectionChange`.
1976
2184
  *
1977
2185
  * @example
1978
2186
  * ```ts
1979
- * const query = { pairReplacements: true };
1980
2187
  * editor.on('selectionChange', () => {
1981
- * const activated = editor.getActivatedReviewItemKey(query);
2188
+ * const activated = editor.getActivatedReviewItemKey();
1982
2189
  * if (activated !== null) showMyCard(activated);
1983
2190
  * });
1984
2191
  * ```
@@ -2005,17 +2212,20 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
2005
2212
  *
2006
2213
  * Refused for a card whose kind the engine cannot resolve structurally, which is why
2007
2214
  * `readOnly` is on the item — a surface should not offer the button in the first place.
2215
+ * Other refusals name their cause, as {@link addComment} describes.
2008
2216
  */
2009
- acceptReviewItem(key: string): ExecResult;
2010
- rejectReviewItem(key: string): ExecResult;
2217
+ acceptReviewItem(key: string, options?: HistoryGroupOptions): ExecResult;
2218
+ /** The rejecting half of {@link acceptReviewItem}, with the same rules and options. */
2219
+ rejectReviewItem(key: string, options?: HistoryGroupOptions): ExecResult;
2011
2220
  /**
2012
2221
  * Resolve or reopen the comment thread behind a review card.
2013
2222
  *
2014
2223
  * The thread state is written through the same package transaction as every other comment
2015
2224
  * mutation, so `commentsExtended.xml`, Undo and save/reopen cannot disagree. Repeating the
2016
- * state already on the item succeeds without adding an undo entry.
2225
+ * state already on the item succeeds without adding an undo entry. A refusal names its cause,
2226
+ * as {@link addComment} describes.
2017
2227
  */
2018
- setCommentResolved(key: string, resolved: boolean): ExecResult;
2228
+ setCommentResolved(key: string, resolved: boolean, options?: HistoryGroupOptions): ExecResult;
2019
2229
  /**
2020
2230
  * Discard the item behind a card: the destructive half of the review verbs.
2021
2231
  *
@@ -2029,9 +2239,10 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
2029
2239
  * a surface can put one "remove this" affordance on every card instead of branching.
2030
2240
  *
2031
2241
  * Refused on a custom node's card, which is informational, and on a revision kind the engine
2032
- * cannot resolve — the same rule {@link rejectReviewItem} follows.
2242
+ * cannot resolve — the same rule {@link rejectReviewItem} follows. Other refusals name their
2243
+ * cause, as {@link addComment} describes, and leave the open card and its draft open.
2033
2244
  */
2034
- deleteReviewItem(key: string): ExecResult;
2245
+ deleteReviewItem(key: string, options?: HistoryGroupOptions): ExecResult;
2035
2246
  /**
2036
2247
  * Reply to a review item.
2037
2248
  *
@@ -2042,8 +2253,11 @@ interface Editor extends EditorAnchorNavigation, EditorHighlights, EditorReviewH
2042
2253
  * The author is AMBIENT — `DocxEditorConfig.author`, the way the rest of the authored commands
2043
2254
  * source it — and the argument overrides it for one call. `CT_Comment` makes `@w:author`
2044
2255
  * required, so a reply with neither is refused rather than written as an empty attribute.
2256
+ * Other refusals name their cause, as {@link addComment} describes.
2045
2257
  */
2046
- replyToReviewItem(key: string, text: string, author?: string): ExecResult;
2258
+ replyToReviewItem(key: string, text: string, options?: HistoryGroupOptions): ExecResult;
2259
+ /** {@link replyToReviewItem} with an author for this call, overriding the configured author. */
2260
+ replyToReviewItem(key: string, text: string, author?: string, options?: HistoryGroupOptions): ExecResult;
2047
2261
  setActiveScope(scope: ViewScope): void;
2048
2262
  getActiveScope(): ViewScope;
2049
2263
  query<K extends keyof EditorQueries>(query: {
@@ -2167,7 +2381,7 @@ type TrackedChangeFilterMode = 'accept' | 'reject';
2167
2381
  * selection, view state, chrome modes, header/footer and note editing. An interface rather than a
2168
2382
  * closed union so an extension can widen it by declaration merging.
2169
2383
  */
2170
- interface EditorCommands extends EditorCommandShape<DocEdits>, EditorHeaderFooterCommands, EditorNoteCommands, EditorFormatPainterCommands {
2384
+ interface EditorCommands extends EditorCommandShape<DocEdits>, EditorHeaderFooterCommands, EditorNoteCommands, EditorFormatPainterCommands, EditorBookmarkCommands {
2171
2385
  /** Switch how edits are written. A view command: it changes no document state. */
2172
2386
  setEditingMode: {
2173
2387
  mode: DocumentEditingMode;
@@ -2186,7 +2400,17 @@ interface EditorCommands extends EditorCommandShape<DocEdits>, EditorHeaderFoote
2186
2400
  toggleParagraphMarks: Record<never, never>;
2187
2401
  /** Word's Protect Document: enforce filling-in-forms protection, or lift the enforced one. */
2188
2402
  toggleDocumentProtection: Record<never, never>;
2189
- /** Navigate tracked changes, including hidden formatting balloons, and wrap at the end. */
2403
+ /**
2404
+ * Navigate tracked changes, including hidden formatting balloons, and wrap at the end.
2405
+ *
2406
+ * A replacement is one stop in every review layout. A replacement is a deletion and the
2407
+ * touching insertion from the same author that took its place. Navigation lands on the
2408
+ * deletion, highlights both halves, and `reviewItemReveal` carries the pair's `pairKey`.
2409
+ *
2410
+ * Navigation steps through the changes {@link Editor.getReviewItems} returns, so a
2411
+ * reviewer or `setTrackedChangesFilter` filter applies. When a filter hides one half of a
2412
+ * replacement, the other half is a stop of its own.
2413
+ */
2190
2414
  navigateReviewChange: {
2191
2415
  direction: 'next' | 'previous';
2192
2416
  };
@@ -2394,11 +2618,10 @@ interface EditorCommands extends EditorCommandShape<DocEdits>, EditorHeaderFoote
2394
2618
  positionTwips: number;
2395
2619
  };
2396
2620
  /**
2397
- * Replace one found match with `text`. Addressed by {@link TextMatch} rather than a
2398
- * `DocTarget` because that is what `findMatches` hands back, and re-deriving a target
2399
- * from it in the caller is where an off-by-one would come from. An empty `text`
2400
- * deletes the match, which is what a find/replace dialog means by replacing with
2401
- * nothing.
2621
+ * Replace one found match with `text`, addressed by the {@link TextMatch} `findMatches`
2622
+ * returns. An empty `text` deletes it. The selection and scroll position stay put. In
2623
+ * suggesting mode it is a tracked replacement under the editor's author, refused where
2624
+ * `proposeReplacement` would be. The match must be in the open story, not a text box.
2402
2625
  */
2403
2626
  replaceMatch: {
2404
2627
  match: TextMatch;
@@ -2505,6 +2728,11 @@ interface EditorCommands extends EditorCommandShape<DocEdits>, EditorHeaderFoote
2505
2728
  drawingNodeId?: string;
2506
2729
  expectedPackageRevision?: number;
2507
2730
  };
2731
+ /**
2732
+ * Replace the document watermark in every header the document shows; null removes it. One
2733
+ * undo step. Refuses with `invalidArgs` for an invalid option and `locked` in a protected
2734
+ * document; a refusal writes nothing. See {@link Watermark} for the options and defaults.
2735
+ */
2508
2736
  setWatermark: {
2509
2737
  watermark: Watermark | null;
2510
2738
  };
@@ -2614,6 +2842,8 @@ interface EditorQueries extends DocQueries {
2614
2842
  pos: number;
2615
2843
  };
2616
2844
  trackedChanges: Record<never, never>;
2845
+ /** Every bookmark in the document, hidden ones included, in document order. */
2846
+ bookmarks: Record<never, never>;
2617
2847
  }
2618
2848
  /**
2619
2849
  * One query, as a discriminated union derived from {@link EditorQueries}.
@@ -2640,6 +2870,7 @@ interface EditorQueryResults extends DocQueryResults {
2640
2870
  contentControlAt: ContentControlSummary | null;
2641
2871
  isInsideToc: boolean;
2642
2872
  trackedChanges: readonly Revision[];
2873
+ bookmarks: readonly BookmarkSummary[];
2643
2874
  }
2644
2875
  /**
2645
2876
  * One occurrence of a search query in the document.
@@ -2744,6 +2975,13 @@ interface EditorSnapshot {
2744
2975
  */
2745
2976
  readonly isOpening?: boolean;
2746
2977
  readonly parseError: string | null;
2978
+ /**
2979
+ * Why the last supplied document did not open, or `null` while it opens or after it opened.
2980
+ * Unlike {@link EditorSnapshot.parseError}, it holds a stable code and never quotes the
2981
+ * file, so a host can show it to a person. `DocxEditor.OpenFailure` renders it. Optional
2982
+ * and additive: absent means the implementation has not derived it, read as `null`.
2983
+ */
2984
+ readonly openFailure?: DocumentOpenFailure | null;
2747
2985
  /** Whether the loaded document is being edited: a patchable document opened in edit mode. A
2748
2986
  * read-only document (tables/SDTs/unpreservable) or `mode: 'view'` reports false. */
2749
2987
  readonly editable: boolean;
@@ -2819,6 +3057,8 @@ interface EditorSnapshot {
2819
3057
  readonly reviewPane: ResolvedReviewPane;
2820
3058
  /** Whether Show/Hide paragraph marks is enabled. */
2821
3059
  readonly showParagraphMarks?: boolean;
3060
+ /** Whether bracket marks are shown at bookmarks. */
3061
+ readonly showBookmarks?: boolean;
2822
3062
  /** The document's `w:documentProtection`, as the file states it; null with no document. */
2823
3063
  readonly documentProtection?: DocumentProtectionState | null;
2824
3064
  /** The displayed revision projection. The document and its revision history stay unchanged. */
@@ -2889,11 +3129,13 @@ interface EditorSnapshot {
2889
3129
  * An error the engine raised, carrying a machine-readable `code` alongside the message.
2890
3130
  *
2891
3131
  * `code` is optional because an `Error` from deeper down (a parser, a codec) is surfaced as-is
2892
- * rather than wrapped in a fabricated code.
3132
+ * rather than wrapped in a fabricated code. The editor's own codes: `invalidTarget` (`attach`
3133
+ * cannot mount there), `unsupported` (a source it refuses to open), and `hostCallback` (a host
3134
+ * callback such as a bookmark mark's `decorate` threw; the editor kept its default behavior).
2893
3135
  */
2894
3136
  interface EditorError extends Error {
2895
3137
  readonly code?: string;
2896
3138
  }
2897
3139
 
2898
- export { DIAGNOSTIC_SCHEMA_VERSION as D, resolveReviewPane as a$, DEFAULT_REVIEW_PANE as aQ, cropPercentFromCropPermille as aW, cropPercentFromPermille as aX, cropPercentFromSourceCrop as aY, cropPermilleFromCropPercent as aZ, cropPermilleFromPercent as a_, reviewPaneListsItem as b0, sourceCropFromCropPercent as b1, validateImageCropPercent as b2, EditorFontError as z };
2899
- export type { HeaderFooterState as $, AnchorHighlightAnimation as A, EditorFontErrorCode as B, CanResult as C, EditorDiagnostic as E, EditorFormatPainterCommands as F, EditorHeaderFooterCommands as G, EditorHighlights as H, EditorNoteCommands as I, EditorPosition as J, EditorQueries as K, EditorQuery as L, EditorQueryResults as M, EditorReviewHits as N, EditorSelection as O, EditorSnapshot as P, FontConfiguration as Q, ReviewPaneOptions as R, FontFaceRequest as S, FontFailedDiagnostic as T, FontSource as U, FontSourceSubstitution as V, FormatPainterLevel as W, FormatPainterMode as X, FormatPainterSurfaceState as Y, FurnitureVariant as Z, HeaderFooterSlotArgs as _, EditorDiagnosticKind as a, HighlightHit as a0, HighlightOptions as a1, HighlightRange as a2, HighlightRect as a3, HighlightResult as a4, HistoryDiagnosticEvent as a5, HyperlinkInfo as a6, ImageContext as a7, ImageCropPercent as a8, NoteKind as a9, TableBorderStyle as aA, TableBorderTarget as aB, TableCellVerticalAlignment as aC, TableColumnDividerResizeTarget as aD, TableColumnOccurrenceTarget as aE, TableContext as aF, TableRightEdgeResizeTarget as aG, TableRowOccurrenceTarget as aH, TextMatch as aI, TimingSummary as aJ, TrackedChangeFilterMode as aK, TrackedChangePredicate as aL, ZoomFitTarget as aM, ZoomMode as aN, ReviewPaneOverflow as aO, CommentMarkerStyle as aP, ImageCropPermille as aR, ResolvedReviewPane as aS, ReviewPaneItemFields as aT, ReviewPaneOpening as aU, RevisionDisplay as aV, NotePropertiesSide as aa, NotePropertiesState as ab, PageSetup as ac, PerformanceDiagnostic as ad, ResolveReviewChangesOptions as ae, ResolvedNoteNumbering as af, ReviewActivationOptions as ag, ReviewChangesAttribution as ah, ReviewCommentPlacement as ai, ReviewCustomPlacement as aj, ReviewItemHit as ak, ReviewItemPlacement as al, ReviewItemPlacementBase as am, ReviewItemQuery as an, ReviewItemRevealEvent as ao, ReviewItemRevealSource as ap, ReviewRevisionPlacement as aq, ReviewSkippedDiagnostic as ar, ScrollPlacement as as, ScrollToAnchorOptions as at, SelectedImageState as au, SessionActivity as av, SessionDiagnostic as aw, SetReviewChangesAuthorOptions as ax, TableBorderEdgeTarget as ay, TableBorderSpec as az, EditorCommand as b, AnchorHighlightOptions as c, AuthoredNoteNumbering as d, ClearAnchorHighlightOptions as e, CollaborationParticipantsDiagnostic as f, CollaborationStatusDiagnostic as g, CustomNodeDiagnosticEvent as h, DiagnosticBase as i, DiagnosticFailureDetail as j, DocumentChange as k, DocumentEditingMode as l, DocumentHandle as m, DocumentOpenDiagnostic as n, DocumentSaveDiagnostic as o, DocumentShape as p, DocumentSource as q, EditRejectedDiagnostic as r, EditRejectionOrigin as s, Editor as t, EditorAnchorNavigation as u, EditorCommandShape as v, EditorCommands as w, EditorError as x, EditorEvents as y };
3140
+ export { DIAGNOSTIC_SCHEMA_VERSION as D, EditorFontError as J, DEFAULT_REVIEW_PANE as aY, cropPercentFromCropPermille as b2, cropPercentFromPermille as b3, cropPercentFromSourceCrop as b4, cropPermilleFromCropPercent as b5, cropPermilleFromPercent as b6, resolveReviewPane as b7, reviewPaneListsItem as b8, sourceCropFromCropPercent as b9, validateImageCropPercent as ba };
3141
+ export type { FontFailedDiagnostic as $, AnchorHighlightAnimation as A, BookmarkPlace as B, CanResult as C, EditorDiagnostic as E, EditorCommandShape as F, EditorCommands as G, EditorError as H, EditorEvents as I, EditorFontErrorCode as K, EditorFormatPainterCommands as L, EditorHeaderFooterCommands as M, EditorHighlights as N, EditorHostChange as O, EditorHostDocument as P, EditorNoteCommands as Q, ReviewPaneOptions as R, EditorPosition as S, EditorQueries as T, EditorQuery as U, EditorQueryResults as V, EditorReviewHits as W, EditorSelection as X, EditorSnapshot as Y, FontConfiguration as Z, FontFaceRequest as _, EditorDiagnosticKind as a, ReviewPaneItemFields as a$, FontSource as a0, FontSourceSubstitution as a1, FormatPainterLevel as a2, FormatPainterMode as a3, FormatPainterSurfaceState as a4, FurnitureVariant as a5, HeaderFooterSlotArgs as a6, HeaderFooterState as a7, HighlightHit as a8, HighlightOptions as a9, ScrollPlacement as aA, ScrollToAnchorOptions as aB, SelectedImageState as aC, SessionActivity as aD, SessionDiagnostic as aE, SetReviewChangesAuthorOptions as aF, TableBorderEdgeTarget as aG, TableBorderSpec as aH, TableBorderStyle as aI, TableBorderTarget as aJ, TableCellVerticalAlignment as aK, TableColumnDividerResizeTarget as aL, TableColumnOccurrenceTarget as aM, TableContext as aN, TableRightEdgeResizeTarget as aO, TableRowOccurrenceTarget as aP, TextMatch as aQ, TimingSummary as aR, TrackedChangeFilterMode as aS, TrackedChangePredicate as aT, ZoomFitTarget as aU, ZoomMode as aV, ReviewPaneOverflow as aW, CommentMarkerStyle as aX, ImageCropPermille as aZ, ResolvedReviewPane as a_, HighlightRange as aa, HighlightRect as ab, HighlightResult as ac, HistoryDiagnosticEvent as ad, HyperlinkInfo as ae, ImageContext as af, ImageCropPercent as ag, NoteKind as ah, NotePropertiesSide as ai, NotePropertiesState as aj, PageSetup as ak, PerformanceDiagnostic as al, ResolveReviewChangesOptions as am, ResolvedNoteNumbering as an, ReviewActivationOptions as ao, ReviewChangesAttribution as ap, ReviewCommentPlacement as aq, ReviewCustomPlacement as ar, ReviewItemHit as as, ReviewItemPlacement as at, ReviewItemPlacementBase as au, ReviewItemQuery as av, ReviewItemRevealEvent as aw, ReviewItemRevealSource as ax, ReviewRevisionPlacement as ay, ReviewSkippedDiagnostic as az, EditorCommand as b, ReviewPaneOpening as b0, RevisionDisplay as b1, AnchorHighlightOptions as c, AuthoredNoteNumbering as d, BookmarkStory as e, BookmarkSummary as f, ClearAnchorHighlightOptions as g, CollaborationParticipantsDiagnostic as h, CollaborationStatusDiagnostic as i, CustomNodeDiagnosticEvent as j, DiagnosticBase as k, DiagnosticFailureDetail as l, DocumentChange as m, DocumentEditingMode as n, DocumentHandle as o, DocumentOpenDiagnostic as p, DocumentOpenFailure as q, DocumentOpenFailureReason as r, DocumentSaveDiagnostic as s, DocumentShape as t, DocumentSource as u, EditRejectedDiagnostic as v, EditRejectionOrigin as w, Editor as x, EditorAnchorNavigation as y, EditorBookmarkCommands as z };
@@ -4,13 +4,33 @@ interface HistoryGroup {
4
4
  readonly [historyGroupBrand]: true;
5
5
  /** Closed after `end()`, document replacement, detach, or destruction. */
6
6
  readonly state: 'open' | 'closed';
7
+ /**
8
+ * The outcome of the latest write that named this handle, or `null` before the first one.
9
+ *
10
+ * Every grouped write reports here. A browser runtime `run({ historyGroup }, callback)` is
11
+ * ONE write, whatever number of syncs it makes: it has no `ExecResult`, and it settles here
12
+ * once, after the callback finishes. A split anywhere in the run makes its outcome `split`. Read it
13
+ * after a write to learn whether the write started, extended, or split the group.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * await runtime.run({ historyGroup: decision }, async (context) => {
18
+ * context.document.body.insertParagraph('Revised terms follow.', 'End');
19
+ * await context.sync();
20
+ * });
21
+ * if (decision.lastOutcome?.kind === 'split') console.warn(decision.lastOutcome.reason);
22
+ * ```
23
+ */
24
+ readonly lastOutcome: HistoryGroupOutcome | null;
7
25
  /** End this gesture without reverting any edits. Safe to call more than once. */
8
26
  end(): void;
9
27
  }
10
28
  /** The history authority's result for this frame. @public */
11
29
  interface HistoryGroupOutcome {
12
30
  readonly kind: 'started' | 'extended' | 'split' | 'none';
13
- readonly reason?: 'history-boundary' | 'undo-redo' | 'no-history' | 'package-unit' | 'composition';
31
+ readonly reason?: 'history-boundary' | 'undo-redo' | 'no-history'
32
+ /** @deprecated No longer reported: writes that span document parts now extend the group. */
33
+ | 'package-unit' | 'composition';
14
34
  }
15
35
  /**
16
36
  * The editor is N+1 editing views: one body plus one per header/footer relationship, plus
@@ -63,12 +83,45 @@ type EditorScope = {
63
83
  type ViewScope = Exclude<EditorScope, {
64
84
  kind: 'all';
65
85
  }>;
86
+ /**
87
+ * Options for a review write that can join an explicit history group.
88
+ *
89
+ * Every write that names one open handle becomes part of one undo step, across commands,
90
+ * review methods, and browser automation runs. A closed handle, or a handle from another
91
+ * editor, refuses the write with `code: 'unsupported'` and changes nothing.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const decision = editor.beginHistoryGroup();
96
+ * // Reply first: the card's key no longer exists after the change is accepted.
97
+ * const reply = editor.replyToReviewItem(key, 'Accepted with one change.', {
98
+ * historyGroup: decision,
99
+ * });
100
+ * const accepted = editor.acceptReviewItem(key, { historyGroup: decision });
101
+ * decision.end();
102
+ * if (!reply.ok || !accepted.ok) throw new Error('the review card was refused');
103
+ * editor.exec({ type: 'undo' }); // reverts both writes
104
+ * ```
105
+ * @public
106
+ */
107
+ interface HistoryGroupOptions {
108
+ /**
109
+ * An open handle from {@link Editor.beginHistoryGroup} on this editor.
110
+ *
111
+ * Undo, redo, and an ungrouped write close the group, so a later frame starts a new undo
112
+ * step. Inspect `ExecResult.history` to see whether a write started, extended, or split it.
113
+ */
114
+ readonly historyGroup?: HistoryGroup;
115
+ }
66
116
  /** Options for a command's editing view and explicit gesture. @public */
67
- interface EditorExecOptions {
117
+ interface EditorExecOptions extends HistoryGroupOptions {
68
118
  /** Omitted, the command addresses the current selection. */
69
119
  readonly scope?: EditorScope;
70
120
  /**
71
- * An open handle from this editor. Supported for synchronous formatting commands.
121
+ * An open handle from this editor. Supported for synchronous formatting commands, tracked
122
+ * proposals (`proposeInsertion`, `proposeDeletion`, `proposeReplacement`),
123
+ * `resolveAllReviewChanges`, and `setReviewChangesAuthor`. Other commands refuse a handle
124
+ * with `code: 'unsupported'`.
72
125
  * Intervening writes and undo/redo can split a gesture; inspect `ExecResult.history`.
73
126
  * Read-only commands do not close a gesture. Ungrouped collaboration uses timed capture.
74
127
  * See the core history grouping guide for gesture bindings and boundary rules.
@@ -81,4 +134,4 @@ interface HistoryDiagnostic {
81
134
  readonly reason: string;
82
135
  }
83
136
 
84
- export type { EditorScope as E, HistoryDiagnostic as H, ViewScope as V, EditorExecOptions as a, HistoryGroup as b, HistoryGroupOutcome as c };
137
+ export type { EditorScope as E, HistoryDiagnostic as H, ViewScope as V, EditorExecOptions as a, HistoryGroup as b, HistoryGroupOptions as c, HistoryGroupOutcome as d };