@stll/folio-core 0.46.0 → 0.47.1

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 (370) hide show
  1. package/dist/ai-edits/apply.d.ts +17 -1
  2. package/dist/ai-edits/apply.js +31 -27
  3. package/dist/ai-edits/headless.d.ts +9 -2
  4. package/dist/ai-edits/headless.js +5 -3
  5. package/dist/ai-edits/read.d.ts +1 -0
  6. package/dist/ai-edits/read.js +1 -0
  7. package/dist/ai-edits/snapshot.js +32 -27
  8. package/dist/ai-edits/table-cell-mutations.js +15 -7
  9. package/dist/ai-edits/table-geometry.js +21 -18
  10. package/dist/ai-edits/table-template.js +2 -2
  11. package/dist/compare/compare.js +2 -1
  12. package/dist/compare/content-alignment.js +192 -46
  13. package/dist/compare/content-types.d.ts +8 -2
  14. package/dist/compare/content.js +2 -11
  15. package/dist/compare/plan.js +7 -4
  16. package/dist/compare/section-boundary-properties.js +1 -2
  17. package/dist/content-controls/checkboxDisplay.d.ts +8 -2
  18. package/dist/content-controls/checkboxDisplay.js +11 -5
  19. package/dist/content-controls/mutateContentControls.js +41 -42
  20. package/dist/controller/layoutPipeline.js +8 -3
  21. package/dist/display-list/build/buildDisplayList.js +7 -7
  22. package/dist/display-list/build/imagePrimitives.d.ts +4 -4
  23. package/dist/display-list/build/imagePrimitives.js +38 -20
  24. package/dist/display-list/build/pageBorderPrimitives.js +2 -1
  25. package/dist/display-list/build/paragraphPrimitives.js +93 -13
  26. package/dist/display-list/build/previewPrimitives.d.ts +10 -0
  27. package/dist/display-list/build/previewPrimitives.js +89 -0
  28. package/dist/display-list/build/strokes.d.ts +177 -8
  29. package/dist/display-list/build/strokes.js +167 -47
  30. package/dist/display-list/build/tablePrimitives.js +4 -2
  31. package/dist/display-list/build/textBoxPrimitives.js +6 -4
  32. package/dist/display-list/build/textDecorations.d.ts +15 -1
  33. package/dist/display-list/build/textDecorations.js +15 -1
  34. package/dist/display-list/dom/renderDisplayListToDom.js +1 -19
  35. package/dist/display-list/primitives.d.ts +13 -2
  36. package/dist/display-list/primitives.js +36 -1
  37. package/dist/document-operations.d.ts +9 -2
  38. package/dist/document-operations.js +5 -3
  39. package/dist/docx/attributeRemainder.d.ts +34 -1
  40. package/dist/docx/attributeRemainder.js +49 -3
  41. package/dist/docx/blockContentParser.d.ts +2 -0
  42. package/dist/docx/blockContentParser.js +39 -67
  43. package/dist/docx/blockPlainText.js +3 -1
  44. package/dist/docx/borderParser.js +26 -11
  45. package/dist/docx/builtInStyles.d.ts +8 -16
  46. package/dist/docx/builtInStyles.js +54 -17
  47. package/dist/docx/commentAnchorIndex.js +1 -1
  48. package/dist/docx/commentParser.js +3 -3
  49. package/dist/docx/commentRangeIntegrity.js +1 -1
  50. package/dist/docx/commentRangeJoin.js +1 -1
  51. package/dist/docx/commentReferenceNormalization.js +3 -2
  52. package/dist/docx/commentReplyMarkers.js +1 -1
  53. package/dist/docx/compatibility.js +56 -42
  54. package/dist/docx/containerChildren.d.ts +110 -13
  55. package/dist/docx/containerChildren.gen.d.ts +16 -1
  56. package/dist/docx/containerChildren.gen.js +18 -1
  57. package/dist/docx/containerChildren.js +63 -13
  58. package/dist/docx/diagramPreview.d.ts +14 -2
  59. package/dist/docx/diagramPreview.js +81 -169
  60. package/dist/docx/documentParser.js +4 -1
  61. package/dist/docx/drawingAnchor.d.ts +87 -0
  62. package/dist/docx/drawingAnchor.js +201 -0
  63. package/dist/docx/drawingUtils.d.ts +43 -38
  64. package/dist/docx/drawingUtils.js +205 -118
  65. package/dist/docx/fontTableParser.js +102 -41
  66. package/dist/docx/footnoteParser.js +10 -6
  67. package/dist/docx/groupDrawingParser.js +4 -3
  68. package/dist/docx/headerFooterReferenceNormalization.js +1 -1
  69. package/dist/docx/hyperlinkParser.d.ts +45 -7
  70. package/dist/docx/hyperlinkParser.js +126 -57
  71. package/dist/docx/imageParser.js +127 -107
  72. package/dist/docx/index.d.ts +2 -1
  73. package/dist/docx/index.js +2 -1
  74. package/dist/docx/inlineContentRemovals.d.ts +28 -0
  75. package/dist/docx/inlineContentRemovals.js +46 -0
  76. package/dist/docx/inlineWrapperContent.d.ts +84 -3
  77. package/dist/docx/inlineWrapperContent.js +85 -4
  78. package/dist/docx/inlineWrapperParser.d.ts +11 -0
  79. package/dist/docx/inlineWrapperParser.js +60 -0
  80. package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
  81. package/dist/docx/normalizeBaseDirection.js +4 -2
  82. package/dist/docx/numberingParser.d.ts +25 -2
  83. package/dist/docx/numberingParser.js +264 -361
  84. package/dist/docx/numberingReference.d.ts +9 -16
  85. package/dist/docx/numberingReference.js +17 -16
  86. package/dist/docx/numberingReferenceNormalization.js +7 -7
  87. package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
  88. package/dist/docx/ooxmlCounterFormatter.js +4 -1
  89. package/dist/docx/paraIdAttribute.d.ts +91 -1
  90. package/dist/docx/paraIdAttribute.js +79 -1
  91. package/dist/docx/paragraphParser.d.ts +9 -24
  92. package/dist/docx/paragraphParser.js +212 -396
  93. package/dist/docx/paragraphProperties.d.ts +23 -0
  94. package/dist/docx/paragraphProperties.js +279 -0
  95. package/dist/docx/paragraphPropertySource.js +2 -0
  96. package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
  97. package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
  98. package/dist/docx/paragraphTraversal.d.ts +14 -10
  99. package/dist/docx/paragraphTraversal.js +47 -49
  100. package/dist/docx/parseWarningMessage.js +3 -0
  101. package/dist/docx/parserEnums.d.ts +6 -8
  102. package/dist/docx/parserEnums.js +4 -6
  103. package/dist/docx/preservedRunContent.js +16 -6
  104. package/dist/docx/previewBudget.d.ts +44 -23
  105. package/dist/docx/previewBudget.js +61 -30
  106. package/dist/docx/propertyElementAttributes.d.ts +178 -0
  107. package/dist/docx/propertyElementAttributes.js +114 -0
  108. package/dist/docx/renderedPageBreakNormalization.js +2 -2
  109. package/dist/docx/rezip.d.ts +28 -2
  110. package/dist/docx/rezip.js +78 -9
  111. package/dist/docx/runConsolidator.d.ts +42 -2
  112. package/dist/docx/runConsolidator.js +60 -6
  113. package/dist/docx/runParser.d.ts +54 -18
  114. package/dist/docx/runParser.js +379 -295
  115. package/dist/docx/runPayload.d.ts +5 -0
  116. package/dist/docx/runPayload.js +4 -0
  117. package/dist/docx/sdtProperties.d.ts +39 -5
  118. package/dist/docx/sdtProperties.js +205 -84
  119. package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
  120. package/dist/docx/sdtPropertiesPatch.js +68 -112
  121. package/dist/docx/sectionParser.d.ts +1 -2
  122. package/dist/docx/sectionParser.js +236 -240
  123. package/dist/docx/selectiveSave.js +3 -2
  124. package/dist/docx/selectiveXmlPatch.d.ts +21 -2
  125. package/dist/docx/selectiveXmlPatch.js +195 -99
  126. package/dist/docx/serializer/blockSdtSerializer.js +2 -96
  127. package/dist/docx/serializer/borderSerializer.d.ts +5 -5
  128. package/dist/docx/serializer/borderSerializer.js +10 -8
  129. package/dist/docx/serializer/documentSerializer.js +3 -0
  130. package/dist/docx/serializer/fontTableSerializer.js +31 -3
  131. package/dist/docx/serializer/headerFooterSerializer.js +3 -0
  132. package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
  133. package/dist/docx/serializer/markupRangeAttributes.js +9 -1
  134. package/dist/docx/serializer/noteSerializer.js +3 -0
  135. package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
  136. package/dist/docx/serializer/numberingSerializer.js +81 -79
  137. package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
  138. package/dist/docx/serializer/paragraphSerializer.js +88 -188
  139. package/dist/docx/serializer/runSerializer.d.ts +1 -5
  140. package/dist/docx/serializer/runSerializer.js +109 -59
  141. package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
  142. package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
  143. package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
  144. package/dist/docx/serializer/settingsSerializer.js +6 -4
  145. package/dist/docx/serializer/stylesSerializer.js +8 -11
  146. package/dist/docx/serializer/tableSerializer.js +268 -100
  147. package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
  148. package/dist/docx/serializer/textFormattingSerializer.js +111 -101
  149. package/dist/docx/serializer/xmlUtils.d.ts +1 -1
  150. package/dist/docx/serializer/xmlUtils.js +1 -1
  151. package/dist/docx/server/createBilingualDocument.js +18 -16
  152. package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
  153. package/dist/docx/settingsParser.js +7 -4
  154. package/dist/docx/shadingParser.d.ts +2 -1
  155. package/dist/docx/shadingParser.js +43 -7
  156. package/dist/docx/shapeParser.js +8 -3
  157. package/dist/docx/strictNames.d.ts +11 -0
  158. package/dist/docx/strictNames.gen.d.ts +45 -0
  159. package/dist/docx/strictNames.gen.js +50 -0
  160. package/dist/docx/strictNames.js +43 -0
  161. package/dist/docx/strictValueEncodings.gen.js +133 -131
  162. package/dist/docx/styleParser.js +17 -349
  163. package/dist/docx/tableParser.d.ts +10 -1
  164. package/dist/docx/tableParser.js +505 -181
  165. package/dist/docx/textBoxParser.d.ts +3 -1
  166. package/dist/docx/textBoxParser.js +18 -8
  167. package/dist/docx/themeColorAttribute.d.ts +13 -0
  168. package/dist/docx/themeColorAttribute.js +24 -0
  169. package/dist/docx/trackedMoveRangeNormalization.js +2 -1
  170. package/dist/docx/vmlImageParser.d.ts +13 -4
  171. package/dist/docx/vmlImageParser.js +74 -31
  172. package/dist/docx/vmlPreview.js +2 -2
  173. package/dist/docx/wrapPolygon.d.ts +30 -0
  174. package/dist/docx/wrapPolygon.js +70 -0
  175. package/dist/docx/xmlParser.d.ts +14 -1
  176. package/dist/docx/xmlParser.js +18 -2
  177. package/dist/fonts/embeddedFonts.js +3 -3
  178. package/dist/headless-layout.js +2 -0
  179. package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
  180. package/dist/i18n/messages/catalogs.gen.js +102 -34
  181. package/dist/i18n/messages/messages.gen.d.ts +4 -0
  182. package/dist/internal/headlessRevisionResolution.js +9 -0
  183. package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
  184. package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
  185. package/dist/internal/paragraphFormattingSerialization.js +118 -83
  186. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  187. package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
  188. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  189. package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
  190. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
  191. package/dist/layout-bridge/convert/toFlowBlocks.js +177 -101
  192. package/dist/layout-engine/index.d.ts +2 -2
  193. package/dist/layout-engine/index.js +53 -17
  194. package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
  195. package/dist/layout-engine/measure/measureBlocks.js +6 -10
  196. package/dist/layout-engine/measure/tableCellGrid.js +2 -1
  197. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
  198. package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
  199. package/dist/layout-engine/paragraphSequence.js +3 -2
  200. package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
  201. package/dist/layout-engine/section-breaks.d.ts +49 -2
  202. package/dist/layout-engine/section-breaks.js +55 -4
  203. package/dist/layout-engine/types.d.ts +47 -17
  204. package/dist/layout-engine/types.js +16 -1
  205. package/dist/layout-painter/borderStroke.d.ts +18 -4
  206. package/dist/layout-painter/renderPage.js +6 -4
  207. package/dist/layout-painter/renderParagraph.d.ts +2 -1
  208. package/dist/layout-painter/renderParagraph.js +13 -26
  209. package/dist/layout-painter/renderTable.d.ts +4 -1
  210. package/dist/layout-painter/renderTable.js +22 -22
  211. package/dist/layout-painter/renderTextBox.js +5 -3
  212. package/dist/markdown/renderBlock.js +3 -1
  213. package/dist/markdown/renderRuns.js +7 -2
  214. package/dist/markdown/renderTable.js +2 -1
  215. package/dist/model.d.ts +3 -3
  216. package/dist/model.js +2 -2
  217. package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
  218. package/dist/paged-layout/sectionBlockWidths.js +26 -4
  219. package/dist/prosemirror/attrs/index.d.ts +22 -4
  220. package/dist/prosemirror/attrs/index.js +498 -60
  221. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
  222. package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
  223. package/dist/prosemirror/commands/comments.js +68 -53
  224. package/dist/prosemirror/commands/contentControls.js +24 -19
  225. package/dist/prosemirror/commands/image.d.ts +1 -1
  226. package/dist/prosemirror/commands/image.js +4 -1
  227. package/dist/prosemirror/commands/paragraph.d.ts +2 -1
  228. package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
  229. package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
  230. package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
  231. package/dist/prosemirror/commands/sectionBreak.js +187 -11
  232. package/dist/prosemirror/conversion/fromProseDoc.d.ts +18 -2
  233. package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
  234. package/dist/prosemirror/conversion/index.d.ts +2 -2
  235. package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
  236. package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
  237. package/dist/prosemirror/conversion/runShadingMark.js +14 -1
  238. package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
  239. package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
  240. package/dist/prosemirror/conversion/toProseDoc.js +371 -141
  241. package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
  242. package/dist/prosemirror/emptyRangeAnchor.js +158 -0
  243. package/dist/prosemirror/extensions/StarterKit.js +8 -2
  244. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  245. package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
  246. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  247. package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
  248. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
  249. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
  250. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
  251. package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
  252. package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
  253. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
  254. package/dist/prosemirror/extensions/markRegistry.d.ts +26 -2
  255. package/dist/prosemirror/extensions/markRegistry.js +73 -10
  256. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
  257. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
  258. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
  259. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
  260. package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
  261. package/dist/prosemirror/extensions/marks/markUtils.js +2 -1
  262. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
  263. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
  264. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
  265. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
  266. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
  267. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +10 -0
  268. package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -1
  269. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
  270. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
  271. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
  272. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
  273. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
  274. package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
  275. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +4 -0
  276. package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
  277. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
  278. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
  279. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
  280. package/dist/prosemirror/extensions/types.d.ts +12 -3
  281. package/dist/prosemirror/index.d.ts +4 -2
  282. package/dist/prosemirror/index.js +2 -1
  283. package/dist/prosemirror/inlineWrapperStack.js +20 -3
  284. package/dist/prosemirror/listMarker.d.ts +2 -2
  285. package/dist/prosemirror/listMarker.js +7 -8
  286. package/dist/prosemirror/listRenderingAttrs.js +11 -1
  287. package/dist/prosemirror/listState.d.ts +62 -0
  288. package/dist/prosemirror/listState.js +49 -0
  289. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
  290. package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
  291. package/dist/prosemirror/numberedRefFields.js +4 -4
  292. package/dist/prosemirror/numberingAttr.d.ts +55 -0
  293. package/dist/prosemirror/numberingAttr.js +74 -0
  294. package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
  295. package/dist/prosemirror/outlineLevelAttr.js +42 -0
  296. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
  297. package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
  298. package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
  299. package/dist/prosemirror/plugins/selectionTracker.js +3 -10
  300. package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
  301. package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
  302. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  303. package/dist/prosemirror/replacedAnnotations.js +24 -6
  304. package/dist/prosemirror/revisionCarriers.d.ts +86 -2
  305. package/dist/prosemirror/revisionCarriers.js +86 -60
  306. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
  307. package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
  308. package/dist/prosemirror/runIdentity.d.ts +28 -0
  309. package/dist/prosemirror/runIdentity.js +36 -0
  310. package/dist/prosemirror/runStyleFormatting.js +1 -1
  311. package/dist/prosemirror/schema/index.d.ts +2 -2
  312. package/dist/prosemirror/schema/marks.d.ts +23 -4
  313. package/dist/prosemirror/schema/nodes.d.ts +220 -24
  314. package/dist/prosemirror/sectionCarrier.d.ts +37 -0
  315. package/dist/prosemirror/sectionCarrier.js +40 -0
  316. package/dist/prosemirror/selectionState.d.ts +3 -0
  317. package/dist/prosemirror/selectionState.js +4 -1
  318. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
  319. package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
  320. package/dist/prosemirror/tableResize.js +5 -6
  321. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
  322. package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
  323. package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
  324. package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
  325. package/dist/prosemirror/validation.js +17 -6
  326. package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
  327. package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
  328. package/dist/prosemirror/zeroWidthAnchors.js +4 -0
  329. package/dist/style-sets/extract.js +4 -4
  330. package/dist/style-sets/stellaStyle.js +36 -23
  331. package/dist/types/colors.d.ts +2 -2
  332. package/dist/types/content.d.ts +2 -2
  333. package/dist/types/documentEnumValues.d.ts +53 -26
  334. package/dist/types/documentEnumValues.js +72 -174
  335. package/dist/types/formatting.d.ts +2 -2
  336. package/dist/types/index.d.ts +9 -2
  337. package/dist/utils/borderCss.d.ts +246 -0
  338. package/dist/utils/borderCss.js +325 -0
  339. package/dist/utils/colorResolver.d.ts +4 -3
  340. package/dist/utils/colorResolver.js +45 -76
  341. package/dist/utils/createDocument.js +24 -6
  342. package/dist/utils/findReplace.js +52 -10
  343. package/dist/utils/formatToStyle.d.ts +84 -2
  344. package/dist/utils/formatToStyle.js +133 -52
  345. package/dist/utils/headingCollector.js +3 -2
  346. package/dist/utils/mergeDocumentContent.js +5 -3
  347. package/dist/utils/paragraphFormattingMerge.js +27 -6
  348. package/dist/utils/replaceText.js +1 -1
  349. package/dist/utils/tableOperations.d.ts +5 -3
  350. package/dist/utils/tableOperations.js +14 -1
  351. package/dist/utils/tablePlacement.d.ts +7 -0
  352. package/dist/utils/tablePlacement.js +14 -0
  353. package/dist/utils/textDirectionFlow.d.ts +15 -0
  354. package/dist/utils/textDirectionFlow.js +38 -0
  355. package/dist/utils/textFormattingMerge.js +16 -4
  356. package/package.json +10 -10
  357. package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
  358. package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
  359. package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
  360. package/dist/compare/__fixtures__/body-sequence.js +0 -225
  361. package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
  362. package/dist/compare/__fixtures__/nested-table.js +0 -50
  363. package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
  364. package/dist/compare/__fixtures__/numbered-list.js +0 -85
  365. package/dist/docx/bookmarkPlacement.d.ts +0 -9
  366. package/dist/docx/bookmarkPlacement.js +0 -52
  367. package/dist/fonts/embeddedFontTable.d.ts +0 -45
  368. package/dist/fonts/embeddedFontTable.js +0 -80
  369. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
  370. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
@@ -67,6 +67,9 @@ declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
67
67
  readonly spacingExplicit: {
68
68
  readonly kind: "derived";
69
69
  };
70
+ readonly spacingPreservedAttributes: {
71
+ readonly kind: "original-only";
72
+ };
70
73
  readonly indentLeft: {
71
74
  readonly kind: "style-resolved-attr";
72
75
  readonly attr: "indentLeft";
@@ -82,6 +85,9 @@ declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
82
85
  readonly hangingIndent: {
83
86
  readonly kind: "direct-provenance";
84
87
  };
88
+ readonly indentPreservedAttributes: {
89
+ readonly kind: "original-only";
90
+ };
85
91
  readonly borders: {
86
92
  readonly kind: "style-resolved-attr";
87
93
  readonly attr: "borders";
@@ -147,6 +153,9 @@ declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
147
153
  readonly kind: "style-resolved-attr";
148
154
  readonly attr: "runInWithNext";
149
155
  };
156
+ readonly preserved: {
157
+ readonly kind: "original-only";
158
+ };
150
159
  };
151
160
  type StyleResolvedParagraphField = { [Field in keyof typeof PARAGRAPH_FORMATTING_WRITE_BACK]: (typeof PARAGRAPH_FORMATTING_WRITE_BACK)[Field] extends {
152
161
  kind: "style-resolved-attr";
@@ -28,6 +28,7 @@ const PARAGRAPH_FORMATTING_WRITE_BACK = {
28
28
  beforeAutospacing: { kind: "direct-provenance" },
29
29
  afterAutospacing: { kind: "direct-provenance" },
30
30
  spacingExplicit: { kind: "derived" },
31
+ spacingPreservedAttributes: { kind: "original-only" },
31
32
  indentLeft: {
32
33
  kind: "style-resolved-attr",
33
34
  attr: "indentLeft"
@@ -41,6 +42,7 @@ const PARAGRAPH_FORMATTING_WRITE_BACK = {
41
42
  attr: "indentFirstLine"
42
43
  },
43
44
  hangingIndent: { kind: "direct-provenance" },
45
+ indentPreservedAttributes: { kind: "original-only" },
44
46
  borders: {
45
47
  kind: "style-resolved-attr",
46
48
  attr: "borders"
@@ -91,7 +93,8 @@ const PARAGRAPH_FORMATTING_WRITE_BACK = {
91
93
  runInWithNext: {
92
94
  kind: "style-resolved-attr",
93
95
  attr: "runInWithNext"
94
- }
96
+ },
97
+ preserved: { kind: "original-only" }
95
98
  };
96
99
  const STYLE_RESOLVED_PARAGRAPH_FIELDS = Object.keys(PARAGRAPH_FORMATTING_WRITE_BACK).filter((field) => PARAGRAPH_FORMATTING_WRITE_BACK[field].kind === "style-resolved-attr");
97
100
  /**
@@ -1,4 +1,5 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
+ import { ListState } from "../listState.js";
2
3
  import { EditorState, Plugin, PluginKey } from "prosemirror-state";
3
4
  //#region src/prosemirror/plugins/selectionTracker.d.ts
4
5
  /**
@@ -17,12 +18,8 @@ type SelectionContext = {
17
18
  startParagraphIndex: number;
18
19
  /** End paragraph index */
19
20
  endParagraphIndex: number;
20
- /** Whether cursor is in a list */
21
- inList: boolean;
22
- /** List type if in list */
23
- listType?: "bullet" | "numbered";
24
- /** List level (0-8) */
25
- listLevel?: number;
21
+ /** Which list the cursor is in, resolved against the numbering definitions. */
22
+ listState: ListState;
26
23
  /** Active comment IDs at cursor position */
27
24
  activeCommentIds: number[];
28
25
  /** Whether cursor is inside a tracked insertion */
@@ -1,4 +1,5 @@
1
1
  import { expectCommentMarkAttrs, expectTrackedChangeMarkAttrs } from "../attrs/index.js";
2
+ import { sameListState } from "../listState.js";
2
3
  import { extractSelectionSnapshot } from "../selectionState.js";
3
4
  import { Plugin, PluginKey } from "prosemirror-state";
4
5
  //#region src/prosemirror/plugins/selectionTracker.ts
@@ -26,12 +27,6 @@ function extractSelectionContext(state) {
26
27
  ...snapshot.paragraphFormatting,
27
28
  styleId: snapshot.styleId
28
29
  };
29
- const numPr = snapshot.paragraphFormatting.numPr;
30
- const inList = !!numPr?.numId;
31
- let listType;
32
- if (numPr?.numId === 1) listType = "bullet";
33
- else if (numPr?.numId) listType = "numbered";
34
- const listLevel = numPr?.ilvl;
35
30
  const allMarks = state.storedMarks || (empty ? selection.$from.marks() : []);
36
31
  const activeCommentIds = [];
37
32
  let inInsertion = false;
@@ -54,9 +49,7 @@ function extractSelectionContext(state) {
54
49
  paragraphFormatting,
55
50
  startParagraphIndex: snapshot.startParagraphIndex,
56
51
  endParagraphIndex: snapshot.endParagraphIndex,
57
- inList,
58
- ...listType !== void 0 ? { listType } : {},
59
- ...listLevel !== void 0 ? { listLevel } : {},
52
+ listState: snapshot.listState,
60
53
  activeCommentIds,
61
54
  inInsertion,
62
55
  inDeletion
@@ -99,7 +92,7 @@ function arraysEqual(a, b) {
99
92
  * Compare two selection contexts for equality
100
93
  */
101
94
  function contextsEqual(a, b) {
102
- return a.hasSelection === b.hasSelection && a.isMultiParagraph === b.isMultiParagraph && a.startParagraphIndex === b.startParagraphIndex && a.endParagraphIndex === b.endParagraphIndex && a.inList === b.inList && a.listType === b.listType && a.listLevel === b.listLevel && a.inInsertion === b.inInsertion && a.inDeletion === b.inDeletion && arraysEqual(a.activeCommentIds, b.activeCommentIds) && JSON.stringify(a.textFormatting) === JSON.stringify(b.textFormatting) && JSON.stringify(a.paragraphFormatting) === JSON.stringify(b.paragraphFormatting);
95
+ return a.hasSelection === b.hasSelection && a.isMultiParagraph === b.isMultiParagraph && a.startParagraphIndex === b.startParagraphIndex && a.endParagraphIndex === b.endParagraphIndex && sameListState(a.listState, b.listState) && a.inInsertion === b.inInsertion && a.inDeletion === b.inDeletion && arraysEqual(a.activeCommentIds, b.activeCommentIds) && JSON.stringify(a.textFormatting) === JSON.stringify(b.textFormatting) && JSON.stringify(a.paragraphFormatting) === JSON.stringify(b.paragraphFormatting);
103
96
  }
104
97
  /**
105
98
  * Get current selection context from editor state
@@ -0,0 +1,14 @@
1
+ import { ReadProseMirrorAttrsResult } from "./attrs/index.js";
2
+ import { RangeAnchorAttrs } from "./emptyRangeAnchor.js";
3
+ import { Node } from "prosemirror-model";
4
+ //#region src/prosemirror/rangeAnchorAttrs.d.ts
5
+ /** The two marker values, checked for every field the DOCX serializer reads. */
6
+ declare const readRangeAnchorValues: (start: unknown, end: unknown) => ReadProseMirrorAttrsResult<RangeAnchorAttrs>;
7
+ /**
8
+ * The anchor's attrs, checked before a save can call string methods or emit
9
+ * invalid range-marker XML.
10
+ */
11
+ declare const readRangeAnchorAttrs: (node: Node) => ReadProseMirrorAttrsResult<RangeAnchorAttrs>;
12
+ declare const expectRangeAnchorAttrs: (node: Node) => RangeAnchorAttrs;
13
+ //#endregion
14
+ export { expectRangeAnchorAttrs, readRangeAnchorAttrs, readRangeAnchorValues };
@@ -0,0 +1,101 @@
1
+ import { isDisplacedByCustomXml } from "./bookmarkBoundaryAttrs.js";
2
+ import { RANGE_END_FOR_START } from "./emptyRangeAnchor.js";
3
+ import { panic } from "better-result";
4
+ //#region src/prosemirror/rangeAnchorAttrs.ts
5
+ const attrsCache = /* @__PURE__ */ new WeakMap();
6
+ const isRecord = (value) => typeof value === "object" && value !== null;
7
+ const isMarkerId = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
8
+ const isRangeStartType = (value) => typeof value === "string" && value in RANGE_END_FOR_START;
9
+ const validateRangeMarkerAttrs = (marker, path, issues) => {
10
+ if (!isMarkerId(marker["id"])) issues.push({
11
+ path: `${path}.id`,
12
+ message: "Expected a non-negative integer."
13
+ });
14
+ const displacedByCustomXml = marker["displacedByCustomXml"];
15
+ if (displacedByCustomXml !== void 0 && !isDisplacedByCustomXml(displacedByCustomXml)) issues.push({
16
+ path: `${path}.displacedByCustomXml`,
17
+ message: "Expected \"next\" or \"prev\"."
18
+ });
19
+ };
20
+ const validateMoveRangeStartAttrs = (marker, path, issues) => {
21
+ for (const required of ["name", "author"]) if (typeof marker[required] !== "string" || marker[required].trim() === "") issues.push({
22
+ path: `${path}.${required}`,
23
+ message: "Expected a non-empty string on a move range start."
24
+ });
25
+ const date = marker["date"];
26
+ if (date !== void 0 && typeof date !== "string") issues.push({
27
+ path: `${path}.date`,
28
+ message: "Expected a string."
29
+ });
30
+ for (const column of ["colFirst", "colLast"]) {
31
+ const value = marker[column];
32
+ if (value !== void 0 && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)) issues.push({
33
+ path: `${path}.${column}`,
34
+ message: "Expected a non-negative integer."
35
+ });
36
+ }
37
+ };
38
+ /** The two marker values, checked for every field the DOCX serializer reads. */
39
+ const readRangeAnchorValues = (start, end) => {
40
+ const issues = [];
41
+ if (!isRecord(start) || !isRangeStartType(start["type"])) {
42
+ issues.push({
43
+ path: "rangeAnchor.attrs.start",
44
+ message: `Expected one of ${Object.keys(RANGE_END_FOR_START).join(", ")}.`
45
+ });
46
+ return {
47
+ ok: false,
48
+ issues
49
+ };
50
+ }
51
+ const expectedEndType = RANGE_END_FOR_START[start["type"]];
52
+ if (!isRecord(end) || end["type"] !== expectedEndType) issues.push({
53
+ path: "rangeAnchor.attrs.end",
54
+ message: `Expected ${expectedEndType}.`
55
+ });
56
+ validateRangeMarkerAttrs(start, "rangeAnchor.attrs.start", issues);
57
+ if (isRecord(end)) {
58
+ validateRangeMarkerAttrs(end, "rangeAnchor.attrs.end", issues);
59
+ if (end["id"] !== start["id"]) issues.push({
60
+ path: "rangeAnchor.attrs.end.id",
61
+ message: "Expected the id its start carries."
62
+ });
63
+ }
64
+ if (start["type"] !== "commentRangeStart") validateMoveRangeStartAttrs(start, "rangeAnchor.attrs.start", issues);
65
+ if (issues.length > 0) return {
66
+ ok: false,
67
+ issues
68
+ };
69
+ return {
70
+ ok: true,
71
+ value: {
72
+ start,
73
+ end
74
+ }
75
+ };
76
+ };
77
+ /**
78
+ * The anchor's attrs, checked before a save can call string methods or emit
79
+ * invalid range-marker XML.
80
+ */
81
+ const readRangeAnchorAttrs = (node) => {
82
+ const result = readRangeAnchorValues(node.attrs["start"], node.attrs["end"]);
83
+ if (node.type.name === "rangeAnchor") return result;
84
+ return {
85
+ ok: false,
86
+ issues: [{
87
+ path: "rangeAnchor.type.name",
88
+ message: `Expected rangeAnchor, got ${node.type.name}.`
89
+ }, ...result.ok ? [] : result.issues]
90
+ };
91
+ };
92
+ const expectRangeAnchorAttrs = (node) => {
93
+ const cached = attrsCache.get(node);
94
+ if (cached) return cached;
95
+ const result = readRangeAnchorAttrs(node);
96
+ if (!result.ok) panic(`Invalid ProseMirror range anchor attrs:\n${result.issues.map((issue) => `${issue.path}: ${issue.message}`).join("\n")}`);
97
+ attrsCache.set(node, result.value);
98
+ return result.value;
99
+ };
100
+ //#endregion
101
+ export { expectRangeAnchorAttrs, readRangeAnchorAttrs, readRangeAnchorValues };
@@ -11,7 +11,7 @@ declare const NON_INCLUSIVE_MARK_DISPOSITION: {
11
11
  readonly comment: "carry";
12
12
  readonly hyperlink: "carry";
13
13
  readonly footnoteRef: "followsTheText";
14
- readonly pageBreakRunOwner: "followsTheText";
14
+ readonly runIdentity: "followsTheText";
15
15
  readonly insertion: "followsTheText";
16
16
  readonly deletion: "followsTheText";
17
17
  readonly runPropertyChange: "followsTheText";
@@ -1,6 +1,9 @@
1
1
  import { BOOKMARK_BOUNDARY_NODE_NAME } from "./extensions/nodes/BookmarkBoundaryExtension.js";
2
2
  import { COMMENT_REFERENCE_NODE_NAME } from "./extensions/nodes/CommentReferenceExtension.js";
3
+ import { MOVE_RANGE_BOUNDARY_NODE_NAME } from "./extensions/nodes/MoveRangeBoundaryExtension.js";
4
+ import { RANGE_ANCHOR_NODE_NAME } from "./extensions/nodes/RangeAnchorExtension.js";
3
5
  import { TEXT_BOX_ANCHOR_NODE_NAME } from "./extensions/nodes/TextBoxAnchorExtension.js";
6
+ import { readMoveRangeBoundaryAttrs } from "./moveRangeBoundaryAttrs.js";
4
7
  import { Fragment, Mark } from "prosemirror-model";
5
8
  //#region src/prosemirror/replacedAnnotations.ts
6
9
  /**
@@ -35,9 +38,11 @@ import { Fragment, Mark } from "prosemirror-model";
35
38
  * bare `w:footnoteReference` run, so carrying it onto a replacement would
36
39
  * discard the new text. Replacing a reference's text deletes the reference,
37
40
  * as deleting that text does.
38
- * - `pageBreakRunOwner` mark: not carried. It is editor-only identity for one
39
- * authored run, not a target, and carrying it would fuse the replacement
40
- * into a run it was never part of.
41
+ * - `runIdentity` mark: not carried. It is one authored run's identity and the
42
+ * markup that run carried, not a target. A replacement is characters the
43
+ * session named by its `w:rsidR` did not write, so carrying it would fuse
44
+ * the replacement into a run it was never part of and stamp it with an
45
+ * editing session it did not belong to.
41
46
  * - tracked-change marks (`insertion`, `deletion`, `runPropertyChange`): not
42
47
  * carried. The applier decides them per edit mode and writes them itself.
43
48
  * - `inlineWrapper` mark: not carried. Every wrapper kind states something
@@ -46,6 +51,11 @@ import { Fragment, Mark } from "prosemirror-model";
46
51
  * override is still inside it, and one that replaces the whole of it is not.
47
52
  * - `commentReference` node: kept after the replacement, where the comment's
48
53
  * last covered position now is.
54
+ * - `rangeAnchor` node: kept after the replacement. A comment or move range
55
+ * that spans no content has no mark to carry, so replacing the words around
56
+ * a point comment would otherwise delete the comment outright.
57
+ * - `moveRangeBoundary` node: a start kept before the replacement, an end
58
+ * after it, so replacing a moved span keeps that range's identity and scope.
49
59
  * - `bookmarkBoundary` node: a start kept before the replacement, an end after
50
60
  * it, so the bookmark still covers the new text.
51
61
  * - `textBoxAnchor` node: kept after the replacement; the shape it anchors
@@ -70,7 +80,7 @@ const NON_INCLUSIVE_MARK_DISPOSITION = {
70
80
  comment: "carry",
71
81
  hyperlink: "carry",
72
82
  footnoteRef: "followsTheText",
73
- pageBreakRunOwner: "followsTheText",
83
+ runIdentity: "followsTheText",
74
84
  insertion: "followsTheText",
75
85
  deletion: "followsTheText",
76
86
  runPropertyChange: "followsTheText",
@@ -82,10 +92,18 @@ const isCarried = (mark) => NON_INCLUSIVE_MARK_DISPOSITION[mark.type.name] === "
82
92
  /** Anchors an edit must put back, and where relative to the replacement. */
83
93
  const ANCHOR_PLACEMENT = {
84
94
  [COMMENT_REFERENCE_NODE_NAME]: "after",
95
+ [RANGE_ANCHOR_NODE_NAME]: "after",
85
96
  [TEXT_BOX_ANCHOR_NODE_NAME]: "after",
86
- [BOOKMARK_BOUNDARY_NODE_NAME]: "byBoundaryType"
97
+ [BOOKMARK_BOUNDARY_NODE_NAME]: "byBoundaryType",
98
+ [MOVE_RANGE_BOUNDARY_NODE_NAME]: "byMoveBoundaryType"
87
99
  };
88
100
  const anchorPlacement = (node) => ANCHOR_PLACEMENT[node.type.name];
101
+ const opensRange = (node, placement) => {
102
+ if (placement === "byBoundaryType") return node.attrs["type"] === "start";
103
+ if (placement !== "byMoveBoundaryType") return false;
104
+ const marker = readMoveRangeBoundaryAttrs(node);
105
+ return marker.ok && marker.value.type.endsWith("Start");
106
+ };
89
107
  const NOTHING_REPLACED = {
90
108
  carried: [],
91
109
  leading: [],
@@ -107,7 +125,7 @@ const surveyReplacedAnnotations = (doc, from, to) => {
107
125
  for (const mark of node.marks) if (isCarried(mark) && !alreadyCarried(mark, carried)) carried.push(mark);
108
126
  const placement = anchorPlacement(node);
109
127
  if (placement === void 0 || position < from || position + node.nodeSize > to) return false;
110
- (placement === "byBoundaryType" && node.attrs["type"] === "start" ? leading : trailing).push(node);
128
+ (opensRange(node, placement) ? leading : trailing).push(node);
111
129
  return false;
112
130
  });
113
131
  return {
@@ -1,6 +1,76 @@
1
1
  import { Node } from "prosemirror-model";
2
+ import { PropertyRevisionKind } from "@stll/docx-core/model";
2
3
  //#region src/prosemirror/revisionCarriers.d.ts
3
- type FolioNodeRevisionKind = "paragraphMarkInserted" | "paragraphMarkDeleted" | "paragraphPropertiesChanged" | "sectionPropertiesChanged" | "tablePropertiesChanged" | "rowPropertiesChanged" | "cellPropertiesChanged";
4
+ declare const PROPERTY_REVISION_SITES: {
5
+ readonly runPropertyChange: {
6
+ readonly kind: "runPropertyChange";
7
+ readonly resolution: "inline-mark";
8
+ };
9
+ readonly paragraphPropertyChange: {
10
+ readonly kind: "paragraphPropertyChange";
11
+ readonly resolution: "paragraph-pass";
12
+ readonly nodeTypes: readonly ["paragraph"];
13
+ readonly path: readonly ["_propertyChanges"];
14
+ readonly carrier: "paragraphPropertiesChanged";
15
+ readonly range: "paragraph-boundary";
16
+ };
17
+ readonly sectionPropertyChange: {
18
+ readonly kind: "sectionPropertyChange";
19
+ readonly resolution: "paragraph-pass";
20
+ readonly nodeTypes: readonly ["paragraph"];
21
+ readonly path: readonly ["_sectionProperties", "propertyChanges"];
22
+ readonly carrier: "sectionPropertiesChanged";
23
+ readonly range: "paragraph-boundary";
24
+ };
25
+ readonly tablePropertyChange: {
26
+ readonly kind: "tablePropertyChange";
27
+ readonly resolution: "node-attrs";
28
+ readonly nodeTypes: readonly ["table"];
29
+ readonly attr: "tblPrChange";
30
+ readonly carrier: "tablePropertiesChanged";
31
+ readonly range: "whole-node";
32
+ };
33
+ readonly tablePropertyExceptionChange: {
34
+ readonly kind: "tablePropertyExceptionChange";
35
+ readonly resolution: "node-attrs";
36
+ readonly nodeTypes: readonly ["tableRow"];
37
+ readonly attr: "tblPrExChange";
38
+ readonly carrier: "tablePropertyExceptionsChanged";
39
+ readonly range: "whole-node";
40
+ };
41
+ readonly tableRowPropertyChange: {
42
+ readonly kind: "tableRowPropertyChange";
43
+ readonly resolution: "node-attrs";
44
+ readonly nodeTypes: readonly ["tableRow"];
45
+ readonly attr: "trPrChange";
46
+ readonly carrier: "rowPropertiesChanged";
47
+ readonly range: "whole-node";
48
+ };
49
+ readonly tableCellPropertyChange: {
50
+ readonly kind: "tableCellPropertyChange";
51
+ readonly resolution: "node-attrs";
52
+ readonly nodeTypes: readonly ["tableCell", "tableHeader"];
53
+ readonly attr: "tcPrChange";
54
+ readonly carrier: "cellPropertiesChanged";
55
+ readonly range: "whole-node";
56
+ };
57
+ };
58
+ type SiteOf<TKind extends PropertyRevisionKind> = (typeof PROPERTY_REVISION_SITES)[TKind];
59
+ /** One property revision carried on a node's attrs rather than on a mark. */
60
+ type NodePropertyRevisionSite = Extract<SiteOf<PropertyRevisionKind>, {
61
+ carrier: string;
62
+ }>;
63
+ /** The sites the shared node-attr pass resolves, and therefore must patch. */
64
+ type NodeAttrsPropertyRevisionSite = Extract<NodePropertyRevisionSite, {
65
+ resolution: "node-attrs";
66
+ }>;
67
+ /** The kinds that pass resolves. */
68
+ type NodeAttrsPropertyRevisionKind = NodeAttrsPropertyRevisionSite["kind"];
69
+ /** The reviewer-facing name of a property revision carried on a node. */
70
+ type PropertyRevisionCarrier = NodePropertyRevisionSite["carrier"];
71
+ type FolioNodeRevisionKind = "paragraphMarkInserted" | "paragraphMarkDeleted" | PropertyRevisionCarrier;
72
+ /** The property revisions a PM node of this type can carry, in element order. */
73
+ declare const nodePropertyRevisionSites: (nodeTypeName: string) => NodePropertyRevisionSite[];
4
74
  type FolioNodeRevisionCarrier = {
5
75
  id: number;
6
76
  type: FolioNodeRevisionKind;
@@ -10,10 +80,24 @@ type FolioNodeRevisionCarrier = {
10
80
  from: number;
11
81
  to: number;
12
82
  };
83
+ type RevisionMetadata = Pick<FolioNodeRevisionCarrier, "id" | "author" | "date">;
84
+ /** The `w:id`, author and date a stored revision's `info` carries, or null. */
85
+ declare const propertyRevisionMetadata: (value: unknown) => RevisionMetadata | null;
86
+ /**
87
+ * A stored property-revision record as ProseMirror attrs carry it. The
88
+ * previous property set is whatever the site's own element stores, which the
89
+ * reject patch filed under that kind narrows.
90
+ */
91
+ type StoredPropertyRevision = {
92
+ info?: unknown;
93
+ previousFormatting?: unknown;
94
+ };
95
+ /** The record array a site names, walked from a node's attrs. */
96
+ declare const propertyRevisionRecords: (node: Node, site: NodePropertyRevisionSite) => StoredPropertyRevision[];
13
97
  /**
14
98
  * Read revision records stored on ProseMirror node attributes and return the
15
99
  * exact range the shared accept/reject command requires for each carrier.
16
100
  */
17
101
  declare const getFolioNodeRevisionCarriers: (node: Node, nodePos: number) => FolioNodeRevisionCarrier[];
18
102
  //#endregion
19
- export { FolioNodeRevisionCarrier, FolioNodeRevisionKind, getFolioNodeRevisionCarriers };
103
+ export { FolioNodeRevisionCarrier, FolioNodeRevisionKind, NodeAttrsPropertyRevisionKind, NodeAttrsPropertyRevisionSite, NodePropertyRevisionSite, PROPERTY_REVISION_SITES, PropertyRevisionCarrier, StoredPropertyRevision, getFolioNodeRevisionCarriers, nodePropertyRevisionSites, propertyRevisionMetadata, propertyRevisionRecords };
@@ -1,6 +1,62 @@
1
- import { expectParagraphAttrs } from "./attrs/index.js";
2
1
  import { PARAGRAPH_MARK_CHANGE_KINDS } from "@stll/docx-core/model";
3
2
  //#region src/prosemirror/revisionCarriers.ts
3
+ const PROPERTY_REVISION_SITES = {
4
+ runPropertyChange: {
5
+ kind: "runPropertyChange",
6
+ resolution: "inline-mark"
7
+ },
8
+ paragraphPropertyChange: {
9
+ kind: "paragraphPropertyChange",
10
+ resolution: "paragraph-pass",
11
+ nodeTypes: ["paragraph"],
12
+ path: ["_propertyChanges"],
13
+ carrier: "paragraphPropertiesChanged",
14
+ range: "paragraph-boundary"
15
+ },
16
+ sectionPropertyChange: {
17
+ kind: "sectionPropertyChange",
18
+ resolution: "paragraph-pass",
19
+ nodeTypes: ["paragraph"],
20
+ path: ["_sectionProperties", "propertyChanges"],
21
+ carrier: "sectionPropertiesChanged",
22
+ range: "paragraph-boundary"
23
+ },
24
+ tablePropertyChange: {
25
+ kind: "tablePropertyChange",
26
+ resolution: "node-attrs",
27
+ nodeTypes: ["table"],
28
+ attr: "tblPrChange",
29
+ carrier: "tablePropertiesChanged",
30
+ range: "whole-node"
31
+ },
32
+ tablePropertyExceptionChange: {
33
+ kind: "tablePropertyExceptionChange",
34
+ resolution: "node-attrs",
35
+ nodeTypes: ["tableRow"],
36
+ attr: "tblPrExChange",
37
+ carrier: "tablePropertyExceptionsChanged",
38
+ range: "whole-node"
39
+ },
40
+ tableRowPropertyChange: {
41
+ kind: "tableRowPropertyChange",
42
+ resolution: "node-attrs",
43
+ nodeTypes: ["tableRow"],
44
+ attr: "trPrChange",
45
+ carrier: "rowPropertiesChanged",
46
+ range: "whole-node"
47
+ },
48
+ tableCellPropertyChange: {
49
+ kind: "tableCellPropertyChange",
50
+ resolution: "node-attrs",
51
+ nodeTypes: ["tableCell", "tableHeader"],
52
+ attr: "tcPrChange",
53
+ carrier: "cellPropertiesChanged",
54
+ range: "whole-node"
55
+ }
56
+ };
57
+ const NODE_PROPERTY_REVISION_SITES = Object.values(PROPERTY_REVISION_SITES).flatMap((site) => site.resolution === "inline-mark" ? [] : [site]);
58
+ /** The property revisions a PM node of this type can carry, in element order. */
59
+ const nodePropertyRevisionSites = (nodeTypeName) => NODE_PROPERTY_REVISION_SITES.filter(({ nodeTypes }) => nodeTypes.some((name) => name === nodeTypeName));
4
60
  /**
5
61
  * Which carrier each paragraph-mark kind reports as. A relocation's break
6
62
  * resolves as the insertion or deletion it is; the kind exists so a reader is
@@ -17,7 +73,8 @@ const PARAGRAPH_MARK_KIND_CARRIERS = {
17
73
  };
18
74
  const isParagraphMarkChangeKind = (value) => PARAGRAPH_MARK_CHANGE_KINDS.some((kind) => kind === value);
19
75
  const isObjectRecord = (value) => typeof value === "object" && value !== null;
20
- const revisionMetadata = (value) => {
76
+ /** The `w:id`, author and date a stored revision's `info` carries, or null. */
77
+ const propertyRevisionMetadata = (value) => {
21
78
  if (!isObjectRecord(value) || typeof value["id"] !== "number") return null;
22
79
  return {
23
80
  id: value["id"],
@@ -25,12 +82,21 @@ const revisionMetadata = (value) => {
25
82
  date: typeof value["date"] === "string" ? value["date"] : null
26
83
  };
27
84
  };
85
+ /** The record array a site names, walked from a node's attrs. */
86
+ const propertyRevisionRecords = (node, site) => {
87
+ const path = site.resolution === "node-attrs" ? [site.attr] : site.path;
88
+ let value = node.attrs;
89
+ for (const key of path) {
90
+ if (!isObjectRecord(value)) return [];
91
+ value = value[key];
92
+ }
93
+ return Array.isArray(value) ? value.filter(isObjectRecord) : [];
94
+ };
28
95
  const appendPropertyCarriers = ({ carriers, changes, type, node, from, to }) => {
29
- if (!Array.isArray(changes)) return;
30
96
  let text = null;
31
97
  for (const change of changes) {
32
98
  if (!isObjectRecord(change)) continue;
33
- const metadata = revisionMetadata(change["info"]);
99
+ const metadata = propertyRevisionMetadata(change["info"]);
34
100
  if (!metadata) continue;
35
101
  text ??= node.textContent;
36
102
  carriers.push({
@@ -49,76 +115,36 @@ const appendPropertyCarriers = ({ carriers, changes, type, node, from, to }) =>
49
115
  const getFolioNodeRevisionCarriers = (node, nodePos) => {
50
116
  const carriers = [];
51
117
  if (node.type.name === "paragraph") {
52
- const from = nodePos + node.nodeSize - 1;
53
- const to = nodePos + node.nodeSize;
54
- const paragraphAttrs = expectParagraphAttrs(node);
55
118
  const paragraphMark = node.attrs["pPrMark"];
56
119
  const paragraphMarkKind = isObjectRecord(paragraphMark) && isParagraphMarkChangeKind(paragraphMark["kind"]) ? PARAGRAPH_MARK_KIND_CARRIERS[paragraphMark["kind"]] : void 0;
57
120
  if (paragraphMarkKind !== void 0 && isObjectRecord(paragraphMark)) {
58
- const metadata = revisionMetadata(paragraphMark["info"]);
121
+ const metadata = propertyRevisionMetadata(paragraphMark["info"]);
59
122
  if (metadata) carriers.push({
60
123
  ...metadata,
61
124
  type: paragraphMarkKind,
62
125
  text: node.textContent,
63
- from,
64
- to
126
+ from: nodePos + node.nodeSize - 1,
127
+ to: nodePos + node.nodeSize
65
128
  });
66
129
  }
130
+ }
131
+ for (const site of nodePropertyRevisionSites(node.type.name)) {
132
+ const range = site.range === "paragraph-boundary" ? {
133
+ from: nodePos + node.nodeSize - 1,
134
+ to: nodePos + node.nodeSize
135
+ } : {
136
+ from: nodePos,
137
+ to: nodePos + node.nodeSize
138
+ };
67
139
  appendPropertyCarriers({
68
140
  carriers,
69
- changes: paragraphAttrs._propertyChanges,
70
- type: "paragraphPropertiesChanged",
71
- node,
72
- from,
73
- to
74
- });
75
- const sectionProperties = node.attrs["_sectionProperties"];
76
- appendPropertyCarriers({
77
- carriers,
78
- changes: isObjectRecord(sectionProperties) ? sectionProperties["propertyChanges"] : null,
79
- type: "sectionPropertiesChanged",
141
+ changes: propertyRevisionRecords(node, site),
142
+ type: site.carrier,
80
143
  node,
81
- from,
82
- to
144
+ ...range
83
145
  });
84
- return carriers;
85
- }
86
- const range = {
87
- from: nodePos,
88
- to: nodePos + node.nodeSize
89
- };
90
- switch (node.type.name) {
91
- case "table":
92
- appendPropertyCarriers({
93
- carriers,
94
- changes: node.attrs["tblPrChange"],
95
- type: "tablePropertiesChanged",
96
- node,
97
- ...range
98
- });
99
- break;
100
- case "tableRow":
101
- appendPropertyCarriers({
102
- carriers,
103
- changes: node.attrs["trPrChange"],
104
- type: "rowPropertiesChanged",
105
- node,
106
- ...range
107
- });
108
- break;
109
- case "tableCell":
110
- case "tableHeader":
111
- appendPropertyCarriers({
112
- carriers,
113
- changes: node.attrs["tcPrChange"],
114
- type: "cellPropertiesChanged",
115
- node,
116
- ...range
117
- });
118
- break;
119
- default: break;
120
146
  }
121
147
  return carriers;
122
148
  };
123
149
  //#endregion
124
- export { getFolioNodeRevisionCarriers };
150
+ export { PROPERTY_REVISION_SITES, getFolioNodeRevisionCarriers, nodePropertyRevisionSites, propertyRevisionMetadata, propertyRevisionRecords };
@@ -17,8 +17,10 @@ declare const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS: Readonly<{
17
17
  readonly hardBreak: "break-run";
18
18
  readonly image: "not-a-run";
19
19
  readonly math: "not-a-run";
20
+ readonly moveRangeBoundary: "not-a-run";
20
21
  readonly pageBreakRun: "page-break-carrier";
21
22
  readonly preservedXml: "preserved-xml-run";
23
+ readonly rangeAnchor: "not-a-run";
22
24
  readonly renderedPageBreak: "not-a-run";
23
25
  readonly shape: "not-a-run";
24
26
  readonly structuredField: "structured-field";
@@ -18,8 +18,10 @@ const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS = Object.freeze({
18
18
  hardBreak: "break-run",
19
19
  image: "not-a-run",
20
20
  math: "not-a-run",
21
+ moveRangeBoundary: "not-a-run",
21
22
  pageBreakRun: "page-break-carrier",
22
23
  preservedXml: "preserved-xml-run",
24
+ rangeAnchor: "not-a-run",
23
25
  renderedPageBreak: "not-a-run",
24
26
  shape: "not-a-run",
25
27
  structuredField: "structured-field",
@@ -0,0 +1,28 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ import { RunIdentityMarkAttrs } from "./schema/marks.js";
3
+ //#region src/prosemirror/runIdentity.d.ts
4
+ /** The DOM attribute that carries a run's identity through copy and paste. */
5
+ declare const RUN_IDENTITY_ATTRIBUTE = "data-docx-run-identity";
6
+ /** The schema name of the mark these attrs belong to. */
7
+ declare const RUN_IDENTITY_MARK_NAME = "runIdentity";
8
+ /**
9
+ * What a run carries beside its id: absent fields left absent, empty
10
+ * collections normalised to absent so a run with nothing to carry keys the
11
+ * same however it was built.
12
+ */
13
+ type RunIdentityPayload = {
14
+ preservedAttributes?: readonly document_d_exports.PreservedAttribute[] | undefined;
15
+ preserved?: document_d_exports.PreservedMarkup | undefined;
16
+ };
17
+ /** A run identity's attrs in canonical form. */
18
+ declare const runIdentityAttrs: (id: number, { preservedAttributes, preserved }?: RunIdentityPayload) => RunIdentityMarkAttrs;
19
+ /**
20
+ * Whether a run holds markup the mark exists to carry.
21
+ *
22
+ * The mint condition, minus the page break: a run with neither remainder nor
23
+ * sink and no break to rejoin its leaves across needs no identity, and 57.5%
24
+ * of corpus files hold none.
25
+ */
26
+ declare const hasRunIdentityPayload: ({ preservedAttributes, preserved }: RunIdentityPayload) => boolean;
27
+ //#endregion
28
+ export { RUN_IDENTITY_ATTRIBUTE, RUN_IDENTITY_MARK_NAME, RunIdentityPayload, hasRunIdentityPayload, runIdentityAttrs };