@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,325 @@
1
+ import { statesNoBorder } from "@stll/docx-core/model";
2
+ //#region src/utils/borderCss.ts
3
+ /**
4
+ * The one OOXML border style → CSS `border-style` table.
5
+ *
6
+ * There were three of these and they covered different amounts of the
7
+ * enumeration. `TableExtension` rendered the nine `thinThick`/`thickThin` gap
8
+ * styles as `double` and `dashDotStroked` as `dashed`; the layout bridge and
9
+ * `formatToStyle` fell through to `solid`, so a table cell and the paragraph
10
+ * above it painted the same authored border differently. The three agreed
11
+ * wherever they overlapped, so this table is their union rather than a new
12
+ * decision: a rendering decision per enumeration member is a table, and a table
13
+ * has one owner.
14
+ *
15
+ * Totality is the point of the `satisfies`: `ST_Border` is generated from the
16
+ * committed schema graph, so a schema refresh that adds a member fails the
17
+ * build here rather than quietly painting it as a plain line.
18
+ */
19
+ /** The CSS `border-style` keywords folio paints a border with, in one tuple. */
20
+ const CSS_BORDER_STYLE_VALUES = [
21
+ "none",
22
+ "solid",
23
+ "double",
24
+ "dotted",
25
+ "dashed",
26
+ "groove",
27
+ "ridge",
28
+ "inset",
29
+ "outset"
30
+ ];
31
+ const CSS_BORDER_STYLES_DECLARED = new Set(CSS_BORDER_STYLE_VALUES);
32
+ /** Whether folio paints a border with this CSS keyword. */
33
+ const isCssBorderStyle = (value) => CSS_BORDER_STYLES_DECLARED.has(value);
34
+ /**
35
+ * Read the CSS keyword an editor attribute carries into the union folio paints.
36
+ *
37
+ * The attribute is a bare `string` because a host may write any CSS keyword
38
+ * into it. A keyword folio does not paint is not guessed at: the caller gets
39
+ * `undefined` and applies its own default.
40
+ */
41
+ const cssBorderStyleOf = (value) => value !== void 0 && isCssBorderStyle(value) ? value : void 0;
42
+ /**
43
+ * Every `ST_Border` member's CSS rendering.
44
+ *
45
+ * The art borders (`apples` … `zigZagStitch`) and the gap-patterned line
46
+ * styles degrade to a plain line, which is how Word itself degrades where the
47
+ * specialised glyphs are unavailable; folio paints the underlying line and
48
+ * round-trips the member. `custom` names art supplied by a relationship, so it
49
+ * degrades the same way.
50
+ */
51
+ const CSS_BORDER_STYLES = {
52
+ nil: "none",
53
+ none: "none",
54
+ single: "solid",
55
+ thick: "solid",
56
+ double: "double",
57
+ dotted: "dotted",
58
+ dashed: "dashed",
59
+ dotDash: "dashed",
60
+ dotDotDash: "dotted",
61
+ triple: "double",
62
+ thinThickSmallGap: "double",
63
+ thickThinSmallGap: "double",
64
+ thinThickThinSmallGap: "double",
65
+ thinThickMediumGap: "double",
66
+ thickThinMediumGap: "double",
67
+ thinThickThinMediumGap: "double",
68
+ thinThickLargeGap: "double",
69
+ thickThinLargeGap: "double",
70
+ thinThickThinLargeGap: "double",
71
+ wave: "solid",
72
+ doubleWave: "double",
73
+ dashSmallGap: "dashed",
74
+ dashDotStroked: "dashed",
75
+ threeDEmboss: "ridge",
76
+ threeDEngrave: "groove",
77
+ outset: "outset",
78
+ inset: "inset",
79
+ apples: "solid",
80
+ archedScallops: "solid",
81
+ babyPacifier: "solid",
82
+ babyRattle: "solid",
83
+ balloons3Colors: "solid",
84
+ balloonsHotAir: "solid",
85
+ basicBlackDashes: "solid",
86
+ basicBlackDots: "solid",
87
+ basicBlackSquares: "solid",
88
+ basicThinLines: "solid",
89
+ basicWhiteDashes: "solid",
90
+ basicWhiteDots: "solid",
91
+ basicWhiteSquares: "solid",
92
+ basicWideInline: "solid",
93
+ basicWideMidline: "solid",
94
+ basicWideOutline: "solid",
95
+ bats: "solid",
96
+ birds: "solid",
97
+ birdsFlight: "solid",
98
+ cabins: "solid",
99
+ cakeSlice: "solid",
100
+ candyCorn: "solid",
101
+ celticKnotwork: "solid",
102
+ certificateBanner: "solid",
103
+ chainLink: "solid",
104
+ champagneBottle: "solid",
105
+ checkedBarBlack: "solid",
106
+ checkedBarColor: "solid",
107
+ checkered: "solid",
108
+ christmasTree: "solid",
109
+ circlesLines: "solid",
110
+ circlesRectangles: "solid",
111
+ classicalWave: "solid",
112
+ clocks: "solid",
113
+ compass: "solid",
114
+ confetti: "solid",
115
+ confettiGrays: "solid",
116
+ confettiOutline: "solid",
117
+ confettiStreamers: "solid",
118
+ confettiWhite: "solid",
119
+ cornerTriangles: "solid",
120
+ couponCutoutDashes: "solid",
121
+ couponCutoutDots: "solid",
122
+ crazyMaze: "solid",
123
+ creaturesButterfly: "solid",
124
+ creaturesFish: "solid",
125
+ creaturesInsects: "solid",
126
+ creaturesLadyBug: "solid",
127
+ crossStitch: "solid",
128
+ cup: "solid",
129
+ decoArch: "solid",
130
+ decoArchColor: "solid",
131
+ decoBlocks: "solid",
132
+ diamondsGray: "solid",
133
+ doubleD: "solid",
134
+ doubleDiamonds: "solid",
135
+ earth1: "solid",
136
+ earth2: "solid",
137
+ earth3: "solid",
138
+ eclipsingSquares1: "solid",
139
+ eclipsingSquares2: "solid",
140
+ eggsBlack: "solid",
141
+ fans: "solid",
142
+ film: "solid",
143
+ firecrackers: "solid",
144
+ flowersBlockPrint: "solid",
145
+ flowersDaisies: "solid",
146
+ flowersModern1: "solid",
147
+ flowersModern2: "solid",
148
+ flowersPansy: "solid",
149
+ flowersRedRose: "solid",
150
+ flowersRoses: "solid",
151
+ flowersTeacup: "solid",
152
+ flowersTiny: "solid",
153
+ gems: "solid",
154
+ gingerbreadMan: "solid",
155
+ gradient: "solid",
156
+ handmade1: "solid",
157
+ handmade2: "solid",
158
+ heartBalloon: "solid",
159
+ heartGray: "solid",
160
+ hearts: "solid",
161
+ heebieJeebies: "solid",
162
+ holly: "solid",
163
+ houseFunky: "solid",
164
+ hypnotic: "solid",
165
+ iceCreamCones: "solid",
166
+ lightBulb: "solid",
167
+ lightning1: "solid",
168
+ lightning2: "solid",
169
+ mapPins: "solid",
170
+ mapleLeaf: "solid",
171
+ mapleMuffins: "solid",
172
+ marquee: "solid",
173
+ marqueeToothed: "solid",
174
+ moons: "solid",
175
+ mosaic: "solid",
176
+ musicNotes: "solid",
177
+ northwest: "solid",
178
+ ovals: "solid",
179
+ packages: "solid",
180
+ palmsBlack: "solid",
181
+ palmsColor: "solid",
182
+ paperClips: "solid",
183
+ papyrus: "solid",
184
+ partyFavor: "solid",
185
+ partyGlass: "solid",
186
+ pencils: "solid",
187
+ people: "solid",
188
+ peopleWaving: "solid",
189
+ peopleHats: "solid",
190
+ poinsettias: "solid",
191
+ postageStamp: "solid",
192
+ pumpkin1: "solid",
193
+ pushPinNote2: "solid",
194
+ pushPinNote1: "solid",
195
+ pyramids: "solid",
196
+ pyramidsAbove: "solid",
197
+ quadrants: "solid",
198
+ rings: "solid",
199
+ safari: "solid",
200
+ sawtooth: "solid",
201
+ sawtoothGray: "solid",
202
+ scaredCat: "solid",
203
+ seattle: "solid",
204
+ shadowedSquares: "solid",
205
+ sharksTeeth: "solid",
206
+ shorebirdTracks: "solid",
207
+ skyrocket: "solid",
208
+ snowflakeFancy: "solid",
209
+ snowflakes: "solid",
210
+ sombrero: "solid",
211
+ southwest: "solid",
212
+ stars: "solid",
213
+ starsTop: "solid",
214
+ stars3d: "solid",
215
+ starsBlack: "solid",
216
+ starsShadowed: "solid",
217
+ sun: "solid",
218
+ swirligig: "solid",
219
+ tornPaper: "solid",
220
+ tornPaperBlack: "solid",
221
+ trees: "solid",
222
+ triangleParty: "solid",
223
+ triangles: "solid",
224
+ triangle1: "solid",
225
+ triangle2: "solid",
226
+ triangleCircle1: "solid",
227
+ triangleCircle2: "solid",
228
+ shapes1: "solid",
229
+ shapes2: "solid",
230
+ twistedLines1: "solid",
231
+ twistedLines2: "solid",
232
+ vine: "solid",
233
+ waveline: "solid",
234
+ weavingAngles: "solid",
235
+ weavingBraid: "solid",
236
+ weavingRibbon: "solid",
237
+ weavingStrips: "solid",
238
+ whiteFlowers: "solid",
239
+ woodwork: "solid",
240
+ xIllusions: "solid",
241
+ zanyTriangles: "solid",
242
+ zigZag: "solid",
243
+ zigZagStitch: "solid",
244
+ custom: "solid"
245
+ };
246
+ /** The CSS keyword for an edge that paints nothing. */
247
+ const CSS_NO_BORDER = "none";
248
+ /**
249
+ * Whether a laid-out border paints a line.
250
+ *
251
+ * Only an explicit `none` does not: a border with a width but no style paints
252
+ * the CSS initial `solid`, which is what the measurers and the painter have
253
+ * always assumed. The argument is a CSS keyword, never an `ST_Border` member —
254
+ * `nil` cannot reach here, which is what typing `BorderStyle.style` bought.
255
+ */
256
+ const paintsCssBorder = (style) => style !== CSS_NO_BORDER;
257
+ /**
258
+ * The CSS `border-style` for a parsed `w:val`.
259
+ *
260
+ * A token the schema does not declare paints as a plain line: the member is
261
+ * kept for the round trip, but nothing can be inferred about how it draws.
262
+ */
263
+ const cssBorderStyle = (style) => {
264
+ if (style === void 0) return "solid";
265
+ if (statesNoBorder(style)) return "none";
266
+ return typeof style === "string" ? CSS_BORDER_STYLES[style] : "solid";
267
+ };
268
+ /**
269
+ * Every `ST_PresetLineDashVal` member's CSS `border-style` rendering.
270
+ *
271
+ * A shape or text-box outline reaches the DOM painter and the editor node as a
272
+ * CSS border, so the dash has to be translated rather than forwarded: `sysDash`
273
+ * in a `border` shorthand invalidates the whole declaration and the outline
274
+ * disappears. CSS has three periodic keywords, so the dash-length and system
275
+ * variants collapse; the model keeps the authored member for the round trip.
276
+ *
277
+ * Not the inverse of {@link CSS_BORDER_PRESET_DASHES}: both directions are
278
+ * many-to-one, so neither can be derived from the other.
279
+ */
280
+ const PRESET_DASH_CSS_BORDER_STYLES = {
281
+ solid: "solid",
282
+ dot: "dotted",
283
+ dash: "dashed",
284
+ lgDash: "dashed",
285
+ dashDot: "dashed",
286
+ lgDashDot: "dashed",
287
+ lgDashDotDot: "dashed",
288
+ sysDash: "dashed",
289
+ sysDot: "dotted",
290
+ sysDashDot: "dashed",
291
+ sysDashDotDot: "dashed"
292
+ };
293
+ /**
294
+ * The CSS `border-style` for a parsed `a:prstDash@val`.
295
+ *
296
+ * A token the schema does not declare paints as a plain line, the way an
297
+ * undeclared `ST_Border` member does: the member is kept for the round trip,
298
+ * but nothing can be inferred about how it draws.
299
+ */
300
+ const cssBorderStyleForDash = (dash) => {
301
+ if (dash === void 0) return "solid";
302
+ return typeof dash === "string" ? PRESET_DASH_CSS_BORDER_STYLES[dash] : "solid";
303
+ };
304
+ /**
305
+ * Every CSS `border-style` folio paints, as the preset dash it serializes to.
306
+ *
307
+ * An image border is authored in CSS on the editor node and written back as an
308
+ * `a:ln` outline, so the translation has to be total: a keyword with no entry
309
+ * was serialized as `solid` by a partial table that could not say so.
310
+ */
311
+ const CSS_BORDER_PRESET_DASHES = {
312
+ none: "solid",
313
+ solid: "solid",
314
+ double: "solid",
315
+ dotted: "dot",
316
+ dashed: "dash",
317
+ groove: "solid",
318
+ ridge: "solid",
319
+ inset: "solid",
320
+ outset: "solid"
321
+ };
322
+ /** The preset dash an authored CSS border style serializes to. */
323
+ const presetDashForCssBorderStyle = (style) => CSS_BORDER_PRESET_DASHES[cssBorderStyleOf(style) ?? "solid"];
324
+ //#endregion
325
+ export { CSS_BORDER_STYLES, CSS_BORDER_STYLE_VALUES, cssBorderStyle, cssBorderStyleForDash, cssBorderStyleOf, paintsCssBorder, presetDashForCssBorderStyle };
@@ -1,4 +1,5 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
+ import { ThemeColor } from "@stll/docx-core/model";
2
3
  //#region src/utils/colorResolver.d.ts
3
4
  /**
4
5
  * Public form of the same hex-color check, for callers that read a color
@@ -77,7 +78,7 @@ declare function parseColorString(colorString: string | undefined): document_d_e
77
78
  * @param shade - Optional shade modifier
78
79
  * @returns ColorValue object
79
80
  */
80
- declare function createThemeColor(themeColor: document_d_exports.ThemeColorSlot, tint?: number, shade?: number): document_d_exports.ColorValue;
81
+ declare function createThemeColor(themeColor: ThemeColor, tint?: number, shade?: number): document_d_exports.ColorValue;
81
82
  /**
82
83
  * Create a ColorValue from RGB hex
83
84
  *
@@ -128,8 +129,8 @@ declare function resolveHighlightToCss(value: string): string;
128
129
  type ThemeMatrixCell = {
129
130
  /** Resolved hex color (6 chars, no #) */
130
131
  hex: string;
131
- /** Theme color slot */
132
- themeSlot: document_d_exports.ThemeColorSlot;
132
+ /** The `w:themeColor` token this swatch writes */
133
+ themeSlot: ThemeColor;
133
134
  /** Tint hex modifier if applicable (e.g., "CC") */
134
135
  tint?: string;
135
136
  /** Shade hex modifier if applicable (e.g., "BF") */
@@ -1,5 +1,26 @@
1
+ import { THEME_COLOR_BY_SCHEME_COLOR_VALUE, isSchemeColorValue, isThemeColor, themeColorSlot } from "@stll/docx-core/model";
1
2
  //#region src/utils/colorResolver.ts
2
3
  /**
4
+ * Color Resolver - Convert OOXML colors to CSS
5
+ *
6
+ * Handles:
7
+ * - Theme color references (accent1, dk1, etc.)
8
+ * - RGB hex values
9
+ * - "auto" colors (context-dependent)
10
+ * - Tint/shade modifications
11
+ *
12
+ * OOXML Color References:
13
+ * - w:color/@w:val - RGB hex or "auto"
14
+ * - w:color/@w:themeColor - Theme color slot
15
+ * - w:color/@w:themeTint - Tint modifier (0-255, hex)
16
+ * - w:color/@w:themeShade - Shade modifier (0-255, hex)
17
+ *
18
+ * Tint/Shade Calculations:
19
+ * - Tint makes color lighter (blend with white)
20
+ * - Shade makes color darker (blend with black)
21
+ * - Value is in hex (00-FF), converted to 0-1 for calculation
22
+ */
23
+ /**
3
24
  * Strict hex-color validator shared by every OOXML → CSS color path in this
4
25
  * module. OOXML readers are lenient about `w:val`/`w:fill` attribute content
5
26
  * and theme swatch text, so a crafted `<w:color>`, table shading, or
@@ -69,38 +90,6 @@ const HIGHLIGHT_COLORS = {
69
90
  none: ""
70
91
  };
71
92
  /**
72
- * Map alternative theme color names to standard slots
73
- * OOXML uses different names in different contexts
74
- */
75
- const THEME_COLOR_ALIASES = {
76
- dk1: "dk1",
77
- lt1: "lt1",
78
- dk2: "dk2",
79
- lt2: "lt2",
80
- accent1: "accent1",
81
- accent2: "accent2",
82
- accent3: "accent3",
83
- accent4: "accent4",
84
- accent5: "accent5",
85
- accent6: "accent6",
86
- hlink: "hlink",
87
- folHlink: "folHlink",
88
- dark1: "dk1",
89
- light1: "lt1",
90
- dark2: "dk2",
91
- light2: "lt2",
92
- hyperlink: "hlink",
93
- followedHyperlink: "folHlink",
94
- background1: "lt1",
95
- text1: "dk1",
96
- background2: "lt2",
97
- text2: "dk2",
98
- tx1: "dk1",
99
- tx2: "dk2",
100
- bg1: "lt1",
101
- bg2: "lt2"
102
- };
103
- /**
104
93
  * Parse a hex color modifier value (tint or shade)
105
94
  * OOXML stores tint/shade as hex string (00-FF) representing 0-255
106
95
  *
@@ -173,46 +162,22 @@ function applyShade(hex, shade) {
173
162
  return rgbToHex(rgb.r * shade, rgb.g * shade, rgb.b * shade);
174
163
  }
175
164
  /**
176
- * Get a theme color by slot name
177
- *
178
- * @param theme - Theme object
179
- * @param slot - Color slot name
180
- * @returns Hex color (6 characters, no #)
165
+ * The hex a theme slot paints, falling back to the Office default theme when
166
+ * the package carries no `theme1.xml` or leaves the slot empty.
181
167
  */
182
168
  function getThemeColorValue(theme, slot) {
183
- const schemeKey = THEME_COLOR_ALIASES[slot] ?? slot;
184
- const schemeKeys = [
185
- "dk1",
186
- "lt1",
187
- "dk2",
188
- "lt2",
189
- "accent1",
190
- "accent2",
191
- "accent3",
192
- "accent4",
193
- "accent5",
194
- "accent6",
195
- "hlink",
196
- "folHlink"
197
- ];
198
- const isSchemeKey = (key) => schemeKeys.includes(key);
199
- if (!theme?.colorScheme) {
200
- if (isSchemeKey(schemeKey)) return DEFAULT_THEME_COLORS[schemeKey] ?? "000000";
201
- return "000000";
202
- }
203
- if (isSchemeKey(schemeKey)) return theme.colorScheme[schemeKey] ?? DEFAULT_THEME_COLORS[schemeKey] ?? "000000";
204
- return "000000";
169
+ return theme?.colorScheme?.[slot] ?? DEFAULT_THEME_COLORS[slot];
205
170
  }
206
171
  /**
207
- * Resolve a theme color name to a standard slot
172
+ * Read a colour name as a theme reference.
208
173
  *
209
- * @param colorName - Theme color name (could be alias)
210
- * @returns Standard ThemeColorSlot or null if unknown
174
+ * Accepts both vocabularies: `ST_ThemeColor`, as a `w:themeColor` writes it,
175
+ * and `ST_SchemeColorVal`, as a DrawingML reference or a host-supplied slot
176
+ * name does.
211
177
  */
212
- function resolveThemeColorSlot(colorName) {
213
- if (!colorName) return null;
214
- const normalized = colorName.toLowerCase();
215
- return THEME_COLOR_ALIASES[colorName] ?? THEME_COLOR_ALIASES[normalized] ?? null;
178
+ function resolveThemeColorName(colorName) {
179
+ if (isThemeColor(colorName)) return colorName;
180
+ return isSchemeColorValue(colorName) ? THEME_COLOR_BY_SCHEME_COLOR_VALUE[colorName] ?? void 0 : void 0;
216
181
  }
217
182
  /**
218
183
  * Resolve a ColorValue to a CSS color string
@@ -228,7 +193,7 @@ function resolveColor(color, theme, defaultColor = "000000") {
228
193
  if (color.auto) return `#${safeDefault}`;
229
194
  let hexColor;
230
195
  if (color.themeColor) {
231
- const slot = resolveThemeColorSlot(color.themeColor);
196
+ const slot = themeColorSlot(color.themeColor);
232
197
  if (slot) hexColor = getThemeColorValue(theme, slot);
233
198
  else hexColor = color.rgb ?? defaultColor;
234
199
  if (color.themeTint) {
@@ -323,8 +288,8 @@ function parseColorString(colorString) {
323
288
  if (!colorString) return;
324
289
  const normalized = colorString.trim();
325
290
  if (normalized.toLowerCase() === "auto") return { auto: true };
326
- const themeSlot = resolveThemeColorSlot(normalized);
327
- if (themeSlot) return { themeColor: themeSlot };
291
+ const themeColor = resolveThemeColorName(normalized);
292
+ if (themeColor) return { themeColor };
328
293
  const hex = normalized.replace(/^#/u, "").toUpperCase();
329
294
  if (/^[0-9A-F]{6}$/iu.test(hex)) return { rgb: hex };
330
295
  if (/^[0-9A-F]{3}$/iu.test(hex)) return { rgb: hex.split("").map((c) => c + c).join("") };
@@ -455,24 +420,27 @@ const STANDARD_TEXT_COLORS = [
455
420
  }
456
421
  ];
457
422
  /**
458
- * Theme color column order matching Word's color picker:
459
- * Background 1 (lt1), Text 1 (dk1), Background 2 (lt2), Text 2 (dk2), Accent 1-6
423
+ * Theme color column order matching Word's color picker.
424
+ *
425
+ * Spelled as `ST_ThemeColor`, because the swatch a user picks is written into a
426
+ * `w:themeColor` attribute; the DrawingML slot it paints with comes from
427
+ * `themeColorSlot`.
460
428
  */
461
429
  const THEME_MATRIX_COLUMNS = [
462
430
  {
463
- slot: "lt1",
431
+ slot: "background1",
464
432
  name: "Background 1"
465
433
  },
466
434
  {
467
- slot: "dk1",
435
+ slot: "text1",
468
436
  name: "Text 1"
469
437
  },
470
438
  {
471
- slot: "lt2",
439
+ slot: "background2",
472
440
  name: "Background 2"
473
441
  },
474
442
  {
475
- slot: "dk2",
443
+ slot: "text2",
476
444
  name: "Text 2"
477
445
  },
478
446
  {
@@ -566,7 +534,8 @@ function getThemeTintShadeHex(baseHex, type, fraction) {
566
534
  function generateThemeTintShadeMatrix(colorScheme) {
567
535
  const scheme = colorScheme ?? DEFAULT_THEME_COLORS;
568
536
  return THEME_MATRIX_ROWS.map((row) => THEME_MATRIX_COLUMNS.map((col) => {
569
- const baseHex = scheme[col.slot] ?? DEFAULT_THEME_COLORS[col.slot] ?? "000000";
537
+ const slot = themeColorSlot(col.slot);
538
+ const baseHex = slot === void 0 ? "000000" : scheme[slot] ?? DEFAULT_THEME_COLORS[slot];
570
539
  let hex;
571
540
  if (row.type === "base") hex = baseHex.toUpperCase();
572
541
  else if (row.type === "tint") hex = applyTint(baseHex, row.value);
@@ -96,7 +96,10 @@ function getDefaultStyles() {
96
96
  spaceBefore: 400,
97
97
  spaceAfter: 120,
98
98
  lineSpacing: 240,
99
- outlineLevel: 0
99
+ outlineLevel: {
100
+ kind: "heading",
101
+ level: 0
102
+ }
100
103
  }
101
104
  },
102
105
  {
@@ -119,7 +122,10 @@ function getDefaultStyles() {
119
122
  spaceBefore: 360,
120
123
  spaceAfter: 80,
121
124
  lineSpacing: 240,
122
- outlineLevel: 1
125
+ outlineLevel: {
126
+ kind: "heading",
127
+ level: 1
128
+ }
123
129
  }
124
130
  },
125
131
  {
@@ -142,7 +148,10 @@ function getDefaultStyles() {
142
148
  spaceBefore: 320,
143
149
  spaceAfter: 80,
144
150
  lineSpacing: 240,
145
- outlineLevel: 2
151
+ outlineLevel: {
152
+ kind: "heading",
153
+ level: 2
154
+ }
146
155
  }
147
156
  },
148
157
  {
@@ -165,7 +174,10 @@ function getDefaultStyles() {
165
174
  spaceBefore: 280,
166
175
  spaceAfter: 80,
167
176
  lineSpacing: 240,
168
- outlineLevel: 3
177
+ outlineLevel: {
178
+ kind: "heading",
179
+ level: 3
180
+ }
169
181
  }
170
182
  },
171
183
  {
@@ -188,7 +200,10 @@ function getDefaultStyles() {
188
200
  spaceBefore: 240,
189
201
  spaceAfter: 80,
190
202
  lineSpacing: 240,
191
- outlineLevel: 4
203
+ outlineLevel: {
204
+ kind: "heading",
205
+ level: 4
206
+ }
192
207
  }
193
208
  },
194
209
  {
@@ -212,7 +227,10 @@ function getDefaultStyles() {
212
227
  spaceBefore: 240,
213
228
  spaceAfter: 80,
214
229
  lineSpacing: 240,
215
- outlineLevel: 5
230
+ outlineLevel: {
231
+ kind: "heading",
232
+ level: 5
233
+ }
216
234
  }
217
235
  },
218
236
  {
@@ -1,3 +1,4 @@
1
+ import { panic } from "better-result";
1
2
  //#region src/utils/findReplace.ts
2
3
  const createDefaultFindOptions = () => ({
3
4
  matchCase: false,
@@ -101,17 +102,58 @@ const getRunSearchProjection = (run) => {
101
102
  pageBreakOffsets
102
103
  };
103
104
  };
104
- const getHyperlinkSearchProjection = (hyperlink) => joinSearchProjections(hyperlink.children.flatMap((child) => child.type === "run" ? [getRunSearchProjection(child)] : []));
105
+ const getHyperlinkSearchProjection = (hyperlink) => joinSearchProjections(hyperlink.children.flatMap((child) => {
106
+ if (child.type === "run") return [getRunSearchProjection(child)];
107
+ return child.type === "inlineWrapper" ? [getParagraphContentSearchProjection(child)] : [];
108
+ }));
109
+ /** Nothing on the line: a marker, or markup with no text under it. */
110
+ const noSearchText = () => ({
111
+ text: "",
112
+ pageBreakOffsets: []
113
+ });
114
+ /**
115
+ * The text one paragraph content item puts on the line, for searching.
116
+ *
117
+ * A `switch` with a `never` default rather than an `if`-chain ending in the
118
+ * empty projection: a chain answers "no text" for a member nobody considered,
119
+ * and a member that holds runs and answers "no text" is text the reader can
120
+ * see and find cannot. That is what the revision wrappers and the transparent
121
+ * inline wrappers were doing — a search for a phrase inside a `w:bdo`, a smart
122
+ * tag or an insertion found nothing.
123
+ *
124
+ * The offsets this produces are resolved back to an editor position by
125
+ * `resolveFindMatchRange`, against the text `getSearchableParagraphText`
126
+ * builds from the ProseMirror tree. So the two have to agree character for
127
+ * character, and this one mirrors that one: every text node counts, including
128
+ * the deleted and moved-away text the editor still shows struck through. A
129
+ * member skipped here shifts every later offset and the replacement lands on
130
+ * the wrong characters.
131
+ */
105
132
  const getParagraphContentSearchProjection = (content) => {
106
- if (content.type === "run") return getRunSearchProjection(content);
107
- if (content.type === "hyperlink") return getHyperlinkSearchProjection(content);
108
- if (content.type === "inlineSdt") return joinSearchProjections(content.content.map(getParagraphContentSearchProjection));
109
- if (content.type === "simpleField") return joinSearchProjections(content.content.map(getParagraphContentSearchProjection));
110
- if (content.type === "complexField") return joinSearchProjections(content.fieldResult.map(getRunSearchProjection));
111
- return {
112
- text: "",
113
- pageBreakOffsets: []
114
- };
133
+ switch (content.type) {
134
+ case "run": return getRunSearchProjection(content);
135
+ case "hyperlink": return getHyperlinkSearchProjection(content);
136
+ case "inlineSdt":
137
+ case "simpleField":
138
+ case "inlineWrapper":
139
+ case "insertion":
140
+ case "deletion":
141
+ case "moveFrom":
142
+ case "moveTo": return joinSearchProjections(content.content.map(getParagraphContentSearchProjection));
143
+ case "complexField": return joinSearchProjections(content.fieldResult.map(getRunSearchProjection));
144
+ case "bookmarkStart":
145
+ case "bookmarkEnd":
146
+ case "commentRangeStart":
147
+ case "commentRangeEnd":
148
+ case "commentReference":
149
+ case "moveFromRangeStart":
150
+ case "moveFromRangeEnd":
151
+ case "moveToRangeStart":
152
+ case "moveToRangeEnd":
153
+ case "mathEquation":
154
+ case "preservedInline": return noSearchText();
155
+ default: panic(`Unsupported paragraph content: ${JSON.stringify(content)}`);
156
+ }
115
157
  };
116
158
  const getParagraphSearchProjection = (paragraph) => joinSearchProjections(paragraph.content.map(getParagraphContentSearchProjection));
117
159
  const findContentIndexAtOffset = (paragraph, offset) => {