@stll/folio-core 0.72.0 → 0.73.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 (192) hide show
  1. package/README.md +12 -6
  2. package/dist/ai-edits/apply.d.ts +6 -114
  3. package/dist/ai-edits/apply.js +9 -131
  4. package/dist/ai-edits/applyTypes.d.ts +85 -0
  5. package/dist/ai-edits/applyTypes.js +24 -0
  6. package/dist/ai-edits/clean-text.d.ts +7 -1
  7. package/dist/ai-edits/clean-text.js +23 -2
  8. package/dist/ai-edits/finalSectionReview.d.ts +1 -1
  9. package/dist/ai-edits/headless.d.ts +29 -147
  10. package/dist/ai-edits/headless.js +213 -1634
  11. package/dist/ai-edits/index.d.ts +3 -3
  12. package/dist/ai-edits/index.js +2 -3
  13. package/dist/ai-edits/pending-suggestions.d.ts +14 -4
  14. package/dist/ai-edits/pending-suggestions.js +183 -90
  15. package/dist/ai-edits/result-validation.js +1 -1
  16. package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
  17. package/dist/ai-edits/snapshot.js +8 -3
  18. package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
  19. package/dist/ai-edits/table-cell-mutations.js +1 -1
  20. package/dist/ai-edits/table-geometry.d.ts +1 -1
  21. package/dist/ai-edits/table-geometry.js +1 -1
  22. package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
  23. package/dist/ai-edits/table-row-column-mutations.js +1 -1
  24. package/dist/ai-edits/tableNodes.d.ts +38 -0
  25. package/dist/ai-edits/tableNodes.js +86 -0
  26. package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
  27. package/dist/ai-edits/undefinedReferences.d.ts +7 -0
  28. package/dist/canonical/batchCommentReferences.js +1 -0
  29. package/dist/canonical/canonicalInlineProjection.js +1 -1
  30. package/dist/canonical/canonicalPublicOperations.js +228 -64
  31. package/dist/canonical/canonicalSession.d.ts +9 -1
  32. package/dist/canonical/canonicalSession.js +95 -15
  33. package/dist/compare/compare.d.ts +1 -1
  34. package/dist/compare/inline-atoms-model.d.ts +1 -1
  35. package/dist/compare/inline-atoms.d.ts +2 -2
  36. package/dist/compare/inline-provenance-model.d.ts +1 -1
  37. package/dist/compare/inline-provenance.d.ts +2 -2
  38. package/dist/compat/eigenpal.d.ts +3 -3
  39. package/dist/compat/eigenpal.js +2 -3
  40. package/dist/controller/canonicalClipboard.d.ts +13 -3
  41. package/dist/controller/canonicalClipboard.js +185 -49
  42. package/dist/controller/canonicalClipboardResources.d.ts +9 -1
  43. package/dist/controller/canonicalClipboardResources.js +22 -2
  44. package/dist/controller/canonicalReview.d.ts +1 -1
  45. package/dist/controller/canonicalReview.js +1 -1
  46. package/dist/controller/canonicalStructure.js +1 -1
  47. package/dist/controller/canonicalWatermark.d.ts +10 -0
  48. package/dist/controller/canonicalWatermark.js +37 -0
  49. package/dist/controller/hiddenEditorApi.d.ts +1 -1
  50. package/dist/controller/hiddenEditorManager.d.ts +4 -3
  51. package/dist/controller/hiddenEditorManager.js +75 -15
  52. package/dist/document-operations-apply.d.ts +15 -0
  53. package/dist/document-operations-apply.js +280 -0
  54. package/dist/document-operations.d.ts +1 -14
  55. package/dist/document-operations.js +2 -279
  56. package/dist/docx/modelValidation.js +1 -1
  57. package/dist/docx/paragraphParser.js +2 -2
  58. package/dist/docx/paragraphPropertySource.d.ts +1 -1
  59. package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
  60. package/dist/docx/reviewResolutionProvenance.js +32 -9
  61. package/dist/docx/revisionIdNormalization.js +30 -7
  62. package/dist/docx/rezip.js +1 -1
  63. package/dist/docx/serializer/borderSerializer.js +1 -1
  64. package/dist/docx/serializer/commentSerializer.js +1 -1
  65. package/dist/docx/serializer/documentSerializer.js +1 -1
  66. package/dist/docx/serializer/paragraphSerializer.js +3 -3
  67. package/dist/docx/serializer/runSerializer.js +1 -1
  68. package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
  69. package/dist/docx/serializer/tableSerializer.js +5 -37
  70. package/dist/docx/serializer/textFormattingSerializer.js +1 -1
  71. package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
  72. package/dist/docx/server/templatePlan/apply.d.ts +15 -0
  73. package/dist/docx/server/templatePlan/apply.js +600 -0
  74. package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
  75. package/dist/docx/server/templatePlan/blocks.js +355 -0
  76. package/dist/docx/server/templatePlan/builders.d.ts +72 -0
  77. package/dist/docx/server/templatePlan/builders.js +237 -0
  78. package/dist/docx/server/templatePlan/emit.d.ts +118 -0
  79. package/dist/docx/server/templatePlan/emit.js +466 -0
  80. package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
  81. package/dist/docx/server/templatePlan/emphasis.js +173 -0
  82. package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
  83. package/dist/docx/server/templatePlan/inspect.js +177 -0
  84. package/dist/docx/server/templatePlan/labels.d.ts +36 -0
  85. package/dist/docx/server/templatePlan/labels.js +126 -0
  86. package/dist/docx/server/templatePlan/package.d.ts +34 -0
  87. package/dist/docx/server/templatePlan/package.js +99 -0
  88. package/dist/docx/server/templatePlan/plan.d.ts +143 -0
  89. package/dist/docx/server/templatePlan/plan.js +841 -0
  90. package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
  91. package/dist/docx/server/templatePlan/planShape.js +161 -0
  92. package/dist/docx/server/templatePlan/resources.d.ts +41 -0
  93. package/dist/docx/server/templatePlan/resources.js +136 -0
  94. package/dist/docx/server/templatePlan/story.d.ts +128 -0
  95. package/dist/docx/server/templatePlan/story.js +440 -0
  96. package/dist/docx/server/templatePlan/types.d.ts +406 -0
  97. package/dist/docx/server/templatePlan/types.js +28 -0
  98. package/dist/docx/server/templatePlan/verify.d.ts +40 -0
  99. package/dist/docx/server/templatePlan/verify.js +968 -0
  100. package/dist/docx/server/templatePlan/xml.d.ts +69 -0
  101. package/dist/docx/server/templatePlan/xml.js +119 -0
  102. package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
  103. package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
  104. package/dist/docx/storyBlockReplay.js +1 -1
  105. package/dist/docx/structuralXmlPatch.js +9 -1
  106. package/dist/docx/tableGridXml.d.ts +30 -0
  107. package/dist/docx/tableGridXml.js +54 -0
  108. package/dist/docx/tableParser.js +7 -0
  109. package/dist/docx/xmlParser.js +1 -1
  110. package/dist/index.d.ts +3 -3
  111. package/dist/index.js +2 -3
  112. package/dist/internal/paragraphFormattingSerialization.js +1 -1
  113. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  114. package/dist/managers/ContextMenuManager.js +2 -1
  115. package/dist/managers/editorShortcuts.d.ts +1 -1
  116. package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
  117. package/dist/prosemirror/canonicalCommands.d.ts +1 -1
  118. package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
  119. package/dist/prosemirror/canonicalTableCommands.js +2 -2
  120. package/dist/prosemirror/commands/comments.js +3 -3
  121. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  122. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  123. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  124. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  125. package/dist/prosemirror/commands/sectionBreak.js +1 -1
  126. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
  127. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
  128. package/dist/prosemirror/commentRecords.d.ts +1 -1
  129. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  130. package/dist/prosemirror/conversion/fromProseDoc.js +1 -1
  131. package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
  132. package/dist/prosemirror/documentStructureCounts.js +76 -0
  133. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  134. package/dist/prosemirror/extensions/StarterKit.d.ts +1 -1
  135. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +1 -7
  136. package/dist/prosemirror/extensions/core/HistoryExtension.js +5 -13
  137. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
  138. package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
  139. package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
  140. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  141. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +2 -35
  142. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +4 -142
  143. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +3 -87
  144. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +7 -162
  145. package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
  146. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  147. package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
  148. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  149. package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -2
  150. package/dist/prosemirror/extensions/types.d.ts +1 -1
  151. package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
  152. package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
  153. package/dist/prosemirror/index.d.ts +1 -1
  154. package/dist/prosemirror/index.js +1 -1
  155. package/dist/prosemirror/insertionGaps.d.ts +1 -1
  156. package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
  157. package/dist/prosemirror/listNumbering.d.ts +1 -1
  158. package/dist/prosemirror/lockedControls.d.ts +1 -1
  159. package/dist/prosemirror/markupViewProjection.d.ts +1 -1
  160. package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
  161. package/dist/prosemirror/noteReferenceReview.js +1 -1
  162. package/dist/prosemirror/paraIds.d.ts +46 -0
  163. package/dist/prosemirror/paraIds.js +152 -0
  164. package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
  165. package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
  166. package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
  167. package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
  168. package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
  169. package/dist/prosemirror/pastedCommentCopies.js +1 -1
  170. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  171. package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
  172. package/dist/prosemirror/plugins/suggestionMode.d.ts +1 -1
  173. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  174. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
  175. package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
  176. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  177. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  178. package/dist/prosemirror/replacedAnnotations.js +16 -1
  179. package/dist/prosemirror/revisionCarriers.d.ts +1 -1
  180. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  181. package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
  182. package/dist/prosemirror/selectionBounds.d.ts +10 -0
  183. package/dist/prosemirror/selectionBounds.js +22 -0
  184. package/dist/prosemirror/storyListNumbering.d.ts +1 -1
  185. package/dist/prosemirror/tableCellPaste.d.ts +1 -1
  186. package/dist/prosemirror/tableGridMutation.d.ts +1 -1
  187. package/dist/prosemirror/textInput.d.ts +1 -1
  188. package/dist/server.d.ts +7 -2
  189. package/dist/server.js +6 -1
  190. package/dist/types/canonicalCapabilities.d.ts +8 -41
  191. package/dist/types/canonicalCapabilities.js +6 -34
  192. package/package.json +4 -4
@@ -5,65 +5,11 @@
5
5
  * were modified. Also detects paragraph and block-structure changes.
6
6
  * Used by the selective save system to patch only changed paragraphs in document.xml.
7
7
  */
8
- import { RemovedSectionReference, TrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
8
+ import { TrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
9
9
  import { document_d_exports } from "../../../types/document.js";
10
+ import { InternalParagraphChangeTrackerState, ParagraphChangeTrackerState } from "../../paragraphChangeTrackerMeta.js";
10
11
  import { Extension } from "../types.js";
11
- import { Node } from "prosemirror-model";
12
- import { EditorState, Plugin, PluginKey, Transaction } from "prosemirror-state";
13
- export declare const paragraphChangeTrackerKey: Readonly<{
14
- key: string;
15
- createKey: () => PluginKey<InternalParagraphChangeTrackerState>;
16
- owns: (plugin: Plugin<InternalParagraphChangeTrackerState>) => boolean;
17
- get: (state: EditorState) => Plugin<InternalParagraphChangeTrackerState> | undefined;
18
- getState: (state: EditorState) => InternalParagraphChangeTrackerState | undefined;
19
- }>;
20
- export type ParagraphChangeTrackerState = {
21
- /** Set of paraIds that were modified since last clear */
22
- changedParaIds: Set<string>;
23
- /** Whether paragraph order, membership, or block structure changed. */
24
- structuralChange: boolean;
25
- /** Whether edited paragraphs still lack IDs or source identity was unavailable. */
26
- hasUntrackedChanges: boolean;
27
- /** Paragraph count in the current tracked document. */
28
- paragraphCount: number;
29
- /** Cached section-endpoint count used to invalidate stale save authorization. */
30
- sectionEndpointCount: number;
31
- /** Exact endpoint owners and properties used to invalidate count-neutral changes. */
32
- sectionEndpointFingerprint: string;
33
- /** Exact tracked-resolution transition that may reduce the saved section count. */
34
- sectionEndpointRemoval: TrackedSectionEndpointRemoval | null;
35
- };
36
- type InternalParagraphChangeTrackerState = ParagraphChangeTrackerState & {
37
- /** Edited paragraph positions retained across allocator-only transactions. */
38
- affectedParagraphPositions: Set<number>;
39
- /** Editing an already unidentified source paragraph cannot become selective. */
40
- hasUntrackedSourceChanges: boolean;
41
- blockStructureFingerprint: string;
42
- /** The section records themselves, by identity. */
43
- sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
44
- };
45
- type DocumentStructureCounts = {
46
- blockStructureFingerprint: string;
47
- sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
48
- paragraphs: number;
49
- /**
50
- * Distinct section records the paragraphs carry, which is the number of
51
- * `w:sectPr` the package states for them. A split copies a node's attrs, so
52
- * both halves of a split section-ending paragraph hold one record until the
53
- * from-leg keeps it on the trailing half: one section, not two.
54
- */
55
- sectionEndpoints: number;
56
- sectionEndpointFingerprint: string;
57
- };
58
- /**
59
- * Count the structural values the tracker compares for every transaction.
60
- *
61
- * Each top-level block's records are kept for the block node, so a keystroke
62
- * recomputes only the block it changed. The fingerprint joins the blocks'
63
- * records in order: two documents' fingerprints are equal exactly when their
64
- * full record lists (every block and nested block with its path) are.
65
- */
66
- export declare function countDocumentStructure(doc: Node): DocumentStructureCounts;
12
+ import { EditorState, Plugin } from "prosemirror-state";
67
13
  export declare function createParagraphChangeTrackerPlugin(): Plugin<InternalParagraphChangeTrackerState>;
68
14
  /**
69
15
  * Get the change tracker state from an EditorState
@@ -101,35 +47,5 @@ type RepackWithEditorSectionRemovalsOptions<T> = {
101
47
  * the edit cannot be saved.
102
48
  */
103
49
  export declare const repackWithEditorSectionRemovals: <T>({ state, document, repack }: RepackWithEditorSectionRemovalsOptions<T>) => Promise<T>;
104
- type MarkTrackedSectionEndpointRemovalOptions = {
105
- sourceDoc: Node;
106
- removedEndpointCount: number;
107
- removedReferences: readonly RemovedSectionReference[];
108
- };
109
- /** Record only a complete, internally consistent endpoint-removal transition. */
110
- export declare function markTrackedSectionEndpointRemoval(tr: Transaction, { sourceDoc, removedEndpointCount, removedReferences }: MarkTrackedSectionEndpointRemovalOptions): Transaction;
111
- /**
112
- * Record that `tr` removed section breaks on purpose: a command whose job is
113
- * to remove the break (not to delete its paragraph mark, which the tracker
114
- * reads for itself). Only a plain removal is recorded; a transaction that also
115
- * adds or replaces a record is left as it is.
116
- */
117
- export declare function markSectionBreakRemoval(tr: Transaction, sourceDoc: Node): Transaction;
118
- /**
119
- * Create a transaction that clears the change tracker
120
- */
121
- export declare function clearTrackedChanges(state: EditorState): Transaction;
122
- export declare function ignoreTrackedChanges(tr: Transaction): Transaction;
123
- export declare function markStructuralChange(tr: Transaction): Transaction;
124
- type MarkChangedParagraphRangesOptions = {
125
- ranges: readonly {
126
- from: number;
127
- to: number;
128
- }[];
129
- mappingFrom: number;
130
- replacesStepMapAt?: number;
131
- };
132
- /** Record mark-only paragraph changes whose replacement step has a granular map. */
133
- export declare function markChangedParagraphRanges(tr: Transaction, batch: MarkChangedParagraphRangesOptions): Transaction;
134
50
  export declare const ParagraphChangeTrackerExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
135
51
  export {};
@@ -1,7 +1,7 @@
1
1
  import { withTrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
2
- import { canonicalJson } from "../../../utils/canonicalJson.js";
2
+ import { countDocumentStructure } from "../../documentStructureCounts.js";
3
3
  import { enclosingParagraphIndexed, nodeAtIndexed, nodesBetweenIndexed } from "../../indexedNodeLookup.js";
4
- import { createPluginKeyOwner } from "../../pluginKeyOwner.js";
4
+ import { CHANGED_PARAGRAPH_RANGES_META, SECTION_ENDPOINT_REMOVAL_META, isChangedParagraphRangesMeta, isTrackedSectionEndpointRemoval, isTrackedSectionEndpointRemovalMeta, paragraphChangeTrackerKey, referencesOf } from "../../paragraphChangeTrackerMeta.js";
5
5
  import { sweepPositions } from "../../positionSweep.js";
6
6
  import { sectionPropertiesOf } from "../../sectionCarrier.js";
7
7
  import { sectionMarkEditsOf } from "../../sectionMarkEdits.js";
@@ -18,90 +18,8 @@ import { isHistoryTransaction } from "prosemirror-history";
18
18
  * were modified. Also detects paragraph and block-structure changes.
19
19
  * Used by the selective save system to patch only changed paragraphs in document.xml.
20
20
  */
21
- const paragraphChangeTrackerKey = createPluginKeyOwner("paragraphChangeTracker");
22
- const CLEAR_META = "clear";
23
- const IGNORE_META = "ignore";
24
- const STRUCTURAL_META = "structural";
25
- const CHANGED_PARAGRAPH_RANGES_META = "folioChangedParagraphRanges";
26
- const SECTION_ENDPOINT_REMOVAL_META = "folioSectionEndpointRemoval";
27
21
  const SECTION_EDIT_META = "folioSectionEdit";
28
- const isChangedParagraphRangesMeta = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "changed-paragraph-ranges";
29
- const isRemovedSectionReference = (value) => typeof value === "object" && value !== null && "part" in value && (value.part === "header" || value.part === "footer") && "type" in value && (value.type === "default" || value.type === "first" || value.type === "even") && "relationshipId" in value && typeof value.relationshipId === "string";
30
- const isTrackedSectionEndpointRemoval = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "tracked-section-endpoint-removal" && "sourceParagraphEndpointCount" in value && typeof value.sourceParagraphEndpointCount === "number" && Number.isSafeInteger(value.sourceParagraphEndpointCount) && "expectedParagraphEndpointCount" in value && typeof value.expectedParagraphEndpointCount === "number" && Number.isSafeInteger(value.expectedParagraphEndpointCount) && value.sourceParagraphEndpointCount > value.expectedParagraphEndpointCount && value.expectedParagraphEndpointCount >= 0 && "sourceEndpointFingerprint" in value && typeof value.sourceEndpointFingerprint === "string" && "expectedEndpointFingerprint" in value && typeof value.expectedEndpointFingerprint === "string" && "removedReferences" in value && Array.isArray(value.removedReferences) && value.removedReferences.every(isRemovedSectionReference);
31
- const isTrackedSectionEndpointRemovalMeta = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "tracked-section-endpoint-removal-meta" && "authorization" in value && isTrackedSectionEndpointRemoval(value.authorization);
32
22
  const isSectionEditMeta = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "section-edit-meta" && "authorization" in value && (value.authorization === null || isTrackedSectionEndpointRemoval(value.authorization)) && "expectedEndpointFingerprint" in value && typeof value.expectedEndpointFingerprint === "string";
33
- const blockStructures = /* @__PURE__ */ new WeakMap();
34
- const relativePath = (parentPath, index) => parentPath.length === 0 ? `${index}` : `${parentPath}.${index}`;
35
- const blockStructureOf = (block) => {
36
- const cached = blockStructures.get(block);
37
- if (cached) return cached;
38
- const records = [];
39
- const endpoints = [];
40
- let paragraphs = 0;
41
- const visit = (node, path) => {
42
- records.push(node.type.name === "paragraph" ? [
43
- path,
44
- node.type.name,
45
- node.attrs["paraId"] ?? null
46
- ] : [
47
- path,
48
- node.type.name,
49
- canonicalJson(node.attrs)
50
- ]);
51
- if (node.type.name === "paragraph") {
52
- paragraphs++;
53
- const sectionProperties = sectionPropertiesOf(node);
54
- if (sectionProperties !== null) endpoints.push({
55
- path,
56
- paraId: node.attrs["paraId"] ?? null,
57
- sectionProperties
58
- });
59
- return;
60
- }
61
- node.forEach((child, _offset, index) => visit(child, relativePath(path, index)));
62
- };
63
- visit(block, "");
64
- const structure = {
65
- records: JSON.stringify(records),
66
- paragraphs,
67
- endpoints
68
- };
69
- blockStructures.set(block, structure);
70
- return structure;
71
- };
72
- /**
73
- * Count the structural values the tracker compares for every transaction.
74
- *
75
- * Each top-level block's records are kept for the block node, so a keystroke
76
- * recomputes only the block it changed. The fingerprint joins the blocks'
77
- * records in order: two documents' fingerprints are equal exactly when their
78
- * full record lists (every block and nested block with its path) are.
79
- */
80
- function countDocumentStructure(doc) {
81
- let paragraphs = 0;
82
- const sectionRecords = /* @__PURE__ */ new Set();
83
- const blockRecords = [];
84
- const endpointRecords = [];
85
- doc.forEach((block, _offset, index) => {
86
- const structure = blockStructureOf(block);
87
- blockRecords.push(structure.records);
88
- paragraphs += structure.paragraphs;
89
- for (const endpoint of structure.endpoints) {
90
- sectionRecords.add(endpoint.sectionProperties);
91
- endpointRecords.push({
92
- ...endpoint,
93
- path: endpoint.path.length === 0 ? `${index}` : `${index}.${endpoint.path}`
94
- });
95
- }
96
- });
97
- return {
98
- blockStructureFingerprint: blockRecords.join(""),
99
- sectionRecords,
100
- paragraphs,
101
- sectionEndpoints: sectionRecords.size,
102
- sectionEndpointFingerprint: canonicalJson(endpointRecords)
103
- };
104
- }
105
23
  /**
106
24
  * Whether a transaction left every section record in place, by identity: the
107
25
  * same sections, however their paragraphs moved around them. An edit before a
@@ -257,7 +175,7 @@ function createParagraphChangeTrackerPlugin() {
257
175
  const changedParagraphRangesMeta = tr.getMeta(CHANGED_PARAGRAPH_RANGES_META);
258
176
  const sectionEndpointRemovalMeta = tr.getMeta(SECTION_ENDPOINT_REMOVAL_META);
259
177
  const sectionEditMeta = tr.getMeta(SECTION_EDIT_META);
260
- if (meta === CLEAR_META) {
178
+ if (meta === "clear") {
261
179
  const counts = countDocumentStructure(tr.doc);
262
180
  return {
263
181
  affectedParagraphPositions: /* @__PURE__ */ new Set(),
@@ -273,7 +191,7 @@ function createParagraphChangeTrackerPlugin() {
273
191
  sectionEndpointRemoval: null
274
192
  };
275
193
  }
276
- if (meta === IGNORE_META) {
194
+ if (meta === "ignore") {
277
195
  if (!tr.docChanged) return prevState;
278
196
  const counts = countDocumentStructure(tr.doc);
279
197
  const affectedParagraphPositions = mapAffectedParagraphPositions(tr, prevState.affectedParagraphPositions);
@@ -323,7 +241,7 @@ function createParagraphChangeTrackerPlugin() {
323
241
  hasUntrackedSourceChanges: prevState.hasUntrackedSourceChanges,
324
242
  blockStructureFingerprint: counts.blockStructureFingerprint,
325
243
  changedParaIds: new Set(prevState.changedParaIds),
326
- structuralChange: prevState.structuralChange || meta === STRUCTURAL_META,
244
+ structuralChange: prevState.structuralChange || meta === "structural",
327
245
  hasUntrackedChanges: prevState.hasUntrackedChanges,
328
246
  paragraphCount: newCount,
329
247
  sectionEndpointCount: counts.sectionEndpoints,
@@ -371,22 +289,6 @@ function createParagraphChangeTrackerPlugin() {
371
289
  appendTransaction: (transactions, oldState, newState) => sectionEditTransaction(transactions, oldState, newState)
372
290
  });
373
291
  }
374
- const referencesOf = (records) => {
375
- const references = [];
376
- for (const record of records) {
377
- for (const { type, rId } of record.headerReferences ?? []) references.push({
378
- part: "header",
379
- type,
380
- relationshipId: rId
381
- });
382
- for (const { type, rId } of record.footerReferences ?? []) references.push({
383
- part: "footer",
384
- type,
385
- relationshipId: rId
386
- });
387
- }
388
- return references;
389
- };
390
292
  /** `references` without one occurrence of each of `restored`. */
391
293
  const withoutReferences = (references, restored) => {
392
294
  const remaining = [...references];
@@ -415,7 +317,7 @@ const withoutReferences = (references, restored) => {
415
317
  * removal back out of the authorization.
416
318
  */
417
319
  const sectionEditTransaction = (transactions, oldState, newState) => {
418
- if (!transactions.some((transaction) => transaction.docChanged && transaction.getMeta(paragraphChangeTrackerKey) !== IGNORE_META) || transactions.some((transaction) => transaction.getMeta(SECTION_EDIT_META) !== void 0 || transaction.getMeta(SECTION_ENDPOINT_REMOVAL_META) !== void 0 || transaction.getMeta(paragraphChangeTrackerKey) === CLEAR_META)) return null;
320
+ if (!transactions.some((transaction) => transaction.docChanged && transaction.getMeta(paragraphChangeTrackerKey) !== "ignore") || transactions.some((transaction) => transaction.getMeta(SECTION_EDIT_META) !== void 0 || transaction.getMeta("folioSectionEndpointRemoval") !== void 0 || transaction.getMeta(paragraphChangeTrackerKey) === "clear")) return null;
419
321
  const base = paragraphChangeTrackerKey.getState(oldState);
420
322
  if (!base) return null;
421
323
  const dropped = droppedCellSections(transactions, oldState.doc, newState.doc);
@@ -499,63 +401,6 @@ const repackWithEditorSectionRemovals = ({ state, document, repack }) => {
499
401
  repack
500
402
  });
501
403
  };
502
- /** Record only a complete, internally consistent endpoint-removal transition. */
503
- function markTrackedSectionEndpointRemoval(tr, { sourceDoc, removedEndpointCount, removedReferences }) {
504
- const sourceStructure = countDocumentStructure(sourceDoc);
505
- const sourceParagraphEndpointCount = sourceStructure.sectionEndpoints;
506
- const expectedStructure = countDocumentStructure(tr.doc);
507
- const expectedParagraphEndpointCount = expectedStructure.sectionEndpoints;
508
- if (sourceParagraphEndpointCount - expectedParagraphEndpointCount !== removedEndpointCount) return tr;
509
- return tr.setMeta(SECTION_ENDPOINT_REMOVAL_META, {
510
- type: "tracked-section-endpoint-removal-meta",
511
- authorization: {
512
- type: "tracked-section-endpoint-removal",
513
- sourceParagraphEndpointCount,
514
- expectedParagraphEndpointCount,
515
- sourceEndpointFingerprint: sourceStructure.sectionEndpointFingerprint,
516
- expectedEndpointFingerprint: expectedStructure.sectionEndpointFingerprint,
517
- removedReferences
518
- }
519
- });
520
- }
521
- /**
522
- * Record that `tr` removed section breaks on purpose: a command whose job is
523
- * to remove the break (not to delete its paragraph mark, which the tracker
524
- * reads for itself). Only a plain removal is recorded; a transaction that also
525
- * adds or replaces a record is left as it is.
526
- */
527
- function markSectionBreakRemoval(tr, sourceDoc) {
528
- const before = countDocumentStructure(sourceDoc).sectionRecords;
529
- const after = countDocumentStructure(tr.doc).sectionRecords;
530
- const removed = [...before].filter((record) => !after.has(record));
531
- if (removed.length === 0 || [...after].some((record) => !before.has(record))) return tr;
532
- return markTrackedSectionEndpointRemoval(tr, {
533
- sourceDoc,
534
- removedEndpointCount: removed.length,
535
- removedReferences: referencesOf(removed)
536
- });
537
- }
538
- /**
539
- * Create a transaction that clears the change tracker
540
- */
541
- function clearTrackedChanges(state) {
542
- return state.tr.setMeta(paragraphChangeTrackerKey, CLEAR_META);
543
- }
544
- function ignoreTrackedChanges(tr) {
545
- return tr.setMeta(paragraphChangeTrackerKey, IGNORE_META);
546
- }
547
- function markStructuralChange(tr) {
548
- return tr.setMeta(paragraphChangeTrackerKey, STRUCTURAL_META);
549
- }
550
- /** Record mark-only paragraph changes whose replacement step has a granular map. */
551
- function markChangedParagraphRanges(tr, batch) {
552
- const previous = tr.getMeta(CHANGED_PARAGRAPH_RANGES_META);
553
- const batches = isChangedParagraphRangesMeta(previous) ? [...previous.batches, batch] : [batch];
554
- return tr.setMeta(CHANGED_PARAGRAPH_RANGES_META, {
555
- type: "changed-paragraph-ranges",
556
- batches
557
- });
558
- }
559
404
  const ParagraphChangeTrackerExtension = createExtension({
560
405
  name: "paragraphChangeTracker",
561
406
  defaultOptions: {},
@@ -563,4 +408,4 @@ const ParagraphChangeTrackerExtension = createExtension({
563
408
  return { plugins: [createParagraphChangeTrackerPlugin()] };
564
409
  }
565
410
  });
566
- export { ParagraphChangeTrackerExtension, clearTrackedChanges, countDocumentStructure, createParagraphChangeTrackerPlugin, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markSectionBreakRemoval, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey, repackWithEditorSectionRemovals };
411
+ export { ParagraphChangeTrackerExtension, createParagraphChangeTrackerPlugin, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, repackWithEditorSectionRemovals };
@@ -5,8 +5,8 @@
5
5
  * in a cell, or that stands in a pasted cell, comes without the break it ended
6
6
  * its own section with.
7
7
  */
8
- import { Node, Slice } from "prosemirror-model";
9
8
  import { Transaction } from "prosemirror-state";
9
+ import { Node, Slice } from "prosemirror-model";
10
10
  import { EditorView } from "prosemirror-view";
11
11
  /**
12
12
  * Where a drop put a section break in a table cell. The drop's target is not
@@ -1,7 +1,7 @@
1
1
  import { readOutlineLevelAttr } from "../../outlineLevelAttr.js";
2
2
  import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "../../plugins/documentStyleState.js";
3
- import { headingLevelOf } from "@stll/docx-core/model";
4
3
  import { Fragment, Slice } from "prosemirror-model";
4
+ import { headingLevelOf } from "@stll/docx-core/model";
5
5
  // src/prosemirror/extensions/features/pastedHeadingStyles.ts
6
6
  /**
7
7
  * Retarget pasted heading paragraphs at the open document's own heading style.
@@ -7,8 +7,8 @@
7
7
  import { document_d_exports } from "../../../types/document.js";
8
8
  import { DeepReadonly } from "../../../types/documentModel.js";
9
9
  import { CanonicalCommandIntent } from "../../canonicalCommands.js";
10
- import { Attrs, Mark, MarkType, Schema } from "prosemirror-model";
11
10
  import { Command, EditorState } from "prosemirror-state";
11
+ import { Attrs, Mark, MarkType, Schema } from "prosemirror-model";
12
12
  import { FormattingPatch } from "@stll/docx-core/ops";
13
13
  type MarkAttrs = Record<string, unknown>;
14
14
  export declare const withRunFormattingLock: (command: Command, describe: (state: EditorState) => readonly CanonicalCommandIntent[] | undefined) => Command;
@@ -7,8 +7,8 @@
7
7
  import { ColorValue } from "../../../types/colors.js";
8
8
  import { DeepReadonly } from "../../../types/documentModel.js";
9
9
  import { AnyExtension, Extension, NodeExtension } from "../types.js";
10
- import { Node } from "prosemirror-model";
11
10
  import { Command, EditorState } from "prosemirror-state";
11
+ import { Node } from "prosemirror-model";
12
12
  export type TableContextInfo = {
13
13
  isInTable: boolean;
14
14
  table?: Node;
@@ -14,8 +14,8 @@ import { insertTableColumn, removeTableColumns, removeTableRow } from "../../tab
14
14
  import { tablePositionedBookmarksPlugin } from "../../tablePositionedBookmarks.js";
15
15
  import { createExtension, createNodeExtension } from "../create.js";
16
16
  import { panic } from "better-result";
17
- import { statesNoBorder } from "@stll/docx-core/model";
18
17
  import { CellSelection, TableMap, columnResizing, mergeCells, selectedRect, splitCell, tableEditing, tableNodeTypes } from "prosemirror-tables";
18
+ import { statesNoBorder } from "@stll/docx-core/model";
19
19
  import { Plugin, PluginKey, Selection, TextSelection } from "prosemirror-state";
20
20
  import { Decoration, DecorationSet } from "prosemirror-view";
21
21
  // src/prosemirror/extensions/nodes/TableExtension.ts
@@ -2028,7 +2028,7 @@ const TablePluginExtension = createExtension({
2028
2028
  setRowHeight: (height, rule) => withCanonicalTableAttributeCommand(setRowHeight(height, rule)),
2029
2029
  toggleHeaderRow: () => withCanonicalTableAttributeCommand(toggleHeaderRow()),
2030
2030
  distributeColumns: () => withCanonicalTableAttributeCommand(distributeColumns()),
2031
- autoFitContents: () => autoFitContents(),
2031
+ autoFitContents: () => withCanonicalTableAttributeCommand(autoFitContents()),
2032
2032
  setTableProperties: (props) => withCanonicalTableAttributeCommand(setTableProperties(props)),
2033
2033
  applyTableStyle: (styleData) => withCanonicalTableAttributeCommand(applyTableStyle(styleData)),
2034
2034
  setCellFillColor: (color) => withCanonicalTableAttributeCommand(setCellFillColor(color)),
@@ -14,8 +14,8 @@ import { TextColorAttrs } from "../schema/marks.js";
14
14
  import { SectionBreakType } from "../sectionCarrier.js";
15
15
  import { GenerateTableOfContentsOptions, ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
16
16
  import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
17
- import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
18
17
  import { Command, Plugin } from "prosemirror-state";
18
+ import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
19
19
  /**
20
20
  * A border a host asks folio to apply.
21
21
  *
@@ -1,8 +1,8 @@
1
1
  import { DisplayMode } from "../managers/EditorModeManager.js";
2
2
  import { document_d_exports } from "../types/document.js";
3
3
  import { FindMatch, FindOptions, FindSearchContext } from "../utils/findReplace.js";
4
- import { Node } from "prosemirror-model";
5
4
  import { EditorState } from "prosemirror-state";
5
+ import { Node } from "prosemirror-model";
6
6
  /**
7
7
  * Positional fields of a document search match that the range resolver needs.
8
8
  *
@@ -11,8 +11,8 @@
11
11
  * the plain text an untracked removal leaves.
12
12
  */
13
13
  import { TaggedErrorClass } from "better-result";
14
- import { Node } from "prosemirror-model";
15
14
  import { EditorState, Transaction } from "prosemirror-state";
15
+ import { Node } from "prosemirror-model";
16
16
  declare const HyperlinkRemovalRefusalBase: TaggedErrorClass<"HyperlinkRemovalRefusal">;
17
17
  export declare class HyperlinkRemovalRefusal extends HyperlinkRemovalRefusalBase<{
18
18
  message: string;
@@ -20,7 +20,6 @@ import "./conversion/index.js";
20
20
  import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
21
21
  import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
22
22
  import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
23
- import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
24
23
  import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
25
24
  import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
26
25
  import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
@@ -28,6 +27,7 @@ import { TableBorderCommandSpec, TableCellBorderCommandSpec } from "./extensions
28
27
  import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
29
28
  import { ListNumberingMenuState, NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
30
29
  import { ActiveListState, ListState, ListType, NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
30
+ import { ensureParaIdsInState } from "./paraIds.js";
31
31
  import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
32
32
  import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
33
33
  import "./plugins/index.js";
@@ -8,13 +8,13 @@ import { fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.j
8
8
  import { createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
9
9
  import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
10
10
  import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
11
- import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
12
11
  import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
13
12
  import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
14
13
  import { getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
15
14
  import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
16
15
  import { NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
17
16
  import { NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
17
+ import { ensureParaIdsInState } from "./paraIds.js";
18
18
  import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
19
19
  import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
20
20
  import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
@@ -1,5 +1,5 @@
1
- import { Node } from "prosemirror-model";
2
1
  import { Transaction } from "prosemirror-state";
2
+ import { Node } from "prosemirror-model";
3
3
  /** The gap a block put on `side` of the block at `boundary` lands in. */
4
4
  export declare const insertionGap: (doc: Node, boundary: number, side: "before" | "after") => number;
5
5
  /**
@@ -12,8 +12,8 @@
12
12
  */
13
13
  import { document_d_exports } from "../types/document.js";
14
14
  import { TrackedRevisionAncestor } from "./schema/marks.js";
15
- import { Node } from "prosemirror-model";
16
15
  import { Transaction } from "prosemirror-state";
16
+ import { Node } from "prosemirror-model";
17
17
  /** A range boundary, as the engine's model writes it. */
18
18
  type BoundaryItem = Extract<document_d_exports.ParagraphContent, {
19
19
  type: "bookmarkStart" | "bookmarkEnd" | "commentRangeStart" | "commentRangeEnd" | "moveFromRangeStart" | "moveFromRangeEnd" | "moveToRangeStart" | "moveToRangeEnd";
@@ -1,8 +1,8 @@
1
1
  import { ListKind, ListLevelFormat } from "../docx/listNumberingInstances.js";
2
2
  import { NumberingMap } from "../docx/numberingParser.js";
3
3
  import { ParagraphAttrs } from "./schema/nodes.js";
4
- import { Node, ResolvedPos } from "prosemirror-model";
5
4
  import { Command, EditorState, Transaction } from "prosemirror-state";
5
+ import { Node, ResolvedPos } from "prosemirror-model";
6
6
  /** What a list command or typed marker asks for. */
7
7
  export type ListRequest = {
8
8
  kind: ListKind;
@@ -4,8 +4,8 @@
4
4
  * document holds, as spans on its position scale, and what a transform did to
5
5
  * them.
6
6
  */
7
- import { Node } from "prosemirror-model";
8
7
  import { LockedControlSpan, LockedControlTouch, LockedControlViolation } from "@stll/docx-core/model";
8
+ import { Node } from "prosemirror-model";
9
9
  import { Transform } from "prosemirror-transform";
10
10
  export declare const lockedControlSpans: (doc: Node) => readonly LockedControlSpan[];
11
11
  /** What the locks of `doc` say about `touches`: `null` when they permit them all. */
@@ -20,8 +20,8 @@ import { RemovedSectionReference } from "../internal/sectionEndpointResolution.j
20
20
  import { DisplayMode } from "../managers/EditorModeManager.js";
21
21
  import { document_d_exports } from "../types/document.js";
22
22
  import { DeepReadonly } from "../types/documentModel.js";
23
- import { Node } from "prosemirror-model";
24
23
  import { EditorState } from "prosemirror-state";
24
+ import { Node } from "prosemirror-model";
25
25
  import { Mapping, Step, StepMap } from "prosemirror-transform";
26
26
  /** Resolve every revision in the state's story with the state's own styles and numbering. */
27
27
  export declare const resolveStateStory: (state: EditorState, mode: RevisionResolutionMode) => {
@@ -1,6 +1,6 @@
1
1
  import { TaggedErrorClass } from "better-result";
2
- import { Node } from "prosemirror-model";
3
2
  import { Plugin, Transaction } from "prosemirror-state";
3
+ import { Node } from "prosemirror-model";
4
4
  declare const NoteReferenceEditRefusalBase: TaggedErrorClass<"NoteReferenceEditRefusal">;
5
5
  export declare class NoteReferenceEditRefusal extends NoteReferenceEditRefusalBase<{
6
6
  message: string;
@@ -11,8 +11,8 @@ import { createDocumentNumberingPlugin } from "./plugins/documentNumbering.js";
11
11
  import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
12
12
  import { mintRevisionId } from "./plugins/revisionIds.js";
13
13
  import { schema, singletonManager } from "./schema/index.js";
14
- import { setDocumentBodyComments } from "@stll/docx-core/model";
15
14
  import { Transform } from "prosemirror-transform";
15
+ import { setDocumentBodyComments } from "@stll/docx-core/model";
16
16
  import { EditorState } from "prosemirror-state";
17
17
  // src/prosemirror/noteReferenceReview.ts
18
18
  const noteKey = (kind, id) => `${kind}:${id}`;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Paragraph-id allocation shared by load-time seeding and the live
3
+ * allocator plugin (`ParaIdAllocatorExtension`).
4
+ *
5
+ * Split out of
6
+ * https://github.com/eigenpal/docx-editor/blob/main/packages/core/src/prosemirror/extensions/features/ParaIdAllocatorExtension.ts
7
+ * (Apache-2.0); see that module for the id lifecycle rules.
8
+ */
9
+ import { EditorState, Plugin, PluginKey, Transaction } from "prosemirror-state";
10
+ import { Node } from "prosemirror-model";
11
+ export type ParagraphPropertySourceSeed = {
12
+ contract: string | null;
13
+ tokens: ReadonlySet<string>;
14
+ };
15
+ export declare const paraIdAllocatorKey: Readonly<{
16
+ key: string;
17
+ createKey: () => PluginKey<ParagraphPropertySourceSeed>;
18
+ owns: (plugin: Plugin<ParagraphPropertySourceSeed>) => boolean;
19
+ get: (state: EditorState) => Plugin<ParagraphPropertySourceSeed> | undefined;
20
+ getState: (state: EditorState) => ParagraphPropertySourceSeed | undefined;
21
+ }>;
22
+ /**
23
+ * Transaction meta asking this plugin to derive the ids it mints from a
24
+ * caller-supplied seed instead of `Math.random()`.
25
+ *
26
+ * A live editor wants random ids: two people typing must not collide. A
27
+ * generator whose whole output has to be reproducible — the document compare —
28
+ * cannot afford them, and it is the only party that knows its run is meant to
29
+ * be deterministic, so it says so on its own transaction rather than leaving
30
+ * the plugin to guess.
31
+ */
32
+ export declare const deterministicParaIdSeedKey = "stll.folio.meta.deterministicParaIdSeed";
33
+ /** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
34
+ export declare const requestDeterministicParaIds: (tr: Transaction, seed: string) => Transaction;
35
+ export declare const isUsableParaId: (value: unknown) => value is string;
36
+ export declare const visitAuthoredParagraphs: (doc: Node, visit: (node: Node, pos: number) => void) => void;
37
+ /**
38
+ * Allocate initial paragraph IDs before constructing editor state.
39
+ *
40
+ * Rebuilding only changed branches avoids applying one ProseMirror transaction
41
+ * step per missing paragraph. Live edits still use the transaction-based plugin
42
+ * below so history, mappings, and duplicate ownership retain their semantics.
43
+ */
44
+ export declare const ensureParaIdsInDoc: (doc: Node) => Node;
45
+ /** {@link ensureParaIdsInDoc} for a state that already exists. */
46
+ export declare const ensureParaIdsInState: (state: EditorState) => EditorState;