@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,28 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ //#region src/prosemirror/authoredTransformAttrs.d.ts
3
+ /** The transform attrs a drawing node (`image`, `shape`, `textBox`) carries. */
4
+ type AuthoredTransformAttrs = {
5
+ docxFlipH: boolean | null;
6
+ docxFlipV: boolean | null;
7
+ docxRotation: number | null;
8
+ /** The rendered CSS, derived from the three above. */
9
+ transform: string | undefined;
10
+ };
11
+ /** What a drawing node's attrs say, as they arrive from a persisted document. */
12
+ type ReadableTransformAttrs = {
13
+ docxFlipH?: boolean | null;
14
+ docxFlipV?: boolean | null;
15
+ docxRotation?: number | null;
16
+ transform?: string;
17
+ };
18
+ /** Project a model transform onto a drawing node's attrs. */
19
+ declare const authoredTransformAttrs: (transform: document_d_exports.ImageTransform | undefined) => AuthoredTransformAttrs;
20
+ /**
21
+ * Read a drawing node's authored transform back.
22
+ *
23
+ * The attrs are the record; the CSS string answers only for a node that states
24
+ * none of them, which is how a node persisted before they existed arrives.
25
+ */
26
+ declare const readAuthoredTransform: (attrs: ReadableTransformAttrs) => document_d_exports.ImageTransform | undefined;
27
+ //#endregion
28
+ export { authoredTransformAttrs, readAuthoredTransform };
@@ -0,0 +1,64 @@
1
+ //#region src/prosemirror/authoredTransformAttrs.ts
2
+ /**
3
+ * The CSS the three authored values render as.
4
+ *
5
+ * Only what the browser has to draw: a rotation of zero and an explicit
6
+ * "not flipped" are the identity, and emitting them would put a no-op
7
+ * transform on every drawing that states one.
8
+ */
9
+ const cssTransform = (rotation, flipH, flipV) => {
10
+ const parts = [];
11
+ if (rotation !== null && rotation !== 0) parts.push(`rotate(${rotation}deg)`);
12
+ if (flipH === true) parts.push("scaleX(-1)");
13
+ if (flipV === true) parts.push("scaleY(-1)");
14
+ return parts.length > 0 ? parts.join(" ") : void 0;
15
+ };
16
+ /** Project a model transform onto a drawing node's attrs. */
17
+ const authoredTransformAttrs = (transform) => {
18
+ const docxRotation = transform?.rotation ?? null;
19
+ const docxFlipH = transform?.flipH ?? null;
20
+ const docxFlipV = transform?.flipV ?? null;
21
+ return {
22
+ docxFlipH,
23
+ docxFlipV,
24
+ docxRotation,
25
+ transform: cssTransform(docxRotation, docxFlipH, docxFlipV)
26
+ };
27
+ };
28
+ /**
29
+ * The transform a node persisted before these attrs existed carries.
30
+ *
31
+ * The CSS can state neither an authored zero rotation nor an authored "not
32
+ * flipped", which is why the attrs exist; such a node never carried them
33
+ * either, so reading it this way loses nothing.
34
+ */
35
+ const transformFromCss = (css) => {
36
+ if (!css) return;
37
+ const transform = {};
38
+ const rotateMatch = /rotate\((?<deg>[-\d.]+)deg\)/u.exec(css);
39
+ if (rotateMatch) {
40
+ const rotation = Number.parseFloat(rotateMatch.groups["deg"]);
41
+ if (Number.isFinite(rotation)) transform.rotation = rotation;
42
+ }
43
+ if (css.includes("scaleX(-1)")) transform.flipH = true;
44
+ if (css.includes("scaleY(-1)")) transform.flipV = true;
45
+ if (transform.rotation === void 0 && !transform.flipH && !transform.flipV) return;
46
+ return transform;
47
+ };
48
+ /**
49
+ * Read a drawing node's authored transform back.
50
+ *
51
+ * The attrs are the record; the CSS string answers only for a node that states
52
+ * none of them, which is how a node persisted before they existed arrives.
53
+ */
54
+ const readAuthoredTransform = (attrs) => {
55
+ const { docxFlipH, docxFlipV, docxRotation } = attrs;
56
+ if (docxRotation == null && docxFlipH == null && docxFlipV == null) return transformFromCss(attrs.transform);
57
+ return {
58
+ ...docxRotation == null ? {} : { rotation: docxRotation },
59
+ ...docxFlipH == null ? {} : { flipH: docxFlipH },
60
+ ...docxFlipV == null ? {} : { flipV: docxFlipV }
61
+ };
62
+ };
63
+ //#endregion
64
+ export { authoredTransformAttrs, readAuthoredTransform };
@@ -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,5 +1,7 @@
1
+ import { checkboxDisplayContent } from "../../content-controls/checkboxDisplay.js";
1
2
  import { ContentControlBoundError, ContentControlLockedError, ContentControlTypeError } from "../../content-controls/errors.js";
2
3
  import { formatDate } from "../../docx/fieldParser.js";
4
+ import { preservedSdtChild, withoutPreservedSdtChild } from "../../docx/sdtProperties.js";
3
5
  import { expectBlockSdtAttrs } from "../attrs/index.js";
4
6
  import { SUGGESTION_BYPASS_META } from "../plugins/suggestionMode.js";
5
7
  //#region src/prosemirror/commands/contentControls.ts
@@ -111,19 +113,26 @@ function ensureSdtNotLocked(node, options) {
111
113
  const lock = node.attrs["lock"];
112
114
  if (lock === "sdtLocked" || lock === "sdtContentLocked") throwLockedNode(node, lock);
113
115
  }
114
- const DATA_BINDING_RE = /<\w+:dataBinding\b(?<attrs>[^>]*)\/?>/iu;
115
116
  /**
116
- * Refuse content mutations on bound SDTs unless force; on force, return
117
- * the stripped rawPropertiesXml so the caller can persist it on the new
118
- * 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`.
119
130
  */
120
131
  function ensureContentNotBound(node, options) {
121
- const raw = node.attrs["rawPropertiesXml"];
122
- if (typeof raw !== "string") return { strippedRawPropertiesXml: void 0 };
123
- const match = DATA_BINDING_RE.exec(raw);
124
- if (!match) return { strippedRawPropertiesXml: void 0 };
132
+ const preserved = preservedOf(node);
133
+ const attrs = preservedSdtChild(preserved, "dataBinding");
134
+ if (attrs === void 0) return {};
125
135
  if (!options.force) {
126
- const attrs = match.groups?.["attrs"] ?? "";
127
136
  const xpathMatch = /\bxpath="(?<xpath>[^"]*)"/iu.exec(attrs);
128
137
  const storeMatch = /\bstoreItemID="(?<storeItemID>[^"]*)"/iu.exec(attrs);
129
138
  const props = attrsToProperties(node);
@@ -135,7 +144,7 @@ function ensureContentNotBound(node, options) {
135
144
  ...props.alias !== void 0 ? { alias: props.alias } : {}
136
145
  });
137
146
  }
138
- return { strippedRawPropertiesXml: raw.replaceAll(/<\w+:dataBinding\b[^>]*\/?>(?:[\s\S]*?<\/\w+:dataBinding>)?/giu, "") };
147
+ return { _preserved: withoutPreservedSdtChild(preserved, "dataBinding") ?? null };
139
148
  }
140
149
  function paragraphFromText(schema, text) {
141
150
  if (text.length === 0) return schema.node("paragraph", {}, []);
@@ -157,13 +166,13 @@ function setContentControlContentTr(state, filter, input, options = {}) {
157
166
  const match = findBlockSdtMatch(state.doc, filter);
158
167
  if (!match) return null;
159
168
  ensureContentNotLocked(match.node, options);
160
- const { strippedRawPropertiesXml } = ensureContentNotBound(match.node, options);
169
+ const bindingOverride = ensureContentNotBound(match.node, options);
161
170
  if (typeof input !== "string") throw new ContentControlTypeError({
162
171
  message: "Block-content fill must go through `setContentControlContentBlocksTr` (avoids a schema/plugin import cycle); pass a string here.",
163
172
  sdtType: match.node.attrs["sdtType"] ?? "richText",
164
173
  reason: "PM-direct path takes string input only"
165
174
  });
166
- return replaceBlockSdtChildren(state, match, [paragraphFromText(state.schema, input)], strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {});
175
+ return replaceBlockSdtChildren(state, match, [paragraphFromText(state.schema, input)], bindingOverride);
167
176
  }
168
177
  /**
169
178
  * Internal helper for the block-content fill variant. Lives in this module
@@ -175,15 +184,13 @@ function replaceBlockSdtChildrenForFill(state, filter, children, options = {}) {
175
184
  const match = findBlockSdtMatch(state.doc, filter);
176
185
  if (!match) return null;
177
186
  ensureContentNotLocked(match.node, options);
178
- const { strippedRawPropertiesXml } = ensureContentNotBound(match.node, options);
179
- return replaceBlockSdtChildren(state, match, children, strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {});
187
+ return replaceBlockSdtChildren(state, match, children, ensureContentNotBound(match.node, options));
180
188
  }
181
189
  function setContentControlValueTr(state, filter, input, options = {}) {
182
190
  const match = findBlockSdtMatch(state.doc, filter);
183
191
  if (!match) return null;
184
192
  ensureContentNotLocked(match.node, options);
185
- const { strippedRawPropertiesXml } = ensureContentNotBound(match.node, options);
186
- const bindingOverride = strippedRawPropertiesXml !== void 0 ? { rawPropertiesXml: strippedRawPropertiesXml } : {};
193
+ const bindingOverride = ensureContentNotBound(match.node, options);
187
194
  const sdtType = match.node.attrs["sdtType"];
188
195
  if (input.kind === "dropdown") {
189
196
  if (sdtType !== "dropdown" && sdtType !== "comboBox") throw new ContentControlTypeError({
@@ -220,8 +227,15 @@ function setContentControlValueTr(state, filter, input, options = {}) {
220
227
  sdtType,
221
228
  reason: "kind=checkbox requires sdtType=checkbox"
222
229
  });
223
- const glyph = input.checked ? "☒" : "☐";
224
- return replaceBlockSdtChildren(state, match, [paragraphFromText(state.schema, glyph)], {
230
+ const display = checkboxDisplayContent(preservedSdtChild(preservedOf(match.node), "checkbox"), input.checked);
231
+ let content = display.type === "symbol" ? state.schema.node("symbol", {
232
+ font: display.font,
233
+ char: display.char
234
+ }) : state.schema.text(display.text);
235
+ const sourceParagraph = match.node.firstChild;
236
+ const sourceInline = sourceParagraph?.firstChild;
237
+ if (sourceInline && sourceInline.marks.length > 0) content = content.mark(sourceInline.marks);
238
+ return replaceBlockSdtChildren(state, match, [state.schema.node("paragraph", sourceParagraph?.type.name === "paragraph" ? sourceParagraph.attrs : {}, [content])], {
225
239
  checked: input.checked,
226
240
  ...bindingOverride
227
241
  });
@@ -270,8 +284,7 @@ function parseSdtDate(iso) {
270
284
  return Number.isNaN(parsed.getTime()) ? null : parsed;
271
285
  }
272
286
  function isRepeatingSection(node) {
273
- const raw = node.attrs["rawPropertiesXml"];
274
- return typeof raw === "string" && /<\w+:repeatingSection\b/u.test(raw);
287
+ return preservedSdtChild(preservedOf(node), "repeatingSection") !== void 0;
275
288
  }
276
289
  function removeContentControlTr(state, filter, options = {}) {
277
290
  const match = findBlockSdtMatch(state.doc, filter);
@@ -1,3 +1,4 @@
1
+ import { document_d_exports } from "../../types/document.js";
1
2
  import { ImageAttrs, ImagePositionAttrs } from "../schema/nodes.js";
2
3
  import { EditorView } from "prosemirror-view";
3
4
  //#region src/prosemirror/commands/image.d.ts
@@ -25,14 +26,20 @@ type ImagePropertiesInput = {
25
26
  };
26
27
  type ImageTransformAction = "rotateCW" | "rotateCCW" | "flipH" | "flipV";
27
28
  type ResolvedImageWrap = {
28
- wrapType: ImageAttrs["wrapType"];
29
+ wrapType: NonNullable<ImageAttrs["wrapType"]>;
29
30
  displayMode: ImageAttrs["displayMode"];
30
31
  cssFloat: ImageAttrs["cssFloat"];
31
32
  };
32
33
  /** Map a toolbar wrap selection to the image's wrapType/displayMode/cssFloat, or null when unknown. */
33
34
  declare const resolveImageWrap: (wrapType: string) => ResolvedImageWrap | null;
34
- /** The CSS transform after applying a rotate/flip action to the current transform string. */
35
- declare const computeImageTransform: (currentTransform: string, action: ImageTransformAction) => string | undefined;
35
+ /**
36
+ * The authored transform after applying a rotate/flip action.
37
+ *
38
+ * Every field the action decides is stated: rotating back to zero states zero,
39
+ * un-flipping states `false`. The editor is saying what the drawing is now, and
40
+ * leaving the field absent would hand the decision back to the file.
41
+ */
42
+ declare const computeImageTransform: (current: document_d_exports.ImageTransform | undefined, action: ImageTransformAction) => document_d_exports.ImageTransform;
36
43
  declare const normalizeImageHorizontalPosition: (data: ImagePositionInput["horizontal"]) => ImagePositionAttrs["horizontal"] | undefined;
37
44
  declare const normalizeImageVerticalPosition: (data: ImagePositionInput["vertical"]) => ImagePositionAttrs["vertical"] | undefined;
38
45
  /** Clamp an image's intrinsic size to the page text width, preserving aspect ratio. */
@@ -1,7 +1,10 @@
1
+ import { FOLIO_INSERTED_PICTURE_FRAME_LOCKS } from "../../docx/graphicFrameLocks.js";
2
+ import { wrapPolygonFor } from "../../docx/wrapPolygon.js";
1
3
  import { IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES } from "../../types/documentEnumValues.js";
2
4
  import { isSafeImageFile } from "../../utils/imageValidation.js";
3
5
  import { sanitizeImageSrc } from "../../utils/sanitizeImageSrc.js";
4
6
  import { expectImageAttrs, mergeImageAttrs } from "../attrs/index.js";
7
+ import { authoredTransformAttrs, readAuthoredTransform } from "../authoredTransformAttrs.js";
5
8
  //#region src/prosemirror/commands/image.ts
6
9
  /** Map a toolbar wrap selection to the image's wrapType/displayMode/cssFloat, or null when unknown. */
7
10
  const resolveImageWrap = (wrapType) => {
@@ -42,32 +45,44 @@ const resolveImageWrap = (wrapType) => {
42
45
  default: return null;
43
46
  }
44
47
  };
45
- /** The CSS transform after applying a rotate/flip action to the current transform string. */
46
- const computeImageTransform = (currentTransform, action) => {
47
- const rotateMatch = /rotate\((?<degrees>-?\d+(?:\.\d+)?)deg\)/u.exec(currentTransform);
48
- let rotation = rotateMatch ? Number.parseFloat(rotateMatch.groups["degrees"]) : 0;
49
- let hasFlipH = currentTransform.includes("scaleX(-1)");
50
- let hasFlipV = currentTransform.includes("scaleY(-1)");
48
+ const QUARTER_TURN = 90;
49
+ const FULL_TURN = 360;
50
+ /**
51
+ * The turn `degrees` names, in `[0, 360)`.
52
+ *
53
+ * `%` keeps the sign of its left operand in JavaScript, and an authored
54
+ * rotation may be negative, so a bare remainder answers `-270` where the
55
+ * drawing is at `90`.
56
+ */
57
+ const withinOneTurn = (degrees) => (degrees % FULL_TURN + FULL_TURN) % FULL_TURN;
58
+ /**
59
+ * The authored transform after applying a rotate/flip action.
60
+ *
61
+ * Every field the action decides is stated: rotating back to zero states zero,
62
+ * un-flipping states `false`. The editor is saying what the drawing is now, and
63
+ * leaving the field absent would hand the decision back to the file.
64
+ */
65
+ const computeImageTransform = (current, action) => {
66
+ const rotation = current?.rotation ?? 0;
51
67
  switch (action) {
52
- case "rotateCW":
53
- rotation = (rotation + 90) % 360;
54
- break;
55
- case "rotateCCW":
56
- rotation = (rotation - 90 + 360) % 360;
57
- break;
58
- case "flipH":
59
- hasFlipH = !hasFlipH;
60
- break;
61
- case "flipV":
62
- hasFlipV = !hasFlipV;
63
- break;
64
- default: break;
68
+ case "rotateCW": return {
69
+ ...current,
70
+ rotation: withinOneTurn(rotation + QUARTER_TURN)
71
+ };
72
+ case "rotateCCW": return {
73
+ ...current,
74
+ rotation: withinOneTurn(rotation - QUARTER_TURN)
75
+ };
76
+ case "flipH": return {
77
+ ...current,
78
+ flipH: current?.flipH !== true
79
+ };
80
+ case "flipV": return {
81
+ ...current,
82
+ flipV: current?.flipV !== true
83
+ };
84
+ default: return action;
65
85
  }
66
- const parts = [];
67
- if (rotation !== 0) parts.push(`rotate(${rotation}deg)`);
68
- if (hasFlipH) parts.push("scaleX(-1)");
69
- if (hasFlipV) parts.push("scaleY(-1)");
70
- return parts.length > 0 ? parts.join(" ") : void 0;
71
86
  };
72
87
  const isOneOf = (value, values) => value !== void 0 && values.some((allowed) => allowed === value);
73
88
  const normalizeImageHorizontalPosition = (data) => {
@@ -114,10 +129,12 @@ const applyImageWrapType = (view, pos, wrapType) => {
114
129
  if (!node) return false;
115
130
  const resolved = resolveImageWrap(wrapType);
116
131
  if (!resolved) return false;
132
+ const authoredPolygon = expectImageAttrs(node).wrapPolygon;
117
133
  const tr = view.state.tr.setNodeMarkup(pos, void 0, mergeImageAttrs(node, {
118
134
  wrapType: resolved.wrapType,
119
135
  displayMode: resolved.displayMode,
120
- cssFloat: resolved.cssFloat
136
+ cssFloat: resolved.cssFloat,
137
+ wrapPolygon: wrapPolygonFor(resolved.wrapType, authoredPolygon) ?? authoredPolygon
121
138
  }));
122
139
  view.dispatch(tr.scrollIntoView());
123
140
  return true;
@@ -126,9 +143,8 @@ const applyImageWrapType = (view, pos, wrapType) => {
126
143
  const applyImageTransform = (view, pos, action) => {
127
144
  const node = imageNodeAt(view, pos);
128
145
  if (!node) return false;
129
- const currentTransform = expectImageAttrs(node).transform ?? "";
130
- const transform = computeImageTransform(currentTransform, action);
131
- const tr = view.state.tr.setNodeMarkup(pos, void 0, mergeImageAttrs(node, { transform }));
146
+ const transform = computeImageTransform(readAuthoredTransform(expectImageAttrs(node)), action);
147
+ const tr = view.state.tr.setNodeMarkup(pos, void 0, mergeImageAttrs(node, authoredTransformAttrs(transform)));
132
148
  view.dispatch(tr.scrollIntoView());
133
149
  return true;
134
150
  };
@@ -185,7 +201,8 @@ const insertImageFromFile = async (view, file, onInserted) => {
185
201
  height: constrained.height,
186
202
  rId: `rId_img_${Date.now()}`,
187
203
  wrapType: "inline",
188
- displayMode: "inline"
204
+ displayMode: "inline",
205
+ frameLocks: FOLIO_INSERTED_PICTURE_FRAME_LOCKS
189
206
  });
190
207
  const { from } = view.state.selection;
191
208
  const tr = view.state.tr.insert(from, imageNode);
@@ -29,7 +29,7 @@ const insertPageBreak = (state, dispatch) => {
29
29
  const { $from } = state.selection;
30
30
  if (!pageBreakRunType || !state.selection.empty || !$from.parent.isTextblock) return false;
31
31
  for (let depth = $from.depth; depth >= 0; depth--) if (UNSUPPORTED_PAGE_BREAK_RUN_ANCESTORS.has($from.node(depth).type.name)) return false;
32
- if ($from.parent.type.name !== "paragraph" || pageBreakRunParagraphProjectionDisposition($from.parent).status === "unsupported" || hasTextBoxAnchorAtOrAfter($from.parent, $from.start(), $from.pos)) return false;
32
+ if ($from.parent.type.name !== "paragraph" || pageBreakRunParagraphProjectionDisposition($from.parent).status === "approximate" || hasTextBoxAnchorAtOrAfter($from.parent, $from.start(), $from.pos)) return false;
33
33
  if (dispatch) {
34
34
  const pageBreak = pageBreakRunType.create();
35
35
  dispatch(state.tr.replaceSelectionWith(pageBreak).scrollIntoView());