@stll/folio-core 0.67.0 → 0.69.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 (350) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +94 -8
  3. package/dist/ai-edits/headless.d.ts +36 -21
  4. package/dist/ai-edits/headless.js +106 -36
  5. package/dist/ai-edits/index.d.ts +2 -2
  6. package/dist/ai-edits/newListNumbering.d.ts +14 -1
  7. package/dist/ai-edits/newListNumbering.js +24 -1
  8. package/dist/ai-edits/note-references.d.ts +6 -0
  9. package/dist/ai-edits/note-references.js +7 -1
  10. package/dist/ai-edits/pending-suggestions.js +2 -2
  11. package/dist/ai-edits/read.d.ts +19 -0
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +8 -3
  14. package/dist/ai-edits/types.d.ts +9 -1
  15. package/dist/ai-suggestions/apply.js +13 -4
  16. package/dist/compare/compare.js +2 -1
  17. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  18. package/dist/compare/inserted-resource-snapshot.js +7 -3
  19. package/dist/controller/canonicalClipboard.js +31 -14
  20. package/dist/controller/canonicalComposition.js +35 -6
  21. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  22. package/dist/controller/canonicalInlineProjection.js +192 -28
  23. package/dist/controller/canonicalInput.d.ts +2 -1
  24. package/dist/controller/canonicalInput.js +32 -7
  25. package/dist/controller/canonicalListRendering.d.ts +2 -1
  26. package/dist/controller/canonicalListRendering.js +1 -1
  27. package/dist/controller/canonicalLockGuard.d.ts +23 -0
  28. package/dist/controller/canonicalLockGuard.js +133 -0
  29. package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
  30. package/dist/controller/canonicalProjectionBlocks.js +75 -0
  31. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  32. package/dist/controller/canonicalPublicOperations.js +676 -46
  33. package/dist/controller/canonicalSeedContent.d.ts +12 -0
  34. package/dist/controller/canonicalSeedContent.js +131 -0
  35. package/dist/controller/canonicalSession.d.ts +133 -21
  36. package/dist/controller/canonicalSession.js +738 -205
  37. package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
  38. package/dist/controller/canonicalSourceNormalization.js +148 -0
  39. package/dist/controller/canonicalStoryEditor.d.ts +4 -3
  40. package/dist/controller/canonicalStoryEditor.js +20 -15
  41. package/dist/controller/canonicalStructure.d.ts +2 -1
  42. package/dist/controller/canonicalStructure.js +129 -7
  43. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  44. package/dist/controller/contentControlWidgetController.js +13 -1
  45. package/dist/controller/folioEditor.js +4 -0
  46. package/dist/controller/headerFooterEditorManager.d.ts +7 -2
  47. package/dist/controller/headerFooterEditorManager.js +11 -6
  48. package/dist/controller/hiddenEditorApi.d.ts +17 -2
  49. package/dist/controller/hiddenEditorApi.js +4 -0
  50. package/dist/controller/hiddenEditorManager.d.ts +11 -3
  51. package/dist/controller/hiddenEditorManager.js +157 -48
  52. package/dist/controller/layoutPipeline.js +50 -16
  53. package/dist/controller/layoutSession.d.ts +3 -0
  54. package/dist/controller/layoutSession.js +3 -1
  55. package/dist/controller/noteEditorManager.d.ts +7 -2
  56. package/dist/controller/noteEditorManager.js +11 -6
  57. package/dist/display-list/build/pageFurniture.js +41 -19
  58. package/dist/display-list/build/tablePrimitives.js +23 -4
  59. package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
  60. package/dist/document-operations.d.ts +9 -1
  61. package/dist/document-operations.js +4 -3
  62. package/dist/docx/blockContentParser.d.ts +7 -3
  63. package/dist/docx/blockContentParser.js +2 -3
  64. package/dist/docx/blockPlainText.js +2 -0
  65. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  66. package/dist/docx/bookmarkRangeJoin.js +43 -0
  67. package/dist/docx/canonicalSave.js +11 -2
  68. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  69. package/dist/docx/canonicalSessionInput.js +7 -2
  70. package/dist/docx/commentAnchorIndex.d.ts +40 -5
  71. package/dist/docx/commentAnchorIndex.js +94 -12
  72. package/dist/docx/commentRangeIntegrity.js +30 -24
  73. package/dist/docx/commentRangeJoin.d.ts +4 -0
  74. package/dist/docx/commentRangeJoin.js +26 -12
  75. package/dist/docx/commentReferenceCompletion.js +5 -4
  76. package/dist/docx/commentReferenceNormalization.js +40 -18
  77. package/dist/docx/compatibility.js +9 -2
  78. package/dist/docx/containerChildren.js +22 -1
  79. package/dist/docx/contentTypeRegistry.js +1 -1
  80. package/dist/docx/encryption/compoundFile.js +9 -1
  81. package/dist/docx/encryption/encryptionInfo.js +16 -2
  82. package/dist/docx/ensureParaIds.js +46 -7
  83. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  84. package/dist/docx/ensureUniqueControlIds.js +110 -0
  85. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  86. package/dist/docx/headerFooterVerbatim.js +13 -2
  87. package/dist/docx/hostCommentThreads.d.ts +27 -0
  88. package/dist/docx/hostCommentThreads.js +72 -0
  89. package/dist/docx/hyperlinkParser.js +9 -2
  90. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  91. package/dist/docx/inlineWrapperContent.js +9 -2
  92. package/dist/docx/listMarkerComputation.d.ts +35 -1
  93. package/dist/docx/listMarkerComputation.js +39 -1
  94. package/dist/docx/listModelNormalization.d.ts +44 -1
  95. package/dist/docx/listModelNormalization.js +226 -96
  96. package/dist/docx/listNumberingInstances.d.ts +1 -1
  97. package/dist/docx/listNumberingInstances.js +2 -2
  98. package/dist/docx/markupRangeMarker.d.ts +14 -0
  99. package/dist/docx/markupRangeMarker.js +15 -1
  100. package/dist/docx/metadataPrivacy.js +43 -22
  101. package/dist/docx/normalizeBaseDirection.js +3 -1
  102. package/dist/docx/numberingIds.d.ts +6 -0
  103. package/dist/docx/numberingIds.js +6 -1
  104. package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
  105. package/dist/docx/numberingReferenceNormalization.js +12 -2
  106. package/dist/docx/paragraphParser.js +159 -48
  107. package/dist/docx/paragraphPropertySource.d.ts +29 -0
  108. package/dist/docx/paragraphPropertySource.js +106 -16
  109. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  110. package/dist/docx/paragraphTraversal.js +2 -0
  111. package/dist/docx/parseWarningMessage.js +2 -1
  112. package/dist/docx/parser.js +8 -0
  113. package/dist/docx/removeHeaderFooterParts.js +1 -1
  114. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  115. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  116. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  117. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  118. package/dist/docx/reviewResolutionProvenance.js +171 -33
  119. package/dist/docx/rezip.d.ts +6 -0
  120. package/dist/docx/rezip.js +38 -21
  121. package/dist/docx/selectiveSave.js +6 -10
  122. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  123. package/dist/docx/selectiveXmlPatch.js +11 -7
  124. package/dist/docx/serializer/documentSerializer.js +5 -2
  125. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  126. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  127. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  128. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  129. package/dist/docx/serializer/noteSerializer.js +23 -16
  130. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  131. package/dist/docx/serializer/partNamespaces.d.ts +1 -1
  132. package/dist/docx/serializer/partNamespaces.js +1 -1
  133. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  134. package/dist/docx/serializer/runSerializer.js +2 -2
  135. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  136. package/dist/docx/serializer/tableSerializer.js +4 -2
  137. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  138. package/dist/docx/server/build.d.ts +1 -1
  139. package/dist/docx/server/createBilingualDocument.js +27 -5
  140. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  141. package/dist/docx/sessionListPruning.d.ts +2 -0
  142. package/dist/docx/sessionListPruning.js +50 -0
  143. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  144. package/dist/docx/splitRevisionPieces.js +14 -0
  145. package/dist/docx/storyBlockReplay.js +19 -2
  146. package/dist/docx/structuralXmlPatch.js +44 -11
  147. package/dist/docx/tableParser.d.ts +6 -2
  148. package/dist/docx/tableParser.js +2 -3
  149. package/dist/docx/textBoxContentParser.d.ts +11 -0
  150. package/dist/docx/textBoxContentParser.js +51 -0
  151. package/dist/docx/textBoxParser.d.ts +0 -5
  152. package/dist/docx/textBoxParser.js +1 -23
  153. package/dist/docx/verticalMergeProjection.js +1 -1
  154. package/dist/docx/xmlParser.d.ts +1 -1
  155. package/dist/docx/xmlParser.js +2 -3
  156. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  157. package/dist/fonts/fontsourceFaces.js +1 -7
  158. package/dist/i18n/messages/ar.gen.js +3 -0
  159. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  160. package/dist/i18n/messages/catalogs.gen.js +51 -0
  161. package/dist/i18n/messages/cs.gen.js +3 -0
  162. package/dist/i18n/messages/de.gen.js +3 -0
  163. package/dist/i18n/messages/en.gen.js +3 -0
  164. package/dist/i18n/messages/es.gen.js +3 -0
  165. package/dist/i18n/messages/et.gen.js +3 -0
  166. package/dist/i18n/messages/fr.gen.js +3 -0
  167. package/dist/i18n/messages/he.gen.js +3 -0
  168. package/dist/i18n/messages/hi.gen.js +3 -0
  169. package/dist/i18n/messages/hu.gen.js +3 -0
  170. package/dist/i18n/messages/lt.gen.js +3 -0
  171. package/dist/i18n/messages/lv.gen.js +3 -0
  172. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  173. package/dist/i18n/messages/pl.gen.js +3 -0
  174. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  175. package/dist/i18n/messages/sk.gen.js +3 -0
  176. package/dist/i18n/messages/tr.gen.js +3 -0
  177. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  178. package/dist/internal/acceptedBlockProjection.js +2 -0
  179. package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
  180. package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
  181. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  182. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  183. package/dist/internal/revisionResolutionInline.js +1 -2
  184. package/dist/internal/subtreeHolds.d.ts +12 -0
  185. package/dist/internal/subtreeHolds.js +25 -0
  186. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  187. package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
  188. package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
  189. package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
  190. package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
  191. package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
  192. package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
  193. package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
  194. package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
  195. package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
  196. package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
  197. package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
  198. package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
  199. package/dist/layout-bridge/convert/tableConversion.js +19 -8
  200. package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
  201. package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
  202. package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
  203. package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
  204. package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
  205. package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
  206. package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
  207. package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
  208. package/dist/layout-bridge/dom/textStreamDom.js +3 -2
  209. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  210. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  211. package/dist/layout-bridge/engine/hitTest.js +9 -10
  212. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  213. package/dist/layout-bridge/headerFooterLayout.js +12 -11
  214. package/dist/layout-bridge/tableInsertHover.js +2 -1
  215. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  216. package/dist/layout-engine/footnoteContinuation.js +210 -0
  217. package/dist/layout-engine/index.d.ts +2 -2
  218. package/dist/layout-engine/index.js +7 -2
  219. package/dist/layout-engine/measure/cache.d.ts +2 -0
  220. package/dist/layout-engine/measure/cache.js +16 -6
  221. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  222. package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
  223. package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
  224. package/dist/layout-engine/tableLayout.js +29 -5
  225. package/dist/layout-engine/tableRowBreak.d.ts +36 -0
  226. package/dist/layout-engine/tableRowBreak.js +43 -1
  227. package/dist/layout-engine/types.d.ts +42 -1
  228. package/dist/layout-painter/imageLayout.js +2 -1
  229. package/dist/layout-painter/pageShellStyles.d.ts +10 -0
  230. package/dist/layout-painter/pageShellStyles.js +32 -0
  231. package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
  232. package/dist/layout-painter/reconcileRenderedContent.js +117 -0
  233. package/dist/layout-painter/renderFragment.js +4 -6
  234. package/dist/layout-painter/renderImage.js +2 -2
  235. package/dist/layout-painter/renderPage.d.ts +4 -4
  236. package/dist/layout-painter/renderPage.js +54 -46
  237. package/dist/layout-painter/renderParagraph.js +3 -3
  238. package/dist/layout-painter/renderTable.js +16 -16
  239. package/dist/layout-painter/renderTextBox.js +2 -2
  240. package/dist/layout-painter/sdtBoundary.js +3 -2
  241. package/dist/managers/AutoSaveManager.d.ts +5 -1
  242. package/dist/managers/FindReplaceManager.js +3 -10
  243. package/dist/markdown/escape.d.ts +20 -1
  244. package/dist/markdown/escape.js +43 -1
  245. package/dist/markdown/renderBlock.js +4 -1
  246. package/dist/markdown/renderParagraph.js +13 -27
  247. package/dist/markdown/renderTable.js +6 -2
  248. package/dist/markdown/trailers.js +1 -0
  249. package/dist/paged-layout/blockGeometry.js +3 -2
  250. package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
  251. package/dist/paged-layout/editorScrollRoot.js +10 -1
  252. package/dist/paged-layout/rangeProjection.js +5 -4
  253. package/dist/paged-layout/scrollToPmPosition.js +3 -3
  254. package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
  255. package/dist/paged-layout/selectionViewportRect.js +8 -2
  256. package/dist/pdf/images.d.ts +17 -1
  257. package/dist/pdf/images.js +22 -4
  258. package/dist/pdf/writePdf.js +4 -2
  259. package/dist/prosemirror/attrs/index.js +2 -0
  260. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  261. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  262. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  263. package/dist/prosemirror/commands/comments.d.ts +30 -2
  264. package/dist/prosemirror/commands/comments.js +189 -18
  265. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  266. package/dist/prosemirror/commands/index.d.ts +1 -1
  267. package/dist/prosemirror/commentIdAllocator.js +2 -2
  268. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  269. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  270. package/dist/prosemirror/commentRecords.d.ts +137 -0
  271. package/dist/prosemirror/commentRecords.js +400 -0
  272. package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
  273. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  274. package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
  275. package/dist/prosemirror/conversion/index.d.ts +2 -2
  276. package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
  277. package/dist/prosemirror/conversion/toProseDoc.js +432 -76
  278. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  279. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  280. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  281. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  282. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  283. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
  284. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
  285. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  286. package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
  287. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  288. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  289. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
  290. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  291. package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
  292. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  293. package/dist/prosemirror/index.d.ts +3 -3
  294. package/dist/prosemirror/listLabels.js +3 -2
  295. package/dist/prosemirror/listNumbering.d.ts +6 -0
  296. package/dist/prosemirror/listNumbering.js +12 -9
  297. package/dist/prosemirror/lockedControls.d.ts +13 -0
  298. package/dist/prosemirror/lockedControls.js +106 -0
  299. package/dist/prosemirror/markupViewProjection.js +1 -1
  300. package/dist/prosemirror/nativeSelection.d.ts +33 -0
  301. package/dist/prosemirror/nativeSelection.js +74 -0
  302. package/dist/prosemirror/noteReferenceReview.js +2 -2
  303. package/dist/prosemirror/numberedRefFields.d.ts +2 -0
  304. package/dist/prosemirror/numberedRefFields.js +16 -5
  305. package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
  306. package/dist/prosemirror/paragraphMarkJoin.js +155 -16
  307. package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
  308. package/dist/prosemirror/plugins/documentNumbering.js +37 -15
  309. package/dist/prosemirror/plugins/suggestionMode.js +33 -10
  310. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  311. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  312. package/dist/prosemirror/replacedAnnotations.js +1 -0
  313. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  314. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  315. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  316. package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
  317. package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
  318. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  319. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  320. package/dist/prosemirror/runStyleFormatting.js +16 -13
  321. package/dist/prosemirror/schema/marks.d.ts +13 -1
  322. package/dist/prosemirror/storyListNumbering.js +7 -2
  323. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  324. package/dist/prosemirror/tableResize.d.ts +10 -9
  325. package/dist/prosemirror/tableResize.js +60 -49
  326. package/dist/prosemirror/textInput.d.ts +30 -1
  327. package/dist/prosemirror/textInput.js +144 -17
  328. package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
  329. package/dist/prosemirror/validation.d.ts +19 -0
  330. package/dist/prosemirror/validation.js +79 -5
  331. package/dist/redline.js +23 -9
  332. package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
  333. package/dist/render-dom/RenderedDomContext.js +7 -6
  334. package/dist/server.d.ts +2 -2
  335. package/dist/style-sets/extract.js +2 -2
  336. package/dist/types/canonicalCapabilities.d.ts +38 -16
  337. package/dist/types/canonicalCapabilities.js +21 -18
  338. package/dist/utils/cssString.d.ts +7 -0
  339. package/dist/utils/cssString.js +9 -0
  340. package/dist/utils/findMatchView.js +4 -3
  341. package/dist/utils/fontResolver.js +4 -1
  342. package/dist/utils/formatToStyle.d.ts +1 -1
  343. package/dist/utils/mergeDocumentContent.js +2 -2
  344. package/dist/utils/paintedPositions.d.ts +60 -0
  345. package/dist/utils/paintedPositions.js +101 -0
  346. package/dist/utils/replaceText.d.ts +11 -0
  347. package/dist/utils/replaceText.js +39 -7
  348. package/dist/version-comparison.d.ts +9 -1
  349. package/dist/version-comparison.js +11 -5
  350. package/package.json +2 -3
package/dist/redline.js CHANGED
@@ -2,6 +2,7 @@ import { FolioDocxReviewer, getFolioDocxComparisonAccess, isFolioResolvedReviewe
2
2
  import { classifyResourceReference } from "./ai-edits/referenceClassification.js";
3
3
  import { createFolioAITextRangeHandle, trailingBodyBlockId } from "./ai-edits/snapshot.js";
4
4
  import { createScopedWordDiffOptions } from "./ai-edits/word-diff.js";
5
+ import { createFolioContentAlignmentWorkSession } from "./compare/content-alignment.js";
5
6
  import { FolioContentInlinePresentationProjectionError } from "./compare/content.js";
6
7
  import { inlineFormattingSegments } from "./compare/formatting.js";
7
8
  import { importStyleClosureWithNumbering } from "./compare/import-style-closure.js";
@@ -10,7 +11,7 @@ import "./document-operations.js";
10
11
  import { pairFolioDocumentStories } from "./document-stories.js";
11
12
  import { resolveFolioDocumentPrivacyTransforms, rewriteDocxMetadataPrivacy } from "./docx/metadataPrivacy.js";
12
13
  import { GenerateRedlineDocxOperationLimitError, MAX_GENERATED_REDLINE_OPERATIONS } from "./redlineOperationLimit.js";
13
- import { alignFolioBlocks } from "./version-comparison.js";
14
+ import { alignFolioBlocksInSession } from "./version-comparison.js";
14
15
  import { TaggedError, panic } from "better-result";
15
16
  // src/redline.ts
16
17
  /**
@@ -78,8 +79,12 @@ const buildFormattingRedlineOperations = ({ baseBlock, revisedBlock, nextOperati
78
79
  }
79
80
  return operations;
80
81
  };
81
- const buildRedlineOperations = ({ baseSnapshot, revisedBlocks, nextOperationId }) => {
82
- const events = alignFolioBlocks(baseSnapshot.blocks, revisedBlocks);
82
+ const buildRedlineOperations = ({ baseSnapshot, revisedBlocks, nextOperationId, alignmentSession }) => {
83
+ const events = alignFolioBlocksInSession({
84
+ baseBlocks: baseSnapshot.blocks,
85
+ revisedBlocks,
86
+ workSession: alignmentSession
87
+ });
83
88
  const anchorIds = nextBaseBlockIdByIndex(events);
84
89
  const operations = [];
85
90
  const trailingAdditions = [];
@@ -249,6 +254,7 @@ const generateRedlineDocx = async (base, revised, options = {}) => {
249
254
  const sourceStyles = new Set(sourceAccess.styleDefinitions()?.styles.map(({ styleId }) => styleId));
250
255
  const unprocessedStories = [];
251
256
  const wordDiff = createScopedWordDiffOptions({});
257
+ const alignmentSession = createFolioContentAlignmentWorkSession();
252
258
  let operationSequence = 0;
253
259
  const nextOperationId = () => {
254
260
  if (operationSequence >= 1e4) throw new GenerateRedlineDocxOperationLimitError({ message: "The document comparison exceeds the generated operation limit." });
@@ -276,14 +282,21 @@ const generateRedlineDocx = async (base, revised, options = {}) => {
276
282
  view: revisedView
277
283
  })?.snapshot;
278
284
  if (!baseSnapshot || !revisedSnapshot) panic("A matched document story could not be read");
285
+ const alignmentAllowance = { ...alignmentSession };
286
+ const projectionSession = { ...alignmentAllowance };
287
+ const inserted = createInsertedResourceProjection({
288
+ base: baseSnapshot,
289
+ revised: revisedSnapshot,
290
+ alignmentSession: projectionSession
291
+ });
292
+ alignmentSession.remainingLcsCells = projectionSession.remainingLcsCells;
293
+ alignmentSession.remainingStructuralTokenLookups = projectionSession.remainingStructuralTokenLookups;
279
294
  plannedStories.push({
280
295
  story: pair.baseStory,
281
296
  snapshot: baseSnapshot,
282
297
  revisedSnapshot,
283
- inserted: createInsertedResourceProjection({
284
- base: baseSnapshot,
285
- revised: revisedSnapshot
286
- })
298
+ inserted,
299
+ alignmentAllowance
287
300
  });
288
301
  }
289
302
  const insertedSnapshots = plannedStories.map(({ inserted }) => inserted.snapshot);
@@ -304,7 +317,7 @@ const generateRedlineDocx = async (base, revised, options = {}) => {
304
317
  });
305
318
  }
306
319
  const destinationStyles = new Set(baseAccess.styleDefinitions()?.styles.map(({ styleId }) => styleId));
307
- for (const [index, { story, snapshot, revisedSnapshot, inserted }] of plannedStories.entries()) {
320
+ for (const [index, { story, snapshot, revisedSnapshot, inserted, alignmentAllowance }] of plannedStories.entries()) {
308
321
  const rebound = resources.snapshots.at(index) ?? panic("A redline resource import lost its snapshot");
309
322
  const insertedById = rebindInsertedResourceBlocks(inserted, rebound);
310
323
  const originalBlocksById = new Map(revisedSnapshot.blocks.map((block) => [block.id, block]));
@@ -325,7 +338,8 @@ const generateRedlineDocx = async (base, revised, options = {}) => {
325
338
  const operations = buildRedlineOperations({
326
339
  baseSnapshot: snapshot,
327
340
  revisedBlocks: revisedSnapshot.blocks.map((block) => insertedById.get(block.id) ?? block),
328
- nextOperationId
341
+ nextOperationId,
342
+ alignmentSession: { ...alignmentAllowance }
329
343
  });
330
344
  if (operations.length === 0) continue;
331
345
  const result = baseReviewer.applyDocumentOperationsToStory({
@@ -1,5 +1,6 @@
1
1
  import { findHfCaretSpan, findHfPmSpans } from "../layout-bridge/dom/findHfPmSpans.js";
2
2
  import { createTextStreamRange, descendantTextNodes, totalTextLength } from "../layout-bridge/dom/textStreamDom.js";
3
+ import { readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
3
4
  // src/render-dom/HeaderFooterSelectionOverlay.ts
4
5
  const CARET_CLASS = "folio-hf-selection-caret";
5
6
  const RANGE_CLASS = "folio-hf-selection-rect";
@@ -25,8 +26,8 @@ const resolveHeaderFooterSelectionGeometry = (pagesContainer, selection, zoom) =
25
26
  let left = hit.edge === "right" ? anchorRect.right : anchorRect.left;
26
27
  let top = anchorRect.top;
27
28
  let height = anchorRect.height || 16;
28
- const pmStart = Number.parseInt(hit.element.dataset["pmStart"] ?? "", 10);
29
- const pmEnd = Number.parseInt(hit.element.dataset["pmEnd"] ?? "", 10);
29
+ const pmStart = readPaintedStart(hit.element) ?? NaN;
30
+ const pmEnd = readPaintedEnd(hit.element) ?? NaN;
30
31
  const textNodes = descendantTextNodes(hit.element);
31
32
  if (textNodes.length > 0 && Number.isFinite(pmStart) && Number.isFinite(pmEnd)) {
32
33
  const offset = Math.min(Math.max(0, selection.from - pmStart), totalTextLength(textNodes));
@@ -53,8 +54,8 @@ const resolveHeaderFooterSelectionGeometry = (pagesContainer, selection, zoom) =
53
54
  const to = Math.max(selection.from, selection.to);
54
55
  const ranges = [];
55
56
  for (const span of findHfPmSpans(pageScope, selection.kind, selection.rId)) {
56
- const spanStart = Number.parseInt(span.dataset["pmStart"] ?? "", 10);
57
- const spanEnd = Number.parseInt(span.dataset["pmEnd"] ?? "", 10);
57
+ const spanStart = readPaintedStart(span) ?? NaN;
58
+ const spanEnd = readPaintedEnd(span) ?? NaN;
58
59
  if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) continue;
59
60
  if (spanEnd <= from || spanStart >= to) continue;
60
61
  const textNodes = descendantTextNodes(span);
@@ -2,6 +2,7 @@ import { findCollapsedLineEdgeCaretTarget, findParagraphGapCaretTarget } from ".
2
2
  import { findBodyEmptyRuns, findBodyPmSpans } from "../layout-bridge/dom/findBodyPmSpans.js";
3
3
  import { createTextStreamRange, descendantTextNodes, measurePaintedSpanRange, totalTextLength } from "../layout-bridge/dom/textStreamDom.js";
4
4
  import { closestHtmlElement } from "../utils/domGuards.js";
5
+ import { readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
5
6
  // src/render-dom/RenderedDomContext.ts
6
7
  /**
7
8
  * Framework-neutral mapping from ProseMirror positions to the DOM emitted by
@@ -29,8 +30,8 @@ var RenderedDomContextImpl = class {
29
30
  height: lineHeightFor(collapsedTarget.span, this.#zoom)
30
31
  };
31
32
  for (const span of spans) {
32
- const pmStart = Number(span.dataset["pmStart"]);
33
- const pmEnd = Number(span.dataset["pmEnd"]);
33
+ const pmStart = readPaintedStart(span) ?? NaN;
34
+ const pmEnd = readPaintedEnd(span) ?? NaN;
34
35
  if (!(span.classList.contains("layout-run-tab") ? pmPos >= pmStart && pmPos < pmEnd : pmPos >= pmStart && pmPos <= pmEnd)) continue;
35
36
  const spanRect = span.getBoundingClientRect();
36
37
  if (span.classList.contains("layout-run-tab")) return {
@@ -63,8 +64,8 @@ var RenderedDomContextImpl = class {
63
64
  for (const emptyRun of findBodyEmptyRuns(this.#pagesContainer)) {
64
65
  const paragraph = closestHtmlElement(emptyRun, ".layout-paragraph");
65
66
  if (!paragraph) continue;
66
- const pmStart = Number(paragraph.dataset["pmStart"]);
67
- const pmEnd = Number(paragraph.dataset["pmEnd"]);
67
+ const pmStart = readPaintedStart(paragraph) ?? NaN;
68
+ const pmEnd = readPaintedEnd(paragraph) ?? NaN;
68
69
  if (pmPos < pmStart || pmPos > pmEnd) continue;
69
70
  const rect = emptyRun.getBoundingClientRect();
70
71
  return {
@@ -77,8 +78,8 @@ var RenderedDomContextImpl = class {
77
78
  }
78
79
  findElementsForRange(from, to) {
79
80
  return findBodyPmSpans(this.#pagesContainer).filter((span) => {
80
- const pmStart = Number(span.dataset["pmStart"]);
81
- return Number(span.dataset["pmEnd"]) > from && pmStart < to;
81
+ const pmStart = readPaintedStart(span) ?? NaN;
82
+ return (readPaintedEnd(span) ?? NaN) > from && pmStart < to;
82
83
  });
83
84
  }
84
85
  getRectsForRange(from, to) {
package/dist/server.d.ts CHANGED
@@ -2,7 +2,7 @@ import { FolioContentParagraphKind } from "./compare/content-types.js";
2
2
  import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIComment, FolioAIDiagnosticBlock, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIParagraphBlock, FolioAIParagraphSpacing, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult } from "./ai-edits/types.js";
3
3
  import { FolioRevisionStamp } from "./ai-edits/apply.js";
4
4
  import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationBatchPrecondition, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationQueuedOperation, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationResultBase, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
5
- import { FolioReviewChange, FolioReviewChangeKind } from "./ai-edits/read.js";
5
+ import { FolioReviewChange, FolioReviewChangeKind, FolioReviewResolution, FolioReviewResolutionSkip } from "./ai-edits/read.js";
6
6
  import { createFolioAITextRangeHandle, hashFolioAIBlockText, isFolioAIContentBlock, normalizeFolioAIBlockText } from "./ai-edits/snapshot.js";
7
7
  import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioApplyDocumentOperationsOptions, FolioApplyDocumentOperationsToStoryOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, FolioDocxReviewerOptions, FolioEditableDocumentStoryHandle, FolioReadReviewedStoryOptions, FolioResolveReviewedStoryOptions, FolioResolvedReviewedView, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, FolioReviewedStory, FolioReviewedView, FolioReviewerRepackReason, FolioReviewerSaveOptions, FolioReviewerSaveResult, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, isFolioResolvedReviewedView, isFolioReviewedView } from "./ai-edits/headless.js";
8
8
  import { getFolioDocumentOutline, readFolioDocumentSection } from "./ai-edits/scoped-reading.js";
@@ -32,4 +32,4 @@ import { FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGM
32
32
  import { FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES, FolioYjsSnapshotMigrationError, FolioYjsSnapshotMigrationErrorCode, FolioYjsSnapshotMigrationResult, migrateFolioYjsSnapshot } from "./docx/server/migrateYjsAttrSchema.js";
33
33
  import { GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, GenerateRedlineDocxResult, GenerateRedlineReferenceWarning, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
34
34
  import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioBlockDiff, FolioBlockProperty, FolioCompareDocxVersionsOptions, FolioDocumentMetadataValue, FolioFormatProperty, FolioMetadataDiff, FolioStoryDiff, FolioVersionBlockHandle, FolioVersionChangeProperty, FolioVersionComparisonPrivacyTransform, FolioVersionComparisonScope, FolioVersionDiff, FolioVersionDiffPrivacyOptions, FolioVersionDiffPrivacyReport, FolioVersionDiffSegment, FolioVersionDiffSummaryCounts, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
35
- export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, BILINGUAL_TABLE_LAYOUTS, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableLayout, type BilingualTableParagraphRef, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxParagraphSource, type DocxTableRowKind, type DocxTableRowPosition, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractDocxTextOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FOLIO_YJS_ATTR_SCHEMA_VERSION, FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES, FOLIO_YJS_UPDATE_MAX_BYTES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioBlockProperty, type FolioCompareDocxVersionsOptions, type FolioContentParagraphKind, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchPrecondition, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationQueuedOperation, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewedStory, type FolioReviewedView, type FolioReviewerRepackReason, type FolioReviewerSaveOptions, type FolioReviewerSaveResult, type FolioRevisionStamp, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionChangeProperty, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, FolioYjsDocxMaterializationError, type FolioYjsDocxMaterializationErrorCode, FolioYjsSnapshotMigrationError, type FolioYjsSnapshotMigrationErrorCode, type FolioYjsSnapshotMigrationResult, type GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, type GenerateRedlineDocxResult, type GenerateRedlineReferenceWarning, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type MaterializeYjsDocxOptions, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, type TableCellSpec, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedFolioDocumentOperationRemovedBlockIds, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, materializeYjsDocx, migrateFolioYjsSnapshot, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
35
+ export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, BILINGUAL_TABLE_LAYOUTS, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableLayout, type BilingualTableParagraphRef, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxParagraphSource, type DocxTableRowKind, type DocxTableRowPosition, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractDocxTextOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FOLIO_YJS_ATTR_SCHEMA_VERSION, FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES, FOLIO_YJS_UPDATE_MAX_BYTES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioBlockProperty, type FolioCompareDocxVersionsOptions, type FolioContentParagraphKind, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchPrecondition, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationQueuedOperation, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewResolution, type FolioReviewResolutionSkip, type FolioReviewedStory, type FolioReviewedView, type FolioReviewerRepackReason, type FolioReviewerSaveOptions, type FolioReviewerSaveResult, type FolioRevisionStamp, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionChangeProperty, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, FolioYjsDocxMaterializationError, type FolioYjsDocxMaterializationErrorCode, FolioYjsSnapshotMigrationError, type FolioYjsSnapshotMigrationErrorCode, type FolioYjsSnapshotMigrationResult, type GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, type GenerateRedlineDocxResult, type GenerateRedlineReferenceWarning, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type MaterializeYjsDocxOptions, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, type TableCellSpec, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedFolioDocumentOperationRemovedBlockIds, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, materializeYjsDocx, migrateFolioYjsSnapshot, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
@@ -118,9 +118,9 @@ const extractReferencedNumbering = (styles, document) => {
118
118
  };
119
119
  const sanitizeFontTable = (fontTable) => {
120
120
  if (!fontTable) return;
121
- return { fonts: fontTable.fonts.map(stripEmbeddedFontRelationships) };
121
+ return { fonts: fontTable.fonts.map(stripFontSourceData) };
122
122
  };
123
- const stripEmbeddedFontRelationships = ({ embedRegular: _embedRegular, embedBold: _embedBold, embedItalic: _embedItalic, embedBoldItalic: _embedBoldItalic, ...font }) => font;
123
+ const stripFontSourceData = ({ embedRegular: _embedRegular, embedBold: _embedBold, embedItalic: _embedItalic, embedBoldItalic: _embedBoldItalic, preserved: _preserved, preservedAttributes: _preservedAttributes, ...font }) => font;
124
124
  const toCatalogEntry = (style) => {
125
125
  const entry = {
126
126
  styleId: style.styleId,
@@ -20,14 +20,50 @@ export declare const CANONICAL_GAP: {
20
20
  readonly documentOperations: "pm-document-operations";
21
21
  readonly aiSnapshots: "pm-ai-snapshots";
22
22
  readonly publicComments: "publicOps.comments";
23
- readonly publicSuggestedMode: "publicOps.suggestedMode";
24
23
  readonly publicUnsupportedInline: "publicOps.unsupportedInline";
25
24
  readonly publicTableStructure: "publicOps.tableStructure";
26
25
  readonly publicPendingParagraphMarkProperties: "publicOps.pendingParagraphMarkProperties";
27
26
  readonly publicHeadlessSession: "publicOps.headlessSession";
28
- readonly publicSecondaryStories: "publicOps.secondaryStories";
29
27
  };
30
28
  export type CanonicalGap = (typeof CANONICAL_GAP)[keyof typeof CANONICAL_GAP];
29
+ /**
30
+ * Rules a document states for itself. A refusal under one is the correct
31
+ * outcome and stays after the cutover; it is never a gap to retire.
32
+ */
33
+ export declare const CANONICAL_RULE: {
34
+ readonly contentControlLock: "contentControlLock";
35
+ };
36
+ export type CanonicalRule = (typeof CANONICAL_RULE)[keyof typeof CANONICAL_RULE];
37
+ /** The editor message, in the folio catalog, a host shows for a refusal under each rule. */
38
+ export declare const CANONICAL_RULE_MESSAGE_KEYS: {
39
+ readonly contentControlLock: "editor.contentLocked";
40
+ };
41
+ /**
42
+ * The editor message, in the folio catalog, a host shows for a refusal under
43
+ * any gap: the change cannot be made here yet.
44
+ */
45
+ export declare const CANONICAL_GAP_MESSAGE_KEY: "editor.changeUnavailable";
46
+ /** A catalog key a refusal notice reads. */
47
+ export type CanonicalRefusalMessageKey = (typeof CANONICAL_RULE_MESSAGE_KEYS)[CanonicalRule] | typeof CANONICAL_GAP_MESSAGE_KEY;
48
+ /**
49
+ * What a host shows for a refusal, always from the folio catalog, which the
50
+ * host translates: the editor's own message for a rule the document states,
51
+ * and that the change cannot be made here yet for a gap. The session's own
52
+ * message describes the refusal for logs and `onError`, never for the user.
53
+ */
54
+ export declare const canonicalRefusalNotice: (ground: CanonicalRefusalGround, translate: (key: CanonicalRefusalMessageKey) => string) => string;
55
+ /**
56
+ * The ground for a refusal: a capability the session does not have yet, or a
57
+ * rule the document states. A host tells "not supported yet" from "not
58
+ * allowed" by which one is present.
59
+ */
60
+ export type CanonicalRefusalGround = {
61
+ gap: CanonicalGap;
62
+ rule?: never;
63
+ } | {
64
+ rule: CanonicalRule;
65
+ gap?: never;
66
+ };
31
67
  export declare const CANONICAL_CAPABILITIES: {
32
68
  readonly "authority-routing": {
33
69
  readonly owner: "controller";
@@ -148,13 +184,6 @@ export declare const CANONICAL_CAPABILITIES: {
148
184
  readonly adapters: readonly ["react", "vue"];
149
185
  readonly summary: "Canonical public comments compile to semantic operations; default sessions retain PM comments.";
150
186
  };
151
- readonly "publicOps.suggestedMode": {
152
- readonly owner: "document-operations";
153
- readonly defaultSessionMutation: "pm-public-operations";
154
- readonly kind: "refusal";
155
- readonly adapters: readonly ["react", "vue"];
156
- readonly summary: "Public suggested mode refuses in canonical sessions until pending suggestions use the journal.";
157
- };
158
187
  readonly "publicOps.unsupportedInline": {
159
188
  readonly owner: "document-operations";
160
189
  readonly defaultSessionMutation: "pm-public-operations";
@@ -176,13 +205,6 @@ export declare const CANONICAL_CAPABILITIES: {
176
205
  readonly adapters: readonly ["react", "vue"];
177
206
  readonly summary: "Separate paragraph property edits refuse while the paragraph mark is pending deletion; atomic merge properties remain supported.";
178
207
  };
179
- readonly "publicOps.secondaryStories": {
180
- readonly owner: "document-operations";
181
- readonly defaultSessionMutation: "pm-public-operations";
182
- readonly kind: "refusal";
183
- readonly adapters: readonly ["react", "vue"];
184
- readonly summary: "Public secondary-story batches refuse until canonical story routing is available.";
185
- };
186
208
  readonly "publicOps.headlessSession": {
187
209
  readonly owner: "document-operations";
188
210
  readonly defaultSessionMutation: "pm-headless-reviewer";
@@ -21,13 +21,30 @@ const CANONICAL_GAP = {
21
21
  documentOperations: "pm-document-operations",
22
22
  aiSnapshots: "pm-ai-snapshots",
23
23
  publicComments: "publicOps.comments",
24
- publicSuggestedMode: "publicOps.suggestedMode",
25
24
  publicUnsupportedInline: "publicOps.unsupportedInline",
26
25
  publicTableStructure: "publicOps.tableStructure",
27
26
  publicPendingParagraphMarkProperties: "publicOps.pendingParagraphMarkProperties",
28
- publicHeadlessSession: "publicOps.headlessSession",
29
- publicSecondaryStories: "publicOps.secondaryStories"
27
+ publicHeadlessSession: "publicOps.headlessSession"
30
28
  };
29
+ /**
30
+ * Rules a document states for itself. A refusal under one is the correct
31
+ * outcome and stays after the cutover; it is never a gap to retire.
32
+ */
33
+ const CANONICAL_RULE = { contentControlLock: "contentControlLock" };
34
+ /** The editor message, in the folio catalog, a host shows for a refusal under each rule. */
35
+ const CANONICAL_RULE_MESSAGE_KEYS = { contentControlLock: "editor.contentLocked" };
36
+ /**
37
+ * The editor message, in the folio catalog, a host shows for a refusal under
38
+ * any gap: the change cannot be made here yet.
39
+ */
40
+ const CANONICAL_GAP_MESSAGE_KEY = "editor.changeUnavailable";
41
+ /**
42
+ * What a host shows for a refusal, always from the folio catalog, which the
43
+ * host translates: the editor's own message for a rule the document states,
44
+ * and that the change cannot be made here yet for a gap. The session's own
45
+ * message describes the refusal for logs and `onError`, never for the user.
46
+ */
47
+ const canonicalRefusalNotice = (ground, translate) => translate(ground.rule === void 0 ? CANONICAL_GAP_MESSAGE_KEY : CANONICAL_RULE_MESSAGE_KEYS[ground.rule]);
31
48
  const CANONICAL_CAPABILITIES = {
32
49
  [CANONICAL_GAP.authorityRouting]: {
33
50
  owner: "controller",
@@ -146,13 +163,6 @@ const CANONICAL_CAPABILITIES = {
146
163
  adapters: ["react", "vue"],
147
164
  summary: "Canonical public comments compile to semantic operations; default sessions retain PM comments."
148
165
  },
149
- [CANONICAL_GAP.publicSuggestedMode]: {
150
- owner: "document-operations",
151
- defaultSessionMutation: "pm-public-operations",
152
- kind: "refusal",
153
- adapters: ["react", "vue"],
154
- summary: "Public suggested mode refuses in canonical sessions until pending suggestions use the journal."
155
- },
156
166
  [CANONICAL_GAP.publicUnsupportedInline]: {
157
167
  owner: "document-operations",
158
168
  defaultSessionMutation: "pm-public-operations",
@@ -174,13 +184,6 @@ const CANONICAL_CAPABILITIES = {
174
184
  adapters: ["react", "vue"],
175
185
  summary: "Separate paragraph property edits refuse while the paragraph mark is pending deletion; atomic merge properties remain supported."
176
186
  },
177
- [CANONICAL_GAP.publicSecondaryStories]: {
178
- owner: "document-operations",
179
- defaultSessionMutation: "pm-public-operations",
180
- kind: "refusal",
181
- adapters: ["react", "vue"],
182
- summary: "Public secondary-story batches refuse until canonical story routing is available."
183
- },
184
187
  [CANONICAL_GAP.publicHeadlessSession]: {
185
188
  owner: "document-operations",
186
189
  defaultSessionMutation: "pm-headless-reviewer",
@@ -201,4 +204,4 @@ const CANONICAL_CAPABILITIES = {
201
204
  */
202
205
  const usesCanonicalSession = (session, _gap) => session === "canonical";
203
206
  const canonicalRefusalMessage = (gap, message) => `[${gap}] ${message}`;
204
- export { CANONICAL_CAPABILITIES, CANONICAL_GAP, canonicalRefusalMessage, usesCanonicalSession };
207
+ export { CANONICAL_CAPABILITIES, CANONICAL_GAP, CANONICAL_GAP_MESSAGE_KEY, CANONICAL_RULE, CANONICAL_RULE_MESSAGE_KEYS, canonicalRefusalMessage, canonicalRefusalNotice, usesCanonicalSession };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A CSS `<string>` token, quoted and escaped. Callers emit authored text
3
+ * (a font family from a document) into a stylesheet or an inline style, so
4
+ * the backslash is escaped first, then the quote, and line terminators
5
+ * become hex escapes, which CSS strings require.
6
+ */
7
+ export declare const cssString: (value: string) => string;
@@ -0,0 +1,9 @@
1
+ // src/utils/cssString.ts
2
+ /**
3
+ * A CSS `<string>` token, quoted and escaped. Callers emit authored text
4
+ * (a font family from a document) into a stylesheet or an inline style, so
5
+ * the backslash is escaped first, then the quote, and line terminators
6
+ * become hex escapes, which CSS strings require.
7
+ */
8
+ const cssString = (value) => `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\A ").replaceAll("\r", "\\D ").replaceAll("\f", "\\C ")}"`;
9
+ export { cssString };
@@ -3,6 +3,7 @@ import { selectSectionHeaderFooterRIds } from "../layout-painter/renderPage.js";
3
3
  import { getEditorScrollRoot, scrollEditorElementIntoView } from "../paged-layout/editorScrollRoot.js";
4
4
  import { headerFooterToProseDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
5
5
  import { resolveFindMatchRanges } from "../prosemirror/findReplaceSelection.js";
6
+ import { PAINTED_RANGE_SELECTOR, readPaintedEnd, readPaintedStart } from "./paintedPositions.js";
6
7
  import { OP_STORIES, documentStories, storyBody } from "@stll/docx-core/ops";
7
8
  // src/utils/findMatchView.ts
8
9
  const storyKey = (story) => {
@@ -195,7 +196,7 @@ const createFindMatchView = (options) => {
195
196
  marks.clear();
196
197
  targets.clear();
197
198
  const spans = /* @__PURE__ */ new Map();
198
- for (const span of container.querySelectorAll(".layout-page span[data-pm-start][data-pm-end], .layout-page span[data-decoration-start][data-decoration-end]")) {
199
+ for (const span of container.querySelectorAll(`.layout-page span${PAINTED_RANGE_SELECTOR}, .layout-page span[data-decoration-start][data-decoration-end]`)) {
199
200
  const key = spanStoryKey(span);
200
201
  const group = spans.get(key);
201
202
  if (group) group.push(span);
@@ -400,6 +401,6 @@ const createFindMatchView = (options) => {
400
401
  }
401
402
  };
402
403
  };
403
- const spanStart = (span) => Number(span.dataset["pmStart"] ?? span.dataset["decorationStart"]);
404
- const spanEnd = (span) => Number(span.dataset["pmEnd"] ?? span.dataset["decorationEnd"]);
404
+ const spanStart = (span) => readPaintedStart(span) ?? Number(span.dataset["decorationStart"]);
405
+ const spanEnd = (span) => readPaintedEnd(span) ?? Number(span.dataset["decorationEnd"]);
405
406
  export { createFindMatchView, getRenderedSearchStories, resolveDocumentFindRanges };
@@ -1167,8 +1167,11 @@ function quoteFontName(fontName) {
1167
1167
  }
1168
1168
  const CSS_NEWLINE_UNESCAPES = {
1169
1169
  a: "\n",
1170
+ A: "\n",
1170
1171
  d: "\r",
1171
- c: "\f"
1172
+ D: "\r",
1173
+ c: "\f",
1174
+ C: "\f"
1172
1175
  };
1173
1176
  /**
1174
1177
  * Split a CSS `font-family` list built by `quoteFontName` back into family
@@ -1,5 +1,5 @@
1
- import { ColorValue } from "../types/colors.js";
2
1
  import { document_d_exports } from "../types/document.js";
2
+ import { ColorValue } from "../types/colors.js";
3
3
  import { Properties } from "csstype";
4
4
  type CSSProperties = Properties<string | number>;
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { createNumberingIdAllocator } from "../docx/numberingIds.js";
1
+ import { createNumberingIdAllocator, numberingNumIdsTaken } from "../docx/numberingIds.js";
2
2
  import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
3
3
  import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
4
4
  // src/utils/mergeDocumentContent.ts
@@ -62,7 +62,7 @@ function mergeDocumentContent(target, source) {
62
62
  };
63
63
  function remapContentNumbering(content, numbering) {
64
64
  const existingAbstractIds = [...(targetNumbering?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId), ...numbering.abstractNums.map(({ abstractNumId }) => abstractNumId)];
65
- const existingNumIds = [...(targetNumbering?.nums ?? []).map(({ numId }) => numId), ...numbering.nums.map(({ numId }) => numId)];
65
+ const existingNumIds = [...numberingNumIdsTaken(targetNumbering), ...numberingNumIdsTaken(numbering)];
66
66
  const abstractIds = createNumberingIdAllocator("abstract", existingAbstractIds);
67
67
  const numIds = createNumberingIdAllocator("num", existingNumIds);
68
68
  const abstractNumIdRemap = /* @__PURE__ */ new Map();
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The one owner of the editor positions a painted element carries.
3
+ *
4
+ * The painter marks the elements it draws with the editor document positions
5
+ * they show: a run, a paragraph line, a table, a table cell, an image, a text
6
+ * box, a content-control boundary. Hit testing, caret and selection drawing,
7
+ * scrolling to a position and the hosts' pointer handling read them back.
8
+ *
9
+ * How a position is stored on an element is this module's business alone:
10
+ * every write and every read goes through it, and the
11
+ * `folio-painted-positions/position-attribute-owner` lint rule forbids
12
+ * touching the attributes anywhere else. That keeps the storage free to
13
+ * change in one place, for instance to positions relative to the painted
14
+ * block, without auditing every reader.
15
+ */
16
+ /** Elements that show where they start. */
17
+ export declare const PAINTED_START_SELECTOR = "[data-pm-start]";
18
+ /** Elements that show where they start and where they end. */
19
+ export declare const PAINTED_RANGE_SELECTOR = "[data-pm-start][data-pm-end]";
20
+ /** Elements that carry any painted position. */
21
+ export declare const PAINTED_POSITION_SELECTOR: string;
22
+ /** Elements that show a range starting exactly at `position`. */
23
+ export declare const paintedStartSelector: (position: number) => string;
24
+ /**
25
+ * The attributes a node can differ in from a fresh painting of it while still
26
+ * showing the same thing: an edit before it shifts them and nothing else.
27
+ */
28
+ export declare const PAINTED_POSITION_ATTRIBUTES: ReadonlySet<string>;
29
+ /** An element that can carry painted positions. */
30
+ export type PaintedElement = Pick<HTMLElement, "dataset">;
31
+ /** Where the content `element` shows starts. */
32
+ export declare const readPaintedStart: (element: PaintedElement) => number | undefined;
33
+ /** Where the content `element` shows ends. */
34
+ export declare const readPaintedEnd: (element: PaintedElement) => number | undefined;
35
+ /** Where the table a table handle or overlay element belongs to starts. */
36
+ export declare const readPaintedTableStart: (element: PaintedElement) => number | undefined;
37
+ /** The raw content-control boundary key a painted box carries. */
38
+ export declare const readPaintedContentControlKey: (element: PaintedElement) => string | undefined;
39
+ /** Whether `element` shows where it starts. */
40
+ export declare const hasPaintedStart: (element: PaintedElement) => boolean;
41
+ /** Whether `element` shows where it starts and where it ends. */
42
+ export declare const hasPaintedRange: (element: PaintedElement) => boolean;
43
+ /** Mark `element` as showing content that starts at `position`. */
44
+ export declare const writePaintedStart: (element: PaintedElement, position: number) => void;
45
+ /** Mark `element` as showing content that ends at `position`. */
46
+ export declare const writePaintedEnd: (element: PaintedElement, position: number) => void;
47
+ /**
48
+ * Mark `element` with the range it shows. A side left `undefined` is not
49
+ * written, as for a fragment that knows only one of them.
50
+ */
51
+ export declare const writePaintedRange: (element: PaintedElement, start: number | undefined, end: number | undefined) => void;
52
+ /** Mark a table handle or overlay element with its table's start. */
53
+ export declare const writePaintedTableStart: (element: PaintedElement, position: number) => void;
54
+ /** Mark a content-control box with the boundary it draws. */
55
+ export declare const writePaintedContentControlKey: (element: PaintedElement, position: number) => void;
56
+ /**
57
+ * Move every painted position under `root` (not `root` itself) by `delta`,
58
+ * for content an edit before it moved without changing it.
59
+ */
60
+ export declare const shiftPaintedPositions: (root: ParentNode, delta: number) => void;
@@ -0,0 +1,101 @@
1
+ // src/utils/paintedPositions.ts
2
+ /**
3
+ * The one owner of the editor positions a painted element carries.
4
+ *
5
+ * The painter marks the elements it draws with the editor document positions
6
+ * they show: a run, a paragraph line, a table, a table cell, an image, a text
7
+ * box, a content-control boundary. Hit testing, caret and selection drawing,
8
+ * scrolling to a position and the hosts' pointer handling read them back.
9
+ *
10
+ * How a position is stored on an element is this module's business alone:
11
+ * every write and every read goes through it, and the
12
+ * `folio-painted-positions/position-attribute-owner` lint rule forbids
13
+ * touching the attributes anywhere else. That keeps the storage free to
14
+ * change in one place, for instance to positions relative to the painted
15
+ * block, without auditing every reader.
16
+ */
17
+ const START_ATTRIBUTE = "data-pm-start";
18
+ const END_ATTRIBUTE = "data-pm-end";
19
+ const TABLE_START_ATTRIBUTE = "data-table-pm-start";
20
+ const CONTENT_CONTROL_ATTRIBUTE = "data-sdt-pm-pos";
21
+ /** Elements that show where they start. */
22
+ const PAINTED_START_SELECTOR = `[${START_ATTRIBUTE}]`;
23
+ /** Elements that show where they start and where they end. */
24
+ const PAINTED_RANGE_SELECTOR = `[${START_ATTRIBUTE}][${END_ATTRIBUTE}]`;
25
+ /** Elements that carry any painted position. */
26
+ const PAINTED_POSITION_SELECTOR = [
27
+ START_ATTRIBUTE,
28
+ END_ATTRIBUTE,
29
+ TABLE_START_ATTRIBUTE
30
+ ].map((attribute) => `[${attribute}]`).join(", ");
31
+ /** Elements that show a range starting exactly at `position`. */
32
+ const paintedStartSelector = (position) => `[${START_ATTRIBUTE}="${String(position)}"]`;
33
+ /**
34
+ * The attributes a node can differ in from a fresh painting of it while still
35
+ * showing the same thing: an edit before it shifts them and nothing else.
36
+ */
37
+ const PAINTED_POSITION_ATTRIBUTES = /* @__PURE__ */ new Set([
38
+ START_ATTRIBUTE,
39
+ END_ATTRIBUTE,
40
+ TABLE_START_ATTRIBUTE,
41
+ CONTENT_CONTROL_ATTRIBUTE
42
+ ]);
43
+ /** A painted value, or `undefined` when the element carries none. */
44
+ const readPosition = (element, key) => {
45
+ const value = element.dataset[key];
46
+ return value === void 0 || value === "" ? void 0 : Number(value);
47
+ };
48
+ /** Where the content `element` shows starts. */
49
+ const readPaintedStart = (element) => readPosition(element, "pmStart");
50
+ /** Where the content `element` shows ends. */
51
+ const readPaintedEnd = (element) => readPosition(element, "pmEnd");
52
+ /** Where the table a table handle or overlay element belongs to starts. */
53
+ const readPaintedTableStart = (element) => readPosition(element, "tablePmStart");
54
+ /** The raw content-control boundary key a painted box carries. */
55
+ const readPaintedContentControlKey = (element) => element.dataset["sdtPmPos"];
56
+ /** Whether `element` shows where it starts. */
57
+ const hasPaintedStart = (element) => readPaintedStart(element) !== void 0;
58
+ /** Whether `element` shows where it starts and where it ends. */
59
+ const hasPaintedRange = (element) => readPaintedStart(element) !== void 0 && readPaintedEnd(element) !== void 0;
60
+ /** Mark `element` as showing content that starts at `position`. */
61
+ const writePaintedStart = (element, position) => {
62
+ element.dataset["pmStart"] = String(position);
63
+ };
64
+ /** Mark `element` as showing content that ends at `position`. */
65
+ const writePaintedEnd = (element, position) => {
66
+ element.dataset["pmEnd"] = String(position);
67
+ };
68
+ /**
69
+ * Mark `element` with the range it shows. A side left `undefined` is not
70
+ * written, as for a fragment that knows only one of them.
71
+ */
72
+ const writePaintedRange = (element, start, end) => {
73
+ if (start !== void 0) writePaintedStart(element, start);
74
+ if (end !== void 0) writePaintedEnd(element, end);
75
+ };
76
+ /** Mark a table handle or overlay element with its table's start. */
77
+ const writePaintedTableStart = (element, position) => {
78
+ element.dataset["tablePmStart"] = String(position);
79
+ };
80
+ /** Mark a content-control box with the boundary it draws. */
81
+ const writePaintedContentControlKey = (element, position) => {
82
+ element.dataset["sdtPmPos"] = String(position);
83
+ };
84
+ const shiftPosition = (element, key, delta) => {
85
+ const value = element.dataset[key];
86
+ if (value === void 0) return;
87
+ const position = Number(value);
88
+ if (Number.isFinite(position)) element.dataset[key] = String(position + delta);
89
+ };
90
+ /**
91
+ * Move every painted position under `root` (not `root` itself) by `delta`,
92
+ * for content an edit before it moved without changing it.
93
+ */
94
+ const shiftPaintedPositions = (root, delta) => {
95
+ for (const element of root.querySelectorAll(PAINTED_POSITION_SELECTOR)) {
96
+ shiftPosition(element, "pmStart", delta);
97
+ shiftPosition(element, "pmEnd", delta);
98
+ shiftPosition(element, "tablePmStart", delta);
99
+ }
100
+ };
101
+ export { PAINTED_POSITION_ATTRIBUTES, PAINTED_POSITION_SELECTOR, PAINTED_RANGE_SELECTOR, PAINTED_START_SELECTOR, hasPaintedRange, hasPaintedStart, paintedStartSelector, readPaintedContentControlKey, readPaintedEnd, readPaintedStart, readPaintedTableStart, shiftPaintedPositions, writePaintedContentControlKey, writePaintedEnd, writePaintedRange, writePaintedStart, writePaintedTableStart };