@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
@@ -0,0 +1,23 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ import { XmlElement } from "./xmlParser.js";
3
+ //#region src/docx/paragraphProperties.d.ts
4
+ /**
5
+ * Read `w:pPr` into {@link ParagraphFormatting}, every declared child carrying
6
+ * a decision.
7
+ *
8
+ * One reader serves all four owners of the set — a paragraph's own properties,
9
+ * the `CT_PPrGeneral` a style carries, a numbering level's, and the
10
+ * `CT_PPrBase` snapshot inside `w:pPrChange` — so a property is read the same
11
+ * way wherever it was authored, and the handler map is total over the content
12
+ * model rather than over whichever names a `switch` happened to list.
13
+ *
14
+ * Three children belong to other readers and are neither modelled nor captured
15
+ * here, because capturing one as well would write it twice: `w:sectPr` is read
16
+ * by the section parser off the paragraph, `w:pPrChange` by the
17
+ * property-change parser, and `w:rPr` is the paragraph mark's own property
18
+ * set, read below off the element for the same reason a run's is read off the
19
+ * run.
20
+ */
21
+ declare function parseParagraphProperties(pPr: XmlElement | null, theme: document_d_exports.Theme | null): document_d_exports.ParagraphFormatting | undefined;
22
+ //#endregion
23
+ export { parseParagraphProperties };
@@ -0,0 +1,279 @@
1
+ import { readAttributeBag } from "./attributeRemainder.js";
2
+ import { parseBorderSpec } from "./borderParser.js";
3
+ import { CAPTURE, dispatchChildren, ownedElsewhere, sequencePositions } from "./containerChildren.js";
4
+ import { readParagraphNumbering } from "./numberingReference.js";
5
+ import { FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, TabLeaderSchema, TabStopAlignmentSchema, narrowEnum } from "./parserEnums.js";
6
+ import { FRAME_ATTRIBUTES, INDENTATION_ATTRIBUTES, SPACING_ATTRIBUTES, TAB_STOP_ATTRIBUTES } from "./propertyElementAttributes.js";
7
+ import { RUN_PROPERTY_OWNERS, parseRunProperties } from "./runParser.js";
8
+ import { parseShading } from "./shadingParser.js";
9
+ import { numericAttributeAnySpelling } from "./strictNames.js";
10
+ import { captureVerbatimXml } from "./verbatimCapture.js";
11
+ import { findChild, findChildren, getAttribute, parseBooleanElement, parseNumericAttribute, parseOnOffAttribute, parseOnOffChild } from "./xmlParser.js";
12
+ import { outlineLevelFromStatedValue } from "@stll/docx-core/model";
13
+ //#region src/docx/paragraphProperties.ts
14
+ /**
15
+ * Parse tab stops (w:tabs)
16
+ */
17
+ function parseTabStops(tabs) {
18
+ if (!tabs) return;
19
+ const tabElements = findChildren(tabs, "w", "tab");
20
+ if (tabElements.length === 0) return;
21
+ const result = [];
22
+ for (const tab of tabElements) {
23
+ const pos = parseNumericAttribute(tab, "w", "pos");
24
+ const alignment = narrowEnum(getAttribute(tab, "w", "val"), TabStopAlignmentSchema);
25
+ if (pos !== void 0 && alignment) {
26
+ const tabStop = {
27
+ position: pos,
28
+ alignment
29
+ };
30
+ const leader = narrowEnum(getAttribute(tab, "w", "leader"), TabLeaderSchema);
31
+ if (leader && leader !== "none") tabStop.leader = leader;
32
+ const preservedAttributes = readAttributeBag(tab, TAB_STOP_ATTRIBUTES);
33
+ if (preservedAttributes) tabStop.preservedAttributes = preservedAttributes;
34
+ result.push(tabStop);
35
+ }
36
+ }
37
+ return result.length > 0 ? result : void 0;
38
+ }
39
+ /**
40
+ * Parse frame properties (w:framePr)
41
+ */
42
+ function parseFrameProperties(framePr) {
43
+ if (!framePr) return;
44
+ const frame = {};
45
+ const dropCap = getAttribute(framePr, "w", "dropCap");
46
+ if (dropCap === "none" || dropCap === "drop" || dropCap === "margin") frame.dropCap = dropCap;
47
+ const lines = parseNumericAttribute(framePr, "w", "lines");
48
+ if (lines !== void 0) frame.lines = lines;
49
+ const w = parseNumericAttribute(framePr, "w", "w");
50
+ if (w !== void 0) frame.width = w;
51
+ const h = parseNumericAttribute(framePr, "w", "h");
52
+ if (h !== void 0) frame.height = h;
53
+ const hSpace = parseNumericAttribute(framePr, "w", "hSpace");
54
+ if (hSpace !== void 0) frame.hSpace = hSpace;
55
+ const vSpace = parseNumericAttribute(framePr, "w", "vSpace");
56
+ if (vSpace !== void 0) frame.vSpace = vSpace;
57
+ const hAnchor = getAttribute(framePr, "w", "hAnchor");
58
+ if (hAnchor === "text" || hAnchor === "margin" || hAnchor === "page") frame.hAnchor = hAnchor;
59
+ const vAnchor = getAttribute(framePr, "w", "vAnchor");
60
+ if (vAnchor === "text" || vAnchor === "margin" || vAnchor === "page") frame.vAnchor = vAnchor;
61
+ const x = parseNumericAttribute(framePr, "w", "x");
62
+ if (x !== void 0) frame.x = x;
63
+ const y = parseNumericAttribute(framePr, "w", "y");
64
+ if (y !== void 0) frame.y = y;
65
+ const xAlign = narrowEnum(getAttribute(framePr, "w", "xAlign"), FrameXAlignSchema);
66
+ if (xAlign) frame.xAlign = xAlign;
67
+ const yAlign = narrowEnum(getAttribute(framePr, "w", "yAlign"), FrameYAlignSchema);
68
+ if (yAlign) frame.yAlign = yAlign;
69
+ const wrap = narrowEnum(getAttribute(framePr, "w", "wrap"), FrameWrapSchema);
70
+ if (wrap) frame.wrap = wrap;
71
+ if (Object.keys(frame).length === 0) return;
72
+ const preservedAttributes = readAttributeBag(framePr, FRAME_ATTRIBUTES);
73
+ if (preservedAttributes) frame.preservedAttributes = preservedAttributes;
74
+ return frame;
75
+ }
76
+ /**
77
+ * Read `w:pPr` into {@link ParagraphFormatting}, every declared child carrying
78
+ * a decision.
79
+ *
80
+ * One reader serves all four owners of the set — a paragraph's own properties,
81
+ * the `CT_PPrGeneral` a style carries, a numbering level's, and the
82
+ * `CT_PPrBase` snapshot inside `w:pPrChange` — so a property is read the same
83
+ * way wherever it was authored, and the handler map is total over the content
84
+ * model rather than over whichever names a `switch` happened to list.
85
+ *
86
+ * Three children belong to other readers and are neither modelled nor captured
87
+ * here, because capturing one as well would write it twice: `w:sectPr` is read
88
+ * by the section parser off the paragraph, `w:pPrChange` by the
89
+ * property-change parser, and `w:rPr` is the paragraph mark's own property
90
+ * set, read below off the element for the same reason a run's is read off the
91
+ * run.
92
+ */
93
+ function parseParagraphProperties(pPr, theme) {
94
+ if (!pPr) return;
95
+ const formatting = {};
96
+ const taken = /* @__PURE__ */ new Set();
97
+ const once = (name, read) => (child) => {
98
+ if (taken.has(name) || !read(child)) return CAPTURE;
99
+ taken.add(name);
100
+ };
101
+ const toggle = (name, field) => once(name, (child) => {
102
+ formatting[field] = parseBooleanElement(child);
103
+ return true;
104
+ });
105
+ const preserved = dispatchChildren({
106
+ element: pPr,
107
+ container: "paragraph-properties",
108
+ capturePosition: sequencePositions("paragraph-properties", pPr),
109
+ handlers: {
110
+ pStyle: once("pStyle", (child) => {
111
+ const val = getAttribute(child, "w", "val");
112
+ if (!val) return false;
113
+ formatting.styleId = val;
114
+ return true;
115
+ }),
116
+ keepNext: toggle("keepNext", "keepNext"),
117
+ keepLines: toggle("keepLines", "keepLines"),
118
+ pageBreakBefore: toggle("pageBreakBefore", "pageBreakBefore"),
119
+ framePr: once("framePr", (child) => {
120
+ const frame = parseFrameProperties(child);
121
+ if (frame === void 0) return false;
122
+ formatting.frame = frame;
123
+ return true;
124
+ }),
125
+ widowControl: toggle("widowControl", "widowControl"),
126
+ numPr: once("numPr", (child) => {
127
+ const stated = readParagraphNumbering(child);
128
+ if (stated !== void 0) formatting.numPr = stated;
129
+ const numberingChange = findChild(child, "w", "numberingChange");
130
+ if (numberingChange) formatting.numberingChangeXml = captureVerbatimXml(numberingChange);
131
+ const statedLevel = parseNumericAttribute(findChild(child, "w", "ilvl"), "w", "val");
132
+ return stated !== void 0 || numberingChange !== null || statedLevel === -1;
133
+ }),
134
+ suppressLineNumbers: toggle("suppressLineNumbers", "suppressLineNumbers"),
135
+ pBdr: once("pBdr", (child) => {
136
+ const borders = {};
137
+ for (const side of PARAGRAPH_BORDER_SIDES) {
138
+ const border = parseBorderSpec(findChild(child, "w", side));
139
+ if (border) borders[side] = border;
140
+ }
141
+ if (Object.keys(borders).length === 0) return false;
142
+ formatting.borders = borders;
143
+ return true;
144
+ }),
145
+ shd: once("shd", (child) => {
146
+ const shading = parseShading(child);
147
+ if (shading === void 0) return false;
148
+ formatting.shading = shading;
149
+ return true;
150
+ }),
151
+ tabs: once("tabs", (child) => {
152
+ const tabs = parseTabStops(child);
153
+ if (tabs === void 0) return false;
154
+ formatting.tabs = tabs;
155
+ return true;
156
+ }),
157
+ suppressAutoHyphens: toggle("suppressAutoHyphens", "suppressAutoHyphens"),
158
+ kinsoku: toggle("kinsoku", "kinsoku"),
159
+ wordWrap: CAPTURE,
160
+ overflowPunct: toggle("overflowPunct", "overflowPunctuation"),
161
+ topLinePunct: CAPTURE,
162
+ autoSpaceDE: CAPTURE,
163
+ autoSpaceDN: CAPTURE,
164
+ bidi: toggle("bidi", "bidi"),
165
+ adjustRightInd: CAPTURE,
166
+ snapToGrid: toggle("snapToGrid", "snapToGrid"),
167
+ spacing: once("spacing", (child) => readParagraphSpacing(child, formatting)),
168
+ ind: once("ind", (child) => readParagraphIndentation(child, formatting)),
169
+ contextualSpacing: toggle("contextualSpacing", "contextualSpacing"),
170
+ mirrorIndents: CAPTURE,
171
+ suppressOverlap: CAPTURE,
172
+ jc: once("jc", (child) => {
173
+ const val = narrowEnum(getAttribute(child, "w", "val"), ParagraphAlignmentSchema);
174
+ if (!val) return false;
175
+ formatting.alignment = val;
176
+ return true;
177
+ }),
178
+ textDirection: CAPTURE,
179
+ textAlignment: CAPTURE,
180
+ textboxTightWrap: CAPTURE,
181
+ outlineLvl: once("outlineLvl", (child) => {
182
+ const val = parseNumericAttribute(child, "w", "val");
183
+ const level = val === void 0 ? void 0 : outlineLevelFromStatedValue(val);
184
+ if (level === void 0) return val === -1;
185
+ formatting.outlineLevel = level;
186
+ return true;
187
+ }),
188
+ divId: CAPTURE,
189
+ cnfStyle: CAPTURE,
190
+ rPr: ownedElsewhere({
191
+ container: "paragraph-properties",
192
+ child: "rPr",
193
+ reader: "paragraphProperties#parseParagraphProperties"
194
+ }),
195
+ sectPr: ownedElsewhere({
196
+ container: "paragraph-properties",
197
+ child: "sectPr",
198
+ reader: "sectionParser#parseSectionProperties"
199
+ }),
200
+ pPrChange: ownedElsewhere({
201
+ container: "paragraph-properties",
202
+ child: "pPrChange",
203
+ reader: "paragraphParser#parseParagraphPropertyChanges"
204
+ })
205
+ }
206
+ });
207
+ const rPr = findChild(pPr, "w", "rPr");
208
+ if (rPr) {
209
+ const runPropsResult = parseRunProperties(rPr, theme, RUN_PROPERTY_OWNERS.paragraphMark);
210
+ if (runPropsResult !== void 0) formatting.runProperties = runPropsResult;
211
+ const specVanish = parseOnOffChild(rPr, "w", "specVanish");
212
+ if (specVanish !== void 0) formatting.runInWithNext = specVanish;
213
+ }
214
+ if (preserved) formatting.preserved = preserved;
215
+ return Object.keys(formatting).length > 0 ? formatting : void 0;
216
+ }
217
+ /** `w:pBdr`'s sides, in the order `CT_PBdr` declares them. */
218
+ const PARAGRAPH_BORDER_SIDES = [
219
+ "top",
220
+ "left",
221
+ "bottom",
222
+ "right",
223
+ "between",
224
+ "bar"
225
+ ];
226
+ /**
227
+ * `w:spacing`, which states up to six independent values.
228
+ *
229
+ * @returns whether any of them was taken; an element that states none keeps
230
+ * its bytes instead, because a `<w:spacing/>` the model cannot rebuild is
231
+ * markup the author wrote.
232
+ */
233
+ const readParagraphSpacing = (spacing, formatting) => {
234
+ const before = parseNumericAttribute(spacing, "w", "before");
235
+ if (before !== void 0) formatting.spaceBefore = before;
236
+ const after = parseNumericAttribute(spacing, "w", "after");
237
+ if (after !== void 0) formatting.spaceAfter = after;
238
+ const line = parseNumericAttribute(spacing, "w", "line");
239
+ if (line !== void 0) formatting.lineSpacing = line;
240
+ const spacingExplicit = {};
241
+ if (before !== void 0) spacingExplicit.before = true;
242
+ if (after !== void 0) spacingExplicit.after = true;
243
+ if (spacingExplicit.before || spacingExplicit.after) formatting.spacingExplicit = spacingExplicit;
244
+ const lineRule = narrowEnum(getAttribute(spacing, "w", "lineRule"), LineSpacingRuleSchema);
245
+ if (lineRule) formatting.lineSpacingRule = lineRule;
246
+ const beforeAutospacing = parseOnOffAttribute(spacing, "w", "beforeAutospacing");
247
+ if (beforeAutospacing !== void 0) formatting.beforeAutospacing = beforeAutospacing;
248
+ const afterAutospacing = parseOnOffAttribute(spacing, "w", "afterAutospacing");
249
+ if (afterAutospacing !== void 0) formatting.afterAutospacing = afterAutospacing;
250
+ if (!(before !== void 0 || after !== void 0 || line !== void 0 || lineRule !== void 0 || beforeAutospacing !== void 0 || afterAutospacing !== void 0)) return false;
251
+ const preservedAttributes = readAttributeBag(spacing, SPACING_ATTRIBUTES);
252
+ if (preservedAttributes) formatting.spacingPreservedAttributes = preservedAttributes;
253
+ return true;
254
+ };
255
+ /**
256
+ * `w:ind`. `w:start`/`w:end` are the Strict spellings of `w:left`/`w:right`,
257
+ * so they fill the same fields when the Transitional pair is absent.
258
+ *
259
+ * @returns whether any indent was taken.
260
+ */
261
+ const readParagraphIndentation = (ind, formatting) => {
262
+ const left = numericAttributeAnySpelling(ind, "CT_Ind @left");
263
+ if (left !== void 0) formatting.indentLeft = left;
264
+ const right = numericAttributeAnySpelling(ind, "CT_Ind @right");
265
+ if (right !== void 0) formatting.indentRight = right;
266
+ const firstLine = parseNumericAttribute(ind, "w", "firstLine");
267
+ if (firstLine !== void 0) formatting.indentFirstLine = firstLine;
268
+ const hanging = parseNumericAttribute(ind, "w", "hanging");
269
+ if (hanging !== void 0) {
270
+ formatting.indentFirstLine = -hanging;
271
+ formatting.hangingIndent = true;
272
+ }
273
+ if (!(left !== void 0 || right !== void 0 || firstLine !== void 0 || hanging !== void 0)) return false;
274
+ const preservedAttributes = readAttributeBag(ind, INDENTATION_ATTRIBUTES);
275
+ if (preservedAttributes) formatting.indentPreservedAttributes = preservedAttributes;
276
+ return true;
277
+ };
278
+ //#endregion
279
+ export { parseParagraphProperties };
@@ -261,6 +261,8 @@ const invalidTableCellParagraphSourcePayload = (classification, path) => {
261
261
  };
262
262
  const tableCellBlockTraversalByType = {
263
263
  blockSdt: "blockSdt",
264
+ bookmarkEnd: "leaf",
265
+ bookmarkStart: "leaf",
264
266
  paragraph: "paragraph",
265
267
  preservedBlock: "leaf",
266
268
  table: "table"
@@ -1,9 +1,10 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { NumberingMap } from "./numberingParser.js";
3
+ import { ParseContext } from "./parseContext.js";
3
4
  import { XmlElement } from "./xmlParser.js";
4
5
  import { StyleMap } from "./styleParser.js";
5
6
  import { TableParserFn } from "./textBoxParser.js";
6
7
  //#region src/docx/paragraphTextBoxEnrichment.d.ts
7
- declare const enrichParagraphTextBoxes: (paragraph: document_d_exports.Paragraph, paraXml: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, parseTable: TableParserFn) => void;
8
+ declare const enrichParagraphTextBoxes: (paragraph: document_d_exports.Paragraph, paraXml: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, parseTable: TableParserFn, context?: ParseContext) => void;
8
9
  //#endregion
9
10
  export { enrichParagraphTextBoxes };
@@ -1,5 +1,6 @@
1
1
  import { pixelsToEmu } from "../utils/units.js";
2
2
  import { parseParagraph } from "./paragraphParser.js";
3
+ import { consolidateParagraphContent } from "./runConsolidator.js";
3
4
  import { getTextBoxContentElement, parseTextBox, parseTextBoxContent, scanRunForTextBoxDrawings } from "./textBoxParser.js";
4
5
  import { isVmlPictParsedByRunParser } from "./vmlImageParser.js";
5
6
  import { findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
@@ -120,7 +121,7 @@ const vmlWrapType = (positioned, zIndex) => {
120
121
  if (Number.isFinite(zIndex) && zIndex < 0) return "behind";
121
122
  return "inFront";
122
123
  };
123
- const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering, rels, media, parseTable) => {
124
+ const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering, rels, media, parseTable, context) => {
124
125
  enrichTextBoxRuns({
125
126
  content: paragraph.content,
126
127
  xmlChildren: getChildElements(paraXml),
@@ -129,15 +130,17 @@ const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering,
129
130
  numbering,
130
131
  rels,
131
132
  media,
132
- parseTable
133
+ parseTable,
134
+ context
133
135
  });
136
+ paragraph.content = consolidateParagraphContent(paragraph.content);
134
137
  };
135
138
  const trackedChangeTypeFromXml = (localName) => {
136
139
  if (localName === "ins") return "insertion";
137
140
  if (localName === "del") return "deletion";
138
141
  if (localName === "moveFrom" || localName === "moveTo") return localName;
139
142
  };
140
- const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rels, media, parseTable }) => {
143
+ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rels, media, parseTable, context }) => {
141
144
  let parsedIndex = 0;
142
145
  let lastConsumedRun;
143
146
  for (const xmlChild of xmlChildren) {
@@ -153,7 +156,8 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
153
156
  numbering,
154
157
  rels,
155
158
  media,
156
- parseTable
159
+ parseTable,
160
+ context
157
161
  });
158
162
  if (localName === "sdt" && parsedContent?.type === "inlineSdt") {
159
163
  const properties = parsedContent.properties;
@@ -174,7 +178,8 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
174
178
  numbering,
175
179
  rels,
176
180
  media,
177
- parseTable
181
+ parseTable,
182
+ context
178
183
  });
179
184
  parsedIndex = lastSegmentIndex + 1;
180
185
  continue;
@@ -190,8 +195,9 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
190
195
  const parsedRun = parsedContent?.type === "run" ? parsedContent : void 0;
191
196
  const targetRun = parsedRun ?? (hasNonTextBoxContent ? lastConsumedRun : void 0);
192
197
  const targetRunMatchesXml = targetRun !== void 0 && (hasNonTextBoxContent || parsedRun?.content.length === 0);
198
+ const fillsEmptyCarrier = targetRunMatchesXml && !hasNonTextBoxContent && parsedRun !== void 0;
193
199
  for (const runEl of textBoxDrawings) {
194
- const textBox = parseTextBox(runEl);
200
+ const textBox = parseTextBox(runEl, context);
195
201
  if (!textBox) continue;
196
202
  const wsp = findDeep(runEl, "wps", "wsp");
197
203
  if (wsp) {
@@ -207,6 +213,7 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
207
213
  ...textBox.title !== void 0 ? { title: textBox.title } : {},
208
214
  ...textBox.position !== void 0 ? { position: textBox.position } : {},
209
215
  ...textBox.wrap !== void 0 ? { wrap: textBox.wrap } : {},
216
+ ...textBox.anchor !== void 0 ? { anchor: textBox.anchor } : {},
210
217
  ...textBox.fill !== void 0 ? { fill: textBox.fill } : {},
211
218
  ...textBox.outline !== void 0 ? { outline: textBox.outline } : {},
212
219
  textBody: {
@@ -252,7 +259,7 @@ const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rel
252
259
  parsedIndex += 1;
253
260
  }
254
261
  }
255
- if (hasNonTextBoxContent && parsedRun) {
262
+ if ((hasNonTextBoxContent || fillsEmptyCarrier) && parsedRun) {
256
263
  lastConsumedRun = parsedRun;
257
264
  parsedIndex += 1;
258
265
  }
@@ -33,18 +33,22 @@ type InlineContentSlot = {
33
33
  * only, and a run is not a marker position.
34
34
  */
35
35
  declare const visitInlineContentSlots: (paragraph: document_d_exports.Paragraph, visit: (slot: InlineContentSlot) => void) => void;
36
+ /** What the walk does below a record it has just visited. */
37
+ declare const BLOCK_TREE_DESCENT: {
38
+ readonly descend: "descend";
39
+ readonly prune: "prune";
40
+ };
41
+ type BlockTreeDescent = (typeof BLOCK_TREE_DESCENT)[keyof typeof BLOCK_TREE_DESCENT];
36
42
  /**
37
- * Positions marked for removal, per inline-content array.
43
+ * Every record a block tree owns in document order: a paragraph, table, and
44
+ * table row. These are the records that carry authored state by identity.
38
45
  *
39
- * Removal shifts every later index in that array, so a normaliser records the
40
- * positions while it reads and drops them once, after it has finished reading.
46
+ * A block container is not always reached through a block. `w:txbxContent`
47
+ * hangs off a shape inside a run, so a walk that recurses on block children
48
+ * alone enters the body, a cell and an `w:sdt` and never enters a text box:
49
+ * every record inside one is then invisible to whatever the walk is deciding.
41
50
  */
42
- declare class InlineContentRemovals {
43
- #private;
44
- mark({ content, index }: Pick<InlineContentSlot, "content" | "index">): void;
45
- /** Applies every marked removal and answers how many items were dropped. */
46
- apply(): number;
47
- }
51
+ declare const visitBlockTreeRecords: (blocks: readonly document_d_exports.BlockContent[], visit: (record: document_d_exports.Paragraph | document_d_exports.Table | document_d_exports.TableRow) => BlockTreeDescent) => void;
48
52
  declare const visitDocxParagraphs: ({ documentBody, headers, footers, footnotes, endnotes }: DocxParagraphSurfaces, visit: (paragraph: document_d_exports.Paragraph) => void) => void;
49
53
  //#endregion
50
- export { DocxParagraphSurfaces, InlineContentRemovals, InlineContentSlot, visitDocxParagraphs, visitInlineContentSlots, visitParagraphRuns };
54
+ export { BLOCK_TREE_DESCENT, BlockTreeDescent, DocxParagraphSurfaces, InlineContentSlot, visitBlockTreeRecords, visitDocxParagraphs, visitInlineContentSlots, visitParagraphRuns };
@@ -92,34 +92,49 @@ const visitInlineContentSlots = (paragraph, visit) => {
92
92
  };
93
93
  visitContent(paragraph.content);
94
94
  };
95
+ /** What the walk does below a record it has just visited. */
96
+ const BLOCK_TREE_DESCENT = {
97
+ descend: "descend",
98
+ prune: "prune"
99
+ };
95
100
  /**
96
- * Positions marked for removal, per inline-content array.
101
+ * Every record a block tree owns in document order: a paragraph, table, and
102
+ * table row. These are the records that carry authored state by identity.
97
103
  *
98
- * Removal shifts every later index in that array, so a normaliser records the
99
- * positions while it reads and drops them once, after it has finished reading.
104
+ * A block container is not always reached through a block. `w:txbxContent`
105
+ * hangs off a shape inside a run, so a walk that recurses on block children
106
+ * alone enters the body, a cell and an `w:sdt` and never enters a text box:
107
+ * every record inside one is then invisible to whatever the walk is deciding.
100
108
  */
101
- var InlineContentRemovals = class {
102
- #byContent = /* @__PURE__ */ new Map();
103
- mark({ content, index }) {
104
- const indexes = this.#byContent.get(content);
105
- if (indexes) {
106
- indexes.add(index);
107
- return;
108
- }
109
- this.#byContent.set(content, /* @__PURE__ */ new Set([index]));
110
- }
111
- /** Applies every marked removal and answers how many items were dropped. */
112
- apply() {
113
- let removed = 0;
114
- for (const [content, indexes] of this.#byContent) {
115
- if (indexes.size === 0) continue;
116
- const next = content.filter((_, index) => !indexes.has(index));
117
- removed += content.length - next.length;
118
- content.length = 0;
119
- content.push(...next);
109
+ const visitBlockTreeRecords = (blocks, visit) => {
110
+ const visitParagraph = (paragraph) => {
111
+ if (visit(paragraph) === BLOCK_TREE_DESCENT.prune) return;
112
+ visitParagraphRuns(paragraph, (run) => {
113
+ for (const content of run.content) if (content.type === "shape" && content.shape.textBody) visitBlocks(content.shape.textBody.content);
114
+ });
115
+ };
116
+ const visitBlocks = (nested) => {
117
+ for (const block of nested) switch (block.type) {
118
+ case "paragraph":
119
+ visitParagraph(block);
120
+ break;
121
+ case "table":
122
+ if (visit(block) === BLOCK_TREE_DESCENT.prune) break;
123
+ for (const row of block.rows) {
124
+ if (visit(row) === BLOCK_TREE_DESCENT.prune) continue;
125
+ for (const cell of row.cells) visitBlocks(cell.content);
126
+ }
127
+ break;
128
+ case "blockSdt":
129
+ visitBlocks(block.content);
130
+ break;
131
+ case "preservedBlock":
132
+ case "bookmarkStart":
133
+ case "bookmarkEnd": break;
134
+ default: panic(`Unsupported block content: ${JSON.stringify(block)}`);
120
135
  }
121
- return removed;
122
- }
136
+ };
137
+ visitBlocks(blocks);
123
138
  };
124
139
  const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnotes }, visit) => {
125
140
  const seenParagraphs = /* @__PURE__ */ new WeakSet();
@@ -127,31 +142,14 @@ const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnot
127
142
  if (seenParagraphs.has(paragraph)) return;
128
143
  seenParagraphs.add(paragraph);
129
144
  visit(paragraph);
130
- visitParagraphRuns(paragraph, visitRun);
131
- };
132
- const visitRun = (run) => {
133
- for (const content of run.content) {
134
- if (content.type !== "shape" || !content.shape.textBody) continue;
135
- for (const block of content.shape.textBody.content) visitBlock(block);
136
- }
137
- };
138
- const visitTable = (table) => {
139
- for (const row of table.rows) for (const cell of row.cells) visitBlocks(cell.content);
140
- };
141
- const visitBlock = (block) => {
142
- if (block.type === "paragraph") {
143
- visitParagraph(block);
144
- return;
145
- }
146
- if (block.type === "table") {
147
- visitTable(block);
148
- return;
149
- }
150
- if (block.type === "preservedBlock") return;
151
- visitBlocks(block.content);
152
145
  };
153
146
  const visitBlocks = (blocks) => {
154
- for (const block of blocks) visitBlock(block);
147
+ visitBlockTreeRecords(blocks, (record) => {
148
+ if (record.type !== "paragraph") return BLOCK_TREE_DESCENT.descend;
149
+ if (seenParagraphs.has(record)) return BLOCK_TREE_DESCENT.prune;
150
+ visitParagraph(record);
151
+ return BLOCK_TREE_DESCENT.descend;
152
+ });
155
153
  };
156
154
  visitBlocks(documentBody.content);
157
155
  for (const section of documentBody.sections ?? []) visitBlocks(section.content);
@@ -159,7 +157,7 @@ const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnot
159
157
  for (const footer of footers?.values() ?? []) visitBlocks(footer.content);
160
158
  for (const footnote of footnotes ?? []) visitBlocks(footnote.content);
161
159
  for (const endnote of endnotes ?? []) visitBlocks(endnote.content);
162
- for (const comment of documentBody.comments ?? []) for (const paragraph of comment.content) visitParagraph(paragraph);
160
+ for (const comment of documentBody.comments ?? []) visitBlocks(comment.content);
163
161
  };
164
162
  //#endregion
165
- export { InlineContentRemovals, visitDocxParagraphs, visitInlineContentSlots, visitParagraphRuns };
163
+ export { BLOCK_TREE_DESCENT, visitBlockTreeRecords, visitDocxParagraphs, visitInlineContentSlots, visitParagraphRuns };
@@ -34,7 +34,10 @@ const PARSE_WARNING_MESSAGES = {
34
34
  [PARSE_WARNING_CODES.unbalancedMoveRange]: (warning) => `Removed ${plural(warning.count, "unbalanced tracked move range marker")}.`,
35
35
  [PARSE_WARNING_CODES.headerFooterTypeOutsideEnum]: (warning) => `Read header/footer type${quoted(warning.value)} as "default"${where(warning)}; ST_HdrFtr is even, default or first.`,
36
36
  [PARSE_WARNING_CODES.unrecognisedOnOffValue]: (warning) => `Ignored on/off value${quoted(warning.value)}${where(warning)}; ST_OnOff is 1, 0, true, false, on or off.`,
37
+ [PARSE_WARNING_CODES.unrecognisedThemeColor]: (warning) => `Kept theme colour${quoted(warning.value)}${where(warning)} without painting it; ST_ThemeColor does not enumerate it.`,
37
38
  [PARSE_WARNING_CODES.borderWithoutValue]: (warning) => `Read a border with no w:val${where(warning)} as having no border style.`,
39
+ [PARSE_WARNING_CODES.borderStyleOutsideEnum]: (warning) => `Kept border style${quoted(warning.value)} verbatim${where(warning)}; ST_Border does not declare it.`,
40
+ [PARSE_WARNING_CODES.outlineDashOutsideEnum]: (warning) => `Kept outline dash${quoted(warning.value)} verbatim${where(warning)}; ST_PresetLineDashVal does not declare it.`,
38
41
  [PARSE_WARNING_CODES.styleSetDuplicateStyleId]: (warning) => `Dropped a style repeating the id${quoted(warning.value)} another style in the set already defines.`,
39
42
  [PARSE_WARNING_CODES.styleSetInitialStyleMissing]: (warning) => `The style set names initial paragraph style${quoted(warning.value)}, which it does not contain; used the set's default instead${where(warning)}.`,
40
43
  [PARSE_WARNING_CODES.pageBreakProjectionApproximated]: (warning) => `${warning.detail ?? "An explicit page break is laid out approximately"}${where(warning)}.`