@stll/folio-core 0.66.2 → 0.68.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 (323) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +138 -17
  3. package/dist/ai-edits/batch-claims.js +5 -3
  4. package/dist/ai-edits/clean-text.js +4 -1
  5. package/dist/ai-edits/headless.d.ts +36 -21
  6. package/dist/ai-edits/headless.js +104 -34
  7. package/dist/ai-edits/index.d.ts +2 -2
  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/read.d.ts +19 -0
  11. package/dist/ai-edits/read.js +6 -4
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +32 -17
  14. package/dist/ai-edits/table-cell-mutations.js +3 -2
  15. package/dist/ai-edits/table-row-column-mutations.js +20 -6
  16. package/dist/ai-edits/types.d.ts +9 -1
  17. package/dist/ai-suggestions/apply.js +13 -4
  18. package/dist/compare/compare.js +2 -1
  19. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  20. package/dist/compare/inserted-resource-snapshot.js +7 -3
  21. package/dist/controller/canonicalClipboard.js +29 -12
  22. package/dist/controller/canonicalComposition.d.ts +1 -1
  23. package/dist/controller/canonicalComposition.js +77 -19
  24. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  25. package/dist/controller/canonicalInlineProjection.js +192 -28
  26. package/dist/controller/canonicalInput.d.ts +2 -2
  27. package/dist/controller/canonicalInput.js +47 -2
  28. package/dist/controller/canonicalListRendering.d.ts +2 -1
  29. package/dist/controller/canonicalListRendering.js +1 -1
  30. package/dist/controller/canonicalLockGuard.d.ts +8 -0
  31. package/dist/controller/canonicalLockGuard.js +88 -0
  32. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  33. package/dist/controller/canonicalPublicOperations.js +274 -20
  34. package/dist/controller/canonicalSession.d.ts +87 -7
  35. package/dist/controller/canonicalSession.js +328 -75
  36. package/dist/controller/canonicalStoryEditor.d.ts +3 -2
  37. package/dist/controller/canonicalStoryEditor.js +4 -3
  38. package/dist/controller/canonicalStructure.d.ts +2 -1
  39. package/dist/controller/canonicalStructure.js +129 -7
  40. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  41. package/dist/controller/contentControlWidgetController.js +13 -1
  42. package/dist/controller/folioEditor.js +1 -0
  43. package/dist/controller/headerFooterEditorManager.d.ts +2 -2
  44. package/dist/controller/headerFooterEditorManager.js +5 -5
  45. package/dist/controller/hiddenEditorApi.d.ts +6 -0
  46. package/dist/controller/hiddenEditorApi.js +1 -0
  47. package/dist/controller/hiddenEditorManager.d.ts +10 -3
  48. package/dist/controller/hiddenEditorManager.js +94 -38
  49. package/dist/controller/layoutPipeline.d.ts +2 -0
  50. package/dist/controller/layoutPipeline.js +55 -18
  51. package/dist/controller/layoutSession.d.ts +1 -0
  52. package/dist/controller/noteEditorManager.d.ts +2 -2
  53. package/dist/controller/noteEditorManager.js +5 -5
  54. package/dist/display-list/build/pageFurniture.js +41 -19
  55. package/dist/display-list/build/tablePrimitives.d.ts +3 -1
  56. package/dist/display-list/build/tablePrimitives.js +49 -14
  57. package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
  58. package/dist/document-operations.d.ts +8 -0
  59. package/dist/document-operations.js +4 -3
  60. package/dist/docx/blockContentParser.d.ts +7 -3
  61. package/dist/docx/blockContentParser.js +2 -3
  62. package/dist/docx/blockPlainText.js +2 -0
  63. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  64. package/dist/docx/bookmarkRangeJoin.js +43 -0
  65. package/dist/docx/canonicalSave.js +5 -1
  66. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  67. package/dist/docx/canonicalSessionInput.js +7 -2
  68. package/dist/docx/chartPreview.d.ts +4 -1
  69. package/dist/docx/chartPreview.js +26 -15
  70. package/dist/docx/commentAnchorIndex.d.ts +21 -5
  71. package/dist/docx/commentAnchorIndex.js +39 -11
  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/encryption/compoundFile.js +9 -1
  80. package/dist/docx/encryption/encryptionInfo.js +16 -2
  81. package/dist/docx/ensureParaIds.js +46 -7
  82. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  83. package/dist/docx/ensureUniqueControlIds.js +110 -0
  84. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  85. package/dist/docx/headerFooterVerbatim.js +13 -2
  86. package/dist/docx/hostCommentThreads.d.ts +17 -0
  87. package/dist/docx/hostCommentThreads.js +49 -0
  88. package/dist/docx/hyperlinkParser.js +9 -2
  89. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  90. package/dist/docx/inlineWrapperContent.js +9 -2
  91. package/dist/docx/listMarkerComputation.d.ts +35 -1
  92. package/dist/docx/listMarkerComputation.js +39 -1
  93. package/dist/docx/listModelNormalization.d.ts +44 -1
  94. package/dist/docx/listModelNormalization.js +227 -96
  95. package/dist/docx/mainDocumentPart.d.ts +6 -0
  96. package/dist/docx/mainDocumentPart.js +65 -0
  97. package/dist/docx/markupRangeMarker.d.ts +14 -0
  98. package/dist/docx/markupRangeMarker.js +15 -1
  99. package/dist/docx/metadataPrivacy.js +43 -22
  100. package/dist/docx/normalizeBaseDirection.js +3 -1
  101. package/dist/docx/packageParts.d.ts +1 -1
  102. package/dist/docx/packageParts.js +10 -4
  103. package/dist/docx/paragraphParser.js +159 -48
  104. package/dist/docx/paragraphPropertySource.d.ts +7 -0
  105. package/dist/docx/paragraphPropertySource.js +22 -1
  106. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  107. package/dist/docx/paragraphTraversal.js +2 -0
  108. package/dist/docx/parseWarningMessage.js +2 -1
  109. package/dist/docx/parser.js +6 -0
  110. package/dist/docx/previewBudget.d.ts +6 -0
  111. package/dist/docx/previewBudget.js +7 -1
  112. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  113. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  114. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  115. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  116. package/dist/docx/reviewResolutionProvenance.js +110 -25
  117. package/dist/docx/rezip.d.ts +6 -0
  118. package/dist/docx/rezip.js +42 -25
  119. package/dist/docx/selectiveSave.js +6 -10
  120. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  121. package/dist/docx/selectiveXmlPatch.js +11 -7
  122. package/dist/docx/serializer/documentSerializer.js +3 -1
  123. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  124. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  125. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  126. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  127. package/dist/docx/serializer/noteSerializer.js +23 -16
  128. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  129. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  130. package/dist/docx/serializer/runSerializer.js +2 -2
  131. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  132. package/dist/docx/serializer/tableSerializer.js +4 -2
  133. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  134. package/dist/docx/server/createBilingualDocument.js +27 -5
  135. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  136. package/dist/docx/sessionListPruning.d.ts +2 -0
  137. package/dist/docx/sessionListPruning.js +50 -0
  138. package/dist/docx/shapeAlternateContent.js +19 -0
  139. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  140. package/dist/docx/splitRevisionPieces.js +14 -0
  141. package/dist/docx/storyBlockReplay.js +4 -0
  142. package/dist/docx/structuralXmlPatch.js +19 -7
  143. package/dist/docx/tableParser.d.ts +6 -2
  144. package/dist/docx/tableParser.js +2 -3
  145. package/dist/docx/textBoxContentParser.d.ts +11 -0
  146. package/dist/docx/textBoxContentParser.js +51 -0
  147. package/dist/docx/textBoxParser.d.ts +0 -5
  148. package/dist/docx/textBoxParser.js +1 -23
  149. package/dist/docx/unzip.js +2 -0
  150. package/dist/docx/verticalMergeProjection.js +1 -1
  151. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  152. package/dist/fonts/fontsourceFaces.js +1 -7
  153. package/dist/i18n/messages/ar.gen.js +3 -0
  154. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  155. package/dist/i18n/messages/catalogs.gen.js +51 -0
  156. package/dist/i18n/messages/cs.gen.js +3 -0
  157. package/dist/i18n/messages/de.gen.js +3 -0
  158. package/dist/i18n/messages/en.gen.js +3 -0
  159. package/dist/i18n/messages/es.gen.js +3 -0
  160. package/dist/i18n/messages/et.gen.js +3 -0
  161. package/dist/i18n/messages/fr.gen.js +3 -0
  162. package/dist/i18n/messages/he.gen.js +3 -0
  163. package/dist/i18n/messages/hi.gen.js +3 -0
  164. package/dist/i18n/messages/hu.gen.js +3 -0
  165. package/dist/i18n/messages/lt.gen.js +3 -0
  166. package/dist/i18n/messages/lv.gen.js +3 -0
  167. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  168. package/dist/i18n/messages/pl.gen.js +3 -0
  169. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  170. package/dist/i18n/messages/sk.gen.js +3 -0
  171. package/dist/i18n/messages/tr.gen.js +3 -0
  172. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  173. package/dist/internal/acceptedBlockProjection.js +2 -0
  174. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  175. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  176. package/dist/internal/revisionResolutionInline.js +1 -2
  177. package/dist/internal/wholeStoryRevisionResolution.js +57 -12
  178. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
  179. package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
  180. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
  181. package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
  182. package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
  183. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  184. package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
  185. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  186. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  187. package/dist/layout-bridge/convert/tableConversion.js +25 -10
  188. package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
  189. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  190. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  191. package/dist/layout-bridge/engine/clickToPosition.js +5 -1
  192. package/dist/layout-bridge/engine/hitTest.js +9 -10
  193. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  194. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  195. package/dist/layout-engine/footnoteContinuation.js +210 -0
  196. package/dist/layout-engine/index.d.ts +2 -2
  197. package/dist/layout-engine/index.js +7 -2
  198. package/dist/layout-engine/measure/cache.js +10 -5
  199. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  200. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  201. package/dist/layout-engine/measure/tableCellFloating.js +1 -0
  202. package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
  203. package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
  204. package/dist/layout-engine/tableLayout.js +34 -7
  205. package/dist/layout-engine/tableRowBreak.d.ts +46 -0
  206. package/dist/layout-engine/tableRowBreak.js +193 -36
  207. package/dist/layout-engine/types.d.ts +43 -3
  208. package/dist/layout-painter/previewSvg.d.ts +8 -0
  209. package/dist/layout-painter/previewSvg.js +47 -0
  210. package/dist/layout-painter/renderImage.js +2 -1
  211. package/dist/layout-painter/renderPage.d.ts +5 -4
  212. package/dist/layout-painter/renderPage.js +52 -20
  213. package/dist/layout-painter/renderParagraph.js +3 -2
  214. package/dist/layout-painter/renderTable.d.ts +5 -2
  215. package/dist/layout-painter/renderTable.js +39 -22
  216. package/dist/managers/AutoSaveManager.d.ts +5 -1
  217. package/dist/managers/FindReplaceManager.js +3 -10
  218. package/dist/markdown/escape.d.ts +20 -1
  219. package/dist/markdown/escape.js +43 -1
  220. package/dist/markdown/renderBlock.js +4 -1
  221. package/dist/markdown/renderParagraph.js +13 -27
  222. package/dist/markdown/renderTable.js +6 -2
  223. package/dist/markdown/trailers.js +1 -0
  224. package/dist/pdf/images.d.ts +17 -1
  225. package/dist/pdf/images.js +22 -4
  226. package/dist/pdf/writePdf.js +4 -2
  227. package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
  228. package/dist/prosemirror/attrs/index.js +1 -0
  229. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  230. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  231. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  232. package/dist/prosemirror/commands/comments.d.ts +25 -0
  233. package/dist/prosemirror/commands/comments.js +122 -18
  234. package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
  235. package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
  236. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  237. package/dist/prosemirror/commands/index.d.ts +1 -1
  238. package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
  239. package/dist/prosemirror/commands/pastePlainText.js +13 -3
  240. package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
  241. package/dist/prosemirror/commentIdAllocator.js +2 -2
  242. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  243. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  244. package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
  245. package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
  246. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  247. package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
  248. package/dist/prosemirror/conversion/index.d.ts +1 -1
  249. package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
  250. package/dist/prosemirror/conversion/toProseDoc.js +325 -55
  251. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  252. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  253. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
  254. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
  255. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  256. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
  257. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  258. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
  259. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  260. package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
  261. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  262. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
  263. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  264. package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
  265. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
  266. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  267. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
  268. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  269. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  270. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
  271. package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
  272. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
  273. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  274. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
  275. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
  276. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
  277. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
  278. package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
  279. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  280. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
  281. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
  282. package/dist/prosemirror/index.d.ts +2 -2
  283. package/dist/prosemirror/listLabels.js +3 -2
  284. package/dist/prosemirror/listNumbering.d.ts +6 -0
  285. package/dist/prosemirror/listNumbering.js +12 -9
  286. package/dist/prosemirror/lockedControls.d.ts +13 -0
  287. package/dist/prosemirror/lockedControls.js +106 -0
  288. package/dist/prosemirror/markupViewProjection.js +1 -1
  289. package/dist/prosemirror/noteReferenceReview.js +2 -2
  290. package/dist/prosemirror/plugins/documentNumbering.js +4 -1
  291. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
  292. package/dist/prosemirror/plugins/suggestionMode.js +195 -30
  293. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  294. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  295. package/dist/prosemirror/replacedAnnotations.js +1 -0
  296. package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
  297. package/dist/prosemirror/rowGridOmissions.js +21 -0
  298. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  299. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  300. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  301. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  302. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  303. package/dist/prosemirror/runStyleFormatting.js +16 -13
  304. package/dist/prosemirror/schema/marks.d.ts +6 -0
  305. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  306. package/dist/prosemirror/tableGridMutation.d.ts +19 -2
  307. package/dist/prosemirror/tableGridMutation.js +118 -15
  308. package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
  309. package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
  310. package/dist/prosemirror/validation.js +2 -1
  311. package/dist/redline.js +23 -9
  312. package/dist/server.d.ts +2 -2
  313. package/dist/style-sets/extract.js +2 -2
  314. package/dist/types/canonicalCapabilities.d.ts +29 -8
  315. package/dist/types/canonicalCapabilities.js +13 -9
  316. package/dist/utils/cssString.d.ts +7 -0
  317. package/dist/utils/cssString.js +9 -0
  318. package/dist/utils/fontResolver.js +4 -1
  319. package/dist/utils/replaceText.d.ts +11 -0
  320. package/dist/utils/replaceText.js +39 -7
  321. package/dist/version-comparison.d.ts +9 -1
  322. package/dist/version-comparison.js +11 -5
  323. package/package.json +2 -2
@@ -26,26 +26,32 @@ const stripParagraphMarkOnlyFormatting = (formatting) => {
26
26
  const { allCaps: _allCaps, highlight: _highlight, shading: _shading, smallCaps: _smallCaps, vertAlign: _vertAlign, preserved: _preserved, ...formattingForBody } = formatting;
27
27
  return Object.keys(formattingForBody).length > 0 ? formattingForBody : void 0;
28
28
  };
29
+ /**
30
+ * Whether a paragraph's mark lends its run properties to the paragraph's
31
+ * runs: only when the paragraph has no style. One rule for reading a run and
32
+ * for the save's view of what a run inherited.
33
+ */
34
+ const paragraphMarkLendsRuns = (styleId) => styleId === void 0;
29
35
  const stripParagraphMarkFormattingForBodyRuns = (formatting) => {
30
36
  const paragraphMarkFormatting = stripParagraphMarkOnlyFormatting(formatting);
31
37
  if (!paragraphMarkFormatting) return;
32
38
  const { fontFamily: _fontFamily, ...bodyRunFormatting } = paragraphMarkFormatting;
33
39
  return Object.keys(bodyRunFormatting).length > 0 ? bodyRunFormatting : void 0;
34
40
  };
35
- const suppressParagraphMarkFormatting = ({ baseFormatting, directFormatting, paragraphMarkFormatting, paragraphMarkPrecedesStyle = false }) => {
41
+ const suppressParagraphMarkFormatting = ({ baseFormatting, directFormatting, paragraphMarkFormatting }) => {
36
42
  if (!paragraphMarkFormatting) return baseFormatting;
37
- const result = (paragraphMarkPrecedesStyle ? mergeTextFormatting(paragraphMarkFormatting, baseFormatting) : mergeTextFormatting(baseFormatting, paragraphMarkFormatting)) ?? {};
43
+ const result = mergeTextFormatting(baseFormatting, paragraphMarkFormatting) ?? {};
38
44
  for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0) Reflect.set(result, property, baseFormatting?.[property] ?? false);
39
45
  for (const property of ["fontSize", "fontSizeCs"]) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && baseFormatting?.[property] !== void 0) result[property] = baseFormatting[property];
40
46
  if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0) result.underline = { style: "none" };
41
47
  if (paragraphMarkFormatting.spacing !== void 0 && directFormatting?.spacing === void 0) result.spacing = 0;
42
48
  return Object.keys(result).length > 0 ? result : void 0;
43
49
  };
44
- const getParagraphMarkSuppressionOverrides = ({ directFormatting, paragraphMarkFormatting, suppressedFormatting }) => {
50
+ const getParagraphMarkSuppressionOverrides = ({ directFormatting, paragraphMarkFormatting, suppressedFormatting, characterStyleFormatting }) => {
45
51
  if (!paragraphMarkFormatting) return;
46
52
  const overrides = {};
47
- for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && suppressedFormatting?.[property] === false) Reflect.set(overrides, property, false);
48
- if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0 && suppressedFormatting?.underline?.style === "none") overrides.underline = { style: "none" };
53
+ for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && characterStyleFormatting?.[property] === void 0 && suppressedFormatting?.[property] === false) Reflect.set(overrides, property, false);
54
+ if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0 && characterStyleFormatting?.underline === void 0 && suppressedFormatting?.underline?.style === "none") overrides.underline = { style: "none" };
49
55
  return Object.keys(overrides).length > 0 ? overrides : void 0;
50
56
  };
51
57
  const withoutFontFamily = (formatting) => {
@@ -137,7 +143,7 @@ const resolveParagraphInheritedRunFormatting = (options) => {
137
143
  };
138
144
  const paragraphRunStyleContext = (paragraph, styleResolver) => {
139
145
  const attrs = expectParagraphAttrs(paragraph);
140
- const paragraphMarkFormatting = attrs._originalFormatting?.runProperties;
146
+ const paragraphMarkFormatting = paragraphMarkLendsRuns(attrs.styleId) ? attrs._originalFormatting?.runProperties : void 0;
141
147
  const characterStyleFormatting = paragraphMarkFormatting?.styleId ? styleResolver?.getRunStyleOwnProperties(paragraphMarkFormatting.styleId) : void 0;
142
148
  const resolvedParagraphMarkFormatting = cascadeStyleTextFormatting([{
143
149
  formatting: characterStyleFormatting,
@@ -154,8 +160,7 @@ const paragraphRunStyleContext = (paragraph, styleResolver) => {
154
160
  styleResolver
155
161
  }).defaultFormatting,
156
162
  paragraphFormatting: attrs.defaultTextFormatting ?? void 0,
157
- paragraphMarkFormatting: inheritableParagraphMarkFormatting,
158
- paragraphMarkPrecedesStyle: attrs.styleId !== void 0
163
+ paragraphMarkFormatting: inheritableParagraphMarkFormatting
159
164
  };
160
165
  };
161
166
  const paragraphFormattingForRun = ({ context, directFormatting, marks }) => {
@@ -163,8 +168,7 @@ const paragraphFormattingForRun = ({ context, directFormatting, marks }) => {
163
168
  return suppressParagraphMarkFormatting({
164
169
  baseFormatting: context.baseParagraphFormatting,
165
170
  directFormatting,
166
- paragraphMarkFormatting: context.paragraphMarkFormatting,
167
- paragraphMarkPrecedesStyle: context.paragraphMarkPrecedesStyle
171
+ paragraphMarkFormatting: context.paragraphMarkFormatting
168
172
  });
169
173
  };
170
174
  const paragraphRunStyleContextAt = ({ doc, pos, styleResolver }) => {
@@ -183,8 +187,7 @@ const paragraphRunStyleContextAt = ({ doc, pos, styleResolver }) => {
183
187
  const nearestParagraphRunStyleContext = (paragraph, styleResolver) => paragraph ? paragraphRunStyleContext(paragraph, styleResolver) : {
184
188
  baseParagraphFormatting: void 0,
185
189
  paragraphFormatting: void 0,
186
- paragraphMarkFormatting: void 0,
187
- paragraphMarkPrecedesStyle: false
190
+ paragraphMarkFormatting: void 0
188
191
  };
189
192
  /** Resolve the non-direct run cascade from shared document styles and the current paragraph. */
190
193
  const resolveEffectiveRunStyleFormatting = ({ marks, paragraphFormatting, styleResolver }) => {
@@ -202,4 +205,4 @@ const resolveEffectiveRunStyleFormatting = ({ marks, paragraphFormatting, styleR
202
205
  styleFormatting
203
206
  });
204
207
  };
205
- export { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, isParagraphMarkSuppressionEligible, nearestParagraphRunStyleContext, paragraphFormattingForRun, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting, resolveParagraphBodyRunFormatting, resolveParagraphInheritedRunFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting };
208
+ export { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, isParagraphMarkSuppressionEligible, nearestParagraphRunStyleContext, paragraphFormattingForRun, paragraphMarkLendsRuns, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting, resolveParagraphBodyRunFormatting, resolveParagraphInheritedRunFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting };
@@ -86,6 +86,12 @@ export type FootnoteRefAttrs = {
86
86
  };
87
87
  export type CommentAttrs = {
88
88
  commentId: number;
89
+ /**
90
+ * The comment was authored at a point (a bare `w:commentReference`): this
91
+ * mark only shows it on the text before the reference. The comment lives
92
+ * as long as its reference does, and saves as a point again.
93
+ */
94
+ point?: boolean;
89
95
  };
90
96
  /**
91
97
  * Provenance of a tracked change.
@@ -5,7 +5,7 @@ import { paragraphNumberingAttr } from "../numberingAttr.js";
5
5
  import { directionFromBidi } from "../paragraphDirection.js";
6
6
  import { styleResolvedParagraphFormatting } from "../paragraphFormattingProvenance.js";
7
7
  import { lineSpacingProvenanceFromSpacing } from "../paragraphSpacing.js";
8
- import { stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting } from "../runStyleFormatting.js";
8
+ import { paragraphMarkLendsRuns, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting } from "../runStyleFormatting.js";
9
9
  import { cascadeStyleTextFormatting } from "./styleToggleCascade.js";
10
10
  // src/prosemirror/styles/paragraphStyleCascade.ts
11
11
  /**
@@ -36,7 +36,7 @@ function resolveRunFormattingWithoutDefaults(formatting, styleResolver) {
36
36
  * document read and for a paragraph whose properties a review restores.
37
37
  */
38
38
  const inheritableParagraphMarkFormatting = ({ runProperties, styleId, styleResolver }) => {
39
- if (styleId !== void 0) return void 0;
39
+ if (!paragraphMarkLendsRuns(styleId)) return void 0;
40
40
  const formatting = resolveRunFormattingWithoutDefaults(runProperties, styleResolver);
41
41
  return formatting ? stripParagraphMarkFormattingForBodyRuns(formatting) : void 0;
42
42
  };
@@ -18,6 +18,20 @@ type RemoveTableRowOptions = {
18
18
  * and the table is left one row shorter than that merge.
19
19
  */
20
20
  export declare const removeTableRow: (tr: Transaction, { map, table, tableStart }: RemoveTableRowOptions, row: number) => void;
21
+ /** A placeholder for an absent grid position is not a cell a row can keep. */
22
+ export declare const rowHoldsNoCells: (row: Node, besides?: Node) => boolean;
23
+ /**
24
+ * The placeholder a new column's place in a row falls to, if any. Nothing can
25
+ * stand after what a row omits at its end or before what it omits at its start:
26
+ * a cell there would move on save, so the omission grows instead.
27
+ */
28
+ export declare const omittedSlotTakingColumn: (map: TableMap, table: Node, row: number, column: number) => number | null;
29
+ /**
30
+ * Size what rows omit to the width their cells now reach. A column whose cells
31
+ * went takes the same column out of a row that omits it; removing a tracked
32
+ * column's last cell does not otherwise reach such a row.
33
+ */
34
+ export declare const reconcileOmittedGridSlots: (tr: Transaction, tablePosition: number, previousTable: Node, removedColumn: number) => void;
21
35
  /** Whether a batch of structural deletions may have emptied rows. */
22
36
  export type RowsEmptiedInBatch = {
23
37
  pending: boolean;
@@ -46,8 +60,11 @@ type RemoveRowsWithoutCellsInRangeOptions = {
46
60
  };
47
61
  /** Close marked rows before their owning cell is captured into a continuation payload. */
48
62
  export declare const removeRowsWithoutCellsInRange: ({ tr, from, to }: RemoveRowsWithoutCellsInRangeOptions) => void;
49
- /** Close all cell-less rows after an immediate structural edit. */
50
- export declare const removeRowsWithoutCells: (tr: Transaction, tablePosition: number) => void;
63
+ /**
64
+ * Close the rows an immediate structural edit left without cells. A row written
65
+ * with none is no row this edit emptied, and it stays.
66
+ */
67
+ export declare const removeRowsWithoutCells: (tr: Transaction, tablePosition: number, previousTable: Node) => void;
51
68
  type ReconcileTableGridAfterColumnRemovalOptions = {
52
69
  tr: Transaction;
53
70
  tablePosition: number;
@@ -44,6 +44,86 @@ const removeTableRow = (tr, { map, table, tableStart }, row) => {
44
44
  column += colspan;
45
45
  }
46
46
  };
47
+ /** A placeholder for an absent grid position is not a cell a row can keep. */
48
+ const rowHoldsNoCells = (row, besides) => {
49
+ let holdsCell = false;
50
+ row.forEach((cell) => {
51
+ holdsCell ||= cell !== besides && cell.attrs["_omittedGridSlot"] == null;
52
+ });
53
+ return !holdsCell;
54
+ };
55
+ const omittedSlotOf = (cell) => cell?.attrs["_omittedGridSlot"];
56
+ /**
57
+ * The placeholder a new column's place in a row falls to, if any. Nothing can
58
+ * stand after what a row omits at its end or before what it omits at its start:
59
+ * a cell there would move on save, so the omission grows instead.
60
+ */
61
+ const omittedSlotTakingColumn = (map, table, row, column) => {
62
+ const left = column > 0 ? map.map[row * map.width + column - 1] : void 0;
63
+ if (left !== void 0 && omittedSlotOf(table.nodeAt(left)) === "after") return left;
64
+ const right = column < map.width ? map.map[row * map.width + column] : void 0;
65
+ return right !== void 0 && omittedSlotOf(table.nodeAt(right)) === "before" ? right : null;
66
+ };
67
+ /**
68
+ * Size what rows omit to the width their cells now reach. A column whose cells
69
+ * went takes the same column out of a row that omits it; removing a tracked
70
+ * column's last cell does not otherwise reach such a row.
71
+ */
72
+ const reconcileOmittedGridSlots = (tr, tablePosition, previousTable, removedColumn) => {
73
+ const table = tr.doc.nodeAt(tablePosition);
74
+ if (!table || table.type.spec["tableRole"] !== "table") return;
75
+ const reached = Array.from({ length: table.childCount }, () => 0);
76
+ let omits = false;
77
+ table.forEach((row, _offset, rowIndex) => {
78
+ row.forEach((cell) => {
79
+ if (omittedSlotOf(cell)) {
80
+ omits = true;
81
+ return;
82
+ }
83
+ const colspan = Number(cell.attrs["colspan"]) || 1;
84
+ const rowspan = Number(cell.attrs["rowspan"]) || 1;
85
+ for (let at = rowIndex; at < rowIndex + rowspan; at++) if (at < reached.length) reached[at] = (reached[at] ?? 0) + colspan;
86
+ });
87
+ });
88
+ if (!omits) return;
89
+ const width = Math.max(...reached);
90
+ const previousMap = TableMap.get(previousTable);
91
+ const rowPositions = [];
92
+ table.forEach((_row, offset) => rowPositions.push(tablePosition + 1 + offset));
93
+ for (let rowIndex = table.childCount - 1; rowIndex >= 0; rowIndex--) {
94
+ const row = table.child(rowIndex);
95
+ let excess = -(width - (reached[rowIndex] ?? 0));
96
+ row.forEach((cell) => {
97
+ if (omittedSlotOf(cell)) excess += Number(cell.attrs["colspan"]) || 1;
98
+ });
99
+ if (excess <= 0) continue;
100
+ const atPlace = previousMap.map[rowIndex * previousMap.width + removedColumn];
101
+ const placeKind = atPlace === void 0 ? void 0 : omittedSlotOf(previousTable.nodeAt(atPlace));
102
+ const slots = [];
103
+ row.forEach((cell, offset) => {
104
+ if (omittedSlotOf(cell)) slots.push({
105
+ node: cell,
106
+ position: (rowPositions[rowIndex] ?? 0) + 1 + offset
107
+ });
108
+ });
109
+ const order = slots.toSorted((left, right) => Number(omittedSlotOf(right.node) === placeKind) - Number(omittedSlotOf(left.node) === placeKind) || right.position - left.position);
110
+ const changes = /* @__PURE__ */ new Map();
111
+ for (const { node, position } of order) {
112
+ if (excess <= 0) break;
113
+ const colspan = Number(node.attrs["colspan"]) || 1;
114
+ const taken = Math.min(colspan, excess);
115
+ changes.set(position, colspan - taken);
116
+ excess -= taken;
117
+ }
118
+ for (const { node, position } of slots.toReversed()) {
119
+ const next = changes.get(position);
120
+ if (next === void 0) continue;
121
+ if (next === 0) tr.delete(position, position + node.nodeSize);
122
+ else tr.setNodeAttribute(position, "colspan", next);
123
+ }
124
+ }
125
+ removeRowsWithoutCells(tr, tablePosition, previousTable);
126
+ };
47
127
  const ROW_CLEANUP_PENDING = "pending";
48
128
  /** A transient row attribute follows node moves; conversion never serializes it. */
49
129
  const markRowEmptiedInBatch = ({ tr, rowPosition, emptied }) => {
@@ -57,7 +137,7 @@ const markRowsEmptiedInBatch = ({ tr, tablePosition, previousTable, emptied }) =
57
137
  const table = tr.doc.nodeAt(tablePosition);
58
138
  if (!table || table.type.spec["tableRole"] !== "table") return;
59
139
  table.forEach((row, offset, index) => {
60
- if (row.childCount === 0 && previousTable.child(index).childCount > 0) markRowEmptiedInBatch({
140
+ if (rowHoldsNoCells(row) && !rowHoldsNoCells(previousTable.child(index))) markRowEmptiedInBatch({
61
141
  tr,
62
142
  rowPosition: tablePosition + 1 + offset,
63
143
  emptied
@@ -70,7 +150,7 @@ const removeEmptyRows = ({ tr, tablePosition, shouldRemove }) => {
70
150
  if (!table || table.type.spec["tableRole"] !== "table" || table.childCount < 2) return;
71
151
  let emptyRow = -1;
72
152
  table.forEach((row, _offset, index) => {
73
- if (emptyRow === -1 && row.childCount === 0 && shouldRemove(row)) emptyRow = index;
153
+ if (emptyRow === -1 && rowHoldsNoCells(row) && shouldRemove(row)) emptyRow = index;
74
154
  });
75
155
  if (emptyRow === -1) return;
76
156
  removeTableRow(tr, {
@@ -110,13 +190,27 @@ const removeRowsWithoutCellsInRange = ({ tr, from, to }) => {
110
190
  });
111
191
  for (const position of tables.toReversed()) removeBatchRows(tr, position);
112
192
  };
113
- /** Close all cell-less rows after an immediate structural edit. */
114
- const removeRowsWithoutCells = (tr, tablePosition) => {
115
- removeEmptyRows({
116
- tr,
117
- tablePosition,
118
- shouldRemove: () => true
193
+ /**
194
+ * Close the rows an immediate structural edit left without cells. A row written
195
+ * with none is no row this edit emptied, and it stays.
196
+ */
197
+ const removeRowsWithoutCells = (tr, tablePosition, previousTable) => {
198
+ const table = tr.doc.nodeAt(tablePosition);
199
+ if (!table || table.type.spec["tableRole"] !== "table") return;
200
+ const emptied = [];
201
+ table.forEach((row, _offset, index) => {
202
+ const before = previousTable.maybeChild(index);
203
+ if (rowHoldsNoCells(row) && before && !rowHoldsNoCells(before)) emptied.push(index);
119
204
  });
205
+ for (const rowIndex of emptied.toReversed()) {
206
+ const current = tr.doc.nodeAt(tablePosition);
207
+ if (!current || current.childCount < 2) return;
208
+ removeTableRow(tr, {
209
+ map: TableMap.get(current),
210
+ table: current,
211
+ tableStart: tablePosition + 1
212
+ }, rowIndex);
213
+ }
120
214
  };
121
215
  /**
122
216
  * Keep the editable table grid aligned with a physical column removal.
@@ -134,7 +228,7 @@ const reconcileTableGridAfterColumnRemoval = ({ tr, tablePosition, previousTable
134
228
  if (columnCount >= previousColumnCount) return;
135
229
  const removedColumnCount = previousColumnCount - columnCount;
136
230
  const previousWidths = expectTableAttrs(previousTable).columnWidths;
137
- const columnWidths = previousWidths?.length === previousColumnCount ? previousWidths.toSpliced(removedColumn, removedColumnCount) : void 0;
231
+ const columnWidths = previousWidths !== void 0 && previousWidths.length >= previousColumnCount ? previousWidths.toSpliced(removedColumn, removedColumnCount) : void 0;
138
232
  setTableGrid({
139
233
  tr,
140
234
  tablePosition,
@@ -159,7 +253,7 @@ const reconcileTableGridAfterColumnInsertion = ({ tr, tablePosition, previousTab
159
253
  const insertedColumnCount = columnCount - previousColumnCount;
160
254
  const previousWidths = expectTableAttrs(previousTable).columnWidths;
161
255
  const neighbourWidth = insertedColumnWidth(previousTable, insertedColumn);
162
- const columnWidths = previousWidths?.length === previousColumnCount && neighbourWidth !== void 0 ? previousWidths.toSpliced(insertedColumn, 0, ...Array.from({ length: insertedColumnCount }, () => neighbourWidth)) : void 0;
256
+ const columnWidths = previousWidths !== void 0 && previousWidths.length >= previousColumnCount && neighbourWidth !== void 0 ? previousWidths.toSpliced(insertedColumn, 0, ...Array.from({ length: insertedColumnCount }, () => neighbourWidth)) : void 0;
163
257
  setTableGrid({
164
258
  tr,
165
259
  tablePosition,
@@ -172,7 +266,7 @@ const reconcileTableGridAfterColumnInsertion = ({ tr, tablePosition, previousTab
172
266
  const insertedColumnWidth = (table, insertedColumn) => {
173
267
  const columnCount = TableMap.get(table).width;
174
268
  const widths = expectTableAttrs(table).columnWidths;
175
- if (widths?.length !== columnCount) return;
269
+ if (widths === void 0 || widths.length < columnCount) return;
176
270
  return widths[Math.max(0, Math.min(insertedColumn, columnCount) - 1)] ?? widths[0];
177
271
  };
178
272
  /**
@@ -196,7 +290,7 @@ const setTableGrid = ({ tr, tablePosition, table, columnWidths, columnCount }) =
196
290
  const originalFormatting = formatting ? { ...formatting } : void 0;
197
291
  if (originalFormatting) delete originalFormatting.gridSourceXml;
198
292
  tr.setNodeMarkup(tablePosition, void 0, mergeTableAttrs(table, {
199
- columnWidths: columnWidths?.length === columnCount ? columnWidths : void 0,
293
+ columnWidths: columnWidths !== void 0 && columnWidths.length >= columnCount ? columnWidths : void 0,
200
294
  _originalFormatting: originalFormatting
201
295
  }));
202
296
  };
@@ -216,6 +310,12 @@ const insertTableColumn = ({ tr, tablePosition, column, templateColumn, createCe
216
310
  for (let row = 0; row < map.height; row++) {
217
311
  const index = row * map.width + column;
218
312
  const position = map.map[index];
313
+ const omitted = omittedSlotTakingColumn(map, table, row, column);
314
+ if (omitted !== null) {
315
+ const slot = table.nodeAt(omitted);
316
+ tr.setNodeAttribute(tr.mapping.slice(mapFrom).map(tableStart + omitted), "colspan", (Number(slot?.attrs["colspan"]) || 1) + 1);
317
+ continue;
318
+ }
219
319
  const straddling = column > 0 && column < map.width && position !== void 0 && map.map[index - 1] === position ? table.nodeAt(position) : null;
220
320
  if (straddling && position !== void 0) {
221
321
  const offset = column - map.colCount(position);
@@ -231,7 +331,8 @@ const insertTableColumn = ({ tr, tablePosition, column, templateColumn, createCe
231
331
  continue;
232
332
  }
233
333
  const templatePosition = map.map[row * map.width + templateColumn];
234
- const template = templatePosition === void 0 ? null : table.nodeAt(templatePosition);
334
+ const templateCell = templatePosition === void 0 ? null : table.nodeAt(templatePosition);
335
+ const template = omittedSlotOf(templateCell) ? null : templateCell;
235
336
  tr.insert(tr.mapping.slice(mapFrom).map(tableStart + map.positionAt(row, column, table)), createCell(template));
236
337
  }
237
338
  reconcileTableGridAfterColumnInsertion({
@@ -247,6 +348,8 @@ const insertTableColumn = ({ tr, tablePosition, column, templateColumn, createCe
247
348
  * and a row left without a cell of its own goes too.
248
349
  */
249
350
  const removeTableColumns = (tr, tablePosition, left, right) => {
351
+ const previousTable = tr.doc.nodeAt(tablePosition);
352
+ if (!previousTable) return;
250
353
  for (let column = right - 1; column >= left; column--) {
251
354
  const table = tr.doc.nodeAt(tablePosition);
252
355
  if (!table || table.type.spec["tableRole"] !== "table") return;
@@ -277,6 +380,6 @@ const removeTableColumns = (tr, tablePosition, left, right) => {
277
380
  removedColumn: column
278
381
  });
279
382
  }
280
- removeRowsWithoutCells(tr, tablePosition);
383
+ removeRowsWithoutCells(tr, tablePosition, previousTable);
281
384
  };
282
- export { insertTableColumn, markRowEmptiedInBatch, markRowsEmptiedInBatch, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeRowsWithoutCellsAfterBatch, removeRowsWithoutCellsInRange, removeTableColumns, removeTableRow };
385
+ export { insertTableColumn, markRowEmptiedInBatch, markRowsEmptiedInBatch, omittedSlotTakingColumn, reconcileOmittedGridSlots, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeRowsWithoutCellsAfterBatch, removeRowsWithoutCellsInRange, removeTableColumns, removeTableRow, rowHoldsNoCells };
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ export declare const tablePositionedBookmarksPlugin: () => Plugin;
@@ -0,0 +1,80 @@
1
+ import { Mapping } from "prosemirror-transform";
2
+ import { Plugin, PluginKey } from "prosemirror-state";
3
+ // src/prosemirror/tablePositionedBookmarks.ts
4
+ const positionedBookmarksOf = (node) => {
5
+ const role = node.type.spec["tableRole"];
6
+ if (role !== "table" && role !== "row") return null;
7
+ const bookmarks = node.attrs["_bookmarks"];
8
+ return Array.isArray(bookmarks) && bookmarks.length > 0 ? bookmarks : null;
9
+ };
10
+ /** Where a boundary between the source's children falls among the new ones. */
11
+ const childIndexAt = (node, nodePosition, at) => {
12
+ let index = 0;
13
+ let end = nodePosition + 1;
14
+ while (index < node.childCount) {
15
+ end += node.child(index).nodeSize;
16
+ if (end > at) break;
17
+ index += 1;
18
+ }
19
+ return index;
20
+ };
21
+ const followingIndex = ({ source, sourcePosition, node, position, index, mapping }) => {
22
+ if (!source || source.type !== node.type || index > source.childCount) return Math.min(index, node.childCount);
23
+ if (index === source.childCount) return node.childCount;
24
+ let boundary = sourcePosition + 1;
25
+ for (let child = 0; child < index; child += 1) boundary += source.child(child).nodeSize;
26
+ return childIndexAt(node, position, mapping.map(boundary, -1));
27
+ };
28
+ const repairChanged = ({ before, after, offset, mapping, back, sourceDoc, tr }) => {
29
+ after.forEach((child, childOffset, index) => {
30
+ if (child === before.maybeChild(index) || child.isTextblock) return;
31
+ const position = offset + childOffset;
32
+ const bookmarks = positionedBookmarksOf(child);
33
+ if (bookmarks) {
34
+ const sourcePosition = back.map(position, 1);
35
+ const source = sourceDoc.nodeAt(sourcePosition);
36
+ const repaired = bookmarks.map((bookmark) => ({
37
+ ...bookmark,
38
+ index: followingIndex({
39
+ source,
40
+ sourcePosition,
41
+ node: child,
42
+ position,
43
+ index: bookmark.index,
44
+ mapping
45
+ })
46
+ }));
47
+ if (repaired.some(({ index: at }, i) => at !== bookmarks[i]?.index)) tr.setNodeAttribute(position, "_bookmarks", repaired);
48
+ }
49
+ repairChanged({
50
+ before: before.maybeChild(index) ?? child.type.create(),
51
+ after: child,
52
+ offset: position + 1,
53
+ mapping,
54
+ back,
55
+ sourceDoc,
56
+ tr
57
+ });
58
+ });
59
+ };
60
+ const tablePositionedBookmarksPlugin = () => new Plugin({
61
+ key: new PluginKey("tablePositionedBookmarks"),
62
+ appendTransaction(transactions, oldState, newState) {
63
+ if (!transactions.some(({ docChanged }) => docChanged)) return null;
64
+ const mapping = new Mapping();
65
+ for (const { mapping: each } of transactions) mapping.appendMapping(each);
66
+ const tr = newState.tr;
67
+ repairChanged({
68
+ before: oldState.doc,
69
+ after: newState.doc,
70
+ offset: 0,
71
+ mapping,
72
+ back: mapping.invert(),
73
+ sourceDoc: oldState.doc,
74
+ tr
75
+ });
76
+ if (!tr.docChanged) return null;
77
+ return tr.setMeta("addToHistory", false);
78
+ }
79
+ });
80
+ export { tablePositionedBookmarksPlugin };
@@ -24,7 +24,7 @@ const COMPLEX_FIELD_RESULT_MARK_NAMES = /* @__PURE__ */ new Set([
24
24
  const hasUnsupportedComplexFieldResultContent = (node) => node.content.content.some((child) => {
25
25
  if (child.type.name === "bookmarkBoundary") return false;
26
26
  const preservedXmlAttrs = child.type.name === "preservedXml" ? readPreservedXmlAttrs(child) : void 0;
27
- return preservedXmlAttrs?.ok && preservedXmlAttrs.value.level === PRESERVED_XML_LEVELS.inline || !isRunContentInlineNodeName(child.type.name) || child.marks.some((mark) => !COMPLEX_FIELD_RESULT_MARK_NAMES.has(mark.type.name));
27
+ return preservedXmlAttrs?.ok && preservedXmlAttrs.value.level === PRESERVED_XML_LEVELS.inline || !isRunContentInlineNodeName(child.type.name) || child.marks.some((mark) => !COMPLEX_FIELD_RESULT_MARK_NAMES.has(mark.type.name) && !mark.isInSet(node.marks));
28
28
  });
29
29
  var ProseMirrorDocumentValidationError = class extends Error {
30
30
  issues;
@@ -212,6 +212,7 @@ const validateNodeAttrs = (node, path, issues) => {
212
212
  appendAttrIssues(path, readCommentReferenceAttrs(node), issues);
213
213
  return;
214
214
  case "commentRangeBoundary":
215
+ case "blockCommentRangeBoundary":
215
216
  appendAttrIssues(path, readCommentRangeBoundaryAttrs(node), issues);
216
217
  return;
217
218
  case "rangeAnchor":
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({
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,