@stll/folio-core 0.71.1 → 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 (213) hide show
  1. package/README.md +14 -8
  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 -4
  39. package/dist/compat/eigenpal.js +2 -4
  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/canonicalYjsRoom.d.ts +1 -1
  50. package/dist/controller/headerFooterEditorManager.d.ts +11 -7
  51. package/dist/controller/headerFooterEditorManager.js +39 -151
  52. package/dist/controller/hiddenEditorApi.d.ts +1 -1
  53. package/dist/controller/hiddenEditorManager.d.ts +6 -40
  54. package/dist/controller/hiddenEditorManager.js +173 -306
  55. package/dist/controller/noteEditorManager.d.ts +3 -10
  56. package/dist/controller/noteEditorManager.js +33 -206
  57. package/dist/document-operations-apply.d.ts +15 -0
  58. package/dist/document-operations-apply.js +280 -0
  59. package/dist/document-operations.d.ts +1 -14
  60. package/dist/document-operations.js +2 -279
  61. package/dist/docx/modelValidation.js +1 -1
  62. package/dist/docx/paragraphParser.js +2 -2
  63. package/dist/docx/paragraphPropertySource.d.ts +1 -1
  64. package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
  65. package/dist/docx/reviewResolutionProvenance.js +32 -9
  66. package/dist/docx/revisionIdNormalization.js +30 -7
  67. package/dist/docx/rezip.js +1 -1
  68. package/dist/docx/serializer/borderSerializer.js +1 -1
  69. package/dist/docx/serializer/commentSerializer.js +1 -1
  70. package/dist/docx/serializer/documentSerializer.js +1 -1
  71. package/dist/docx/serializer/paragraphSerializer.js +3 -3
  72. package/dist/docx/serializer/runSerializer.js +1 -1
  73. package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
  74. package/dist/docx/serializer/tableSerializer.js +5 -37
  75. package/dist/docx/serializer/textFormattingSerializer.js +1 -1
  76. package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
  77. package/dist/docx/server/templatePlan/apply.d.ts +15 -0
  78. package/dist/docx/server/templatePlan/apply.js +600 -0
  79. package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
  80. package/dist/docx/server/templatePlan/blocks.js +355 -0
  81. package/dist/docx/server/templatePlan/builders.d.ts +72 -0
  82. package/dist/docx/server/templatePlan/builders.js +237 -0
  83. package/dist/docx/server/templatePlan/emit.d.ts +118 -0
  84. package/dist/docx/server/templatePlan/emit.js +466 -0
  85. package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
  86. package/dist/docx/server/templatePlan/emphasis.js +173 -0
  87. package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
  88. package/dist/docx/server/templatePlan/inspect.js +177 -0
  89. package/dist/docx/server/templatePlan/labels.d.ts +36 -0
  90. package/dist/docx/server/templatePlan/labels.js +126 -0
  91. package/dist/docx/server/templatePlan/package.d.ts +34 -0
  92. package/dist/docx/server/templatePlan/package.js +99 -0
  93. package/dist/docx/server/templatePlan/plan.d.ts +143 -0
  94. package/dist/docx/server/templatePlan/plan.js +841 -0
  95. package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
  96. package/dist/docx/server/templatePlan/planShape.js +161 -0
  97. package/dist/docx/server/templatePlan/resources.d.ts +41 -0
  98. package/dist/docx/server/templatePlan/resources.js +136 -0
  99. package/dist/docx/server/templatePlan/story.d.ts +128 -0
  100. package/dist/docx/server/templatePlan/story.js +440 -0
  101. package/dist/docx/server/templatePlan/types.d.ts +406 -0
  102. package/dist/docx/server/templatePlan/types.js +28 -0
  103. package/dist/docx/server/templatePlan/verify.d.ts +40 -0
  104. package/dist/docx/server/templatePlan/verify.js +968 -0
  105. package/dist/docx/server/templatePlan/xml.d.ts +69 -0
  106. package/dist/docx/server/templatePlan/xml.js +119 -0
  107. package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
  108. package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
  109. package/dist/docx/storyBlockReplay.js +1 -1
  110. package/dist/docx/structuralXmlPatch.js +9 -1
  111. package/dist/docx/tableGridXml.d.ts +30 -0
  112. package/dist/docx/tableGridXml.js +54 -0
  113. package/dist/docx/tableParser.js +7 -0
  114. package/dist/docx/xmlParser.js +1 -1
  115. package/dist/index.d.ts +3 -4
  116. package/dist/index.js +2 -4
  117. package/dist/internal/paragraphFormattingSerialization.js +1 -1
  118. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  119. package/dist/managers/ContextMenuManager.js +2 -1
  120. package/dist/managers/DocumentLoaderManager.d.ts +0 -4
  121. package/dist/managers/DocumentLoaderManager.js +4 -12
  122. package/dist/managers/editorShortcuts.d.ts +1 -1
  123. package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
  124. package/dist/prosemirror/canonicalCommands.d.ts +1 -1
  125. package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
  126. package/dist/prosemirror/canonicalTableCommands.js +2 -2
  127. package/dist/prosemirror/commands/comments.js +3 -3
  128. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  129. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  130. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  131. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  132. package/dist/prosemirror/commands/sectionBreak.js +1 -1
  133. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
  134. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
  135. package/dist/prosemirror/commentRecords.d.ts +1 -1
  136. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  137. package/dist/prosemirror/conversion/fromProseDoc.js +1 -1
  138. package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
  139. package/dist/prosemirror/documentStructureCounts.js +76 -0
  140. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  141. package/dist/prosemirror/extensions/StarterKit.d.ts +1 -1
  142. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +1 -7
  143. package/dist/prosemirror/extensions/core/HistoryExtension.js +5 -13
  144. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
  145. package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
  146. package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
  147. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  148. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +2 -35
  149. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +4 -142
  150. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +3 -87
  151. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +7 -162
  152. package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
  153. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  154. package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
  155. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  156. package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -2
  157. package/dist/prosemirror/extensions/types.d.ts +1 -1
  158. package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
  159. package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
  160. package/dist/prosemirror/index.d.ts +1 -1
  161. package/dist/prosemirror/index.js +1 -1
  162. package/dist/prosemirror/insertionGaps.d.ts +1 -1
  163. package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
  164. package/dist/prosemirror/listNumbering.d.ts +1 -1
  165. package/dist/prosemirror/lockedControls.d.ts +1 -1
  166. package/dist/prosemirror/markupViewProjection.d.ts +1 -1
  167. package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
  168. package/dist/prosemirror/noteReferenceReview.js +1 -1
  169. package/dist/prosemirror/numberingAttr.d.ts +1 -2
  170. package/dist/prosemirror/numberingAttr.js +1 -2
  171. package/dist/prosemirror/outlineLevelAttr.d.ts +1 -2
  172. package/dist/prosemirror/outlineLevelAttr.js +1 -2
  173. package/dist/prosemirror/paraIds.d.ts +46 -0
  174. package/dist/prosemirror/paraIds.js +152 -0
  175. package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
  176. package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
  177. package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
  178. package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
  179. package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
  180. package/dist/prosemirror/pastedCommentCopies.js +1 -1
  181. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  182. package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
  183. package/dist/prosemirror/plugins/suggestionMode.d.ts +1 -1
  184. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  185. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
  186. package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
  187. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  188. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  189. package/dist/prosemirror/replacedAnnotations.js +16 -1
  190. package/dist/prosemirror/revisionCarriers.d.ts +1 -1
  191. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  192. package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
  193. package/dist/prosemirror/selectionBounds.d.ts +10 -0
  194. package/dist/prosemirror/selectionBounds.js +22 -0
  195. package/dist/prosemirror/storyListNumbering.d.ts +1 -1
  196. package/dist/prosemirror/tableCellPaste.d.ts +1 -1
  197. package/dist/prosemirror/tableGridMutation.d.ts +1 -1
  198. package/dist/prosemirror/textInput.d.ts +1 -1
  199. package/dist/server.d.ts +7 -5
  200. package/dist/server.js +6 -4
  201. package/dist/types/canonicalCapabilities.d.ts +8 -41
  202. package/dist/types/canonicalCapabilities.js +6 -34
  203. package/package.json +4 -6
  204. package/dist/controller/collaborationModules.d.ts +0 -3
  205. package/dist/controller/collaborationModules.js +0 -14
  206. package/dist/docx/server/materializeYjsDocx.d.ts +0 -30
  207. package/dist/docx/server/materializeYjsDocx.js +0 -96
  208. package/dist/docx/server/migrateYjsAttrSchema.d.ts +0 -53
  209. package/dist/docx/server/migrateYjsAttrSchema.js +0 -111
  210. package/dist/prosemirror/plugins/derivedFields.d.ts +0 -8
  211. package/dist/prosemirror/plugins/derivedFields.js +0 -52
  212. package/dist/prosemirror/yjsDocumentMetadata.d.ts +0 -89
  213. package/dist/prosemirror/yjsDocumentMetadata.js +0 -697
@@ -1,54 +1,24 @@
1
1
  import { CanonicalSessionError } from "../canonical/canonicalSession.js";
2
- import { clearHeaderFooterVerbatimXml } from "../docx/headerFooterVerbatim.js";
3
- import { cloneParagraphWithPropertySource } from "../docx/paragraphPropertySource.js";
4
- import { proseDocToBlocks } from "../prosemirror/conversion/fromProseDoc.js";
5
- import { storyConversionOptions } from "../prosemirror/conversion/storyConversionOptions.js";
6
- import { headerFooterToProseDoc } from "../prosemirror/conversion/toProseDoc.js";
7
- import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
8
- import { createStarterKit } from "../prosemirror/extensions/StarterKit.js";
9
- import { ensureBaseDirectionInState } from "../prosemirror/extensions/features/AutoBidiDetectionExtension.js";
10
- import { ensureParaIdsInState } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
11
2
  import { createNativeNavigationPlugin, createNativeSelectionRefreshPlugin } from "../prosemirror/nativeSelection.js";
12
3
  import { noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
13
4
  import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNumbering.js";
14
- import { createDocumentStyleContextPlugin, createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
15
- import { schema } from "../prosemirror/schema/index.js";
16
- import { storyListNumbering } from "../prosemirror/storyListNumbering.js";
17
- import { CANONICAL_GAP, usesCanonicalSession } from "../types/canonicalCapabilities.js";
5
+ import { createDocumentStyleContextPlugin } from "../prosemirror/plugins/documentStyles.js";
6
+ import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
18
7
  import { readModel } from "../types/documentModel.js";
19
8
  import { createCanonicalStoryEditor, refreshCanonicalStoryView } from "./canonicalStoryEditor.js";
20
9
  import { OP_STORIES } from "@stll/docx-core/ops";
21
10
  import { EditorState } from "prosemirror-state";
22
11
  import { EditorView } from "prosemirror-view";
23
12
  // src/controller/headerFooterEditorManager.ts
13
+ /**
14
+ * Framework-neutral lifecycle owner for persistent header/footer EditorViews.
15
+ *
16
+ * Each distinct relationship id owns one off-screen ProseMirror view. Painted
17
+ * header/footer instances that share that relationship therefore share live
18
+ * editor state, and adapters only decide when to synchronize or destroy the
19
+ * manager.
20
+ */
24
21
  const createEditorView = (mountNode, props) => new EditorView(mountNode, props);
25
- const DETACHED_WATERMARK_HOST = Symbol.for("stll.detachedWatermarkHost");
26
- const headerFooterToProseDocWithDetachedWatermarkHost = (headerFooter, options) => {
27
- const markedContent = headerFooter.content.map((block, blockIndex) => {
28
- if (blockIndex !== headerFooter.watermarkBlockIndex || block.type !== "paragraph") return block;
29
- const marked = cloneParagraphWithPropertySource(block, {});
30
- Reflect.set(marked, DETACHED_WATERMARK_HOST, true);
31
- return marked;
32
- });
33
- return headerFooterToProseDoc(markedContent, options);
34
- };
35
- const buildInitialState = (headerFooter, styles, theme, numbering, manager) => {
36
- const proseDocOptions = storyConversionOptions({
37
- styles,
38
- theme,
39
- numbering
40
- });
41
- const document = headerFooter.watermarkBlockIndex === void 0 ? headerFooterToProseDoc(headerFooter.content, proseDocOptions) : headerFooterToProseDocWithDetachedWatermarkHost(headerFooter, proseDocOptions);
42
- return ensureBaseDirectionInState(ensureParaIdsInState(EditorState.create({
43
- doc: document,
44
- schema,
45
- plugins: [
46
- createDocumentNumberingPlugin(numbering),
47
- ...manager.getPlugins(),
48
- createDocumentStylesPlugin(styles)
49
- ]
50
- })));
51
- };
52
22
  const enumerateHeaderFooterParts = ({ headers, footers }) => {
53
23
  const parts = [];
54
24
  if (headers) for (const rId of headers.keys()) parts.push({
@@ -77,14 +47,12 @@ const createHeaderFooterEditorManager = (deps) => {
77
47
  const mounted = /* @__PURE__ */ new Map();
78
48
  const destroyMounted = (part) => {
79
49
  part.view.destroy();
80
- part.manager.destroy();
81
50
  part.mountNode.remove();
82
51
  };
83
52
  const destroy = () => {
84
53
  for (const part of mounted.values()) destroyMounted(part);
85
54
  mounted.clear();
86
55
  };
87
- const getOwnedDocument = () => usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) ? deps.readCanonicalDocument() : deps.getDocument();
88
56
  const sync = () => {
89
57
  const host = deps.getHost();
90
58
  if (!host) return;
@@ -97,11 +65,10 @@ const createHeaderFooterEditorManager = (deps) => {
97
65
  part.view.setProps({ editable: () => !getReadOnly() });
98
66
  }
99
67
  }
100
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) && !deps.getCanonicalApi?.()?.getCanonicalStoryProjection(OP_STORIES.MAIN)) return;
101
- const owned = getOwnedDocument();
68
+ if (!deps.getCanonicalApi?.()?.getCanonicalStoryProjection(OP_STORIES.MAIN)) return;
69
+ const owned = deps.readCanonicalDocument();
102
70
  const document = owned && readModel(owned);
103
71
  const styles = deps.getStyles();
104
- const theme = deps.getTheme();
105
72
  const numbering = document?.package.numbering;
106
73
  const wanted = new Map(enumerateDocumentHeaderFooterParts(document).map((part) => [part.rId, part]));
107
74
  for (const [rId, part] of mounted) {
@@ -110,47 +77,20 @@ const createHeaderFooterEditorManager = (deps) => {
110
77
  mounted.delete(rId);
111
78
  }
112
79
  for (const part of wanted.values()) {
113
- const headerFooter = resolveHeaderFooter(document, part);
114
- if (!headerFooter) continue;
80
+ if (!resolveHeaderFooter(document, part)) continue;
115
81
  const existing = mounted.get(part.rId);
116
82
  if (existing) {
117
83
  if (existing.mountNode.parentElement !== host) host.append(existing.mountNode);
118
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting)) {
119
- refreshCanonicalStoryView({
120
- view: existing.view,
121
- story: {
122
- kind: part.kind,
123
- rId: part.rId
124
- },
125
- api: deps.getCanonicalApi?.()
126
- });
127
- existing.appliedHeaderFooter = headerFooter;
128
- existing.appliedContent = headerFooter.content;
129
- existing.appliedStyles = styles;
130
- existing.appliedTheme = theme;
131
- existing.appliedNumbering = numbering;
132
- existing.dirty = false;
133
- continue;
134
- }
135
- const contentIsCurrent = existing.appliedHeaderFooter === headerFooter && existing.appliedContent === headerFooter.content;
136
- const contextIsCurrent = existing.appliedStyles === styles && existing.appliedTheme === theme && existing.appliedNumbering === numbering;
137
- if (contentIsCurrent && contextIsCurrent) continue;
138
- existing.view.updateState(buildInitialState(headerFooter, styles, theme, numbering, existing.manager));
139
- existing.appliedHeaderFooter = headerFooter;
140
- existing.appliedContent = headerFooter.content;
141
- existing.appliedStyles = styles;
142
- existing.appliedTheme = theme;
143
- existing.appliedNumbering = numbering;
144
- existing.dirty = false;
84
+ refreshCanonicalStoryView({
85
+ view: existing.view,
86
+ story: {
87
+ kind: part.kind,
88
+ rId: part.rId
89
+ },
90
+ api: deps.getCanonicalApi?.()
91
+ });
145
92
  continue;
146
93
  }
147
- const manager = new ExtensionManager(createStarterKit());
148
- manager.buildSchema();
149
- manager.initializeRuntime();
150
- const mountNode = host.ownerDocument.createElement("div");
151
- mountNode.dataset["hfRId"] = part.rId;
152
- mountNode.dataset["hfKind"] = part.kind;
153
- host.append(mountNode);
154
94
  const canonical = createCanonicalStoryEditor({
155
95
  story: {
156
96
  kind: part.kind,
@@ -158,7 +98,7 @@ const createHeaderFooterEditorManager = (deps) => {
158
98
  },
159
99
  getView: () => view,
160
100
  getApi: () => deps.getCanonicalApi?.() ?? null,
161
- enabled: () => usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting),
101
+ enabled: () => true,
162
102
  onRefusal: deps.onSessionRefusal,
163
103
  onSelectionChange: () => deps.onTransaction?.({
164
104
  kind: part.kind,
@@ -168,19 +108,19 @@ const createHeaderFooterEditorManager = (deps) => {
168
108
  selectionChanged: true
169
109
  })
170
110
  });
171
- const canonicalProjection = usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) ? deps.getCanonicalApi?.()?.getCanonicalStoryProjection({
111
+ const canonicalProjection = deps.getCanonicalApi?.()?.getCanonicalStoryProjection({
172
112
  kind: part.kind,
173
113
  rId: part.rId
174
- }) : null;
175
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) && !canonicalProjection) {
176
- manager.destroy();
177
- mountNode.remove();
178
- continue;
179
- }
114
+ });
115
+ if (!canonicalProjection) continue;
116
+ const mountNode = host.ownerDocument.createElement("div");
117
+ mountNode.dataset["hfRId"] = part.rId;
118
+ mountNode.dataset["hfKind"] = part.kind;
119
+ host.append(mountNode);
180
120
  const view = (deps.createView ?? createEditorView)(mountNode, {
181
121
  ...canonical.props,
182
122
  editable: () => !(deps.getReadOnly?.() ?? false),
183
- state: canonicalProjection ? EditorState.create({
123
+ state: EditorState.create({
184
124
  doc: canonicalProjection,
185
125
  plugins: [
186
126
  createDocumentNumberingPlugin(numbering),
@@ -188,7 +128,7 @@ const createHeaderFooterEditorManager = (deps) => {
188
128
  createNativeSelectionRefreshPlugin(),
189
129
  createNativeNavigationPlugin()
190
130
  ]
191
- }) : buildInitialState(headerFooter, styles, theme, numbering, manager),
131
+ }),
192
132
  dispatchTransaction(transaction) {
193
133
  if ((deps.getReadOnly?.() ?? false) && transaction.docChanged) return;
194
134
  if (canonical.dispatch(transaction)) return;
@@ -197,8 +137,6 @@ const createHeaderFooterEditorManager = (deps) => {
197
137
  const noteIssue = noteReferenceTransactionIssue(transaction);
198
138
  if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
199
139
  view.updateState(nextState);
200
- const mountedPart = mounted.get(part.rId);
201
- if (mountedPart && docChanged) mountedPart.dirty = true;
202
140
  deps.onTransaction?.({
203
141
  docChanged,
204
142
  kind: part.kind,
@@ -209,14 +147,7 @@ const createHeaderFooterEditorManager = (deps) => {
209
147
  }
210
148
  });
211
149
  mounted.set(part.rId, {
212
- appliedContent: headerFooter.content,
213
- appliedHeaderFooter: headerFooter,
214
- appliedNumbering: numbering,
215
- appliedStyles: styles,
216
- appliedTheme: theme,
217
- dirty: false,
218
150
  kind: part.kind,
219
- manager,
220
151
  mountNode,
221
152
  rId: part.rId,
222
153
  view
@@ -230,57 +161,14 @@ const createHeaderFooterEditorManager = (deps) => {
230
161
  kind,
231
162
  rId
232
163
  })),
233
- snapshotDocument: (model) => {
234
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting)) {
235
- const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
236
- if (canonical) return canonical;
237
- throw new CanonicalSessionError({
238
- ground: { gap: CANONICAL_GAP.authorityRouting },
239
- reason: "refused",
240
- message: "Canonical story snapshot is unavailable."
241
- });
242
- }
243
- const document = readModel(model);
244
- let headers = document.package.headers;
245
- let footers = document.package.footers;
246
- let headersChanged = false;
247
- let footersChanged = false;
248
- let numbering = document.package.numbering;
249
- for (const { dirty, kind, rId, view } of mounted.values()) {
250
- if (!dirty) continue;
251
- const source = kind === "header" ? headers : footers;
252
- const existing = source?.get(rId);
253
- if (!source || !existing) continue;
254
- const story = storyListNumbering(view.state, numbering);
255
- numbering = story.numbering;
256
- const updated = {
257
- ...existing,
258
- content: proseDocToBlocks(story.doc, existing.content, document.package.styles)
259
- };
260
- clearHeaderFooterVerbatimXml(updated);
261
- if (kind === "header") {
262
- if (!headersChanged) {
263
- headers = new Map(headers);
264
- headersChanged = true;
265
- }
266
- headers?.set(rId, updated);
267
- } else {
268
- if (!footersChanged) {
269
- footers = new Map(footers);
270
- footersChanged = true;
271
- }
272
- footers?.set(rId, updated);
273
- }
274
- }
275
- if (!headersChanged && !footersChanged) return model;
276
- const packageWithSnapshots = { ...document.package };
277
- if (numbering) packageWithSnapshots.numbering = numbering;
278
- if (headersChanged && headers) packageWithSnapshots.headers = headers;
279
- if (footersChanged && footers) packageWithSnapshots.footers = footers;
280
- return {
281
- ...document,
282
- package: packageWithSnapshots
283
- };
164
+ snapshotDocument: () => {
165
+ const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
166
+ if (canonical) return canonical;
167
+ throw new CanonicalSessionError({
168
+ ground: { gap: CANONICAL_GAP.authorityRouting },
169
+ reason: "refused",
170
+ message: "Canonical story snapshot is unavailable."
171
+ });
284
172
  },
285
173
  sync
286
174
  };
@@ -20,8 +20,8 @@ import { FolioDocxSerializationPath } from "../types/docxSerialization.js";
20
20
  import { FolioFieldInsertion } from "../types/fields.js";
21
21
  import { AnonymizationHighlightsView } from "./anonymizationHighlights.js";
22
22
  import { createCanonicalInputBoundary } from "./canonicalInput.js";
23
- import { Node } from "prosemirror-model";
24
23
  import { Command, EditorState, Transaction } from "prosemirror-state";
24
+ import { Node } from "prosemirror-model";
25
25
  import { DocumentOp, FormattingPatch, OpStory, TextPosition } from "@stll/docx-core/ops";
26
26
  import { EditorView } from "prosemirror-view";
27
27
  /** The inline suggestion, and what painting it needs. */
@@ -2,9 +2,9 @@ import { CanonicalHistoryDrop, CanonicalHistoryEffect } from "../canonical/canon
2
2
  import { HiddenEditorStateReason } from "../layout-engine/layoutInstrumentation.js";
3
3
  import { EditorMode } from "../managers/EditorModeManager.js";
4
4
  import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
5
- import { HistoryShortcutOwner } from "../prosemirror/extensions/core/HistoryExtension.js";
5
+ import { HistoryShortcutOwner } from "../prosemirror/extensions/core/historyCommands.js";
6
6
  import { FolioAnonymizationTerm } from "../types/anonymization.js";
7
- import { CanonicalRefusalGround, EditorSession } from "../types/canonicalCapabilities.js";
7
+ import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
8
8
  import { document_d_exports } from "../types/document.js";
9
9
  import { DeepReadonly, ReadonlyDocument } from "../types/documentModel.js";
10
10
  import { FolioDerivedFields } from "../types/fields.js";
@@ -15,40 +15,19 @@ import { HiddenEditorApi } from "./hiddenEditorApi.js";
15
15
  import { TaggedErrorClass } from "better-result";
16
16
  import { EditorState, Plugin, Transaction } from "prosemirror-state";
17
17
  import { EditorView } from "prosemirror-view";
18
- import * as Yjs from "yjs";
19
- import { XmlFragment } from "yjs";
20
- import * as YProseMirror from "y-prosemirror";
21
18
  declare const CanonicalSessionRefusalErrorBase: TaggedErrorClass<"CanonicalSessionRefusalError">;
22
19
  /** A refused input, with whether the session lacks the capability or the document forbids it. */
23
20
  export declare class CanonicalSessionRefusalError extends CanonicalSessionRefusalErrorBase<{
24
21
  ground: CanonicalRefusalGround;
25
22
  message: string;
26
23
  }> {}
27
- type YProseMirrorModule = typeof YProseMirror;
28
- type YjsModule = typeof Yjs;
29
- export type CollaborationModules = {
30
- yProseMirror: YProseMirrorModule;
31
- yjs: YjsModule;
32
- };
33
- type CollaborationAwareness = {
34
- clientID: number;
35
- getStates: () => Map<number, unknown>;
36
- off: (event: "change" | "update", handler: () => void) => void;
37
- on: (event: "change" | "update", handler: () => void) => void;
38
- };
39
- export type HiddenProseMirrorCollaboration = {
40
- awareness?: CollaborationAwareness | undefined;
41
- onSeeded?: (() => void) | undefined;
42
- shouldSeed?: boolean | undefined;
43
- yXmlFragment: XmlFragment;
44
- };
45
24
  export type HiddenProseMirrorRemoteSelection = RemoteSelection;
46
- export declare const collectRemoteSelections: (state: EditorState, awareness: CollaborationAwareness, collaborationModules: CollaborationModules) => HiddenProseMirrorRemoteSelection[];
47
25
  /**
48
26
  * Create ProseMirror state from document
49
27
  *
50
- * When an ExtensionManager is provided, it supplies the schema and plugins.
51
- * Otherwise falls back to the default singleton schema with no extension plugins.
28
+ * When an ExtensionManager is provided, it supplies the schema. The state
29
+ * paints the document before the canonical session's state replaces it, so it
30
+ * carries none of the extensions' editing plugins.
52
31
  */
53
32
  export type CreateHiddenEditorStateOptions = {
54
33
  /** The model; the editor state is built from it through `readModel`. */
@@ -56,8 +35,6 @@ export type CreateHiddenEditorStateOptions = {
56
35
  styles?: DeepReadonly<document_d_exports.StyleDefinitions> | null | undefined;
57
36
  manager?: ExtensionManager | undefined;
58
37
  externalPlugins?: Plugin[] | undefined;
59
- collaboration?: HiddenProseMirrorCollaboration | undefined;
60
- collaborationModules?: CollaborationModules | null | undefined;
61
38
  reason?: HiddenEditorStateReason | undefined;
62
39
  };
63
40
  export declare function createHiddenEditorState(options: CreateHiddenEditorStateOptions): EditorState;
@@ -67,20 +44,9 @@ export type HiddenEditorManagerDeps = {
67
44
  getStyles: () => DeepReadonly<document_d_exports.StyleDefinitions> | null | undefined;
68
45
  getExtensionManager: () => ExtensionManager | undefined;
69
46
  getExternalPlugins: () => Plugin[];
70
- /** The Yjs fragment a legacy session edits. */
71
- getCollaboration: () => HiddenProseMirrorCollaboration | undefined;
72
- getCollaborationModules: () => CollaborationModules | null;
73
- /** The room a canonical session joins. */
47
+ /** The room the session joins. */
74
48
  getCanonicalRoom?: () => CanonicalRoomCollaboration | undefined;
75
- /**
76
- * The state the adapter converted from the document for its pages before a
77
- * view existed. Read only when the view is built from the document: a
78
- * canonical session seeds the view with its own projection, so an adapter
79
- * that converts on this read converts the document once per open.
80
- */
81
- getPrecomputedInitialState: () => EditorState | null | undefined;
82
49
  getReadOnly: () => boolean;
83
- getExperimentalSession?: () => EditorSession | undefined;
84
50
  /** The terms the host wants highlighted; none when unset. */
85
51
  getAnonymizationTerms?: () => readonly FolioAnonymizationTerm[];
86
52
  /** The fields whose display text the host derives; none when unset. */