@stll/folio-core 0.45.0 → 0.47.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 (451) hide show
  1. package/dist/ai-edits/apply.js +85 -43
  2. package/dist/ai-edits/headless.js +2 -2
  3. package/dist/ai-edits/read.d.ts +1 -0
  4. package/dist/ai-edits/read.js +1 -0
  5. package/dist/ai-edits/snapshot.js +32 -27
  6. package/dist/ai-edits/table-cell-mutations.js +15 -7
  7. package/dist/ai-edits/table-geometry.js +21 -18
  8. package/dist/ai-edits/table-template.js +2 -2
  9. package/dist/compare/compare.js +2 -5
  10. package/dist/compare/content-alignment.js +108 -12
  11. package/dist/compare/content-types.d.ts +8 -2
  12. package/dist/compare/content.js +2 -11
  13. package/dist/compare/plan.js +7 -4
  14. package/dist/compare/scenario.js +2 -5
  15. package/dist/compare/section-boundary-properties.js +1 -2
  16. package/dist/compare/types.d.ts +9 -1
  17. package/dist/compare/types.js +12 -1
  18. package/dist/compat/eigenpal.d.ts +2 -1
  19. package/dist/compat/eigenpal.js +2 -1
  20. package/dist/content-controls/checkboxDisplay.d.ts +17 -0
  21. package/dist/content-controls/checkboxDisplay.js +46 -0
  22. package/dist/content-controls/findContentControls.js +3 -1
  23. package/dist/content-controls/mutateContentControls.js +57 -43
  24. package/dist/controller/contentControlWidgetController.d.ts +1 -0
  25. package/dist/controller/contentControlWidgetController.js +3 -0
  26. package/dist/controller/hiddenEditorApi.js +3 -1
  27. package/dist/controller/hiddenEditorManager.d.ts +1 -1
  28. package/dist/controller/hiddenEditorManager.js +6 -3
  29. package/dist/controller/layoutPipeline.js +8 -3
  30. package/dist/display-list/build/buildDisplayList.js +20 -1
  31. package/dist/display-list/build/imagePrimitives.d.ts +4 -4
  32. package/dist/display-list/build/imagePrimitives.js +38 -18
  33. package/dist/display-list/build/pageBorderPrimitives.js +2 -1
  34. package/dist/display-list/build/paragraphPrimitives.js +113 -14
  35. package/dist/display-list/build/previewPrimitives.d.ts +10 -0
  36. package/dist/display-list/build/previewPrimitives.js +89 -0
  37. package/dist/display-list/build/strokes.d.ts +177 -8
  38. package/dist/display-list/build/strokes.js +167 -47
  39. package/dist/display-list/build/tablePrimitives.js +4 -2
  40. package/dist/display-list/build/textBoxPrimitives.js +6 -4
  41. package/dist/display-list/build/textDecorations.d.ts +15 -1
  42. package/dist/display-list/build/textDecorations.js +15 -1
  43. package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
  44. package/dist/display-list/primitives.d.ts +13 -2
  45. package/dist/display-list/primitives.js +36 -1
  46. package/dist/display-list/types.d.ts +17 -0
  47. package/dist/document-operations.js +2 -1
  48. package/dist/docx/attributeRemainder.d.ts +76 -0
  49. package/dist/docx/attributeRemainder.js +111 -0
  50. package/dist/docx/blockContentParser.d.ts +3 -1
  51. package/dist/docx/blockContentParser.js +102 -106
  52. package/dist/docx/blockPlainText.d.ts +3 -4
  53. package/dist/docx/blockPlainText.js +3 -0
  54. package/dist/docx/borderParser.js +26 -11
  55. package/dist/docx/builtInStyles.d.ts +8 -16
  56. package/dist/docx/builtInStyles.js +54 -17
  57. package/dist/docx/commentAnchorIndex.d.ts +30 -0
  58. package/dist/docx/commentAnchorIndex.js +50 -0
  59. package/dist/docx/commentParser.d.ts +1 -1
  60. package/dist/docx/commentParser.js +56 -39
  61. package/dist/docx/commentRangeIntegrity.d.ts +16 -1
  62. package/dist/docx/commentRangeIntegrity.js +42 -1
  63. package/dist/docx/commentRangeJoin.d.ts +9 -0
  64. package/dist/docx/commentRangeJoin.js +33 -0
  65. package/dist/docx/commentReferenceCompletion.d.ts +9 -0
  66. package/dist/docx/commentReferenceCompletion.js +47 -0
  67. package/dist/docx/commentReferenceNormalization.js +3 -1
  68. package/dist/docx/commentReplyMarkers.js +11 -19
  69. package/dist/docx/compatibility.js +56 -41
  70. package/dist/docx/containerChildren.d.ts +208 -0
  71. package/dist/docx/containerChildren.gen.d.ts +43 -0
  72. package/dist/docx/containerChildren.gen.js +263 -0
  73. package/dist/docx/containerChildren.js +153 -0
  74. package/dist/docx/diagramPreview.d.ts +14 -2
  75. package/dist/docx/diagramPreview.js +81 -169
  76. package/dist/docx/documentParser.d.ts +1 -1
  77. package/dist/docx/documentParser.js +7 -4
  78. package/dist/docx/drawingAnchor.d.ts +87 -0
  79. package/dist/docx/drawingAnchor.js +201 -0
  80. package/dist/docx/drawingUtils.d.ts +43 -38
  81. package/dist/docx/drawingUtils.js +205 -118
  82. package/dist/docx/ensureParaIds.js +17 -7
  83. package/dist/docx/fieldParser.d.ts +1 -1
  84. package/dist/docx/fieldParser.js +4 -4
  85. package/dist/docx/fieldState.d.ts +26 -0
  86. package/dist/docx/fieldState.js +53 -0
  87. package/dist/docx/fontTableParser.js +102 -41
  88. package/dist/docx/footnoteParser.d.ts +1 -1
  89. package/dist/docx/footnoteParser.js +10 -6
  90. package/dist/docx/graphicFrameLocks.d.ts +16 -4
  91. package/dist/docx/graphicFrameLocks.js +19 -6
  92. package/dist/docx/groupDrawingParser.js +4 -3
  93. package/dist/docx/headerFooterParser.js +1 -1
  94. package/dist/docx/headerFooterReferenceNormalization.js +1 -0
  95. package/dist/docx/hyperlinkParser.d.ts +66 -9
  96. package/dist/docx/hyperlinkParser.js +153 -26
  97. package/dist/docx/imageParser.js +160 -115
  98. package/dist/docx/index.d.ts +2 -1
  99. package/dist/docx/index.js +2 -1
  100. package/dist/docx/inlineContentRemovals.d.ts +28 -0
  101. package/dist/docx/inlineContentRemovals.js +46 -0
  102. package/dist/docx/inlineWrapperContent.d.ts +166 -0
  103. package/dist/docx/inlineWrapperContent.js +165 -0
  104. package/dist/docx/inlineWrapperParser.d.ts +11 -0
  105. package/dist/docx/inlineWrapperParser.js +60 -0
  106. package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
  107. package/dist/docx/normalizeBaseDirection.js +12 -1
  108. package/dist/docx/numberingParser.d.ts +25 -2
  109. package/dist/docx/numberingParser.js +264 -361
  110. package/dist/docx/numberingReference.d.ts +9 -16
  111. package/dist/docx/numberingReference.js +17 -16
  112. package/dist/docx/numberingReferenceNormalization.js +7 -7
  113. package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
  114. package/dist/docx/ooxmlCounterFormatter.js +4 -1
  115. package/dist/docx/paraIdAttribute.d.ts +111 -0
  116. package/dist/docx/paraIdAttribute.js +142 -0
  117. package/dist/docx/paragraphParser.d.ts +10 -25
  118. package/dist/docx/paragraphParser.js +421 -496
  119. package/dist/docx/paragraphProperties.d.ts +23 -0
  120. package/dist/docx/paragraphProperties.js +279 -0
  121. package/dist/docx/paragraphPropertySource.js +7 -1
  122. package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
  123. package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
  124. package/dist/docx/paragraphTraversal.d.ts +14 -10
  125. package/dist/docx/paragraphTraversal.js +53 -52
  126. package/dist/docx/parseWarningMessage.js +5 -1
  127. package/dist/docx/parserEnums.d.ts +6 -8
  128. package/dist/docx/parserEnums.js +4 -6
  129. package/dist/docx/preservedRunContent.d.ts +32 -0
  130. package/dist/docx/preservedRunContent.js +96 -0
  131. package/dist/docx/previewBudget.d.ts +44 -23
  132. package/dist/docx/previewBudget.js +61 -30
  133. package/dist/docx/propertyElementAttributes.d.ts +178 -0
  134. package/dist/docx/propertyElementAttributes.js +114 -0
  135. package/dist/docx/renderedPageBreakNormalization.js +4 -6
  136. package/dist/docx/rezip.d.ts +28 -2
  137. package/dist/docx/rezip.js +152 -27
  138. package/dist/docx/runConsolidator.d.ts +42 -2
  139. package/dist/docx/runConsolidator.js +60 -6
  140. package/dist/docx/runParser.d.ts +55 -19
  141. package/dist/docx/runParser.js +394 -306
  142. package/dist/docx/runPayload.d.ts +5 -0
  143. package/dist/docx/runPayload.js +4 -0
  144. package/dist/docx/sdtProperties.d.ts +39 -5
  145. package/dist/docx/sdtProperties.js +205 -84
  146. package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
  147. package/dist/docx/sdtPropertiesPatch.js +68 -112
  148. package/dist/docx/sectionParser.d.ts +1 -2
  149. package/dist/docx/sectionParser.js +241 -238
  150. package/dist/docx/selectiveSave.js +3 -2
  151. package/dist/docx/selectiveXmlPatch.d.ts +66 -3
  152. package/dist/docx/selectiveXmlPatch.js +276 -133
  153. package/dist/docx/serializer/blockSdtSerializer.js +2 -96
  154. package/dist/docx/serializer/borderSerializer.d.ts +5 -5
  155. package/dist/docx/serializer/borderSerializer.js +12 -10
  156. package/dist/docx/serializer/commentSerializer.js +5 -7
  157. package/dist/docx/serializer/documentSerializer.js +11 -11
  158. package/dist/docx/serializer/fontTableSerializer.js +31 -3
  159. package/dist/docx/serializer/headerFooterSerializer.js +10 -9
  160. package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
  161. package/dist/docx/serializer/markupRangeAttributes.js +9 -1
  162. package/dist/docx/serializer/noteSerializer.js +11 -8
  163. package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
  164. package/dist/docx/serializer/numberingSerializer.js +81 -79
  165. package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
  166. package/dist/docx/serializer/paragraphSerializer.js +156 -236
  167. package/dist/docx/serializer/runSerializer.d.ts +1 -5
  168. package/dist/docx/serializer/runSerializer.js +134 -75
  169. package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
  170. package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
  171. package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
  172. package/dist/docx/serializer/settingsSerializer.js +6 -4
  173. package/dist/docx/serializer/stylesSerializer.js +8 -11
  174. package/dist/docx/serializer/tableSerializer.js +283 -105
  175. package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
  176. package/dist/docx/serializer/textFormattingSerializer.js +111 -101
  177. package/dist/docx/serializer/xmlUtils.d.ts +1 -1
  178. package/dist/docx/serializer/xmlUtils.js +1 -1
  179. package/dist/docx/server/createBilingualDocument.js +20 -16
  180. package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
  181. package/dist/docx/server/materializeYjsDocx.js +9 -1
  182. package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
  183. package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
  184. package/dist/docx/settingsParser.js +7 -4
  185. package/dist/docx/shadingParser.d.ts +2 -1
  186. package/dist/docx/shadingParser.js +43 -7
  187. package/dist/docx/shapeParser.js +13 -8
  188. package/dist/docx/strictNames.d.ts +11 -0
  189. package/dist/docx/strictNames.gen.d.ts +45 -0
  190. package/dist/docx/strictNames.gen.js +50 -0
  191. package/dist/docx/strictNames.js +43 -0
  192. package/dist/docx/strictValueEncodings.gen.js +133 -131
  193. package/dist/docx/styleParser.js +17 -349
  194. package/dist/docx/tableParser.d.ts +11 -2
  195. package/dist/docx/tableParser.js +665 -220
  196. package/dist/docx/textBoxParser.d.ts +28 -3
  197. package/dist/docx/textBoxParser.js +69 -9
  198. package/dist/docx/themeColorAttribute.d.ts +13 -0
  199. package/dist/docx/themeColorAttribute.js +24 -0
  200. package/dist/docx/trackedMoveRangeNormalization.js +2 -1
  201. package/dist/docx/unzip.js +5 -4
  202. package/dist/docx/vmlImageParser.d.ts +30 -5
  203. package/dist/docx/vmlImageParser.js +91 -32
  204. package/dist/docx/vmlPreview.js +2 -2
  205. package/dist/docx/wrapPolygon.d.ts +30 -0
  206. package/dist/docx/wrapPolygon.js +70 -0
  207. package/dist/docx/xmlEncoding.d.ts +5 -0
  208. package/dist/docx/xmlEncoding.js +12 -0
  209. package/dist/docx/xmlParser.d.ts +23 -1
  210. package/dist/docx/xmlParser.js +31 -2
  211. package/dist/fonts/embeddedFonts.js +3 -3
  212. package/dist/headless-layout.js +12 -1
  213. package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
  214. package/dist/i18n/messages/catalogs.gen.js +102 -34
  215. package/dist/i18n/messages/messages.gen.d.ts +4 -0
  216. package/dist/index.d.ts +2 -1
  217. package/dist/index.js +2 -1
  218. package/dist/internal/headlessRevisionResolution.js +9 -0
  219. package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
  220. package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
  221. package/dist/internal/paragraphFormattingSerialization.js +118 -83
  222. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  223. package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
  224. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  225. package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
  226. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
  227. package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
  228. package/dist/layout-engine/index.d.ts +2 -2
  229. package/dist/layout-engine/index.js +53 -17
  230. package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
  231. package/dist/layout-engine/measure/measureBlocks.js +6 -10
  232. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  233. package/dist/layout-engine/measure/tableCellFloating.js +2 -0
  234. package/dist/layout-engine/measure/tableCellGrid.js +2 -1
  235. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
  236. package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
  237. package/dist/layout-engine/paragraphSequence.js +3 -2
  238. package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
  239. package/dist/layout-engine/section-breaks.d.ts +49 -2
  240. package/dist/layout-engine/section-breaks.js +55 -4
  241. package/dist/layout-engine/types.d.ts +69 -17
  242. package/dist/layout-engine/types.js +16 -1
  243. package/dist/layout-painter/borderStroke.d.ts +18 -4
  244. package/dist/layout-painter/renderImage.d.ts +5 -1
  245. package/dist/layout-painter/renderImage.js +10 -3
  246. package/dist/layout-painter/renderPage.d.ts +2 -0
  247. package/dist/layout-painter/renderPage.js +10 -4
  248. package/dist/layout-painter/renderParagraph.d.ts +14 -1
  249. package/dist/layout-painter/renderParagraph.js +34 -28
  250. package/dist/layout-painter/renderTable.d.ts +4 -1
  251. package/dist/layout-painter/renderTable.js +22 -22
  252. package/dist/layout-painter/renderTextBox.js +5 -3
  253. package/dist/managers/autoSaveCodec.d.ts +9 -1
  254. package/dist/managers/autoSaveCodec.js +12 -4
  255. package/dist/markdown/renderBlock.js +3 -0
  256. package/dist/markdown/renderRuns.d.ts +1 -1
  257. package/dist/markdown/renderRuns.js +34 -6
  258. package/dist/markdown/renderTable.js +24 -6
  259. package/dist/markdown/trailers.js +4 -1
  260. package/dist/model.d.ts +3 -3
  261. package/dist/model.js +2 -2
  262. package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
  263. package/dist/paged-layout/sectionBlockWidths.js +26 -4
  264. package/dist/pdf/images.js +142 -6
  265. package/dist/prosemirror/attrs/index.d.ts +34 -5
  266. package/dist/prosemirror/attrs/index.js +639 -48
  267. package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
  268. package/dist/prosemirror/authoredTransformAttrs.js +64 -0
  269. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
  270. package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
  271. package/dist/prosemirror/commands/comments.js +68 -53
  272. package/dist/prosemirror/commands/contentControls.js +33 -20
  273. package/dist/prosemirror/commands/image.d.ts +10 -3
  274. package/dist/prosemirror/commands/image.js +46 -29
  275. package/dist/prosemirror/commands/pageBreak.js +1 -1
  276. package/dist/prosemirror/commands/paragraph.d.ts +2 -1
  277. package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
  278. package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
  279. package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
  280. package/dist/prosemirror/commands/sectionBreak.js +187 -11
  281. package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
  282. package/dist/prosemirror/commentReferenceAttrs.js +33 -0
  283. package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
  284. package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
  285. package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
  286. package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
  287. package/dist/prosemirror/conversion/index.d.ts +2 -2
  288. package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
  289. package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
  290. package/dist/prosemirror/conversion/runShadingMark.js +14 -1
  291. package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
  292. package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
  293. package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
  294. package/dist/prosemirror/conversion/toProseDoc.js +801 -411
  295. package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
  296. package/dist/prosemirror/emptyRangeAnchor.js +158 -0
  297. package/dist/prosemirror/extensions/StarterKit.js +14 -58
  298. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  299. package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
  300. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
  301. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
  302. package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
  303. package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
  304. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
  305. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
  306. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
  307. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
  308. package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
  309. package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
  310. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
  311. package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
  312. package/dist/prosemirror/extensions/markRegistry.js +138 -0
  313. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
  314. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
  315. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
  316. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
  317. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
  318. package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
  319. package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
  320. package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
  321. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
  322. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
  323. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
  324. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
  325. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
  326. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
  327. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
  328. package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
  329. package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
  330. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
  331. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
  332. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
  333. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
  334. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
  335. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
  336. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
  337. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
  338. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
  339. package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
  340. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
  341. package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
  342. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
  343. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
  344. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
  345. package/dist/prosemirror/extensions/types.d.ts +12 -3
  346. package/dist/prosemirror/index.d.ts +4 -2
  347. package/dist/prosemirror/index.js +2 -1
  348. package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
  349. package/dist/prosemirror/inlineWrapperStack.js +92 -0
  350. package/dist/prosemirror/listMarker.d.ts +2 -2
  351. package/dist/prosemirror/listMarker.js +7 -8
  352. package/dist/prosemirror/listRenderingAttrs.js +11 -1
  353. package/dist/prosemirror/listState.d.ts +62 -0
  354. package/dist/prosemirror/listState.js +49 -0
  355. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
  356. package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
  357. package/dist/prosemirror/numberedRefFields.js +4 -4
  358. package/dist/prosemirror/numberingAttr.d.ts +55 -0
  359. package/dist/prosemirror/numberingAttr.js +74 -0
  360. package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
  361. package/dist/prosemirror/outlineLevelAttr.js +42 -0
  362. package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
  363. package/dist/prosemirror/pageBreakRunProjection.js +19 -9
  364. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
  365. package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
  366. package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
  367. package/dist/prosemirror/plugins/selectionTracker.js +3 -10
  368. package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
  369. package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
  370. package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
  371. package/dist/prosemirror/replacedAnnotations.js +183 -0
  372. package/dist/prosemirror/revisionCarriers.d.ts +86 -2
  373. package/dist/prosemirror/revisionCarriers.js +86 -60
  374. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
  375. package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
  376. package/dist/prosemirror/runIdentity.d.ts +28 -0
  377. package/dist/prosemirror/runIdentity.js +36 -0
  378. package/dist/prosemirror/runStyleFormatting.js +1 -1
  379. package/dist/prosemirror/schema/index.d.ts +3 -3
  380. package/dist/prosemirror/schema/marks.d.ts +47 -4
  381. package/dist/prosemirror/schema/nodes.d.ts +309 -26
  382. package/dist/prosemirror/schema/nodes.js +16 -1
  383. package/dist/prosemirror/sectionCarrier.d.ts +37 -0
  384. package/dist/prosemirror/sectionCarrier.js +40 -0
  385. package/dist/prosemirror/selectionState.d.ts +3 -0
  386. package/dist/prosemirror/selectionState.js +4 -1
  387. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
  388. package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
  389. package/dist/prosemirror/tableResize.js +5 -6
  390. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
  391. package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
  392. package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
  393. package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
  394. package/dist/prosemirror/validation.js +31 -6
  395. package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
  396. package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
  397. package/dist/prosemirror/zeroWidthAnchors.js +6 -0
  398. package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
  399. package/dist/render-dom/commentAnchorAttributes.js +54 -0
  400. package/dist/server.d.ts +3 -1
  401. package/dist/server.js +3 -1
  402. package/dist/style-sets/extract.js +4 -4
  403. package/dist/style-sets/stellaStyle.js +36 -23
  404. package/dist/types/colors.d.ts +2 -2
  405. package/dist/types/content.d.ts +2 -2
  406. package/dist/types/documentEnumValues.d.ts +53 -26
  407. package/dist/types/documentEnumValues.js +72 -174
  408. package/dist/types/formatting.d.ts +2 -2
  409. package/dist/types/index.d.ts +9 -2
  410. package/dist/utils/borderCss.d.ts +246 -0
  411. package/dist/utils/borderCss.js +325 -0
  412. package/dist/utils/clipboard.d.ts +9 -1
  413. package/dist/utils/clipboard.js +27 -1
  414. package/dist/utils/colorResolver.d.ts +4 -3
  415. package/dist/utils/colorResolver.js +45 -76
  416. package/dist/utils/createDocument.js +24 -6
  417. package/dist/utils/findReplace.js +52 -10
  418. package/dist/utils/formatToStyle.d.ts +84 -2
  419. package/dist/utils/formatToStyle.js +133 -52
  420. package/dist/utils/headingCollector.js +3 -2
  421. package/dist/utils/imageLuminance.d.ts +15 -0
  422. package/dist/utils/imageLuminance.js +32 -0
  423. package/dist/utils/mergeDocumentContent.js +12 -20
  424. package/dist/utils/paragraphFormattingMerge.js +27 -6
  425. package/dist/utils/replaceText.js +1 -0
  426. package/dist/utils/tableOperations.d.ts +5 -3
  427. package/dist/utils/tableOperations.js +14 -1
  428. package/dist/utils/tablePlacement.d.ts +7 -0
  429. package/dist/utils/tablePlacement.js +14 -0
  430. package/dist/utils/textDirectionFlow.d.ts +15 -0
  431. package/dist/utils/textDirectionFlow.js +38 -0
  432. package/dist/utils/textFormattingMerge.js +16 -4
  433. package/package.json +10 -10
  434. package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
  435. package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
  436. package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
  437. package/dist/compare/__fixtures__/body-sequence.js +0 -225
  438. package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
  439. package/dist/compare/__fixtures__/nested-table.js +0 -50
  440. package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
  441. package/dist/compare/__fixtures__/numbered-list.js +0 -85
  442. package/dist/docx/blockRangeMarkers.d.ts +0 -36
  443. package/dist/docx/blockRangeMarkers.js +0 -59
  444. package/dist/docx/bookmarkPlacement.d.ts +0 -9
  445. package/dist/docx/bookmarkPlacement.js +0 -50
  446. package/dist/fonts/embeddedFontTable.d.ts +0 -45
  447. package/dist/fonts/embeddedFontTable.js +0 -80
  448. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
  449. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
  450. package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
  451. package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
@@ -1,3 +1,4 @@
1
+ import { paragraphNumberingReference, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
1
2
  import { formattingEquals } from "../docx/runConsolidator.js";
2
3
  import { expectParagraphAttrs, expectRunPropertyChangeMarkAttrs } from "../prosemirror/attrs/index.js";
3
4
  import { hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot } from "../prosemirror/commands/propertyChangeScope.js";
@@ -5,11 +6,13 @@ import { addedBreakCarrierBefore, finalParagraphsOf, paragraphEndsItsContainer }
5
6
  import { requestDeterministicParaIds } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
6
7
  import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
7
8
  import { CLEARED_LIST_RENDERING_ATTRS } from "../prosemirror/listMarker.js";
9
+ import { paragraphNumberingAttr, readParagraphNumberingAttr } from "../prosemirror/numberingAttr.js";
8
10
  import { directParagraphAlignment } from "../prosemirror/paragraphAlignment.js";
9
11
  import { directParagraphIndentation, paragraphIndentationAttrPatch, paragraphIndentationEqual, paragraphIndentationFromFormatting, withDirectParagraphIndentation } from "../prosemirror/paragraphIndentation.js";
10
12
  import { directParagraphSpacing, paragraphSpacingAttrPatch, paragraphSpacingEqual, paragraphSpacingFromFormatting, withDirectParagraphSpacing } from "../prosemirror/paragraphSpacing.js";
11
13
  import { getDocumentNumbering } from "../prosemirror/plugins/documentNumbering.js";
12
14
  import { getDocumentStyleResolver } from "../prosemirror/plugins/documentStyles.js";
15
+ import { addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, surveyReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
13
16
  import { applyMarksToRunFormattingRepresentation, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations } from "../prosemirror/runFormattingInlineCarriers.js";
14
17
  import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "../prosemirror/runFormattingReconciliation.js";
15
18
  import { paragraphRunStyleContext, paragraphRunStyleContextAt } from "../prosemirror/runStyleFormatting.js";
@@ -187,26 +190,25 @@ const paragraphPropertiesPatch = ({ node, properties, resolvedFormattingFromStyl
187
190
  ilvl: properties.numbering.level
188
191
  }, numbering));
189
192
  if (properties.listLevel === null) {
190
- patch["numPr"] = { numId: properties.numbering.numId };
193
+ patch["numPr"] = paragraphNumberingAttr(paragraphNumberingReference({ numId: properties.numbering.numId }));
191
194
  patch["numPrFromStyle"] = null;
192
195
  }
193
196
  }
194
- else if (properties.listLevel !== void 0) {
195
- const numPr = node.attrs["numPr"];
196
- if (properties.listLevel === null) {
197
- patch["numPr"] = null;
198
- Object.assign(patch, CLEARED_LIST_RENDERING_ATTRS);
199
- } else {
200
- const numId = typeof numPr === "object" && numPr !== null && "numId" in numPr ? numPr.numId : void 0;
201
- if (typeof numId === "number") Object.assign(patch, listLevelAttrPatch(attrs, {
202
- numId,
197
+ else if (properties.listLevel !== void 0) if (properties.listLevel === null) {
198
+ patch["numPr"] = null;
199
+ Object.assign(patch, CLEARED_LIST_RENDERING_ATTRS);
200
+ } else {
201
+ const numId = paragraphNumberingReferenceId(readParagraphNumberingAttr(node.attrs["numPr"]) ?? void 0);
202
+ if (numId === void 0) {
203
+ patch["numPr"] = paragraphNumberingAttr({
204
+ kind: "levelOnly",
203
205
  ilvl: properties.listLevel
204
- }, numbering));
205
- else {
206
- patch["numPr"] = { ilvl: properties.listLevel };
207
- Object.assign(patch, CLEARED_LIST_RENDERING_ATTRS);
208
- }
209
- }
206
+ });
207
+ Object.assign(patch, CLEARED_LIST_RENDERING_ATTRS);
208
+ } else Object.assign(patch, listLevelAttrPatch(attrs, {
209
+ numId,
210
+ ilvl: properties.listLevel
211
+ }, numbering));
210
212
  }
211
213
  if (properties.alignment !== void 0 && (styleChanged || (currentDirectAlignment ?? null) !== properties.alignment)) {
212
214
  originalFormatting ??= {};
@@ -949,6 +951,14 @@ const buildEmphasisInlineContent = (schema, text, baseMarks) => {
949
951
  }
950
952
  return nodes.length > 0 ? nodes : [schema.text(text, [...baseMarks])];
951
953
  };
954
+ /**
955
+ * Inline content for a block the applier rebuilds whole, carrying over the
956
+ * annotations the block's old content held (see `replacedAnnotations`).
957
+ */
958
+ const rebuiltBlockContent = ({ doc, blockFrom, blockTo, content }) => annotatedReplacement({
959
+ annotations: surveyReplacedAnnotations(doc, blockFrom + 1, blockTo - 1),
960
+ content: Fragment.fromArray([...content])
961
+ }).fragment;
952
962
  const isBatchableParagraphInsertion = (item, mode) => {
953
963
  if (item.operation.type !== "insertAfterBlock" && item.operation.type !== "insertBeforeBlock") return false;
954
964
  if (item.commentText !== void 0) return false;
@@ -1143,23 +1153,24 @@ const buildInsertedParagraphs = ({ item, schema, formattingFromStyle, mode, auth
1143
1153
  ilvl: explicitNumbering.level
1144
1154
  }, numbering));
1145
1155
  if (listLevel === null) {
1146
- attrs["numPr"] = { numId: explicitNumbering.numId };
1156
+ attrs["numPr"] = paragraphNumberingAttr(paragraphNumberingReference({ numId: explicitNumbering.numId }));
1147
1157
  attrs["numPrFromStyle"] = null;
1148
1158
  }
1149
1159
  } else if (listLevel === null) {
1150
1160
  attrs["numPr"] = null;
1151
1161
  Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
1152
1162
  } else if (typeof listLevel === "number") {
1153
- const anchorNumPr = Reflect.get(baseAttrs, "numPr");
1154
- const numId = typeof anchorNumPr === "object" && anchorNumPr !== null && "numId" in anchorNumPr ? anchorNumPr.numId : void 0;
1155
- if (typeof numId === "number") Object.assign(attrs, listLevelAttrPatch(operation.inheritFormatting === false ? {} : expectParagraphAttrs(item.blockNode), {
1163
+ const numId = paragraphNumberingReferenceId(readParagraphNumberingAttr(Reflect.get(baseAttrs, "numPr")) ?? void 0);
1164
+ if (numId === void 0) {
1165
+ attrs["numPr"] = paragraphNumberingAttr({
1166
+ kind: "levelOnly",
1167
+ ilvl: listLevel
1168
+ });
1169
+ Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
1170
+ } else Object.assign(attrs, listLevelAttrPatch(operation.inheritFormatting === false ? {} : expectParagraphAttrs(item.blockNode), {
1156
1171
  numId,
1157
1172
  ilvl: listLevel
1158
1173
  }, numbering));
1159
- else {
1160
- attrs["numPr"] = { ilvl: listLevel };
1161
- Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
1162
- }
1163
1174
  }
1164
1175
  }
1165
1176
  if (formatsParagraph && operation.styleId !== void 0) {
@@ -1608,7 +1619,12 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations, mode =
1608
1619
  const replacement = item.operation.text;
1609
1620
  const paragraphType = view.state.schema.nodes["paragraph"];
1610
1621
  if (paragraphType) {
1611
- const node = paragraphType.create(null, replacement.length === 0 ? null : buildEmphasisInlineContent(view.state.schema, replacement, commentMark ? [commentMark] : []));
1622
+ const node = paragraphType.create(null, rebuiltBlockContent({
1623
+ doc: tr.doc,
1624
+ blockFrom: item.blockFrom,
1625
+ blockTo: item.blockTo,
1626
+ content: replacement.length === 0 ? [] : buildEmphasisInlineContent(view.state.schema, replacement, commentMark ? [commentMark] : [])
1627
+ }));
1612
1628
  tr = tr.replaceWith(item.blockFrom, item.blockTo, node);
1613
1629
  tr = applyReplaceBlockStyleId({
1614
1630
  item,
@@ -1619,7 +1635,12 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations, mode =
1619
1635
  }
1620
1636
  }
1621
1637
  if (mode === "direct" && hasInlineEmphasis(item.operation.text)) {
1622
- const node = item.blockNode.type.create({ ...item.blockNode.attrs }, buildEmphasisInlineContent(view.state.schema, item.operation.text, commentMark ? [commentMark] : []));
1638
+ const node = item.blockNode.type.create({ ...item.blockNode.attrs }, rebuiltBlockContent({
1639
+ doc: tr.doc,
1640
+ blockFrom: item.blockFrom,
1641
+ blockTo: item.blockTo,
1642
+ content: buildEmphasisInlineContent(view.state.schema, item.operation.text, commentMark ? [commentMark] : [])
1643
+ }));
1623
1644
  tr = tr.replaceWith(item.blockFrom, item.blockTo, node);
1624
1645
  tr = applyReplaceBlockStyleId({
1625
1646
  item,
@@ -2342,18 +2363,28 @@ const cleanTextInlineNodes = ({ schema, text, marks = [] }) => {
2342
2363
  if (trailing.length > 0) nodes.push(schema.text(trailing, marks));
2343
2364
  return nodes;
2344
2365
  };
2345
- const insertCleanText = ({ tr, from, to, text }) => {
2346
- if (!hasCleanTextControls(text)) return {
2366
+ const insertCleanText = ({ tr, from, to, text, standsInFor }) => {
2367
+ const annotations = surveyReplacedAnnotations(tr.doc, from, to);
2368
+ const replaced = standsInFor ? surveyReplacedAnnotations(tr.doc, standsInFor.from, standsInFor.to).carried : [];
2369
+ if (!hasReplacedAnnotations(annotations) && replaced.length === 0 && !hasCleanTextControls(text)) return {
2347
2370
  transaction: tr.insertText(text, from, to),
2371
+ start: from,
2348
2372
  end: from + text.length
2349
2373
  };
2350
- const content = Fragment.fromArray(cleanTextInlineNodes({
2351
- schema: tr.doc.type.schema,
2352
- text
2353
- }));
2374
+ const schema = tr.doc.type.schema;
2375
+ const { fragment, leadingSize, contentSize } = annotatedReplacement({
2376
+ annotations,
2377
+ content: Fragment.fromArray(cleanTextInlineNodes({
2378
+ schema,
2379
+ text,
2380
+ marks: addCarriedMarks(inheritedReplacementMarks(tr.doc, from, to), replaced)
2381
+ }))
2382
+ });
2383
+ const start = from + leadingSize;
2354
2384
  return {
2355
- transaction: tr.replaceWith(from, to, content),
2356
- end: from + content.size
2385
+ transaction: tr.replaceWith(from, to, fragment),
2386
+ start,
2387
+ end: start + contentSize
2357
2388
  };
2358
2389
  };
2359
2390
  const applyTextReplacement = ({ tr, item, mode, author, date, revisionIdDelete, revisionIdInsert, commentMark, suggestionId = null, initials, diffText }) => {
@@ -2365,8 +2396,11 @@ const applyTextReplacement = ({ tr, item, mode, author, date, revisionIdDelete,
2365
2396
  })());
2366
2397
  if (mode === "direct") {
2367
2398
  if ((item.operation.type === "replaceInBlock" || item.operation.type === "replaceRange") && hasInlineEmphasis(item.operation.replace)) {
2368
- const content = buildEmphasisInlineContent(nextTr.doc.type.schema, item.operation.replace, commentMark ? [commentMark] : []);
2369
- return nextTr.replaceWith(item.from, item.to, content);
2399
+ const { fragment } = annotatedReplacement({
2400
+ annotations: surveyReplacedAnnotations(nextTr.doc, item.from, item.to),
2401
+ content: Fragment.fromArray(buildEmphasisInlineContent(nextTr.doc.type.schema, item.operation.replace, commentMark ? [commentMark] : []))
2402
+ });
2403
+ return nextTr.replaceWith(item.from, item.to, fragment);
2370
2404
  }
2371
2405
  const inserted = insertCleanText({
2372
2406
  tr: nextTr,
@@ -2375,7 +2409,7 @@ const applyTextReplacement = ({ tr, item, mode, author, date, revisionIdDelete,
2375
2409
  text: replacement
2376
2410
  });
2377
2411
  nextTr = inserted.transaction;
2378
- if (commentMark && replacement.length > 0) nextTr = nextTr.addMark(item.from, inserted.end, commentMark);
2412
+ if (commentMark && replacement.length > 0) nextTr = nextTr.addMark(inserted.start, inserted.end, commentMark);
2379
2413
  return nextTr;
2380
2414
  }
2381
2415
  const insertionType = nextTr.doc.type.schema.marks["insertion"];
@@ -2465,11 +2499,15 @@ const applyTextReplacement = ({ tr, item, mode, author, date, revisionIdDelete,
2465
2499
  tr: nextTr,
2466
2500
  from: step.at,
2467
2501
  to: step.at,
2468
- text: step.text
2502
+ text: step.text,
2503
+ standsInFor: {
2504
+ from: item.from,
2505
+ to: item.to
2506
+ }
2469
2507
  });
2470
2508
  nextTr = inserted.transaction;
2471
- nextTr = nextTr.addMark(step.at, inserted.end, insertionType.create(insAttrs));
2472
- if (commentMark) nextTr = nextTr.addMark(step.at, inserted.end, commentMark);
2509
+ nextTr = nextTr.addMark(inserted.start, inserted.end, insertionType.create(insAttrs));
2510
+ if (commentMark) nextTr = nextTr.addMark(inserted.start, inserted.end, commentMark);
2473
2511
  }
2474
2512
  }
2475
2513
  return nextTr;
@@ -2480,11 +2518,15 @@ const applyTextReplacement = ({ tr, item, mode, author, date, revisionIdDelete,
2480
2518
  tr: nextTr,
2481
2519
  from: item.to,
2482
2520
  to: item.to,
2483
- text: replacement
2521
+ text: replacement,
2522
+ standsInFor: {
2523
+ from: item.from,
2524
+ to: item.to
2525
+ }
2484
2526
  });
2485
2527
  nextTr = inserted.transaction;
2486
- nextTr = nextTr.addMark(item.to, inserted.end, insertionType.create(insAttrs));
2487
- if (commentMark) nextTr = nextTr.addMark(item.to, inserted.end, commentMark);
2528
+ nextTr = nextTr.addMark(inserted.start, inserted.end, insertionType.create(insAttrs));
2529
+ if (commentMark) nextTr = nextTr.addMark(inserted.start, inserted.end, commentMark);
2488
2530
  }
2489
2531
  if (item.to > item.from && deletionType) {
2490
2532
  nextTr = nextTr.addMark(item.from, item.to, deletionType.create(delAttrs));
@@ -35,9 +35,9 @@ import { createFolioAIEditSnapshotWithStyleResolver, detachFolioAIEditSnapshotEx
35
35
  import { matchTableGeometry } from "./table-geometry.js";
36
36
  import { tableTemplateCanCrossPackageLosslessly } from "./table-template.js";
37
37
  import { TaggedError, panic } from "better-result";
38
+ import { REVIEW_CARRIERS } from "@stll/docx-core/model";
38
39
  import { Fragment } from "prosemirror-model";
39
40
  import { EditorState } from "prosemirror-state";
40
- import { REVIEW_CARRIERS } from "@stll/docx-core/model";
41
41
  import JSZip from "jszip";
42
42
  //#region src/ai-edits/headless.ts
43
43
  /**
@@ -1544,7 +1544,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1544
1544
  * same states, so the text now describes exactly what a save would write.
1545
1545
  */
1546
1546
  storyBlocks(state, source) {
1547
- return state ? proseDocToBlocks(state.doc, source.content, this.baseDocument.package.styles, { emptyFieldResult: "authored" }) : source.content;
1547
+ return state ? proseDocToBlocks(state.doc, source.content, this.baseDocument.package.styles) : source.content;
1548
1548
  }
1549
1549
  getHeaderFooterStoryText(story, source) {
1550
1550
  const state = this.secondaryStoryStates.get(headerFooterStoryKey(story))?.state;
@@ -25,6 +25,7 @@ declare const FOLIO_REVIEW_CHANGE_KINDS: Readonly<{
25
25
  readonly paragraphPropertiesChanged: "paragraphPropertiesChanged";
26
26
  readonly sectionPropertiesChanged: "sectionPropertiesChanged";
27
27
  readonly tablePropertiesChanged: "tablePropertiesChanged";
28
+ readonly tablePropertyExceptionsChanged: "tablePropertyExceptionsChanged";
28
29
  readonly rowPropertiesChanged: "rowPropertiesChanged";
29
30
  readonly cellPropertiesChanged: "cellPropertiesChanged";
30
31
  }>;
@@ -26,6 +26,7 @@ const FOLIO_REVIEW_CHANGE_KINDS = Object.freeze({
26
26
  paragraphPropertiesChanged: "paragraphPropertiesChanged",
27
27
  sectionPropertiesChanged: "sectionPropertiesChanged",
28
28
  tablePropertiesChanged: "tablePropertiesChanged",
29
+ tablePropertyExceptionsChanged: "tablePropertyExceptionsChanged",
29
30
  rowPropertiesChanged: "rowPropertiesChanged",
30
31
  cellPropertiesChanged: "cellPropertiesChanged"
31
32
  });
@@ -1,7 +1,10 @@
1
1
  import { EMPTY_BUILT_IN_STYLE_INDEX, resolveHeadingLevel } from "../docx/builtInStyles.js";
2
+ import { resolveParagraphNumbering } from "../docx/numberingReference.js";
2
3
  import { recreateProseNodeWithParagraphPropertySource } from "../docx/paragraphPropertySource.js";
3
4
  import { expectCharacterStyleMarkAttrs, expectHyperlinkMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs } from "../prosemirror/attrs/index.js";
4
5
  import { marksToTextFormatting } from "../prosemirror/conversion/fromProseDoc.js";
6
+ import { paragraphNumberingAttr, readParagraphNumberingAttr } from "../prosemirror/numberingAttr.js";
7
+ import { readOutlineLevelAttr } from "../prosemirror/outlineLevelAttr.js";
5
8
  import { directParagraphAlignment } from "../prosemirror/paragraphAlignment.js";
6
9
  import { directParagraphIndentation } from "../prosemirror/paragraphIndentation.js";
7
10
  import { directParagraphSpacing } from "../prosemirror/paragraphSpacing.js";
@@ -34,18 +37,16 @@ const remapFolioAIEditSnapshotNumberingReferences = (snapshot, numIdMap) => {
34
37
  if (numIdMap.size === 0) return snapshot;
35
38
  const metadata = metadataOf(snapshot);
36
39
  const remapNode = (node) => {
37
- const numPr = node.attrs["numPr"];
38
- if (typeof numPr !== "object" || numPr === null || !("numId" in numPr)) return node;
39
- const numId = numPr.numId;
40
- if (typeof numId !== "number") return node;
41
- const remappedNumId = numIdMap.get(numId);
40
+ const numPr = readParagraphNumberingAttr(node.attrs["numPr"]);
41
+ if (numPr?.kind !== "reference") return node;
42
+ const remappedNumId = numIdMap.get(numPr.numId);
42
43
  if (remappedNumId === void 0) return node;
43
44
  return recreateProseNodeWithParagraphPropertySource(node, { attrs: {
44
45
  ...node.attrs,
45
- numPr: {
46
+ numPr: paragraphNumberingAttr({
46
47
  ...numPr,
47
48
  numId: remappedNumId
48
- }
49
+ })
49
50
  } });
50
51
  };
51
52
  const remapped = remapDocument(metadata.sourceDocument, remapNode);
@@ -481,10 +482,9 @@ const getBlockKind = (node, headingLevel) => {
481
482
  };
482
483
  /** The block's 1-based heading level, as {@link resolveHeadingLevel} classifies it. */
483
484
  const getHeadingLevel = (node, styles) => {
484
- const outlineLevel = node.attrs["outlineLevel"];
485
485
  const styleId = node.attrs["styleId"];
486
486
  const level = resolveHeadingLevel({
487
- outlineLevel: typeof outlineLevel === "number" ? outlineLevel : null,
487
+ outlineLevel: readOutlineLevelAttr(node.attrs["outlineLevel"]),
488
488
  styleId: typeof styleId === "string" ? styleId : null
489
489
  }, styles);
490
490
  return level === void 0 ? void 0 : level + 1;
@@ -495,30 +495,35 @@ const getDisplayLabel = (node, isHeading) => {
495
495
  const styleId = node.attrs["styleId"];
496
496
  if (isHeading && typeof styleId === "string") return styleId;
497
497
  };
498
+ /**
499
+ * The level the paragraph's `<w:numPr>` states, and only that. An absent
500
+ * `w:ilvl` renders as level zero but is not a stated zero, and a caller that
501
+ * writes it back would turn an untouched paragraph into one stating a level
502
+ * its source never did.
503
+ */
498
504
  const getListLevel = (node) => {
499
- const numPr = node.attrs["numPr"];
500
- if (typeof numPr !== "object" || numPr === null || !("ilvl" in numPr)) return;
501
- const { ilvl } = numPr;
502
- return typeof ilvl === "number" && Number.isInteger(ilvl) && ilvl >= 0 ? ilvl : void 0;
505
+ const numPr = readParagraphNumberingAttr(node.attrs["numPr"]);
506
+ return numPr === null || numPr.kind === "none" ? void 0 : numPr.ilvl;
503
507
  };
508
+ /**
509
+ * The numbering a paragraph attr states, read through the model's own reader.
510
+ *
511
+ * The two functions below used to test the reserved id relationally
512
+ * (`numId > 0`, `numId <= 0`), which is the one spelling that disagreed with
513
+ * the other four: a malformed package's negative id is a dangling reference
514
+ * everywhere else and "not numbered" here.
515
+ */
516
+ const statedNumbering = (node) => resolveParagraphNumbering(readParagraphNumberingAttr(node.attrs["numPr"]) ?? void 0);
504
517
  const getListReference = (node) => {
505
- const numPr = node.attrs["numPr"];
506
- if (typeof numPr !== "object" || numPr === null || !("numId" in numPr)) return void 0;
507
- const { numId } = numPr;
508
- const level = "ilvl" in numPr ? numPr.ilvl : 0;
509
- return typeof numId === "number" && Number.isInteger(numId) && numId > 0 && typeof level === "number" && Number.isInteger(level) && level >= 0 ? {
510
- numId,
511
- level
518
+ const numbering = statedNumbering(node);
519
+ return numbering.kind === "reference" ? {
520
+ numId: numbering.numId,
521
+ level: numbering.ilvl
512
522
  } : void 0;
513
523
  };
514
524
  const getNumberingReferenceKey = (node) => {
515
- const numPr = node.attrs["numPr"];
516
- if (typeof numPr !== "object" || numPr === null || !("numId" in numPr)) return null;
517
- const { numId } = numPr;
518
- if (typeof numId !== "number" || !Number.isInteger(numId) || numId <= 0) return null;
519
- const level = "ilvl" in numPr ? numPr.ilvl : void 0;
520
- if (level !== void 0 && (typeof level !== "number" || !Number.isInteger(level) || level < 0)) return null;
521
- return `${String(numId)}:${String(level ?? 0)}`;
525
+ const numbering = statedNumbering(node);
526
+ return numbering.kind === "reference" ? `${String(numbering.numId)}:${String(numbering.ilvl)}` : null;
522
527
  };
523
528
  const getStyleId = (node) => {
524
529
  const styleId = node.attrs["styleId"];
@@ -51,7 +51,11 @@ const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
51
51
  rowspan: rectangle.bottom - rectangle.top,
52
52
  colwidth: nextColwidth,
53
53
  width: preferredWidth.type === "value" ? preferredWidth.width : null,
54
- widthType: preferredWidth.type === "value" ? preferredWidth.widthType : null
54
+ widthType: preferredWidth.type === "value" ? preferredWidth.widthType : null,
55
+ _authoredWidth: preferredWidth.type === "value" ? {
56
+ value: preferredWidth.width,
57
+ type: preferredWidth.widthType
58
+ } : null
55
59
  });
56
60
  if (appendedContent.size > 0) {
57
61
  const contentEnd = absoluteMergedPosition + 1 + merged.cell.content.size;
@@ -74,16 +78,20 @@ const mergeTopRowColwidths = (cells, mergedColspan) => {
74
78
  * preferred widths; retaining only the first cell's width makes a 50%+50%
75
79
  * bilingual row serialize as a 50%-wide spanning cell. Mixed/implicit units
76
80
  * cannot be composed safely, so clear the preference and let the table grid
77
- * define the merged width. */
81
+ * define the merged width.
82
+ *
83
+ * The summands are `_authoredWidth`, not the rendered `width`: a cell that
84
+ * states no preferred width still renders at the width the table grid
85
+ * resolved, and summing those would give the merged cell a `w:tcW` no source
86
+ * cell wrote. */
78
87
  const mergeTopRowPreferredWidths = (cells) => {
79
88
  let width = 0;
80
89
  let widthType;
81
90
  for (const cell of cells) {
82
- const candidateWidth = cell.attrs["width"];
83
- const candidateType = cell.attrs["widthType"];
84
- if (typeof candidateWidth !== "number" || !Number.isFinite(candidateWidth) || candidateType !== "dxa" && candidateType !== "pct" || widthType !== void 0 && candidateType !== widthType) return { type: "absent" };
85
- width += candidateWidth;
86
- widthType = candidateType;
91
+ const stated = expectTableCellAttrs(cell)._authoredWidth;
92
+ if (stated === void 0 || !Number.isFinite(stated.value) || stated.type !== "dxa" && stated.type !== "pct" || widthType !== void 0 && stated.type !== widthType) return { type: "absent" };
93
+ width += stated.value;
94
+ widthType = stated.type;
87
95
  }
88
96
  return widthType === void 0 ? { type: "absent" } : {
89
97
  type: "value",
@@ -80,21 +80,24 @@ const TABLE_SCOPE = {
80
80
  changeAttr: "tblPrChange",
81
81
  changeType: "tablePropertyChange"
82
82
  };
83
- const ROW_SCOPE = {
84
- keys: ROW_SCOPED_ATTRS,
85
- signatureOf: (node) => scopedValues(node.attrs, ROW_SCOPED_ATTRS),
86
- formattingOf: (node) => tableRowAttrsToFormatting(node.attrs),
87
- rejectPatch: (previousFormatting) => tableRowRejectAttrPatch(previousFormatting),
88
- changeAttr: "trPrChange",
89
- changeType: "tableRowPropertyChange"
90
- };
91
- const CELL_SCOPE = {
92
- keys: CELL_SCOPED_ATTRS,
93
- signatureOf: (node) => scopedValues(node.attrs, CELL_SCOPED_ATTRS),
94
- formattingOf: (node) => tableCellAttrsToFormatting(cellAttrsOf(node)),
95
- rejectPatch: (previousFormatting, liveFormatting) => tableCellRejectAttrPatch(previousFormatting, liveFormatting),
96
- changeAttr: "tcPrChange",
97
- changeType: "tableCellPropertyChange"
83
+ const GEOMETRY_SCOPES = {
84
+ tablePropertyChange: TABLE_SCOPE,
85
+ tableRowPropertyChange: {
86
+ keys: ROW_SCOPED_ATTRS,
87
+ signatureOf: (node) => scopedValues(node.attrs, ROW_SCOPED_ATTRS),
88
+ formattingOf: (node) => tableRowAttrsToFormatting(node.attrs),
89
+ rejectPatch: (previousFormatting) => tableRowRejectAttrPatch(previousFormatting),
90
+ changeAttr: "trPrChange",
91
+ changeType: "tableRowPropertyChange"
92
+ },
93
+ tableCellPropertyChange: {
94
+ keys: CELL_SCOPED_ATTRS,
95
+ signatureOf: (node) => scopedValues(node.attrs, CELL_SCOPED_ATTRS),
96
+ formattingOf: (node) => tableCellAttrsToFormatting(cellAttrsOf(node)),
97
+ rejectPatch: (previousFormatting, liveFormatting) => tableCellRejectAttrPatch(previousFormatting, liveFormatting),
98
+ changeAttr: "tcPrChange",
99
+ changeType: "tableCellPropertyChange"
100
+ }
98
101
  };
99
102
  const scopedValues = (attrs, keys) => canonicalJson(scopedAttrs(attrs, keys));
100
103
  /**
@@ -200,9 +203,9 @@ const matchTableGeometry = ({ tr, baseTables, targetTables, pairings, revision }
200
203
  const targetCell = targetRow.maybeChild(target.cellIndex);
201
204
  const cellPosition = childPositions(baseRow, rowPosition)[base.cellIndex];
202
205
  if (!baseCell || !targetCell || cellPosition === void 0) continue;
203
- consider(baseTable.node, targetTable, baseTable.start, TABLE_SCOPE);
204
- consider(baseRow, targetRow, rowPosition, ROW_SCOPE);
205
- consider(baseCell, targetCell, cellPosition, CELL_SCOPE);
206
+ consider(baseTable.node, targetTable, baseTable.start, GEOMETRY_SCOPES.tablePropertyChange);
207
+ consider(baseRow, targetRow, rowPosition, GEOMETRY_SCOPES.tableRowPropertyChange);
208
+ consider(baseCell, targetCell, cellPosition, GEOMETRY_SCOPES.tableCellPropertyChange);
206
209
  }
207
210
  let revisionId = revision.idSeed;
208
211
  for (const target of targets) {
@@ -70,7 +70,6 @@ const CLEARED_PARAGRAPH_ATTRS = [
70
70
  "pPrMark",
71
71
  "_suggestedInsert",
72
72
  "_sectionProperties",
73
- "sectionBreakType",
74
73
  "renderedPageBreakBefore"
75
74
  ];
76
75
  /** Table, row and cell attrs that record the other document's revisions. */
@@ -78,7 +77,8 @@ const CLEARED_TABLE_ATTRS = ["tblPrChange", "_suggestedInsert"];
78
77
  const CLEARED_ROW_ATTRS = [
79
78
  "trIns",
80
79
  "trDel",
81
- "trPrChange"
80
+ "trPrChange",
81
+ "tblPrExChange"
82
82
  ];
83
83
  const CLEARED_CELL_ATTRS = ["cellMarker", "tcPrChange"];
84
84
  const hasAuthoredValue = (value) => {
@@ -15,7 +15,7 @@ import { sameAuthoredInlineProvenance } from "./inline-provenance.js";
15
15
  import { planStoryCompare } from "./plan.js";
16
16
  import { withFixedPackageDates } from "./reproducible-package.js";
17
17
  import { compareSectionBoundaryProperties } from "./section-boundary-properties.js";
18
- import { CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, InvalidCompareDocxOptionsError } from "./types.js";
18
+ import { CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, InvalidCompareDocxOptionsError, compareDocxSerializeError } from "./types.js";
19
19
  import { classifyGeometryMismatch, classifyProjectionMismatch, revisedFinalParagraphMarks } from "./verification.js";
20
20
  import { Result, panic } from "better-result";
21
21
  //#region src/compare/compare.ts
@@ -903,10 +903,7 @@ const serializeComparison = async ({ baseBuffer, baseCarriedRevisions, reviewer,
903
903
  }));
904
904
  return await Result.tryPromise({
905
905
  try: async () => await withFixedPackageDates(await reviewer.toBuffer(), packageDate),
906
- catch: (cause) => new CompareDocxSerializeError({
907
- message: "The compared document could not be serialized.",
908
- cause
909
- })
906
+ catch: (cause) => compareDocxSerializeError("The compared document could not be serialized", cause)
910
907
  });
911
908
  };
912
909
  /**