@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
@@ -1,9 +1,13 @@
1
1
  import { setTableLookFlags } from "../../../docx/tableLook.js";
2
- import { TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_WIDTH_TYPE_VALUES } from "../../../types/documentEnumValues.js";
2
+ import { TABLE_JUSTIFICATION_VALUES, TABLE_WIDTH_TYPE_VALUES, TEXT_DIRECTION_VALUES } from "../../../types/documentEnumValues.js";
3
+ import { cssBorderStyle } from "../../../utils/borderCss.js";
3
4
  import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
5
+ import { resolveTablePlacementAlignment } from "../../../utils/tablePlacement.js";
6
+ import { textFlowCss } from "../../../utils/textDirectionFlow.js";
4
7
  import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
5
8
  import { createExtension, createNodeExtension } from "../create.js";
6
9
  import { panic } from "better-result";
10
+ import { statesNoBorder } from "@stll/docx-core/model";
7
11
  import { CellSelection, TableMap, columnResizing, mergeCells, removeRow, selectedRect, splitCell, tableEditing } from "prosemirror-tables";
8
12
  import { Plugin, PluginKey, Selection, TextSelection } from "prosemirror-state";
9
13
  import { Decoration, DecorationSet } from "prosemirror-view";
@@ -14,6 +18,27 @@ import { Decoration, DecorationSet } from "prosemirror-view";
14
18
  * Uses separate NodeExtension instances for each table node type,
15
19
  * plus an Extension for plugins and commands.
16
20
  */
21
+ const isOmittedGridSlot = (value) => value === "before" || value === "after";
22
+ const isEmptyOmittedGridSlotNode = (node) => {
23
+ if (node.childCount !== 1) return false;
24
+ const paragraph = node.child(0);
25
+ return paragraph.type.name === "paragraph" && paragraph.content.size === 0;
26
+ };
27
+ const hasOmittedGridSlots = (table) => {
28
+ let found = false;
29
+ table.forEach((row) => {
30
+ if (row.type.name !== "tableRow") return;
31
+ row.forEach((cell) => {
32
+ if ((cell.type.name === "tableCell" || cell.type.name === "tableHeader") && isOmittedGridSlot(expectTableCellAttrs(cell)._omittedGridSlot)) found = true;
33
+ });
34
+ });
35
+ return found;
36
+ };
37
+ const preserveOmittedGridSlots = (command) => (state, dispatch, view) => {
38
+ const { table } = getTableContext(state);
39
+ if (table && hasOmittedGridSlots(table)) return false;
40
+ return command(state, dispatch, view);
41
+ };
17
42
  const isOneOf = (value, values) => value !== null && value !== void 0 && values.some((allowed) => allowed === value);
18
43
  /** Map CSS border-style to OOXML border style. */
19
44
  function cssBorderStyleToOoxml(cssStyle) {
@@ -121,6 +146,12 @@ function mapCssVerticalAlign(cssValue) {
121
146
  function parseCssColorToHex(cssColor) {
122
147
  return parseCssColorToColorValue(cssColor)?.rgb;
123
148
  }
149
+ const isEmptyOmittedGridSlotDOM = (element) => {
150
+ if (!element.children || element.children.length !== 1) return false;
151
+ const paragraph = element.children[0];
152
+ if (paragraph?.localName !== "p" || paragraph.textContent !== "") return false;
153
+ return Array.from(paragraph.children).every((child) => child.localName === "br");
154
+ };
124
155
  /** Shared parseDOM getAttrs for td/th — extracts borders, padding, alignment from CSS. */
125
156
  function parseCellAttrsFromDOM(element) {
126
157
  const style = element.style;
@@ -130,13 +161,16 @@ function parseCellAttrsFromDOM(element) {
130
161
  const verticalAlign = (rawValign === "top" || rawValign === "center" || rawValign === "bottom" ? rawValign : void 0) ?? mapCssVerticalAlign(style.verticalAlign) ?? void 0;
131
162
  const rawBgColor = element.dataset["bgcolor"];
132
163
  const backgroundColor = (isValidHexColor(rawBgColor) ? rawBgColor : void 0) || parseCssColorToHex(style.backgroundColor) || void 0;
164
+ const rawOmittedGridSlot = element.dataset["omittedGridSlot"];
165
+ const omittedGridSlot = isEmptyOmittedGridSlotDOM(element) && isOmittedGridSlot(rawOmittedGridSlot) ? rawOmittedGridSlot : void 0;
133
166
  return {
134
167
  colspan: Number(element.getAttribute("colspan") ?? "1") || 1,
135
168
  rowspan: Number(element.getAttribute("rowspan") ?? "1") || 1,
136
169
  ...verticalAlign !== void 0 ? { verticalAlign } : {},
137
170
  ...backgroundColor !== void 0 ? { backgroundColor } : {},
138
171
  ...borders ? { borders } : {},
139
- ...margins ? { margins } : {}
172
+ ...margins ? { margins } : {},
173
+ ...omittedGridSlot !== void 0 ? { _omittedGridSlot: omittedGridSlot } : {}
140
174
  };
141
175
  }
142
176
  const tableSpec = {
@@ -160,6 +194,8 @@ const tableSpec = {
160
194
  _resolvedBidi: { default: null },
161
195
  _originalFormatting: { default: null },
162
196
  tblPrChange: { default: null },
197
+ _bookmarks: { default: null },
198
+ _preserved: { default: null },
163
199
  _suggestedInsert: { default: null }
164
200
  },
165
201
  parseDOM: [{
@@ -167,7 +203,7 @@ const tableSpec = {
167
203
  getAttrs(dom) {
168
204
  const styleId = dom.dataset["styleId"];
169
205
  const rawJustification = dom.dataset["justification"];
170
- const justification = rawJustification === "left" || rawJustification === "center" || rawJustification === "right" ? rawJustification : void 0;
206
+ const justification = rawJustification !== void 0 && isOneOf(rawJustification, TABLE_JUSTIFICATION_VALUES) ? rawJustification : void 0;
171
207
  return {
172
208
  ...styleId ? { styleId } : {},
173
209
  ...justification !== void 0 ? { justification } : {}
@@ -185,8 +221,7 @@ const tableSpec = {
185
221
  styles.push(`width: ${widthPx}px`);
186
222
  } else styles.push("width: 100%");
187
223
  styles.push("table-layout: fixed");
188
- if (attrs.justification === "center") styles.push("margin-left: auto", "margin-right: auto");
189
- else if (attrs.justification === "right") styles.push("margin-left: auto");
224
+ styles.push(...tablePlacementStyles(attrs));
190
225
  domAttrs["style"] = styles.join("; ");
191
226
  return [
192
227
  "table",
@@ -202,11 +237,16 @@ const tableRowSpec = {
202
237
  height: { default: null },
203
238
  heightRule: { default: null },
204
239
  isHeader: { default: false },
205
- hidden: { default: false },
240
+ hidden: { default: null },
206
241
  _resolvedJustification: { default: null },
207
242
  _originalFormatting: { default: null },
243
+ _tablePropertyExceptions: { default: null },
208
244
  trPrChange: { default: null },
245
+ tblPrExChange: { default: null },
209
246
  _preservedAttributes: { default: null },
247
+ _bookmarks: { default: null },
248
+ contentControls: { default: null },
249
+ _preserved: { default: null },
210
250
  trIns: { default: null },
211
251
  trDel: { default: null }
212
252
  },
@@ -223,40 +263,15 @@ const tableRowSpec = {
223
263
  ];
224
264
  }
225
265
  };
226
- const BORDER_STYLE_CSS = {
227
- single: "solid",
228
- double: "double",
229
- dotted: "dotted",
230
- dashed: "dashed",
231
- thick: "solid",
232
- dashSmallGap: "dashed",
233
- dotDash: "dashed",
234
- dotDotDash: "dotted",
235
- triple: "double",
236
- thinThickSmallGap: "double",
237
- thickThinSmallGap: "double",
238
- thinThickThinSmallGap: "double",
239
- thinThickMediumGap: "double",
240
- thickThinMediumGap: "double",
241
- thinThickThinMediumGap: "double",
242
- thinThickLargeGap: "double",
243
- thickThinLargeGap: "double",
244
- thinThickThinLargeGap: "double",
245
- wave: "solid",
246
- doubleWave: "double",
247
- dashDotStroked: "dashed",
248
- threeDEmboss: "ridge",
249
- threeDEngrave: "groove",
250
- outset: "outset",
251
- inset: "inset"
252
- };
253
266
  function buildCellBorderStyles(attrs) {
254
267
  const styles = [];
255
268
  const borders = attrs.borders;
256
269
  if (!borders) return styles;
257
270
  const borderToCss = (border) => {
258
- if (!border || !border.style || border.style === "none" || border.style === "nil") return "none";
259
- return `${border.size !== void 0 && border.size > 0 ? Math.max(1, Math.round(border.size / 8 * 1.333)) : 1}px ${BORDER_STYLE_CSS[border.style] || "solid"} ${resolveColor(border.color, void 0)}`;
271
+ if (!border || border.style === void 0 || statesNoBorder(border.style)) return "none";
272
+ const widthPx = border.size !== void 0 && border.size > 0 ? Math.max(1, Math.round(border.size / 8 * 1.333)) : 1;
273
+ const color = resolveColor(border.color, void 0);
274
+ return `${widthPx}px ${cssBorderStyle(border.style)} ${color}`;
260
275
  };
261
276
  styles.push(`border-top: ${borderToCss(borders.top)}`);
262
277
  styles.push(`border-bottom: ${borderToCss(borders.bottom)}`);
@@ -273,27 +288,18 @@ function buildCellPaddingStyles(attrs) {
273
288
  const toPixels = (twips) => twips !== void 0 && twips > 0 ? Math.round(twips / 20 * 1.333) : 0;
274
289
  return [`padding: ${toPixels(margins.top)}px ${toPixels(margins.right)}px ${toPixels(margins.bottom)}px ${toPixels(margins.left)}px`];
275
290
  }
291
+ const tablePlacementStyles = (attrs) => {
292
+ if (attrs.justification === void 0) return [];
293
+ const alignment = resolveTablePlacementAlignment(attrs.justification, attrs._resolvedBidi === true);
294
+ if (alignment === "center") return ["margin-left: auto", "margin-right: auto"];
295
+ return alignment === "right" ? ["margin-left: auto"] : [];
296
+ };
276
297
  function buildTextDirectionStyles(textDirection) {
277
298
  if (!textDirection) return [];
299
+ const flow = textFlowCss(textDirection);
278
300
  const styles = [];
279
- switch (textDirection) {
280
- case "tbRl":
281
- case "tbRlV":
282
- styles.push("writing-mode: vertical-rl");
283
- break;
284
- case "btLr":
285
- styles.push("writing-mode: vertical-lr", "transform: rotate(180deg)");
286
- break;
287
- case "rl":
288
- case "rlV":
289
- styles.push("direction: rtl");
290
- break;
291
- case "tb":
292
- case "tbV":
293
- styles.push("writing-mode: vertical-lr");
294
- break;
295
- default: break;
296
- }
301
+ if (flow.writingMode !== "horizontal-tb") styles.push(`writing-mode: ${flow.writingMode}`);
302
+ if (flow.rotateDegrees !== void 0) styles.push(`transform: rotate(${String(flow.rotateDegrees)}deg)`);
297
303
  return styles;
298
304
  }
299
305
  function buildCellWidthStyles(attrs) {
@@ -308,16 +314,33 @@ function buildCellWidthStyles(attrs) {
308
314
  }
309
315
  return styles;
310
316
  }
317
+ /**
318
+ * The width attrs of a cell that states `value`.
319
+ *
320
+ * `mergeTableCellAttrs` derives `_authoredWidth` for a command that patches an
321
+ * existing cell; a command that builds a cell's attr record from scratch has no
322
+ * node to merge against and states them here.
323
+ */
324
+ const statedCellWidth = (value, type) => ({
325
+ width: value,
326
+ widthType: type,
327
+ _authoredWidth: {
328
+ value,
329
+ type
330
+ }
331
+ });
311
332
  const tableCellSpec = {
312
- content: "(paragraph | table | textBox | preservedBlock)+",
333
+ content: "(paragraph | table | textBox | preservedBlock | blockBookmarkBoundary)+",
313
334
  tableRole: "cell",
314
335
  isolating: true,
315
336
  attrs: {
316
337
  colspan: { default: 1 },
317
338
  rowspan: { default: 1 },
339
+ _omittedGridSlot: { default: null },
318
340
  colwidth: { default: null },
319
341
  width: { default: null },
320
342
  widthType: { default: null },
343
+ _authoredWidth: { default: null },
321
344
  verticalAlign: { default: null },
322
345
  backgroundColor: { default: null },
323
346
  _resolvedBackgroundColor: { default: null },
@@ -331,6 +354,7 @@ const tableCellSpec = {
331
354
  _originalFormatting: { default: null },
332
355
  tcPrChange: { default: null },
333
356
  cellMarker: { default: null },
357
+ contentControls: { default: null },
334
358
  _preserveVMergeRestart: { default: null },
335
359
  _docxVMergeContinuationCells: { default: null }
336
360
  },
@@ -341,10 +365,17 @@ const tableCellSpec = {
341
365
  toDOM(node) {
342
366
  const attrs = expectTableCellAttrs(node);
343
367
  const domAttrs = { class: "docx-table-cell" };
368
+ const omittedGridSlot = isEmptyOmittedGridSlotNode(node) && isOmittedGridSlot(attrs._omittedGridSlot) ? attrs._omittedGridSlot : void 0;
344
369
  if (attrs.colspan > 1) domAttrs["colspan"] = String(attrs.colspan);
345
370
  if (attrs.rowspan > 1) domAttrs["rowspan"] = String(attrs.rowspan);
346
371
  const styles = [];
347
- styles.push(...buildCellPaddingStyles(attrs));
372
+ if (omittedGridSlot !== void 0) {
373
+ domAttrs["aria-hidden"] = "true";
374
+ domAttrs["class"] = "docx-table-omitted-grid-slot";
375
+ domAttrs["contenteditable"] = "false";
376
+ domAttrs["data-omitted-grid-slot"] = omittedGridSlot;
377
+ styles.push("visibility: hidden", "pointer-events: none", "padding: 0", "border: none");
378
+ } else styles.push(...buildCellPaddingStyles(attrs));
348
379
  if (attrs.noWrap) styles.push("white-space: nowrap");
349
380
  else styles.push("word-wrap: break-word", "overflow-wrap: break-word", "overflow: hidden");
350
381
  styles.push(...buildCellWidthStyles(attrs));
@@ -367,15 +398,17 @@ const tableCellSpec = {
367
398
  }
368
399
  };
369
400
  const tableHeaderSpec = {
370
- content: "(paragraph | table | textBox | preservedBlock)+",
401
+ content: "(paragraph | table | textBox | preservedBlock | blockBookmarkBoundary)+",
371
402
  tableRole: "header_cell",
372
403
  isolating: true,
373
404
  attrs: {
374
405
  colspan: { default: 1 },
375
406
  rowspan: { default: 1 },
407
+ _omittedGridSlot: { default: null },
376
408
  colwidth: { default: null },
377
409
  width: { default: null },
378
410
  widthType: { default: null },
411
+ _authoredWidth: { default: null },
379
412
  verticalAlign: { default: null },
380
413
  backgroundColor: { default: null },
381
414
  _resolvedBackgroundColor: { default: null },
@@ -389,6 +422,7 @@ const tableHeaderSpec = {
389
422
  _originalFormatting: { default: null },
390
423
  tcPrChange: { default: null },
391
424
  cellMarker: { default: null },
425
+ contentControls: { default: null },
392
426
  _preserveVMergeRestart: { default: null },
393
427
  _docxVMergeContinuationCells: { default: null }
394
428
  },
@@ -399,10 +433,17 @@ const tableHeaderSpec = {
399
433
  toDOM(node) {
400
434
  const attrs = expectTableCellAttrs(node);
401
435
  const domAttrs = { class: "docx-table-header" };
436
+ const omittedGridSlot = isEmptyOmittedGridSlotNode(node) && isOmittedGridSlot(attrs._omittedGridSlot) ? attrs._omittedGridSlot : void 0;
402
437
  if (attrs.colspan > 1) domAttrs["colspan"] = String(attrs.colspan);
403
438
  if (attrs.rowspan > 1) domAttrs["rowspan"] = String(attrs.rowspan);
404
439
  const styles = ["font-weight: bold"];
405
- styles.push(...buildCellPaddingStyles(attrs));
440
+ if (omittedGridSlot !== void 0) {
441
+ domAttrs["aria-hidden"] = "true";
442
+ domAttrs["class"] = "docx-table-omitted-grid-slot";
443
+ domAttrs["contenteditable"] = "false";
444
+ domAttrs["data-omitted-grid-slot"] = omittedGridSlot;
445
+ styles.push("visibility: hidden", "pointer-events: none", "padding: 0", "border: none");
446
+ } else styles.push(...buildCellPaddingStyles(attrs));
406
447
  if (attrs.noWrap) styles.push("white-space: nowrap");
407
448
  else styles.push("word-wrap: break-word", "overflow-wrap: break-word", "overflow: hidden");
408
449
  styles.push(...buildCellWidthStyles(attrs));
@@ -474,7 +515,7 @@ function getTableContext(state) {
474
515
  "left"
475
516
  ]) {
476
517
  const border = borders[side];
477
- if (border?.color && border.style && border.style !== "none" && border.style !== "nil") {
518
+ if (border?.color && border.style !== void 0 && !statesNoBorder(border.style)) {
478
519
  cellBorderColor = border.color;
479
520
  break;
480
521
  }
@@ -537,64 +578,44 @@ function findCellInfo(state) {
537
578
  tableDepth
538
579
  };
539
580
  }
540
- function goToNextCell() {
581
+ const authoredCells = (table, tablePos) => {
582
+ const cells = [];
583
+ table.forEach((row, rowOffset) => {
584
+ const rowPos = tablePos + 1 + rowOffset;
585
+ row.forEach((cell, cellOffset) => {
586
+ const omittedGridSlot = expectTableCellAttrs(cell)._omittedGridSlot;
587
+ if (omittedGridSlot === void 0 || omittedGridSlot === null) cells.push({
588
+ node: cell,
589
+ pos: rowPos + 1 + cellOffset
590
+ });
591
+ });
592
+ });
593
+ return cells;
594
+ };
595
+ const goToAdjacentAuthoredCell = (direction) => {
541
596
  return (state, dispatch) => {
542
597
  if (!isInTableCell(state)) return false;
543
598
  const info = findCellInfo(state);
544
599
  if (!info) return false;
545
600
  const { $from } = state.selection;
546
601
  const table = $from.node(info.tableDepth);
547
- const row = $from.node(info.rowDepth);
548
- const cellIndex = $from.index(info.rowDepth);
549
- const rowIndex = $from.index(info.tableDepth);
550
- if (cellIndex < row.childCount - 1) {
551
- const nextCellPos = info.cellPos + $from.node(info.cellDepth).nodeSize;
552
- if (dispatch) {
553
- const textPos = nextCellPos + 1 + 1;
554
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos))).scrollIntoView());
555
- }
556
- return true;
557
- }
558
- if (rowIndex < table.childCount - 1) {
559
- const nextRowPos = $from.before(info.rowDepth) + row.nodeSize;
560
- if (dispatch) {
561
- const textPos = nextRowPos + 1 + 1 + 1;
562
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos))).scrollIntoView());
563
- }
564
- return true;
602
+ const cells = authoredCells(table, $from.before(info.tableDepth));
603
+ const currentIndex = cells.findIndex(({ pos }) => pos === info.cellPos);
604
+ const targetIndex = currentIndex + direction;
605
+ const target = currentIndex === -1 || targetIndex < 0 || targetIndex >= cells.length ? void 0 : cells[targetIndex];
606
+ if (!target) return false;
607
+ if (dispatch) {
608
+ const textPos = direction === 1 ? target.pos + 2 : target.pos + target.node.nodeSize - 2;
609
+ dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos), direction)).scrollIntoView());
565
610
  }
566
- return false;
611
+ return true;
567
612
  };
613
+ };
614
+ function goToNextCell() {
615
+ return goToAdjacentAuthoredCell(1);
568
616
  }
569
617
  function goToPrevCell() {
570
- return (state, dispatch) => {
571
- if (!isInTableCell(state)) return false;
572
- const info = findCellInfo(state);
573
- if (!info) return false;
574
- const { $from } = state.selection;
575
- const table = $from.node(info.tableDepth);
576
- const cellIndex = $from.index(info.rowDepth);
577
- const rowIndex = $from.index(info.tableDepth);
578
- if (cellIndex > 0) {
579
- const prevCell = $from.node(info.rowDepth).child(cellIndex - 1);
580
- const cellStartPos = info.cellPos - prevCell.nodeSize;
581
- if (dispatch) {
582
- const textPos = cellStartPos + prevCell.nodeSize - 2;
583
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos), -1)).scrollIntoView());
584
- }
585
- return true;
586
- }
587
- if (rowIndex > 0) {
588
- const prevRow = table.child(rowIndex - 1);
589
- const prevRowPos = $from.before(info.rowDepth) - prevRow.nodeSize;
590
- if (dispatch) {
591
- const textPos = prevRowPos + prevRow.nodeSize - 1 - 1;
592
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos), -1)).scrollIntoView());
593
- }
594
- return true;
595
- }
596
- return false;
597
- };
618
+ return goToAdjacentAuthoredCell(-1);
598
619
  }
599
620
  const TableNodeExtension = createNodeExtension({
600
621
  name: "table",
@@ -642,6 +663,7 @@ const TablePluginExtension = createExtension({
642
663
  colwidth: baseAttrs["colwidth"],
643
664
  width: baseAttrs["width"],
644
665
  widthType: baseAttrs["widthType"],
666
+ _authoredWidth: baseAttrs["_authoredWidth"],
645
667
  verticalAlign: baseAttrs["verticalAlign"],
646
668
  backgroundColor: baseAttrs["backgroundColor"],
647
669
  borders: baseAttrs["borders"],
@@ -675,8 +697,7 @@ const TablePluginExtension = createExtension({
675
697
  colspan: 1,
676
698
  rowspan: 1,
677
699
  borders: defaultBorders,
678
- width: colWidthTwips,
679
- widthType: "dxa"
700
+ ...statedCellWidth(colWidthTwips, "dxa")
680
701
  };
681
702
  cells.push(nodeTypeTableCell.create(cellAttrs, paragraph));
682
703
  }
@@ -754,7 +775,7 @@ const TablePluginExtension = createExtension({
754
775
  */
755
776
  function insertTableRow(state, dispatch, boundaryOffset) {
756
777
  const context = getTableContext(state);
757
- if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
778
+ if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0 || hasOmittedGridSlots(context.table)) return false;
758
779
  if (!dispatch) return true;
759
780
  const { table, tablePos, rowIndex } = context;
760
781
  const boundaryRow = rowIndex + boundaryOffset;
@@ -803,6 +824,7 @@ const TablePluginExtension = createExtension({
803
824
  function deleteRow(state, dispatch) {
804
825
  const context = getTableContext(state);
805
826
  if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
827
+ if (hasOmittedGridSlots(context.table)) return false;
806
828
  const tablePos = context.tablePos;
807
829
  const table = context.table;
808
830
  const rowCount = context.rowCount ?? 0;
@@ -847,7 +869,7 @@ const TablePluginExtension = createExtension({
847
869
  }
848
870
  function addColumnLeft(state, dispatch) {
849
871
  const context = getTableContext(state);
850
- if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0) return false;
872
+ if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || hasOmittedGridSlots(context.table)) return false;
851
873
  if (dispatch) {
852
874
  let tr = state.tr;
853
875
  const newColumnCount = (context.columnCount ?? 1) + 1;
@@ -864,8 +886,7 @@ const TablePluginExtension = createExtension({
864
886
  colspan: 1,
865
887
  rowspan: 1
866
888
  });
867
- cellAttrs["width"] = newColWidthPercent;
868
- cellAttrs["widthType"] = "pct";
889
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
869
890
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
870
891
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
871
892
  }
@@ -878,8 +899,7 @@ const TablePluginExtension = createExtension({
878
899
  colspan: 1,
879
900
  rowspan: 1
880
901
  });
881
- cellAttrs["width"] = newColWidthPercent;
882
- cellAttrs["widthType"] = "pct";
902
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
883
903
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
884
904
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
885
905
  }
@@ -910,7 +930,7 @@ const TablePluginExtension = createExtension({
910
930
  }
911
931
  function addColumnRight(state, dispatch) {
912
932
  const context = getTableContext(state);
913
- if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0) return false;
933
+ if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || hasOmittedGridSlots(context.table)) return false;
914
934
  if (dispatch) {
915
935
  let tr = state.tr;
916
936
  const newColumnCount = (context.columnCount ?? 1) + 1;
@@ -930,8 +950,7 @@ const TablePluginExtension = createExtension({
930
950
  colspan: 1,
931
951
  rowspan: 1
932
952
  });
933
- cellAttrs["width"] = newColWidthPercent;
934
- cellAttrs["widthType"] = "pct";
953
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
935
954
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
936
955
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
937
956
  insertedCount += 1;
@@ -943,8 +962,7 @@ const TablePluginExtension = createExtension({
943
962
  colspan: 1,
944
963
  rowspan: 1
945
964
  });
946
- cellAttrs["width"] = newColWidthPercent;
947
- cellAttrs["widthType"] = "pct";
965
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
948
966
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
949
967
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
950
968
  }
@@ -975,7 +993,7 @@ const TablePluginExtension = createExtension({
975
993
  }
976
994
  function deleteColumn(state, dispatch) {
977
995
  const context = getTableContext(state);
978
- if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1) return false;
996
+ if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1 || hasOmittedGridSlots(context.table)) return false;
979
997
  if (dispatch) {
980
998
  let tr = state.tr;
981
999
  const newColumnCount = (context.columnCount ?? 2) - 1;
@@ -1486,7 +1504,7 @@ const TablePluginExtension = createExtension({
1486
1504
  const context = getTableContext(state);
1487
1505
  if (!context.isInTable || context.tablePos === void 0 || !context.table) return false;
1488
1506
  if (dispatch) {
1489
- if (direction !== null && !isOneOf(direction, TABLE_CELL_TEXT_DIRECTION_VALUES)) return false;
1507
+ if (direction !== null && !isOneOf(direction, TEXT_DIRECTION_VALUES)) return false;
1490
1508
  const tr = state.tr;
1491
1509
  const cells = getTargetCellPositions(state);
1492
1510
  for (const { pos, node } of cells) tr.setNodeMarkup(tr.mapping.map(pos), void 0, mergeTableCellAttrs(node, { textDirection: direction ?? void 0 }));
@@ -1985,8 +2003,8 @@ const TablePluginExtension = createExtension({
1985
2003
  selectTable: () => selectTable,
1986
2004
  selectRow: () => selectRow,
1987
2005
  selectColumn: () => selectColumn,
1988
- mergeCells: () => mergeCells,
1989
- splitCell: () => splitCell,
2006
+ mergeCells: () => preserveOmittedGridSlots(mergeCells),
2007
+ splitCell: () => preserveOmittedGridSlots(splitCell),
1990
2008
  setCellBorder: (side, spec, clearOthers) => setCellBorder(side, spec, clearOthers),
1991
2009
  setTableBorders: (preset, borderSpec) => setTableBorders(preset, borderSpec),
1992
2010
  setTableBorderPreset: (preset) => setTableBorderPreset(preset),
@@ -107,6 +107,10 @@ const TextBoxExtension = createNodeExtension({
107
107
  distLeft: { default: null },
108
108
  distRight: { default: null },
109
109
  position: { default: null },
110
+ anchor: { default: null },
111
+ wrapDistanceSlots: { default: null },
112
+ wrapEffectExtentSlots: { default: null },
113
+ wrapPolygon: { default: null },
110
114
  _docxPlacement: { default: null },
111
115
  _docxGroupId: { default: null },
112
116
  _docxAnchorId: { default: null },
@@ -0,0 +1,23 @@
1
+ import { Node } from "prosemirror-model";
2
+ //#region src/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts
3
+ declare const bookmarkBoundaryAttrSpec: {
4
+ type: {};
5
+ id: {};
6
+ name: {
7
+ default: null;
8
+ };
9
+ colFirst: {
10
+ default: null;
11
+ };
12
+ colLast: {
13
+ default: null;
14
+ };
15
+ displacedByCustomXml: {
16
+ default: null;
17
+ };
18
+ };
19
+ /** `false` when the element does not describe a boundary ProseMirror can hold. */
20
+ declare const parseBookmarkBoundaryDom: (dom: HTMLElement | string) => Record<string, unknown> | false;
21
+ declare const bookmarkBoundaryDomAttributes: (node: Node, internalClipboardToken?: string) => Record<string, string>;
22
+ //#endregion
23
+ export { bookmarkBoundaryAttrSpec, bookmarkBoundaryDomAttributes, parseBookmarkBoundaryDom };
@@ -0,0 +1,57 @@
1
+ import { expectBookmarkBoundaryAttrs, isDisplacedByCustomXml } from "../../bookmarkBoundaryAttrs.js";
2
+ //#region src/prosemirror/extensions/nodes/bookmarkBoundaryDom.ts
3
+ const readNonnegativeInteger = (value) => {
4
+ if (value === null || !/^(?:0|[1-9]\d*)$/.test(value)) return false;
5
+ const parsed = Number(value);
6
+ return Number.isSafeInteger(parsed) ? parsed : false;
7
+ };
8
+ const readOptionalColumn = (dom, attribute) => {
9
+ const value = dom.getAttribute(attribute);
10
+ return value === null ? void 0 : readNonnegativeInteger(value);
11
+ };
12
+ const bookmarkBoundaryAttrSpec = {
13
+ type: {},
14
+ id: {},
15
+ name: { default: null },
16
+ colFirst: { default: null },
17
+ colLast: { default: null },
18
+ displacedByCustomXml: { default: null }
19
+ };
20
+ /** `false` when the element does not describe a boundary ProseMirror can hold. */
21
+ const parseBookmarkBoundaryDom = (dom) => {
22
+ if (typeof dom === "string") return false;
23
+ const type = dom.getAttribute("data-docx-bookmark-boundary");
24
+ const id = readNonnegativeInteger(dom.getAttribute("data-docx-bookmark-id"));
25
+ if (type !== "start" && type !== "end" || id === false) return false;
26
+ const name = dom.getAttribute("data-docx-bookmark-name");
27
+ if (type === "start" && !name) return false;
28
+ const colFirst = readOptionalColumn(dom, "data-docx-bookmark-col-first");
29
+ const colLast = readOptionalColumn(dom, "data-docx-bookmark-col-last");
30
+ if (colFirst === false || colLast === false) return false;
31
+ const displaced = dom.getAttribute("data-docx-bookmark-displaced");
32
+ return {
33
+ type,
34
+ id,
35
+ ...name ? { name } : {},
36
+ ...colFirst !== void 0 ? { colFirst } : {},
37
+ ...colLast !== void 0 ? { colLast } : {},
38
+ ...isDisplacedByCustomXml(displaced) ? { displacedByCustomXml: displaced } : {}
39
+ };
40
+ };
41
+ const bookmarkBoundaryDomAttributes = (node, internalClipboardToken) => {
42
+ const attrs = expectBookmarkBoundaryAttrs(node);
43
+ return {
44
+ "data-docx-bookmark-boundary": attrs.type,
45
+ "data-docx-bookmark-id": String(attrs.id),
46
+ ...attrs.type === "start" ? { "data-docx-bookmark-name": attrs.name } : {},
47
+ ...attrs.type === "start" && attrs.colFirst !== void 0 ? { "data-docx-bookmark-col-first": String(attrs.colFirst) } : {},
48
+ ...attrs.type === "start" && attrs.colLast !== void 0 ? { "data-docx-bookmark-col-last": String(attrs.colLast) } : {},
49
+ ...attrs.displacedByCustomXml !== void 0 ? { "data-docx-bookmark-displaced": attrs.displacedByCustomXml } : {},
50
+ "aria-hidden": "true",
51
+ contenteditable: "false",
52
+ style: "display: none;",
53
+ ...internalClipboardToken === void 0 ? {} : { "data-docx-internal-clipboard": internalClipboardToken }
54
+ };
55
+ };
56
+ //#endregion
57
+ export { bookmarkBoundaryAttrSpec, bookmarkBoundaryDomAttributes, parseBookmarkBoundaryDom };
@@ -2,20 +2,29 @@ import { document_d_exports } from "../../types/document.js";
2
2
  import { TextColorAttrs } from "../schema/marks.js";
3
3
  import "../schema/index.js";
4
4
  import { TablePropertiesCommand } from "../../utils/tableOperations.js";
5
+ import { SectionBreakType } from "../sectionCarrier.js";
5
6
  import { GenerateTableOfContentsOptions, ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
6
7
  import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
7
8
  import { Command, Plugin } from "prosemirror-state";
8
9
  import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
9
10
  //#region src/prosemirror/extensions/types.d.ts
11
+ /**
12
+ * A border a host asks folio to apply.
13
+ *
14
+ * `style` is what the model holds, not a narrower authoring union: a table
15
+ * style preset is built by reading a parsed `w:tblBorders` and handing it
16
+ * back, so a token the schema does not declare has to survive the round trip
17
+ * rather than be refused at the command.
18
+ */
10
19
  type TableCellBorderCommandSpec = {
11
- style: string;
20
+ style: document_d_exports.BorderStyleValue;
12
21
  size?: number;
13
22
  color?: {
14
23
  rgb: string;
15
24
  };
16
25
  };
17
26
  type TableBorderCommandSpec = {
18
- style: string;
27
+ style: document_d_exports.BorderStyleValue;
19
28
  size: number;
20
29
  color: {
21
30
  rgb: string;
@@ -98,7 +107,7 @@ type FolioCommandArguments = {
98
107
  setSpaceAfter: [twips: number];
99
108
  applyStyle: [styleId: string, resolvedAttrs?: ResolvedStyleAttrs];
100
109
  clearStyle: [];
101
- insertSectionBreak: [breakType: "nextPage" | "continuous" | "oddPage" | "evenPage"];
110
+ insertSectionBreak: [breakType: SectionBreakType];
102
111
  removeSectionBreak: [];
103
112
  addTabStop: [position: number, alignment?: document_d_exports.TabStopAlignment, leader?: document_d_exports.TabLeader];
104
113
  removeTabStop: [position: number];