@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
@@ -0,0 +1,183 @@
1
+ import { BOOKMARK_BOUNDARY_NODE_NAME } from "./extensions/nodes/BookmarkBoundaryExtension.js";
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";
5
+ import { TEXT_BOX_ANCHOR_NODE_NAME } from "./extensions/nodes/TextBoxAnchorExtension.js";
6
+ import { readMoveRangeBoundaryAttrs } from "./moveRangeBoundaryAttrs.js";
7
+ import { Fragment, Mark } from "prosemirror-model";
8
+ //#region src/prosemirror/replacedAnnotations.ts
9
+ /**
10
+ * What survives when an edit replaces a span of inline content.
11
+ *
12
+ * ProseMirror gives a replacement the marks it inherits at the boundary, and
13
+ * drops any mark declared `inclusive: false` once the span reaches the end of
14
+ * what that mark covers. For formatting that is right. For a mark that names
15
+ * something outside itself — the comment this text is commented by, the
16
+ * address this text links to — it is not: the target survives the edit, and
17
+ * only the mark saying so is lost. A comment loses the range start that lived
18
+ * on the replaced text, so the save emits a `commentRangeEnd` with no
19
+ * `commentRangeStart`, invalid OOXML and a comment anchored to nothing; a
20
+ * hyperlink simply stops being a link. Zero-width anchors fare worse still: a
21
+ * plain replace deletes them outright.
22
+ *
23
+ * Word moves a range start that sits inside a replaced span to the beginning
24
+ * of the replacement and lets the range keep covering the new text; it keeps
25
+ * a link across a replacement of its display text. A range wholly inside the
26
+ * span collapses onto the replacement, and disappears only when every
27
+ * character it covered is gone. One rule per marker kind, and that is the
28
+ * whole contract:
29
+ *
30
+ * - `comment` mark: the replacement carries every comment the span covered, so
31
+ * a range that started inside it starts at the replacement instead.
32
+ * - `hyperlink` mark: the replacement carries the first link the span held, so
33
+ * replacing a link's display text leaves the link on the new text. A span
34
+ * crossing two links keeps the one it opens in, because the mark excludes
35
+ * itself and a replacement is one run of text with one address.
36
+ * - `footnoteRef` mark (footnotes and endnotes alike): not carried. It marks
37
+ * the reference's own number, not prose around it, and it serializes as a
38
+ * bare `w:footnoteReference` run, so carrying it onto a replacement would
39
+ * discard the new text. Replacing a reference's text deletes the reference,
40
+ * as deleting that text does.
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.
46
+ * - tracked-change marks (`insertion`, `deletion`, `runPropertyChange`): not
47
+ * carried. The applier decides them per edit mode and writes them itself.
48
+ * - `inlineWrapper` mark: not carried. Every wrapper kind states something
49
+ * about the text under it and names nothing outside itself, so boundary
50
+ * inheritance is the right rule: a replacement inside a bidirectional
51
+ * override is still inside it, and one that replaces the whole of it is not.
52
+ * - `commentReference` node: kept after the replacement, where the comment's
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.
59
+ * - `bookmarkBoundary` node: a start kept before the replacement, an end after
60
+ * it, so the bookmark still covers the new text.
61
+ * - `textBoxAnchor` node: kept after the replacement; the shape it anchors
62
+ * outlives the sentence it was typed into.
63
+ * - `renderedPageBreak` node: dropped with the text. It is Word's cached
64
+ * pagination, re-derived on layout, and nothing else names it.
65
+ * - every other mark: formatting, and left to boundary inheritance, which
66
+ * already gives the replacement the formatting of the text it replaces.
67
+ *
68
+ * Deleting the whole of a comment's span leaves it no mark anywhere, so
69
+ * `CommentReferenceExtension` drops the orphan reference and the save drops
70
+ * the comment: the one case where a range is meant to disappear.
71
+ */
72
+ /**
73
+ * What a replacement does with each mark the schema declares
74
+ * `inclusive: false`. Boundary inheritance already handles every other mark,
75
+ * so this table is exactly the set that needs a decision; a new
76
+ * non-inclusive mark that is missing from it fails
77
+ * `replacedAnnotations.test.ts` rather than silently following the text.
78
+ */
79
+ const NON_INCLUSIVE_MARK_DISPOSITION = {
80
+ comment: "carry",
81
+ hyperlink: "carry",
82
+ footnoteRef: "followsTheText",
83
+ runIdentity: "followsTheText",
84
+ insertion: "followsTheText",
85
+ deletion: "followsTheText",
86
+ runPropertyChange: "followsTheText",
87
+ inlineWrapper: "followsTheText"
88
+ };
89
+ /** The mark names in the schema that a replacement must not silently drop. */
90
+ const nonInclusiveMarkNames = (schema) => Object.entries(schema.marks).filter(([, type]) => type.spec.inclusive === false).map(([name]) => name);
91
+ const isCarried = (mark) => NON_INCLUSIVE_MARK_DISPOSITION[mark.type.name] === "carry";
92
+ /** Anchors an edit must put back, and where relative to the replacement. */
93
+ const ANCHOR_PLACEMENT = {
94
+ [COMMENT_REFERENCE_NODE_NAME]: "after",
95
+ [RANGE_ANCHOR_NODE_NAME]: "after",
96
+ [TEXT_BOX_ANCHOR_NODE_NAME]: "after",
97
+ [BOOKMARK_BOUNDARY_NODE_NAME]: "byBoundaryType",
98
+ [MOVE_RANGE_BOUNDARY_NODE_NAME]: "byMoveBoundaryType"
99
+ };
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
+ };
107
+ const NOTHING_REPLACED = {
108
+ carried: [],
109
+ leading: [],
110
+ trailing: []
111
+ };
112
+ const hasReplacedAnnotations = ({ carried, leading, trailing }) => carried.length > 0 || leading.length > 0 || trailing.length > 0;
113
+ /**
114
+ * The annotations carried by `[from, to)`. An anchor counts only when the
115
+ * range covers it whole: a partially covered atom is not deleted by the
116
+ * replacement either.
117
+ */
118
+ const surveyReplacedAnnotations = (doc, from, to) => {
119
+ if (to <= from) return NOTHING_REPLACED;
120
+ const carried = [];
121
+ const leading = [];
122
+ const trailing = [];
123
+ doc.nodesBetween(from, to, (node, position) => {
124
+ if (!node.isInline) return true;
125
+ for (const mark of node.marks) if (isCarried(mark) && !alreadyCarried(mark, carried)) carried.push(mark);
126
+ const placement = anchorPlacement(node);
127
+ if (placement === void 0 || position < from || position + node.nodeSize > to) return false;
128
+ (opensRange(node, placement) ? leading : trailing).push(node);
129
+ return false;
130
+ });
131
+ return {
132
+ carried,
133
+ leading,
134
+ trailing
135
+ };
136
+ };
137
+ /**
138
+ * Whether the span already contributed this mark, or one the mark would evict.
139
+ * Comments do not exclude each other, so every comment is collected; a
140
+ * hyperlink excludes its own type, so the first address in the span wins
141
+ * rather than the last silently overwriting it.
142
+ */
143
+ const alreadyCarried = (mark, carried) => carried.some((other) => other.eq(mark) || mark.type.excludes(other.type));
144
+ const anchorsSize = (anchors) => {
145
+ let size = 0;
146
+ for (const node of anchors) size += node.nodeSize;
147
+ return size;
148
+ };
149
+ /** `marks` with the carried marks added, each type's exclusions respected. */
150
+ const addCarriedMarks = (marks, carried) => {
151
+ let next = marks;
152
+ for (const mark of carried) next = mark.addToSet(next);
153
+ return next;
154
+ };
155
+ const withCarriedMarks = (node, carried) => node.mark(addCarriedMarks(node.marks, carried));
156
+ /** `content` with the surveyed marks on it and the surveyed anchors around it. */
157
+ const annotatedReplacement = ({ annotations: { carried, leading, trailing }, content }) => {
158
+ const inline = [];
159
+ content.forEach((child) => {
160
+ inline.push(carried.length === 0 ? child : withCarriedMarks(child, carried));
161
+ });
162
+ const fragment = Fragment.fromArray([
163
+ ...leading,
164
+ ...inline,
165
+ ...trailing
166
+ ]);
167
+ const leadingSize = anchorsSize(leading);
168
+ return {
169
+ fragment,
170
+ leadingSize,
171
+ contentSize: fragment.size - leadingSize - anchorsSize(trailing)
172
+ };
173
+ };
174
+ /**
175
+ * The marks a replacement inherits at `[from, to)`, exactly as
176
+ * `Transaction.insertText` would compute them.
177
+ */
178
+ const inheritedReplacementMarks = (doc, from, to) => {
179
+ const $from = doc.resolve(from);
180
+ return (to === from ? $from.marks() : $from.marksAcross(doc.resolve(to))) ?? Mark.none;
181
+ };
182
+ //#endregion
183
+ export { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, surveyReplacedAnnotations };
@@ -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 };
@@ -1,7 +1,7 @@
1
1
  import { Transaction } from "prosemirror-state";
2
2
  import { Mark, Node } from "prosemirror-model";
3
3
  //#region src/prosemirror/runFormattingInlineCarriers.d.ts
4
- type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run" | "page-break-carrier" | "structured-field" | "symbol-run" | "tab-run" | "text-run";
4
+ type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run" | "page-break-carrier" | "preserved-xml-run" | "structured-field" | "symbol-run" | "tab-run" | "text-run";
5
5
  /**
6
6
  * How every inline atom maps to a serialized run-formatting carrier.
7
7
  *
@@ -12,11 +12,15 @@ type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run
12
12
  */
13
13
  declare const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS: Readonly<{
14
14
  readonly bookmarkBoundary: "not-a-run";
15
+ readonly commentReference: "not-a-run";
15
16
  readonly field: "field-run";
16
17
  readonly hardBreak: "break-run";
17
18
  readonly image: "not-a-run";
18
19
  readonly math: "not-a-run";
20
+ readonly moveRangeBoundary: "not-a-run";
19
21
  readonly pageBreakRun: "page-break-carrier";
22
+ readonly preservedXml: "preserved-xml-run";
23
+ readonly rangeAnchor: "not-a-run";
20
24
  readonly renderedPageBreak: "not-a-run";
21
25
  readonly shape: "not-a-run";
22
26
  readonly structuredField: "structured-field";
@@ -1,5 +1,5 @@
1
1
  import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
2
- import { expectFieldAttrs, expectSymbolAttrs } from "./attrs/index.js";
2
+ import { expectFieldAttrs, expectPreservedXmlAttrs, expectSymbolAttrs } from "./attrs/index.js";
3
3
  import { panic } from "better-result";
4
4
  import { Mark } from "prosemirror-model";
5
5
  //#region src/prosemirror/runFormattingInlineCarriers.ts
@@ -13,11 +13,15 @@ import { Mark } from "prosemirror-model";
13
13
  */
14
14
  const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS = Object.freeze({
15
15
  bookmarkBoundary: "not-a-run",
16
+ commentReference: "not-a-run",
16
17
  field: "field-run",
17
18
  hardBreak: "break-run",
18
19
  image: "not-a-run",
19
20
  math: "not-a-run",
21
+ moveRangeBoundary: "not-a-run",
20
22
  pageBreakRun: "page-break-carrier",
23
+ preservedXml: "preserved-xml-run",
24
+ rangeAnchor: "not-a-run",
21
25
  renderedPageBreak: "not-a-run",
22
26
  shape: "not-a-run",
23
27
  structuredField: "structured-field",
@@ -32,6 +36,7 @@ const CONTROL_CHARACTER_BY_DISPOSITION = Object.freeze({
32
36
  "field-run": null,
33
37
  "not-a-run": null,
34
38
  "page-break-carrier": null,
39
+ "preserved-xml-run": null,
35
40
  "structured-field": null,
36
41
  "symbol-run": null,
37
42
  "tab-run": " ",
@@ -162,6 +167,7 @@ const runFormattingCarrierReviewText = (carrier) => {
162
167
  const { char } = expectSymbolAttrs(carrier.node);
163
168
  return decodeOoxmlSymbolCharacter(char) ?? "�";
164
169
  }
170
+ case "preserved-xml-run": return expectPreservedXmlAttrs(carrier.node).text;
165
171
  case "field-run":
166
172
  case "structured-field": return expectFieldAttrs(carrier.node).displayText ?? carrier.node.textContent;
167
173
  }
@@ -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 };
@@ -0,0 +1,36 @@
1
+ //#region src/prosemirror/runIdentity.ts
2
+ /** The DOM attribute that carries a run's identity through copy and paste. */
3
+ const RUN_IDENTITY_ATTRIBUTE = "data-docx-run-identity";
4
+ /** The schema name of the mark these attrs belong to. */
5
+ const RUN_IDENTITY_MARK_NAME = "runIdentity";
6
+ /** One remainder entry with its keys in canonical order. */
7
+ const preservedAttribute = ({ namespace, name, value }) => namespace === void 0 ? {
8
+ name,
9
+ value
10
+ } : {
11
+ namespace,
12
+ name,
13
+ value
14
+ };
15
+ /** The property-set sink with its keys in canonical order. */
16
+ const preservedMarkup = ({ children }) => ({ children: (children ?? []).map(({ index, xml }) => ({
17
+ index,
18
+ xml
19
+ })) });
20
+ /** A run identity's attrs in canonical form. */
21
+ const runIdentityAttrs = (id, { preservedAttributes, preserved } = {}) => {
22
+ const attrs = { id };
23
+ if (preservedAttributes && preservedAttributes.length > 0) attrs.preservedAttributes = preservedAttributes.map(preservedAttribute);
24
+ if (preserved && (preserved.children?.length ?? 0) > 0) attrs.preserved = preservedMarkup(preserved);
25
+ return attrs;
26
+ };
27
+ /**
28
+ * Whether a run holds markup the mark exists to carry.
29
+ *
30
+ * The mint condition, minus the page break: a run with neither remainder nor
31
+ * sink and no break to rejoin its leaves across needs no identity, and 57.5%
32
+ * of corpus files hold none.
33
+ */
34
+ const hasRunIdentityPayload = ({ preservedAttributes, preserved }) => (preservedAttributes?.length ?? 0) > 0 || (preserved?.children?.length ?? 0) > 0;
35
+ //#endregion
36
+ export { RUN_IDENTITY_ATTRIBUTE, RUN_IDENTITY_MARK_NAME, hasRunIdentityPayload, runIdentityAttrs };
@@ -21,7 +21,7 @@ const hasDirectRunFormatting = (formatting) => {
21
21
  return Object.entries(formatting).some(([property, value]) => property !== "styleId" && value !== void 0);
22
22
  };
23
23
  const stripParagraphMarkOnlyFormatting = (formatting) => {
24
- const { allCaps: _allCaps, highlight: _highlight, shading: _shading, smallCaps: _smallCaps, vertAlign: _vertAlign, ...formattingForBody } = formatting;
24
+ const { allCaps: _allCaps, highlight: _highlight, shading: _shading, smallCaps: _smallCaps, vertAlign: _vertAlign, preserved: _preserved, ...formattingForBody } = formatting;
25
25
  return Object.keys(formattingForBody).length > 0 ? formattingForBody : void 0;
26
26
  };
27
27
  const stripParagraphMarkFormattingForBodyRuns = (formatting) => {
@@ -1,5 +1,5 @@
1
- import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
2
- import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
1
+ import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperKind, InlineWrapperLayer, LanguageAttrs, RunFormattingOverrideAttrs, RunIdentityMarkAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
2
+ import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
3
3
  import { ExtensionManager } from "../extensions/ExtensionManager.js";
4
4
  //#region src/prosemirror/schema/index.d.ts
5
5
  declare const singletonManager: ExtensionManager;
@@ -11,4 +11,4 @@ type DocxSchema = typeof schema;
11
11
  type DocxNode = ReturnType<typeof schema.node>;
12
12
  type DocxMark = ReturnType<typeof schema.mark>;
13
13
  //#endregion
14
- export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type PageBreakRunOwnerMarkAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type RunFormattingOverrideAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
14
+ export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type InlineWrapperAttrs, type InlineWrapperKind, type InlineWrapperLayer, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type PreservedBlockAttrs, type PreservedXmlAttrs, type PreservedXmlLevel, type RunFormattingOverrideAttrs, type RunIdentityMarkAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };