@stll/folio-core 0.46.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 (366) hide show
  1. package/dist/ai-edits/apply.js +26 -24
  2. package/dist/ai-edits/headless.js +1 -1
  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/content-alignment.js +108 -12
  10. package/dist/compare/content-types.d.ts +8 -2
  11. package/dist/compare/content.js +2 -11
  12. package/dist/compare/plan.js +7 -4
  13. package/dist/compare/section-boundary-properties.js +1 -2
  14. package/dist/content-controls/checkboxDisplay.d.ts +8 -2
  15. package/dist/content-controls/checkboxDisplay.js +11 -5
  16. package/dist/content-controls/mutateContentControls.js +41 -42
  17. package/dist/controller/layoutPipeline.js +8 -3
  18. package/dist/display-list/build/buildDisplayList.js +7 -7
  19. package/dist/display-list/build/imagePrimitives.d.ts +4 -4
  20. package/dist/display-list/build/imagePrimitives.js +38 -20
  21. package/dist/display-list/build/pageBorderPrimitives.js +2 -1
  22. package/dist/display-list/build/paragraphPrimitives.js +93 -13
  23. package/dist/display-list/build/previewPrimitives.d.ts +10 -0
  24. package/dist/display-list/build/previewPrimitives.js +89 -0
  25. package/dist/display-list/build/strokes.d.ts +177 -8
  26. package/dist/display-list/build/strokes.js +167 -47
  27. package/dist/display-list/build/tablePrimitives.js +4 -2
  28. package/dist/display-list/build/textBoxPrimitives.js +6 -4
  29. package/dist/display-list/build/textDecorations.d.ts +15 -1
  30. package/dist/display-list/build/textDecorations.js +15 -1
  31. package/dist/display-list/dom/renderDisplayListToDom.js +1 -19
  32. package/dist/display-list/primitives.d.ts +13 -2
  33. package/dist/display-list/primitives.js +36 -1
  34. package/dist/document-operations.js +2 -1
  35. package/dist/docx/attributeRemainder.d.ts +34 -1
  36. package/dist/docx/attributeRemainder.js +49 -3
  37. package/dist/docx/blockContentParser.d.ts +2 -0
  38. package/dist/docx/blockContentParser.js +39 -67
  39. package/dist/docx/blockPlainText.js +3 -1
  40. package/dist/docx/borderParser.js +26 -11
  41. package/dist/docx/builtInStyles.d.ts +8 -16
  42. package/dist/docx/builtInStyles.js +54 -17
  43. package/dist/docx/commentAnchorIndex.js +1 -1
  44. package/dist/docx/commentParser.js +3 -3
  45. package/dist/docx/commentRangeIntegrity.js +1 -1
  46. package/dist/docx/commentRangeJoin.js +1 -1
  47. package/dist/docx/commentReferenceNormalization.js +3 -2
  48. package/dist/docx/commentReplyMarkers.js +1 -1
  49. package/dist/docx/compatibility.js +56 -42
  50. package/dist/docx/containerChildren.d.ts +110 -13
  51. package/dist/docx/containerChildren.gen.d.ts +16 -1
  52. package/dist/docx/containerChildren.gen.js +18 -1
  53. package/dist/docx/containerChildren.js +63 -13
  54. package/dist/docx/diagramPreview.d.ts +14 -2
  55. package/dist/docx/diagramPreview.js +81 -169
  56. package/dist/docx/documentParser.js +4 -1
  57. package/dist/docx/drawingAnchor.d.ts +87 -0
  58. package/dist/docx/drawingAnchor.js +201 -0
  59. package/dist/docx/drawingUtils.d.ts +43 -38
  60. package/dist/docx/drawingUtils.js +205 -118
  61. package/dist/docx/fontTableParser.js +102 -41
  62. package/dist/docx/footnoteParser.js +10 -6
  63. package/dist/docx/groupDrawingParser.js +4 -3
  64. package/dist/docx/headerFooterReferenceNormalization.js +1 -1
  65. package/dist/docx/hyperlinkParser.d.ts +45 -7
  66. package/dist/docx/hyperlinkParser.js +126 -57
  67. package/dist/docx/imageParser.js +127 -107
  68. package/dist/docx/index.d.ts +2 -1
  69. package/dist/docx/index.js +2 -1
  70. package/dist/docx/inlineContentRemovals.d.ts +28 -0
  71. package/dist/docx/inlineContentRemovals.js +46 -0
  72. package/dist/docx/inlineWrapperContent.d.ts +84 -3
  73. package/dist/docx/inlineWrapperContent.js +85 -4
  74. package/dist/docx/inlineWrapperParser.d.ts +11 -0
  75. package/dist/docx/inlineWrapperParser.js +60 -0
  76. package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
  77. package/dist/docx/normalizeBaseDirection.js +4 -2
  78. package/dist/docx/numberingParser.d.ts +25 -2
  79. package/dist/docx/numberingParser.js +264 -361
  80. package/dist/docx/numberingReference.d.ts +9 -16
  81. package/dist/docx/numberingReference.js +17 -16
  82. package/dist/docx/numberingReferenceNormalization.js +7 -7
  83. package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
  84. package/dist/docx/ooxmlCounterFormatter.js +4 -1
  85. package/dist/docx/paraIdAttribute.d.ts +91 -1
  86. package/dist/docx/paraIdAttribute.js +79 -1
  87. package/dist/docx/paragraphParser.d.ts +9 -24
  88. package/dist/docx/paragraphParser.js +212 -396
  89. package/dist/docx/paragraphProperties.d.ts +23 -0
  90. package/dist/docx/paragraphProperties.js +279 -0
  91. package/dist/docx/paragraphPropertySource.js +2 -0
  92. package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
  93. package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
  94. package/dist/docx/paragraphTraversal.d.ts +14 -10
  95. package/dist/docx/paragraphTraversal.js +47 -49
  96. package/dist/docx/parseWarningMessage.js +3 -0
  97. package/dist/docx/parserEnums.d.ts +6 -8
  98. package/dist/docx/parserEnums.js +4 -6
  99. package/dist/docx/preservedRunContent.js +16 -6
  100. package/dist/docx/previewBudget.d.ts +44 -23
  101. package/dist/docx/previewBudget.js +61 -30
  102. package/dist/docx/propertyElementAttributes.d.ts +178 -0
  103. package/dist/docx/propertyElementAttributes.js +114 -0
  104. package/dist/docx/renderedPageBreakNormalization.js +2 -2
  105. package/dist/docx/rezip.d.ts +28 -2
  106. package/dist/docx/rezip.js +78 -9
  107. package/dist/docx/runConsolidator.d.ts +42 -2
  108. package/dist/docx/runConsolidator.js +60 -6
  109. package/dist/docx/runParser.d.ts +54 -18
  110. package/dist/docx/runParser.js +379 -295
  111. package/dist/docx/runPayload.d.ts +5 -0
  112. package/dist/docx/runPayload.js +4 -0
  113. package/dist/docx/sdtProperties.d.ts +39 -5
  114. package/dist/docx/sdtProperties.js +205 -84
  115. package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
  116. package/dist/docx/sdtPropertiesPatch.js +68 -112
  117. package/dist/docx/sectionParser.d.ts +1 -2
  118. package/dist/docx/sectionParser.js +236 -240
  119. package/dist/docx/selectiveSave.js +3 -2
  120. package/dist/docx/selectiveXmlPatch.d.ts +21 -2
  121. package/dist/docx/selectiveXmlPatch.js +195 -99
  122. package/dist/docx/serializer/blockSdtSerializer.js +2 -96
  123. package/dist/docx/serializer/borderSerializer.d.ts +5 -5
  124. package/dist/docx/serializer/borderSerializer.js +10 -8
  125. package/dist/docx/serializer/documentSerializer.js +3 -0
  126. package/dist/docx/serializer/fontTableSerializer.js +31 -3
  127. package/dist/docx/serializer/headerFooterSerializer.js +3 -0
  128. package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
  129. package/dist/docx/serializer/markupRangeAttributes.js +9 -1
  130. package/dist/docx/serializer/noteSerializer.js +3 -0
  131. package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
  132. package/dist/docx/serializer/numberingSerializer.js +81 -79
  133. package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
  134. package/dist/docx/serializer/paragraphSerializer.js +88 -188
  135. package/dist/docx/serializer/runSerializer.d.ts +1 -5
  136. package/dist/docx/serializer/runSerializer.js +109 -59
  137. package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
  138. package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
  139. package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
  140. package/dist/docx/serializer/settingsSerializer.js +6 -4
  141. package/dist/docx/serializer/stylesSerializer.js +8 -11
  142. package/dist/docx/serializer/tableSerializer.js +268 -100
  143. package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
  144. package/dist/docx/serializer/textFormattingSerializer.js +111 -101
  145. package/dist/docx/serializer/xmlUtils.d.ts +1 -1
  146. package/dist/docx/serializer/xmlUtils.js +1 -1
  147. package/dist/docx/server/createBilingualDocument.js +18 -16
  148. package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
  149. package/dist/docx/settingsParser.js +7 -4
  150. package/dist/docx/shadingParser.d.ts +2 -1
  151. package/dist/docx/shadingParser.js +43 -7
  152. package/dist/docx/shapeParser.js +8 -3
  153. package/dist/docx/strictNames.d.ts +11 -0
  154. package/dist/docx/strictNames.gen.d.ts +45 -0
  155. package/dist/docx/strictNames.gen.js +50 -0
  156. package/dist/docx/strictNames.js +43 -0
  157. package/dist/docx/strictValueEncodings.gen.js +133 -131
  158. package/dist/docx/styleParser.js +17 -349
  159. package/dist/docx/tableParser.d.ts +10 -1
  160. package/dist/docx/tableParser.js +505 -181
  161. package/dist/docx/textBoxParser.d.ts +3 -1
  162. package/dist/docx/textBoxParser.js +18 -8
  163. package/dist/docx/themeColorAttribute.d.ts +13 -0
  164. package/dist/docx/themeColorAttribute.js +24 -0
  165. package/dist/docx/trackedMoveRangeNormalization.js +2 -1
  166. package/dist/docx/vmlImageParser.d.ts +13 -4
  167. package/dist/docx/vmlImageParser.js +74 -31
  168. package/dist/docx/vmlPreview.js +2 -2
  169. package/dist/docx/wrapPolygon.d.ts +30 -0
  170. package/dist/docx/wrapPolygon.js +70 -0
  171. package/dist/docx/xmlParser.d.ts +14 -1
  172. package/dist/docx/xmlParser.js +18 -2
  173. package/dist/fonts/embeddedFonts.js +3 -3
  174. package/dist/headless-layout.js +2 -0
  175. package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
  176. package/dist/i18n/messages/catalogs.gen.js +102 -34
  177. package/dist/i18n/messages/messages.gen.d.ts +4 -0
  178. package/dist/internal/headlessRevisionResolution.js +9 -0
  179. package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
  180. package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
  181. package/dist/internal/paragraphFormattingSerialization.js +118 -83
  182. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  183. package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
  184. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  185. package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
  186. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
  187. package/dist/layout-bridge/convert/toFlowBlocks.js +177 -101
  188. package/dist/layout-engine/index.d.ts +2 -2
  189. package/dist/layout-engine/index.js +53 -17
  190. package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
  191. package/dist/layout-engine/measure/measureBlocks.js +6 -10
  192. package/dist/layout-engine/measure/tableCellGrid.js +2 -1
  193. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
  194. package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
  195. package/dist/layout-engine/paragraphSequence.js +3 -2
  196. package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
  197. package/dist/layout-engine/section-breaks.d.ts +49 -2
  198. package/dist/layout-engine/section-breaks.js +55 -4
  199. package/dist/layout-engine/types.d.ts +47 -17
  200. package/dist/layout-engine/types.js +16 -1
  201. package/dist/layout-painter/borderStroke.d.ts +18 -4
  202. package/dist/layout-painter/renderPage.js +6 -4
  203. package/dist/layout-painter/renderParagraph.d.ts +2 -1
  204. package/dist/layout-painter/renderParagraph.js +13 -26
  205. package/dist/layout-painter/renderTable.d.ts +4 -1
  206. package/dist/layout-painter/renderTable.js +22 -22
  207. package/dist/layout-painter/renderTextBox.js +5 -3
  208. package/dist/markdown/renderBlock.js +3 -1
  209. package/dist/markdown/renderRuns.js +7 -2
  210. package/dist/markdown/renderTable.js +2 -1
  211. package/dist/model.d.ts +3 -3
  212. package/dist/model.js +2 -2
  213. package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
  214. package/dist/paged-layout/sectionBlockWidths.js +26 -4
  215. package/dist/prosemirror/attrs/index.d.ts +22 -4
  216. package/dist/prosemirror/attrs/index.js +498 -60
  217. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
  218. package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
  219. package/dist/prosemirror/commands/comments.js +68 -53
  220. package/dist/prosemirror/commands/contentControls.js +24 -19
  221. package/dist/prosemirror/commands/image.d.ts +1 -1
  222. package/dist/prosemirror/commands/image.js +4 -1
  223. package/dist/prosemirror/commands/paragraph.d.ts +2 -1
  224. package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
  225. package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
  226. package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
  227. package/dist/prosemirror/commands/sectionBreak.js +187 -11
  228. package/dist/prosemirror/conversion/fromProseDoc.d.ts +18 -2
  229. package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
  230. package/dist/prosemirror/conversion/index.d.ts +2 -2
  231. package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
  232. package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
  233. package/dist/prosemirror/conversion/runShadingMark.js +14 -1
  234. package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
  235. package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
  236. package/dist/prosemirror/conversion/toProseDoc.js +371 -141
  237. package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
  238. package/dist/prosemirror/emptyRangeAnchor.js +158 -0
  239. package/dist/prosemirror/extensions/StarterKit.js +8 -2
  240. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  241. package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
  242. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  243. package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
  244. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
  245. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
  246. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
  247. package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
  248. package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
  249. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
  250. package/dist/prosemirror/extensions/markRegistry.d.ts +26 -2
  251. package/dist/prosemirror/extensions/markRegistry.js +73 -10
  252. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
  253. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
  254. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
  255. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
  256. package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
  257. package/dist/prosemirror/extensions/marks/markUtils.js +2 -1
  258. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
  259. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
  260. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
  261. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
  262. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
  263. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +10 -0
  264. package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -1
  265. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
  266. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
  267. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
  268. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
  269. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
  270. package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
  271. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +4 -0
  272. package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
  273. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
  274. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
  275. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
  276. package/dist/prosemirror/extensions/types.d.ts +12 -3
  277. package/dist/prosemirror/index.d.ts +4 -2
  278. package/dist/prosemirror/index.js +2 -1
  279. package/dist/prosemirror/inlineWrapperStack.js +20 -3
  280. package/dist/prosemirror/listMarker.d.ts +2 -2
  281. package/dist/prosemirror/listMarker.js +7 -8
  282. package/dist/prosemirror/listRenderingAttrs.js +11 -1
  283. package/dist/prosemirror/listState.d.ts +62 -0
  284. package/dist/prosemirror/listState.js +49 -0
  285. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
  286. package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
  287. package/dist/prosemirror/numberedRefFields.js +4 -4
  288. package/dist/prosemirror/numberingAttr.d.ts +55 -0
  289. package/dist/prosemirror/numberingAttr.js +74 -0
  290. package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
  291. package/dist/prosemirror/outlineLevelAttr.js +42 -0
  292. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
  293. package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
  294. package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
  295. package/dist/prosemirror/plugins/selectionTracker.js +3 -10
  296. package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
  297. package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
  298. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  299. package/dist/prosemirror/replacedAnnotations.js +24 -6
  300. package/dist/prosemirror/revisionCarriers.d.ts +86 -2
  301. package/dist/prosemirror/revisionCarriers.js +86 -60
  302. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
  303. package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
  304. package/dist/prosemirror/runIdentity.d.ts +28 -0
  305. package/dist/prosemirror/runIdentity.js +36 -0
  306. package/dist/prosemirror/runStyleFormatting.js +1 -1
  307. package/dist/prosemirror/schema/index.d.ts +2 -2
  308. package/dist/prosemirror/schema/marks.d.ts +23 -4
  309. package/dist/prosemirror/schema/nodes.d.ts +220 -24
  310. package/dist/prosemirror/sectionCarrier.d.ts +37 -0
  311. package/dist/prosemirror/sectionCarrier.js +40 -0
  312. package/dist/prosemirror/selectionState.d.ts +3 -0
  313. package/dist/prosemirror/selectionState.js +4 -1
  314. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
  315. package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
  316. package/dist/prosemirror/tableResize.js +5 -6
  317. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
  318. package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
  319. package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
  320. package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
  321. package/dist/prosemirror/validation.js +17 -6
  322. package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
  323. package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
  324. package/dist/prosemirror/zeroWidthAnchors.js +4 -0
  325. package/dist/style-sets/extract.js +4 -4
  326. package/dist/style-sets/stellaStyle.js +36 -23
  327. package/dist/types/colors.d.ts +2 -2
  328. package/dist/types/content.d.ts +2 -2
  329. package/dist/types/documentEnumValues.d.ts +53 -26
  330. package/dist/types/documentEnumValues.js +72 -174
  331. package/dist/types/formatting.d.ts +2 -2
  332. package/dist/types/index.d.ts +9 -2
  333. package/dist/utils/borderCss.d.ts +246 -0
  334. package/dist/utils/borderCss.js +325 -0
  335. package/dist/utils/colorResolver.d.ts +4 -3
  336. package/dist/utils/colorResolver.js +45 -76
  337. package/dist/utils/createDocument.js +24 -6
  338. package/dist/utils/findReplace.js +52 -10
  339. package/dist/utils/formatToStyle.d.ts +84 -2
  340. package/dist/utils/formatToStyle.js +133 -52
  341. package/dist/utils/headingCollector.js +3 -2
  342. package/dist/utils/mergeDocumentContent.js +5 -3
  343. package/dist/utils/paragraphFormattingMerge.js +27 -6
  344. package/dist/utils/replaceText.js +1 -1
  345. package/dist/utils/tableOperations.d.ts +5 -3
  346. package/dist/utils/tableOperations.js +14 -1
  347. package/dist/utils/tablePlacement.d.ts +7 -0
  348. package/dist/utils/tablePlacement.js +14 -0
  349. package/dist/utils/textDirectionFlow.d.ts +15 -0
  350. package/dist/utils/textDirectionFlow.js +38 -0
  351. package/dist/utils/textFormattingMerge.js +16 -4
  352. package/package.json +10 -10
  353. package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
  354. package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
  355. package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
  356. package/dist/compare/__fixtures__/body-sequence.js +0 -225
  357. package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
  358. package/dist/compare/__fixtures__/nested-table.js +0 -50
  359. package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
  360. package/dist/compare/__fixtures__/numbered-list.js +0 -85
  361. package/dist/docx/bookmarkPlacement.d.ts +0 -9
  362. package/dist/docx/bookmarkPlacement.js +0 -52
  363. package/dist/fonts/embeddedFontTable.d.ts +0 -45
  364. package/dist/fonts/embeddedFontTable.js +0 -80
  365. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
  366. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
@@ -12,7 +12,15 @@ declare const isDisplacedByCustomXml: (value: unknown) => value is document_d_ex
12
12
  declare const bookmarkBoundaryDisplacement: (attrs: BookmarkBoundaryAttrs) => {
13
13
  displacedByCustomXml?: document_d_exports.DisplacedByCustomXml;
14
14
  };
15
+ /**
16
+ * The model marker a boundary node carries, at either level.
17
+ *
18
+ * A paragraph, a hyperlink, a revision wrapper and a block container each
19
+ * rebuild the same two elements from the same attributes; spelling that out
20
+ * per caller is how one of them comes to forget `w:colFirst`.
21
+ */
22
+ declare const bookmarkMarkerFromAttrs: (attrs: BookmarkBoundaryAttrs) => document_d_exports.BookmarkStart | document_d_exports.BookmarkEnd;
15
23
  declare const readBookmarkBoundaryAttrs: (node: Node) => ReadProseMirrorAttrsResult<BookmarkBoundaryAttrs>;
16
24
  declare const expectBookmarkBoundaryAttrs: (node: Node) => BookmarkBoundaryAttrs;
17
25
  //#endregion
18
- export { bookmarkBoundaryDisplacement, expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs };
26
+ export { bookmarkBoundaryDisplacement, bookmarkMarkerFromAttrs, expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs };
@@ -8,11 +8,30 @@ const attrsCache = /* @__PURE__ */ new WeakMap();
8
8
  * that build either one share this rather than each remembering the attribute.
9
9
  */
10
10
  const bookmarkBoundaryDisplacement = (attrs) => attrs.displacedByCustomXml === void 0 ? {} : { displacedByCustomXml: attrs.displacedByCustomXml };
11
+ /**
12
+ * The model marker a boundary node carries, at either level.
13
+ *
14
+ * A paragraph, a hyperlink, a revision wrapper and a block container each
15
+ * rebuild the same two elements from the same attributes; spelling that out
16
+ * per caller is how one of them comes to forget `w:colFirst`.
17
+ */
18
+ const bookmarkMarkerFromAttrs = (attrs) => attrs.type === "start" ? {
19
+ type: "bookmarkStart",
20
+ id: attrs.id,
21
+ name: attrs.name,
22
+ ...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
23
+ ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
24
+ ...bookmarkBoundaryDisplacement(attrs)
25
+ } : {
26
+ type: "bookmarkEnd",
27
+ id: attrs.id,
28
+ ...bookmarkBoundaryDisplacement(attrs)
29
+ };
11
30
  const readBookmarkBoundaryAttrs = (node) => {
12
31
  const issues = [];
13
- if (node.type.name !== "bookmarkBoundary") issues.push({
32
+ if (node.type.name !== "bookmarkBoundary" && node.type.name !== "blockBookmarkBoundary") issues.push({
14
33
  path: "bookmarkBoundary.type.name",
15
- message: `Expected bookmarkBoundary, got ${node.type.name}.`
34
+ message: `Expected a bookmark boundary, got ${node.type.name}.`
16
35
  });
17
36
  const type = node.attrs["type"];
18
37
  if (type !== "start" && type !== "end") issues.push({
@@ -78,4 +97,4 @@ const expectBookmarkBoundaryAttrs = (node) => {
78
97
  return result.value;
79
98
  };
80
99
  //#endregion
81
- export { bookmarkBoundaryDisplacement, expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs };
100
+ export { bookmarkBoundaryDisplacement, bookmarkMarkerFromAttrs, expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs };
@@ -1,3 +1,4 @@
1
+ import { sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
1
2
  import { joinProseParagraphsWithRightPropertySource } from "../../docx/paragraphPropertySource.js";
2
3
  import { appendHeadlessInlineResolution } from "../../internal/headlessRevisionResolution.js";
3
4
  import { stateAllowsHeadlessRevisionResolution } from "../../internal/headlessRevisionResolutionGuard.js";
@@ -5,9 +6,10 @@ import { expectParagraphAttrs, expectRunPropertyChangeMarkAttrs } from "../attrs
5
6
  import { addedBreakCarrierBefore, finalParagraphsOf, paragraphEndsItsContainer } from "../containerFinalParagraph.js";
6
7
  import { resolveParagraphDefaultTextFormatting } from "../conversion/toProseDoc.js";
7
8
  import { markChangedParagraphRanges, markStructuralChange, markTrackedSectionEndpointRemoval } from "../extensions/features/ParagraphChangeTrackerExtension.js";
9
+ import "../extensions/nodes/SdtExtension.js";
8
10
  import { getDocumentStyleResolver } from "../plugins/documentStyles.js";
9
11
  import { setParagraphAttrsWithRebasedRunFormatting } from "../rebaseParagraphRunFormatting.js";
10
- import { getFolioNodeRevisionCarriers } from "../revisionCarriers.js";
12
+ import { getFolioNodeRevisionCarriers, nodePropertyRevisionSites, propertyRevisionMetadata, propertyRevisionRecords } from "../revisionCarriers.js";
11
13
  import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
12
14
  import { reconstructRejectedRunFormattingMarks } from "../runPropertyChangeResolution.js";
13
15
  import { paragraphRunStyleContextAt } from "../runStyleFormatting.js";
@@ -15,11 +17,11 @@ import { getTableCellMergeChange } from "../tableCellMergeRevision.js";
15
17
  import { isTableCellRetainedInReviewView } from "../tableCellRevisionVisibility.js";
16
18
  import { reconcileTableGridAfterColumnRemoval } from "../tableGridMutation.js";
17
19
  import { holdsNoContent } from "../zeroWidthAnchors.js";
18
- import { hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch } from "./propertyChangeScope.js";
20
+ import { hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tablePropertyExceptionsRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch } from "./propertyChangeScope.js";
19
21
  import { hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge } from "./tableCellMergeResolution.js";
22
+ import { PARAGRAPH_MARK_CHANGE_KINDS, REVIEW_CARRIERS } from "@stll/docx-core/model";
20
23
  import { TableMap, removeRow } from "prosemirror-tables";
21
24
  import { Mapping } from "prosemirror-transform";
22
- import { PARAGRAPH_MARK_CHANGE_KINDS, REVIEW_CARRIERS } from "@stll/docx-core/model";
23
25
  //#region src/prosemirror/commands/comments.ts
24
26
  /**
25
27
  * Add a comment mark to the current selection.
@@ -131,7 +133,6 @@ function resolveChange(from, to, mode, revisionIds, execution = "legacy") {
131
133
  if (remaining.length > 0) restored.propertyChanges = remaining;
132
134
  nextAttrs = nextAttrs ?? { ...node.attrs };
133
135
  nextAttrs["_sectionProperties"] = restored;
134
- nextAttrs["sectionBreakType"] = sectionBreakTypeFromSectionStart(restored.sectionStart);
135
136
  }
136
137
  }
137
138
  if (nextAttrs) if (nextAttrs["styleId"] !== node.attrs["styleId"] && styleResolver) setParagraphAttrsWithRebasedRunFormatting({
@@ -153,10 +154,10 @@ function resolveChange(from, to, mode, revisionIds, execution = "legacy") {
153
154
  if (op) tableRowStructuralOps.push(op);
154
155
  }
155
156
  if ((node.type.name === "tableCell" || node.type.name === "tableHeader") && rangeCoversNode(from, to, pos, node)) tableCellStructuralOps.push(...collectTableCellStructuralOps(node, pos, mode, revisionSet));
156
- const tableChangeAttrName = TABLE_PROPERTY_CHANGE_ATTR_BY_NODE[node.type.name];
157
- if (tableChangeAttrName !== void 0) {
158
- if (rangeCoversNode(from, to, pos, node)) {
159
- const nextAttrs = resolveTablePropertyChangeAttrs(node, tableChangeAttrName, mode, revisionSet);
157
+ const nodeAttrSites = nodePropertyRevisionSites(node.type.name).filter((site) => site.resolution === "node-attrs");
158
+ if (nodeAttrSites.length > 0) {
159
+ if (rangeCoversNode(from, to, pos, node)) for (const site of nodeAttrSites) {
160
+ const nextAttrs = resolveNodePropertyChangeAttrs(tr.doc.nodeAt(pos) ?? node, site, mode, revisionSet);
160
161
  if (nextAttrs) {
161
162
  tr.setNodeMarkup(pos, void 0, nextAttrs);
162
163
  markStructuralChange(tr);
@@ -169,6 +170,13 @@ function resolveChange(from, to, mode, revisionIds, execution = "legacy") {
169
170
  const nodeEnd = pos + node.nodeSize;
170
171
  const rangeFrom = Math.max(from, pos);
171
172
  const rangeTo = Math.min(to, nodeEnd);
173
+ if (node.type.name === "sdt" && removeType !== void 0 && rangeCoversNode(from, to, pos, node) && revisionCoversWholeControl(node, removeType, matchesRevision)) {
174
+ deleteRanges.push({
175
+ from: pos,
176
+ to: nodeEnd
177
+ });
178
+ return false;
179
+ }
172
180
  const runPropertyChangeMark = node.marks.find((mark) => mark.type.name === "runPropertyChange");
173
181
  const removesNode = removeType !== void 0 && node.marks.some((mark) => mark.type === removeType && matchesRevision(mark));
174
182
  if (runPropertyChangeMark) resolveRunPropertyChange({
@@ -248,7 +256,6 @@ function resolveChange(from, to, mode, revisionIds, execution = "legacy") {
248
256
  const joinedAttrs = {
249
257
  ...(emptyFirstParagraph ? nextNode : paragraph).attrs,
250
258
  pPrMark: nextNode.attrs["pPrMark"],
251
- sectionBreakType: nextNode.attrs["sectionBreakType"],
252
259
  _sectionProperties: nextNode.attrs["_sectionProperties"]
253
260
  };
254
261
  try {
@@ -554,42 +561,64 @@ function rangeCoversParagraphBoundary(from, to, pos, node) {
554
561
  function rangeCoversNode(from, to, pos, node) {
555
562
  return from <= pos && to >= pos + node.nodeSize;
556
563
  }
557
- const SECTION_BREAK_TYPE_VALUES = [
558
- "nextPage",
559
- "continuous",
560
- "oddPage",
561
- "evenPage"
562
- ];
563
- function sectionBreakTypeFromSectionStart(sectionStart) {
564
- return SECTION_BREAK_TYPE_VALUES.find((value) => value === sectionStart) ?? null;
564
+ /**
565
+ * Whether a revision covers everything an inline content control holds.
566
+ *
567
+ * The save leg writes such a revision around the control (`w:ins > w:sdt`),
568
+ * so resolving it is an operation over the control itself: a reader who
569
+ * rejects an inserted control gets no control, not an empty one standing
570
+ * where it was. A revision over part of the content is a revision over that
571
+ * part, and a control that holds nothing is covered by nothing.
572
+ */
573
+ function revisionCoversWholeControl(node, removeType, matchesRevision) {
574
+ if (node.childCount === 0) return false;
575
+ for (let index = 0; index < node.childCount; index += 1) {
576
+ const child = node.child(index);
577
+ if (child.marks.some((mark) => mark.type === removeType && matchesRevision(mark))) continue;
578
+ if (child.type.name !== "sdt" || !revisionCoversWholeControl(child, removeType, matchesRevision)) return false;
579
+ }
580
+ return true;
565
581
  }
566
- /** PM node type name → the attr its tracked property-change records live on. */
567
- const TABLE_PROPERTY_CHANGE_ATTR_BY_NODE = {
568
- table: "tblPrChange",
569
- tableRow: "trPrChange",
570
- tableCell: "tcPrChange",
571
- tableHeader: "tcPrChange"
582
+ /**
583
+ * The attrs a reject restores for each property revision the shared node-attr
584
+ * pass owns. Total over those kinds, so a revision the model gains either
585
+ * declares a different resolution or states here what rejecting it restores.
586
+ *
587
+ * Each patch narrows the stored set to the property set its own element
588
+ * carries. The casts are the ProseMirror attrs boundary: attrs are untyped,
589
+ * and a record reached through the site filed under a kind is the one that
590
+ * kind's parser and converter wrote.
591
+ */
592
+ const NODE_ATTRS_REJECT_PATCHES = {
593
+ tablePropertyChange: (previousFormatting) => tableRejectAttrPatch(previousFormatting),
594
+ tablePropertyExceptionChange: (previousFormatting) => tablePropertyExceptionsRejectAttrPatch(previousFormatting),
595
+ tableRowPropertyChange: (previousFormatting) => tableRowRejectAttrPatch(previousFormatting),
596
+ tableCellPropertyChange: (previousFormatting, node) => tableCellRejectAttrPatch(previousFormatting, node.attrs["_originalFormatting"])
572
597
  };
573
598
  /**
574
- * Resolve the tracked property-change records on one table / row / cell node.
599
+ * Resolve the tracked property-change records one site carries on a node.
575
600
  * Accept keeps the live formatting and clears the matched records; reject
576
601
  * additionally restores the stored previous formatting wholesale (the change
577
602
  * element stores the complete old property set — see propertyChangeScope.ts).
578
603
  * Returns the next attrs, or `null` when no record matches.
579
604
  */
580
- function resolveTablePropertyChangeAttrs(node, attrName, mode, revisionSet) {
581
- const changes = node.attrs[attrName];
582
- if (!Array.isArray(changes) || changes.length === 0) return null;
583
- const matches = changes.filter((c) => revisionSet === null || c.info && revisionSet.has(c.info.id));
605
+ function resolveNodePropertyChangeAttrs(node, site, mode, revisionSet) {
606
+ const changes = propertyRevisionRecords(node, site);
607
+ if (changes.length === 0) return null;
608
+ const matches = changes.filter((change) => {
609
+ const metadata = propertyRevisionMetadata(change.info);
610
+ return revisionSet === null || metadata !== null && revisionSet.has(metadata.id);
611
+ });
584
612
  if (matches.length === 0) return null;
585
- const remaining = changes.filter((c) => revisionSet !== null && (!c.info || !revisionSet.has(c.info.id)));
613
+ const remaining = revisionSet === null ? [] : changes.filter((change) => !matches.includes(change));
586
614
  const nextAttrs = {
587
615
  ...node.attrs,
588
- [attrName]: remaining.length > 0 ? remaining : null
616
+ [site.attr]: remaining.length > 0 ? remaining : null
589
617
  };
590
- if (mode === "reject") for (const change of matches.toReversed()) if (attrName === "tblPrChange") Object.assign(nextAttrs, tableRejectAttrPatch(change.previousFormatting));
591
- else if (attrName === "trPrChange") Object.assign(nextAttrs, tableRowRejectAttrPatch(change.previousFormatting));
592
- else Object.assign(nextAttrs, tableCellRejectAttrPatch(change.previousFormatting, node.attrs["_originalFormatting"]));
618
+ if (mode === "reject") {
619
+ const rejectPatch = NODE_ATTRS_REJECT_PATCHES[site.kind];
620
+ for (const change of matches.toReversed()) Object.assign(nextAttrs, rejectPatch(change.previousFormatting, node));
621
+ }
593
622
  return nextAttrs;
594
623
  }
595
624
  function isPPrMarkAttr(value) {
@@ -607,10 +636,7 @@ function isPPrMarkAttr(value) {
607
636
  * the two ends belong together, not because they resolve differently.
608
637
  */
609
638
  const paragraphMarkWasAdded = (kind) => kind === "ins" || kind === "moveTo";
610
- const ownsSectionEndpoint = (paragraph) => {
611
- const attrs = expectParagraphAttrs(paragraph);
612
- return attrs._sectionProperties !== void 0 || attrs.sectionBreakType !== void 0;
613
- };
639
+ const ownsSectionEndpoint = (paragraph) => expectParagraphAttrs(paragraph)._sectionProperties !== void 0;
614
640
  const sectionReferencesOf = (paragraph) => {
615
641
  const sectionProperties = expectParagraphAttrs(paragraph)._sectionProperties;
616
642
  if (!sectionProperties) return [];
@@ -632,23 +658,12 @@ function readRevisionInfo(info) {
632
658
  if (typeof info?.id === "number") revision.revisionId = info.id;
633
659
  return revision;
634
660
  }
635
- function getListPropertyChangeType(attrs, change) {
661
+ function getListPropertyChangeType(node, change) {
636
662
  const previousFormatting = change.previousFormatting;
637
663
  if (previousFormatting == null || !Object.hasOwn(previousFormatting, "numPr")) return null;
638
- const currentNumPr = attrs["numPr"];
639
- const previousNumPr = previousFormatting["numPr"];
640
- if (previousNumPr == null && currentNumPr != null) return "insertion";
641
- if (previousNumPr != null && currentNumPr == null) return "deletion";
642
- if (!areNumPrValuesEqual(previousNumPr, currentNumPr)) return currentNumPr == null ? "deletion" : "insertion";
643
- return null;
644
- }
645
- function areNumPrValuesEqual(left, right) {
646
- if (left == null || right == null) return left == right;
647
- if (!isObjectRecord(left) || !isObjectRecord(right)) return Object.is(left, right);
648
- return left["numId"] === right["numId"] && left["ilvl"] === right["ilvl"];
649
- }
650
- function isObjectRecord(value) {
651
- return typeof value === "object" && value !== null;
664
+ const current = expectParagraphAttrs(node).numPr;
665
+ if (sameStatedParagraphNumbering$1(previousFormatting["numPr"] ?? void 0, current)) return null;
666
+ return current === void 0 ? "deletion" : "insertion";
652
667
  }
653
668
  function toParagraphBoundaryChange(node, pos, type, info) {
654
669
  return {
@@ -668,7 +683,7 @@ function findParagraphBoundaryChangeAtPosition(state, pos) {
668
683
  const propertyChanges = expectParagraphAttrs(node)._propertyChanges;
669
684
  if (!Array.isArray(propertyChanges)) return null;
670
685
  for (const change of propertyChanges) {
671
- const type = getListPropertyChangeType(node.attrs, change);
686
+ const type = getListPropertyChangeType(node, change);
672
687
  if (type) return toParagraphBoundaryChange(node, paragraphPos, type, change.info);
673
688
  }
674
689
  return null;
@@ -1,6 +1,7 @@
1
1
  import { checkboxDisplayContent } from "../../content-controls/checkboxDisplay.js";
2
2
  import { ContentControlBoundError, ContentControlLockedError, ContentControlTypeError } from "../../content-controls/errors.js";
3
3
  import { formatDate } from "../../docx/fieldParser.js";
4
+ import { preservedSdtChild, withoutPreservedSdtChild } from "../../docx/sdtProperties.js";
4
5
  import { expectBlockSdtAttrs } from "../attrs/index.js";
5
6
  import { SUGGESTION_BYPASS_META } from "../plugins/suggestionMode.js";
6
7
  //#region src/prosemirror/commands/contentControls.ts
@@ -112,19 +113,26 @@ function ensureSdtNotLocked(node, options) {
112
113
  const lock = node.attrs["lock"];
113
114
  if (lock === "sdtLocked" || lock === "sdtContentLocked") throwLockedNode(node, lock);
114
115
  }
115
- const DATA_BINDING_RE = /<\w+:dataBinding\b(?<attrs>[^>]*)\/?>/iu;
116
116
  /**
117
- * Refuse content mutations on bound SDTs unless force; on force, return
118
- * the stripped rawPropertiesXml so the caller can persist it on the new
119
- * node attrs. Mirrors the headless `ensureContentNotBound` helper.
117
+ * The control's preserved `w:sdtPr` children, off the node's attrs.
118
+ *
119
+ * `readBlockSdtAttrs` validates the shape at the document boundary, so this
120
+ * is the same record the model carries rather than a second parse of it.
121
+ */
122
+ const preservedOf = (node) => {
123
+ const value = node.attrs["_preserved"];
124
+ return value === null || value === void 0 ? void 0 : value;
125
+ };
126
+ /**
127
+ * Refuse content mutations on bound SDTs unless force; on force, return the
128
+ * attrs override that drops the `w:dataBinding` child, so the caller can
129
+ * persist it on the new node. Mirrors the headless `ensureContentNotBound`.
120
130
  */
121
131
  function ensureContentNotBound(node, options) {
122
- const raw = node.attrs["rawPropertiesXml"];
123
- if (typeof raw !== "string") return { strippedRawPropertiesXml: void 0 };
124
- const match = DATA_BINDING_RE.exec(raw);
125
- if (!match) return { strippedRawPropertiesXml: void 0 };
132
+ const preserved = preservedOf(node);
133
+ const attrs = preservedSdtChild(preserved, "dataBinding");
134
+ if (attrs === void 0) return {};
126
135
  if (!options.force) {
127
- const attrs = match.groups?.["attrs"] ?? "";
128
136
  const xpathMatch = /\bxpath="(?<xpath>[^"]*)"/iu.exec(attrs);
129
137
  const storeMatch = /\bstoreItemID="(?<storeItemID>[^"]*)"/iu.exec(attrs);
130
138
  const props = attrsToProperties(node);
@@ -136,7 +144,7 @@ function ensureContentNotBound(node, options) {
136
144
  ...props.alias !== void 0 ? { alias: props.alias } : {}
137
145
  });
138
146
  }
139
- return { strippedRawPropertiesXml: raw.replaceAll(/<\w+:dataBinding\b[^>]*\/?>(?:[\s\S]*?<\/\w+:dataBinding>)?/giu, "") };
147
+ return { _preserved: withoutPreservedSdtChild(preserved, "dataBinding") ?? null };
140
148
  }
141
149
  function paragraphFromText(schema, text) {
142
150
  if (text.length === 0) return schema.node("paragraph", {}, []);
@@ -158,13 +166,13 @@ function setContentControlContentTr(state, filter, input, options = {}) {
158
166
  const match = findBlockSdtMatch(state.doc, filter);
159
167
  if (!match) return null;
160
168
  ensureContentNotLocked(match.node, options);
161
- const { strippedRawPropertiesXml } = ensureContentNotBound(match.node, options);
169
+ const bindingOverride = ensureContentNotBound(match.node, options);
162
170
  if (typeof input !== "string") throw new ContentControlTypeError({
163
171
  message: "Block-content fill must go through `setContentControlContentBlocksTr` (avoids a schema/plugin import cycle); pass a string here.",
164
172
  sdtType: match.node.attrs["sdtType"] ?? "richText",
165
173
  reason: "PM-direct path takes string input only"
166
174
  });
167
- return replaceBlockSdtChildren(state, match, [paragraphFromText(state.schema, input)], strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {});
175
+ return replaceBlockSdtChildren(state, match, [paragraphFromText(state.schema, input)], bindingOverride);
168
176
  }
169
177
  /**
170
178
  * Internal helper for the block-content fill variant. Lives in this module
@@ -176,15 +184,13 @@ function replaceBlockSdtChildrenForFill(state, filter, children, options = {}) {
176
184
  const match = findBlockSdtMatch(state.doc, filter);
177
185
  if (!match) return null;
178
186
  ensureContentNotLocked(match.node, options);
179
- const { strippedRawPropertiesXml } = ensureContentNotBound(match.node, options);
180
- return replaceBlockSdtChildren(state, match, children, strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {});
187
+ return replaceBlockSdtChildren(state, match, children, ensureContentNotBound(match.node, options));
181
188
  }
182
189
  function setContentControlValueTr(state, filter, input, options = {}) {
183
190
  const match = findBlockSdtMatch(state.doc, filter);
184
191
  if (!match) return null;
185
192
  ensureContentNotLocked(match.node, options);
186
- const { strippedRawPropertiesXml } = ensureContentNotBound(match.node, options);
187
- const bindingOverride = strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {};
193
+ const bindingOverride = ensureContentNotBound(match.node, options);
188
194
  const sdtType = match.node.attrs["sdtType"];
189
195
  if (input.kind === "dropdown") {
190
196
  if (sdtType !== "dropdown" && sdtType !== "comboBox") throw new ContentControlTypeError({
@@ -221,7 +227,7 @@ function setContentControlValueTr(state, filter, input, options = {}) {
221
227
  sdtType,
222
228
  reason: "kind=checkbox requires sdtType=checkbox"
223
229
  });
224
- const display = checkboxDisplayContent(typeof match.node.attrs["rawPropertiesXml"] === "string" ? match.node.attrs["rawPropertiesXml"] : void 0, input.checked);
230
+ const display = checkboxDisplayContent(preservedSdtChild(preservedOf(match.node), "checkbox"), input.checked);
225
231
  let content = display.type === "symbol" ? state.schema.node("symbol", {
226
232
  font: display.font,
227
233
  char: display.char
@@ -278,8 +284,7 @@ function parseSdtDate(iso) {
278
284
  return Number.isNaN(parsed.getTime()) ? null : parsed;
279
285
  }
280
286
  function isRepeatingSection(node) {
281
- const raw = node.attrs["rawPropertiesXml"];
282
- return typeof raw === "string" && /<\w+:repeatingSection\b/u.test(raw);
287
+ return preservedSdtChild(preservedOf(node), "repeatingSection") !== void 0;
283
288
  }
284
289
  function removeContentControlTr(state, filter, options = {}) {
285
290
  const match = findBlockSdtMatch(state.doc, filter);
@@ -26,7 +26,7 @@ type ImagePropertiesInput = {
26
26
  };
27
27
  type ImageTransformAction = "rotateCW" | "rotateCCW" | "flipH" | "flipV";
28
28
  type ResolvedImageWrap = {
29
- wrapType: ImageAttrs["wrapType"];
29
+ wrapType: NonNullable<ImageAttrs["wrapType"]>;
30
30
  displayMode: ImageAttrs["displayMode"];
31
31
  cssFloat: ImageAttrs["cssFloat"];
32
32
  };
@@ -1,4 +1,5 @@
1
1
  import { FOLIO_INSERTED_PICTURE_FRAME_LOCKS } from "../../docx/graphicFrameLocks.js";
2
+ import { wrapPolygonFor } from "../../docx/wrapPolygon.js";
2
3
  import { IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES } from "../../types/documentEnumValues.js";
3
4
  import { isSafeImageFile } from "../../utils/imageValidation.js";
4
5
  import { sanitizeImageSrc } from "../../utils/sanitizeImageSrc.js";
@@ -128,10 +129,12 @@ const applyImageWrapType = (view, pos, wrapType) => {
128
129
  if (!node) return false;
129
130
  const resolved = resolveImageWrap(wrapType);
130
131
  if (!resolved) return false;
132
+ const authoredPolygon = expectImageAttrs(node).wrapPolygon;
131
133
  const tr = view.state.tr.setNodeMarkup(pos, void 0, mergeImageAttrs(node, {
132
134
  wrapType: resolved.wrapType,
133
135
  displayMode: resolved.displayMode,
134
- cssFloat: resolved.cssFloat
136
+ cssFloat: resolved.cssFloat,
137
+ wrapPolygon: wrapPolygonFor(resolved.wrapType, authoredPolygon) ?? authoredPolygon
135
138
  }));
136
139
  view.dispatch(tr.scrollIntoView());
137
140
  return true;
@@ -1,4 +1,5 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
+ import { SectionBreakType } from "../sectionCarrier.js";
2
3
  import { GenerateTableOfContentsOptions, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId } from "../extensions/core/ParagraphExtension.js";
3
4
  import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
4
5
  import { Command } from "prosemirror-state";
@@ -26,7 +27,7 @@ declare function setSpaceBefore(twips: number): Command;
26
27
  declare function setSpaceAfter(twips: number): Command;
27
28
  declare function applyStyle(styleId: string, resolvedAttrs?: ResolvedStyleAttrs): Command;
28
29
  declare const clearStyle: Command;
29
- declare function insertSectionBreak(breakType: "nextPage" | "continuous" | "oddPage" | "evenPage"): Command;
30
+ declare function insertSectionBreak(breakType: SectionBreakType): Command;
30
31
  declare const removeSectionBreak: Command;
31
32
  declare function addTabStop(position: number, alignment?: document_d_exports.TabStopAlignment, leader?: document_d_exports.TabLeader): Command;
32
33
  declare function removeTabStop(position: number): Command;
@@ -32,9 +32,9 @@ declare const removeParagraphPropertyChanges: (changes: readonly ParagraphProper
32
32
  * stored record resets to the schema default (`null`).
33
33
  *
34
34
  * Deliberately OUT of scope (preserved across a reject):
35
- * - identity/structure: `paraId`, `textId`, `sectionBreakType`,
36
- * `_sectionProperties`, `_propertyChanges`, `pPrMark`, `bookmarks`,
37
- * `_emptyHyperlinks`, `renderedPageBreakBefore`
35
+ * - identity/structure: `paraId`, `textId`, `_sectionProperties`,
36
+ * `_propertyChanges`, `pPrMark`, `bookmarks`, `_emptyHyperlinks`,
37
+ * `renderedPageBreakBefore`
38
38
  * - paragraph-mark run properties — `pPr/rPr` is CT_PPr-only, not part of the
39
39
  * CT_PPrBase payload a pPrChange stores: `defaultTextFormatting`,
40
40
  * `runInWithNext` (`w:specVanish` lives in that rPr)
@@ -83,6 +83,14 @@ declare function sectionRejectProperties({ live, previousProperties, previousRef
83
83
  * and is untouched.
84
84
  */
85
85
  declare function tableRejectAttrPatch(previousFormatting: document_d_exports.TableFormatting | undefined): AttrPatch;
86
+ /**
87
+ * Attr patch for rejecting a `w:tblPrExChange`: the stored old `w:tblPrEx`
88
+ * wholesale. The exceptions ride the row node whole rather than as attrs (the
89
+ * editor surfaces none of the nine properties), so restoring the previous set
90
+ * is restoring that one attr — and a record with no stored set says the row
91
+ * overrode nothing, which is the element's absence, not an empty one.
92
+ */
93
+ declare function tablePropertyExceptionsRejectAttrPatch(previousFormatting: document_d_exports.TablePropertyExceptionFormatting | undefined): AttrPatch;
86
94
  /** Attr patch for rejecting a `w:trPrChange`: the stored old trPr wholesale. */
87
95
  declare function tableRowRejectAttrPatch(previousFormatting: document_d_exports.TableRowFormatting | undefined): AttrPatch;
88
96
  /**
@@ -96,4 +104,4 @@ declare function tableRowRejectAttrPatch(previousFormatting: document_d_exports.
96
104
  */
97
105
  declare function tableCellRejectAttrPatch(previousFormatting: document_d_exports.TableCellFormatting | undefined, liveOriginalFormatting: document_d_exports.TableCellFormatting | null | undefined): AttrPatch;
98
106
  //#endregion
99
- export { PPR_CHANGE_SCOPED_ATTR_KEYS, ParagraphPropertyChangeRemoval, hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
107
+ export { PPR_CHANGE_SCOPED_ATTR_KEYS, ParagraphPropertyChangeRemoval, hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tablePropertyExceptionsRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
@@ -1,4 +1,5 @@
1
1
  import { expectParagraphAttrs } from "../attrs/index.js";
2
+ import { readParagraphNumberingAttr } from "../numberingAttr.js";
2
3
  import { directParagraphAlignment } from "../paragraphAlignment.js";
3
4
  import { directionFromBidi } from "../paragraphDirection.js";
4
5
  import { directParagraphSpacing, paragraphSpacingAttrPatch, paragraphSpacingFromFormatting } from "../paragraphSpacing.js";
@@ -56,9 +57,9 @@ const removeParagraphPropertyChanges = (changes, shouldRemove) => {
56
57
  * stored record resets to the schema default (`null`).
57
58
  *
58
59
  * Deliberately OUT of scope (preserved across a reject):
59
- * - identity/structure: `paraId`, `textId`, `sectionBreakType`,
60
- * `_sectionProperties`, `_propertyChanges`, `pPrMark`, `bookmarks`,
61
- * `_emptyHyperlinks`, `renderedPageBreakBefore`
60
+ * - identity/structure: `paraId`, `textId`, `_sectionProperties`,
61
+ * `_propertyChanges`, `pPrMark`, `bookmarks`, `_emptyHyperlinks`,
62
+ * `renderedPageBreakBefore`
62
63
  * - paragraph-mark run properties — `pPr/rPr` is CT_PPr-only, not part of the
63
64
  * CT_PPrBase payload a pPrChange stores: `defaultTextFormatting`,
64
65
  * `runInWithNext` (`w:specVanish` lives in that rPr)
@@ -214,6 +215,9 @@ function paragraphRejectOriginalFormatting(previousFormatting, liveOriginal) {
214
215
  const value = Object.hasOwn(prev, key) ? prev[key] : void 0;
215
216
  if (value != null) Object.assign(result, { [key]: value });
216
217
  }
218
+ const numbering = readParagraphNumberingAttr(prev.numPr);
219
+ if (numbering === null) Reflect.deleteProperty(result, "numPr");
220
+ else result.numPr = numbering;
217
221
  const live = isRecord(liveOriginal) ? liveOriginal : {};
218
222
  if (live["runProperties"] != null) Object.assign(result, { runProperties: live["runProperties"] });
219
223
  if (live["runInWithNext"] != null) Object.assign(result, { runInWithNext: live["runInWithNext"] });
@@ -249,6 +253,16 @@ function tableRejectAttrPatch(previousFormatting) {
249
253
  _originalFormatting: previousFormatting ?? null
250
254
  };
251
255
  }
256
+ /**
257
+ * Attr patch for rejecting a `w:tblPrExChange`: the stored old `w:tblPrEx`
258
+ * wholesale. The exceptions ride the row node whole rather than as attrs (the
259
+ * editor surfaces none of the nine properties), so restoring the previous set
260
+ * is restoring that one attr — and a record with no stored set says the row
261
+ * overrode nothing, which is the element's absence, not an empty one.
262
+ */
263
+ function tablePropertyExceptionsRejectAttrPatch(previousFormatting) {
264
+ return { _tablePropertyExceptions: previousFormatting ?? null };
265
+ }
252
266
  /** Attr patch for rejecting a `w:trPrChange`: the stored old trPr wholesale. */
253
267
  function tableRowRejectAttrPatch(previousFormatting) {
254
268
  return {
@@ -277,6 +291,10 @@ function tableCellRejectAttrPatch(previousFormatting, liveOriginalFormatting) {
277
291
  return {
278
292
  width: previousFormatting?.width?.value ?? null,
279
293
  widthType: previousFormatting?.width?.type ?? null,
294
+ _authoredWidth: previousFormatting?.width ? {
295
+ value: previousFormatting.width.value,
296
+ type: previousFormatting.width.type
297
+ } : null,
280
298
  verticalAlign: previousFormatting?.verticalAlign ?? null,
281
299
  backgroundColor: previousFormatting?.shading?.fill?.rgb ?? null,
282
300
  textDirection: previousFormatting?.textDirection ?? null,
@@ -306,4 +324,4 @@ function isRecord(value) {
306
324
  return typeof value === "object" && value !== null && !Array.isArray(value);
307
325
  }
308
326
  //#endregion
309
- export { PPR_CHANGE_SCOPED_ATTR_KEYS, hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
327
+ export { PPR_CHANGE_SCOPED_ATTR_KEYS, hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tablePropertyExceptionsRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
@@ -1,5 +1,37 @@
1
+ import { SectionBreakType } from "../sectionCarrier.js";
1
2
  import { Command } from "prosemirror-state";
2
3
  //#region src/prosemirror/commands/sectionBreak.d.ts
4
+ /**
5
+ * Run a command, keeping every section break on the paragraph whose mark
6
+ * survived it.
7
+ *
8
+ * A section break is a property of a paragraph *mark*. The transfer is keyed on
9
+ * the mark's position surviving the transaction, not on which command ran, so
10
+ * deleting a section-ending paragraph outright still removes its section: that
11
+ * mark is gone, and nothing inherits it.
12
+ */
13
+ declare const keepSectionBreaksOnSurvivingMarks: (command: Command) => Command;
14
+ /**
15
+ * End the selection's sections with `breakType`.
16
+ *
17
+ * A paragraph that already ends a section keeps its page size, margins,
18
+ * columns and header references and changes only `w:type` (§17.6.22), which is
19
+ * the one field the type names; a paragraph that ends none mints a record
20
+ * stating that type alone, and inherits the rest from the section that follows
21
+ * it.
22
+ */
23
+ declare const setSectionBreakType: (breakType: SectionBreakType) => Command;
24
+ /**
25
+ * Remove the section break the selection's paragraphs carry.
26
+ *
27
+ * The record goes, and with it the section boundary: the paragraphs it
28
+ * governed become part of the section that follows, whose `w:sectPr` governs
29
+ * them from then on. That is Word's own rule for deleting a section break, and
30
+ * it is what §17.6.18 says a paragraph with no `w:sectPr` means — nothing has
31
+ * to be merged into the following record, because the following record already
32
+ * states the whole of the section it heads.
33
+ */
34
+ declare const removeSectionBreakAtSelection: Command;
3
35
  /**
4
36
  * Insert a "next page" section break at the cursor — starts a new section on a
5
37
  * new page.
@@ -11,4 +43,4 @@ declare const insertSectionBreakNextPage: Command;
11
43
  */
12
44
  declare const insertSectionBreakContinuous: Command;
13
45
  //#endregion
14
- export { insertSectionBreakContinuous, insertSectionBreakNextPage };
46
+ export { insertSectionBreakContinuous, insertSectionBreakNextPage, keepSectionBreaksOnSurvivingMarks, removeSectionBreakAtSelection, setSectionBreakType };