@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
@@ -6,6 +6,8 @@ import { NodeExtension } from "../types.js";
6
6
  * Represents OOXML inline SDTs as an inline node wrapping text content.
7
7
  * Supports: richText, plainText, date, dropdown, comboBox, checkbox.
8
8
  */
9
+ /** The editor's node for an inline `w:sdt`. */
10
+ declare const INLINE_CONTENT_CONTROL_NODE_NAME = "sdt";
9
11
  declare const SdtExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
10
12
  //#endregion
11
- export { SdtExtension };
13
+ export { INLINE_CONTENT_CONTROL_NODE_NAME, SdtExtension };
@@ -1,4 +1,5 @@
1
1
  import { expectSdtAttrs } from "../../attrs/index.js";
2
+ import { onOffFromDataset } from "../../conversion/sdtAttrs.js";
2
3
  import { createNodeExtension } from "../create.js";
3
4
  //#region src/prosemirror/extensions/nodes/SdtExtension.ts
4
5
  /**
@@ -7,6 +8,8 @@ import { createNodeExtension } from "../create.js";
7
8
  * Represents OOXML inline SDTs as an inline node wrapping text content.
8
9
  * Supports: richText, plainText, date, dropdown, comboBox, checkbox.
9
10
  */
11
+ /** The editor's node for an inline `w:sdt`. */
12
+ const INLINE_CONTENT_CONTROL_NODE_NAME = "sdt";
10
13
  const SdtExtension = createNodeExtension({
11
14
  name: "sdt",
12
15
  schemaNodeName: "sdt",
@@ -28,7 +31,8 @@ const SdtExtension = createNodeExtension({
28
31
  /** Placeholder text */
29
32
  placeholder: { default: null },
30
33
  /** Whether showing placeholder */
31
- showingPlaceholder: { default: false },
34
+ /** `w:showingPlcHdr`: `null` when the control states nothing. */
35
+ showingPlaceholder: { default: null },
32
36
  /** Date format for date controls */
33
37
  dateFormat: { default: null },
34
38
  /** ISO 8601 bound date value (`w:date@w:fullDate`). */
@@ -40,12 +44,17 @@ const SdtExtension = createNodeExtension({
40
44
  /** Checkbox checked state */
41
45
  checked: { default: null },
42
46
  /**
43
- * Verbatim `<w:sdtPr>` / `<w:sdtEndPr>` captured by the parser so
44
- * unmodeled OOXML features (`w:dataBinding`, `w15:*`, custom XML
45
- * mappings) round-trip after a save, mirroring the block-SDT node.
47
+ * The `w:sdtPr` children folio does not model, at their schema ordinal,
48
+ * and the verbatim `<w:sdtEndPr>` the parser captured, so a control keeps
49
+ * what it carries after a save. Mirrors the block-SDT node.
46
50
  */
47
- rawPropertiesXml: { default: null },
48
- rawEndPropertiesXml: { default: null }
51
+ _preserved: { default: null },
52
+ rawEndPropertiesXml: { default: null },
53
+ /**
54
+ * `w:sdtEndPr` as a record, so a control the editor rebuilds still
55
+ * writes its end mark once the captured bytes are gone.
56
+ */
57
+ endProperties: { default: null }
49
58
  },
50
59
  parseDOM: [{
51
60
  tag: "span.docx-sdt",
@@ -61,18 +70,15 @@ const SdtExtension = createNodeExtension({
61
70
  id: id !== null && !Number.isNaN(id) ? id : null,
62
71
  lock: el.dataset["lock"] || null,
63
72
  placeholder: el.dataset["placeholder"] || null,
64
- showingPlaceholder: el.dataset["showingPlaceholder"] === "true",
73
+ showingPlaceholder: onOffFromDataset(el.dataset["showingPlaceholder"]),
65
74
  dateFormat: el.dataset["dateFormat"] || null,
66
75
  dateValueISO: el.dataset["dateValueIso"] || null,
67
76
  listItems: el.dataset["listItems"] || null,
68
77
  dropdownLastValue: el.dataset["dropdownLastValue"] || null,
69
- checked: (() => {
70
- if (el.dataset["checked"] === "true") return true;
71
- if (el.dataset["checked"] === "false") return false;
72
- return null;
73
- })(),
74
- rawPropertiesXml: null,
75
- rawEndPropertiesXml: null
78
+ checked: onOffFromDataset(el.dataset["checked"]),
79
+ _preserved: null,
80
+ rawEndPropertiesXml: null,
81
+ endProperties: null
76
82
  };
77
83
  }
78
84
  }],
@@ -87,7 +93,7 @@ const SdtExtension = createNodeExtension({
87
93
  if (typeof attrs.id === "number") dataAttrs["data-sdt-id"] = String(attrs.id);
88
94
  if (attrs.lock) dataAttrs["data-lock"] = attrs.lock;
89
95
  if (attrs.placeholder) dataAttrs["data-placeholder"] = attrs.placeholder;
90
- if (attrs.showingPlaceholder) dataAttrs["data-showing-placeholder"] = "true";
96
+ if (attrs.showingPlaceholder !== null && attrs.showingPlaceholder !== void 0) dataAttrs["data-showing-placeholder"] = String(attrs.showingPlaceholder);
91
97
  if (attrs.dateFormat) dataAttrs["data-date-format"] = attrs.dateFormat;
92
98
  if (attrs.dateValueISO) dataAttrs["data-date-value-iso"] = attrs.dateValueISO;
93
99
  if (attrs.listItems) dataAttrs["data-list-items"] = attrs.listItems;
@@ -104,4 +110,4 @@ const SdtExtension = createNodeExtension({
104
110
  }
105
111
  });
106
112
  //#endregion
107
- export { SdtExtension };
113
+ export { INLINE_CONTENT_CONTROL_NODE_NAME, SdtExtension };
@@ -392,6 +392,9 @@ const ShapeExtension = createNodeExtension({
392
392
  outlineHeadEnd: { default: null },
393
393
  outlineTailEnd: { default: null },
394
394
  transform: { default: null },
395
+ docxRotation: { default: null },
396
+ docxFlipH: { default: null },
397
+ docxFlipV: { default: null },
395
398
  displayMode: { default: "inline" },
396
399
  cssFloat: { default: null },
397
400
  wrapType: { default: "inline" },
@@ -401,6 +404,10 @@ const ShapeExtension = createNodeExtension({
401
404
  distLeft: { default: null },
402
405
  distRight: { default: null },
403
406
  position: { default: null },
407
+ anchor: { default: null },
408
+ wrapDistanceSlots: { default: null },
409
+ wrapEffectExtentSlots: { default: null },
410
+ wrapPolygon: { default: null },
404
411
  shadowColor: { default: null },
405
412
  shadowBlur: { default: null },
406
413
  shadowOffsetX: { default: null },
@@ -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,10 +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 },
246
+ _preservedAttributes: { default: null },
247
+ _bookmarks: { default: null },
248
+ contentControls: { default: null },
249
+ _preserved: { default: null },
209
250
  trIns: { default: null },
210
251
  trDel: { default: null }
211
252
  },
@@ -222,40 +263,15 @@ const tableRowSpec = {
222
263
  ];
223
264
  }
224
265
  };
225
- const BORDER_STYLE_CSS = {
226
- single: "solid",
227
- double: "double",
228
- dotted: "dotted",
229
- dashed: "dashed",
230
- thick: "solid",
231
- dashSmallGap: "dashed",
232
- dotDash: "dashed",
233
- dotDotDash: "dotted",
234
- triple: "double",
235
- thinThickSmallGap: "double",
236
- thickThinSmallGap: "double",
237
- thinThickThinSmallGap: "double",
238
- thinThickMediumGap: "double",
239
- thickThinMediumGap: "double",
240
- thinThickThinMediumGap: "double",
241
- thinThickLargeGap: "double",
242
- thickThinLargeGap: "double",
243
- thinThickThinLargeGap: "double",
244
- wave: "solid",
245
- doubleWave: "double",
246
- dashDotStroked: "dashed",
247
- threeDEmboss: "ridge",
248
- threeDEngrave: "groove",
249
- outset: "outset",
250
- inset: "inset"
251
- };
252
266
  function buildCellBorderStyles(attrs) {
253
267
  const styles = [];
254
268
  const borders = attrs.borders;
255
269
  if (!borders) return styles;
256
270
  const borderToCss = (border) => {
257
- if (!border || !border.style || border.style === "none" || border.style === "nil") return "none";
258
- 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}`;
259
275
  };
260
276
  styles.push(`border-top: ${borderToCss(borders.top)}`);
261
277
  styles.push(`border-bottom: ${borderToCss(borders.bottom)}`);
@@ -272,27 +288,18 @@ function buildCellPaddingStyles(attrs) {
272
288
  const toPixels = (twips) => twips !== void 0 && twips > 0 ? Math.round(twips / 20 * 1.333) : 0;
273
289
  return [`padding: ${toPixels(margins.top)}px ${toPixels(margins.right)}px ${toPixels(margins.bottom)}px ${toPixels(margins.left)}px`];
274
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
+ };
275
297
  function buildTextDirectionStyles(textDirection) {
276
298
  if (!textDirection) return [];
299
+ const flow = textFlowCss(textDirection);
277
300
  const styles = [];
278
- switch (textDirection) {
279
- case "tbRl":
280
- case "tbRlV":
281
- styles.push("writing-mode: vertical-rl");
282
- break;
283
- case "btLr":
284
- styles.push("writing-mode: vertical-lr", "transform: rotate(180deg)");
285
- break;
286
- case "rl":
287
- case "rlV":
288
- styles.push("direction: rtl");
289
- break;
290
- case "tb":
291
- case "tbV":
292
- styles.push("writing-mode: vertical-lr");
293
- break;
294
- default: break;
295
- }
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)`);
296
303
  return styles;
297
304
  }
298
305
  function buildCellWidthStyles(attrs) {
@@ -307,16 +314,33 @@ function buildCellWidthStyles(attrs) {
307
314
  }
308
315
  return styles;
309
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
+ });
310
332
  const tableCellSpec = {
311
- content: "(paragraph | table | textBox)+",
333
+ content: "(paragraph | table | textBox | preservedBlock | blockBookmarkBoundary)+",
312
334
  tableRole: "cell",
313
335
  isolating: true,
314
336
  attrs: {
315
337
  colspan: { default: 1 },
316
338
  rowspan: { default: 1 },
339
+ _omittedGridSlot: { default: null },
317
340
  colwidth: { default: null },
318
341
  width: { default: null },
319
342
  widthType: { default: null },
343
+ _authoredWidth: { default: null },
320
344
  verticalAlign: { default: null },
321
345
  backgroundColor: { default: null },
322
346
  _resolvedBackgroundColor: { default: null },
@@ -330,6 +354,7 @@ const tableCellSpec = {
330
354
  _originalFormatting: { default: null },
331
355
  tcPrChange: { default: null },
332
356
  cellMarker: { default: null },
357
+ contentControls: { default: null },
333
358
  _preserveVMergeRestart: { default: null },
334
359
  _docxVMergeContinuationCells: { default: null }
335
360
  },
@@ -340,10 +365,17 @@ const tableCellSpec = {
340
365
  toDOM(node) {
341
366
  const attrs = expectTableCellAttrs(node);
342
367
  const domAttrs = { class: "docx-table-cell" };
368
+ const omittedGridSlot = isEmptyOmittedGridSlotNode(node) && isOmittedGridSlot(attrs._omittedGridSlot) ? attrs._omittedGridSlot : void 0;
343
369
  if (attrs.colspan > 1) domAttrs["colspan"] = String(attrs.colspan);
344
370
  if (attrs.rowspan > 1) domAttrs["rowspan"] = String(attrs.rowspan);
345
371
  const styles = [];
346
- 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));
347
379
  if (attrs.noWrap) styles.push("white-space: nowrap");
348
380
  else styles.push("word-wrap: break-word", "overflow-wrap: break-word", "overflow: hidden");
349
381
  styles.push(...buildCellWidthStyles(attrs));
@@ -366,15 +398,17 @@ const tableCellSpec = {
366
398
  }
367
399
  };
368
400
  const tableHeaderSpec = {
369
- content: "(paragraph | table | textBox)+",
401
+ content: "(paragraph | table | textBox | preservedBlock | blockBookmarkBoundary)+",
370
402
  tableRole: "header_cell",
371
403
  isolating: true,
372
404
  attrs: {
373
405
  colspan: { default: 1 },
374
406
  rowspan: { default: 1 },
407
+ _omittedGridSlot: { default: null },
375
408
  colwidth: { default: null },
376
409
  width: { default: null },
377
410
  widthType: { default: null },
411
+ _authoredWidth: { default: null },
378
412
  verticalAlign: { default: null },
379
413
  backgroundColor: { default: null },
380
414
  _resolvedBackgroundColor: { default: null },
@@ -388,6 +422,7 @@ const tableHeaderSpec = {
388
422
  _originalFormatting: { default: null },
389
423
  tcPrChange: { default: null },
390
424
  cellMarker: { default: null },
425
+ contentControls: { default: null },
391
426
  _preserveVMergeRestart: { default: null },
392
427
  _docxVMergeContinuationCells: { default: null }
393
428
  },
@@ -398,10 +433,17 @@ const tableHeaderSpec = {
398
433
  toDOM(node) {
399
434
  const attrs = expectTableCellAttrs(node);
400
435
  const domAttrs = { class: "docx-table-header" };
436
+ const omittedGridSlot = isEmptyOmittedGridSlotNode(node) && isOmittedGridSlot(attrs._omittedGridSlot) ? attrs._omittedGridSlot : void 0;
401
437
  if (attrs.colspan > 1) domAttrs["colspan"] = String(attrs.colspan);
402
438
  if (attrs.rowspan > 1) domAttrs["rowspan"] = String(attrs.rowspan);
403
439
  const styles = ["font-weight: bold"];
404
- 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));
405
447
  if (attrs.noWrap) styles.push("white-space: nowrap");
406
448
  else styles.push("word-wrap: break-word", "overflow-wrap: break-word", "overflow: hidden");
407
449
  styles.push(...buildCellWidthStyles(attrs));
@@ -473,7 +515,7 @@ function getTableContext(state) {
473
515
  "left"
474
516
  ]) {
475
517
  const border = borders[side];
476
- if (border?.color && border.style && border.style !== "none" && border.style !== "nil") {
518
+ if (border?.color && border.style !== void 0 && !statesNoBorder(border.style)) {
477
519
  cellBorderColor = border.color;
478
520
  break;
479
521
  }
@@ -536,64 +578,44 @@ function findCellInfo(state) {
536
578
  tableDepth
537
579
  };
538
580
  }
539
- 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) => {
540
596
  return (state, dispatch) => {
541
597
  if (!isInTableCell(state)) return false;
542
598
  const info = findCellInfo(state);
543
599
  if (!info) return false;
544
600
  const { $from } = state.selection;
545
601
  const table = $from.node(info.tableDepth);
546
- const row = $from.node(info.rowDepth);
547
- const cellIndex = $from.index(info.rowDepth);
548
- const rowIndex = $from.index(info.tableDepth);
549
- if (cellIndex < row.childCount - 1) {
550
- const nextCellPos = info.cellPos + $from.node(info.cellDepth).nodeSize;
551
- if (dispatch) {
552
- const textPos = nextCellPos + 1 + 1;
553
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos))).scrollIntoView());
554
- }
555
- return true;
556
- }
557
- if (rowIndex < table.childCount - 1) {
558
- const nextRowPos = $from.before(info.rowDepth) + row.nodeSize;
559
- if (dispatch) {
560
- const textPos = nextRowPos + 1 + 1 + 1;
561
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos))).scrollIntoView());
562
- }
563
- 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());
564
610
  }
565
- return false;
611
+ return true;
566
612
  };
613
+ };
614
+ function goToNextCell() {
615
+ return goToAdjacentAuthoredCell(1);
567
616
  }
568
617
  function goToPrevCell() {
569
- return (state, dispatch) => {
570
- if (!isInTableCell(state)) return false;
571
- const info = findCellInfo(state);
572
- if (!info) return false;
573
- const { $from } = state.selection;
574
- const table = $from.node(info.tableDepth);
575
- const cellIndex = $from.index(info.rowDepth);
576
- const rowIndex = $from.index(info.tableDepth);
577
- if (cellIndex > 0) {
578
- const prevCell = $from.node(info.rowDepth).child(cellIndex - 1);
579
- const cellStartPos = info.cellPos - prevCell.nodeSize;
580
- if (dispatch) {
581
- const textPos = cellStartPos + prevCell.nodeSize - 2;
582
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos), -1)).scrollIntoView());
583
- }
584
- return true;
585
- }
586
- if (rowIndex > 0) {
587
- const prevRow = table.child(rowIndex - 1);
588
- const prevRowPos = $from.before(info.rowDepth) - prevRow.nodeSize;
589
- if (dispatch) {
590
- const textPos = prevRowPos + prevRow.nodeSize - 1 - 1;
591
- dispatch(state.tr.setSelection(Selection.near(state.doc.resolve(textPos), -1)).scrollIntoView());
592
- }
593
- return true;
594
- }
595
- return false;
596
- };
618
+ return goToAdjacentAuthoredCell(-1);
597
619
  }
598
620
  const TableNodeExtension = createNodeExtension({
599
621
  name: "table",
@@ -641,6 +663,7 @@ const TablePluginExtension = createExtension({
641
663
  colwidth: baseAttrs["colwidth"],
642
664
  width: baseAttrs["width"],
643
665
  widthType: baseAttrs["widthType"],
666
+ _authoredWidth: baseAttrs["_authoredWidth"],
644
667
  verticalAlign: baseAttrs["verticalAlign"],
645
668
  backgroundColor: baseAttrs["backgroundColor"],
646
669
  borders: baseAttrs["borders"],
@@ -674,8 +697,7 @@ const TablePluginExtension = createExtension({
674
697
  colspan: 1,
675
698
  rowspan: 1,
676
699
  borders: defaultBorders,
677
- width: colWidthTwips,
678
- widthType: "dxa"
700
+ ...statedCellWidth(colWidthTwips, "dxa")
679
701
  };
680
702
  cells.push(nodeTypeTableCell.create(cellAttrs, paragraph));
681
703
  }
@@ -753,7 +775,7 @@ const TablePluginExtension = createExtension({
753
775
  */
754
776
  function insertTableRow(state, dispatch, boundaryOffset) {
755
777
  const context = getTableContext(state);
756
- 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;
757
779
  if (!dispatch) return true;
758
780
  const { table, tablePos, rowIndex } = context;
759
781
  const boundaryRow = rowIndex + boundaryOffset;
@@ -802,6 +824,7 @@ const TablePluginExtension = createExtension({
802
824
  function deleteRow(state, dispatch) {
803
825
  const context = getTableContext(state);
804
826
  if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
827
+ if (hasOmittedGridSlots(context.table)) return false;
805
828
  const tablePos = context.tablePos;
806
829
  const table = context.table;
807
830
  const rowCount = context.rowCount ?? 0;
@@ -846,7 +869,7 @@ const TablePluginExtension = createExtension({
846
869
  }
847
870
  function addColumnLeft(state, dispatch) {
848
871
  const context = getTableContext(state);
849
- 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;
850
873
  if (dispatch) {
851
874
  let tr = state.tr;
852
875
  const newColumnCount = (context.columnCount ?? 1) + 1;
@@ -863,8 +886,7 @@ const TablePluginExtension = createExtension({
863
886
  colspan: 1,
864
887
  rowspan: 1
865
888
  });
866
- cellAttrs["width"] = newColWidthPercent;
867
- cellAttrs["widthType"] = "pct";
889
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
868
890
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
869
891
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
870
892
  }
@@ -877,8 +899,7 @@ const TablePluginExtension = createExtension({
877
899
  colspan: 1,
878
900
  rowspan: 1
879
901
  });
880
- cellAttrs["width"] = newColWidthPercent;
881
- cellAttrs["widthType"] = "pct";
902
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
882
903
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
883
904
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
884
905
  }
@@ -909,7 +930,7 @@ const TablePluginExtension = createExtension({
909
930
  }
910
931
  function addColumnRight(state, dispatch) {
911
932
  const context = getTableContext(state);
912
- 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;
913
934
  if (dispatch) {
914
935
  let tr = state.tr;
915
936
  const newColumnCount = (context.columnCount ?? 1) + 1;
@@ -929,8 +950,7 @@ const TablePluginExtension = createExtension({
929
950
  colspan: 1,
930
951
  rowspan: 1
931
952
  });
932
- cellAttrs["width"] = newColWidthPercent;
933
- cellAttrs["widthType"] = "pct";
953
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
934
954
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
935
955
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
936
956
  insertedCount += 1;
@@ -942,8 +962,7 @@ const TablePluginExtension = createExtension({
942
962
  colspan: 1,
943
963
  rowspan: 1
944
964
  });
945
- cellAttrs["width"] = newColWidthPercent;
946
- cellAttrs["widthType"] = "pct";
965
+ Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
947
966
  const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
948
967
  tr = tr.insert(tr.mapping.map(cellPos), newCell);
949
968
  }
@@ -974,7 +993,7 @@ const TablePluginExtension = createExtension({
974
993
  }
975
994
  function deleteColumn(state, dispatch) {
976
995
  const context = getTableContext(state);
977
- 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;
978
997
  if (dispatch) {
979
998
  let tr = state.tr;
980
999
  const newColumnCount = (context.columnCount ?? 2) - 1;
@@ -1485,7 +1504,7 @@ const TablePluginExtension = createExtension({
1485
1504
  const context = getTableContext(state);
1486
1505
  if (!context.isInTable || context.tablePos === void 0 || !context.table) return false;
1487
1506
  if (dispatch) {
1488
- if (direction !== null && !isOneOf(direction, TABLE_CELL_TEXT_DIRECTION_VALUES)) return false;
1507
+ if (direction !== null && !isOneOf(direction, TEXT_DIRECTION_VALUES)) return false;
1489
1508
  const tr = state.tr;
1490
1509
  const cells = getTargetCellPositions(state);
1491
1510
  for (const { pos, node } of cells) tr.setNodeMarkup(tr.mapping.map(pos), void 0, mergeTableCellAttrs(node, { textDirection: direction ?? void 0 }));
@@ -1984,8 +2003,8 @@ const TablePluginExtension = createExtension({
1984
2003
  selectTable: () => selectTable,
1985
2004
  selectRow: () => selectRow,
1986
2005
  selectColumn: () => selectColumn,
1987
- mergeCells: () => mergeCells,
1988
- splitCell: () => splitCell,
2006
+ mergeCells: () => preserveOmittedGridSlots(mergeCells),
2007
+ splitCell: () => preserveOmittedGridSlots(splitCell),
1989
2008
  setCellBorder: (side, spec, clearOthers) => setCellBorder(side, spec, clearOthers),
1990
2009
  setTableBorders: (preset, borderSpec) => setTableBorders(preset, borderSpec),
1991
2010
  setTableBorderPreset: (preset) => setTableBorderPreset(preset),
@@ -90,6 +90,9 @@ const TextBoxExtension = createNodeExtension({
90
90
  outlineColor: { default: null },
91
91
  outlineStyle: { default: null },
92
92
  transform: { default: null },
93
+ docxRotation: { default: null },
94
+ docxFlipH: { default: null },
95
+ docxFlipV: { default: null },
93
96
  marginTop: { default: null },
94
97
  marginBottom: { default: null },
95
98
  marginLeft: { default: null },
@@ -104,12 +107,17 @@ const TextBoxExtension = createNodeExtension({
104
107
  distLeft: { default: null },
105
108
  distRight: { default: null },
106
109
  position: { default: null },
110
+ anchor: { default: null },
111
+ wrapDistanceSlots: { default: null },
112
+ wrapEffectExtentSlots: { default: null },
113
+ wrapPolygon: { default: null },
107
114
  _docxPlacement: { default: null },
108
115
  _docxGroupId: { default: null },
109
116
  _docxAnchorId: { default: null },
110
117
  _docxTextBodyContentState: { default: { type: "authored" } },
111
118
  _docxTrackedChange: { default: null },
112
- _docxInlineSdts: { default: null }
119
+ _docxInlineSdts: { default: null },
120
+ _preservedAttributes: { default: null }
113
121
  },
114
122
  parseDOM: [{
115
123
  tag: "div.docx-textbox",