@stll/folio-core 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/dist/ai-edits/apply.js +85 -43
  2. package/dist/ai-edits/headless.js +2 -2
  3. package/dist/ai-edits/read.d.ts +1 -0
  4. package/dist/ai-edits/read.js +1 -0
  5. package/dist/ai-edits/snapshot.js +32 -27
  6. package/dist/ai-edits/table-cell-mutations.js +15 -7
  7. package/dist/ai-edits/table-geometry.js +21 -18
  8. package/dist/ai-edits/table-template.js +2 -2
  9. package/dist/compare/compare.js +2 -5
  10. package/dist/compare/content-alignment.js +108 -12
  11. package/dist/compare/content-types.d.ts +8 -2
  12. package/dist/compare/content.js +2 -11
  13. package/dist/compare/plan.js +7 -4
  14. package/dist/compare/scenario.js +2 -5
  15. package/dist/compare/section-boundary-properties.js +1 -2
  16. package/dist/compare/types.d.ts +9 -1
  17. package/dist/compare/types.js +12 -1
  18. package/dist/compat/eigenpal.d.ts +2 -1
  19. package/dist/compat/eigenpal.js +2 -1
  20. package/dist/content-controls/checkboxDisplay.d.ts +17 -0
  21. package/dist/content-controls/checkboxDisplay.js +46 -0
  22. package/dist/content-controls/findContentControls.js +3 -1
  23. package/dist/content-controls/mutateContentControls.js +57 -43
  24. package/dist/controller/contentControlWidgetController.d.ts +1 -0
  25. package/dist/controller/contentControlWidgetController.js +3 -0
  26. package/dist/controller/hiddenEditorApi.js +3 -1
  27. package/dist/controller/hiddenEditorManager.d.ts +1 -1
  28. package/dist/controller/hiddenEditorManager.js +6 -3
  29. package/dist/controller/layoutPipeline.js +8 -3
  30. package/dist/display-list/build/buildDisplayList.js +20 -1
  31. package/dist/display-list/build/imagePrimitives.d.ts +4 -4
  32. package/dist/display-list/build/imagePrimitives.js +38 -18
  33. package/dist/display-list/build/pageBorderPrimitives.js +2 -1
  34. package/dist/display-list/build/paragraphPrimitives.js +113 -14
  35. package/dist/display-list/build/previewPrimitives.d.ts +10 -0
  36. package/dist/display-list/build/previewPrimitives.js +89 -0
  37. package/dist/display-list/build/strokes.d.ts +177 -8
  38. package/dist/display-list/build/strokes.js +167 -47
  39. package/dist/display-list/build/tablePrimitives.js +4 -2
  40. package/dist/display-list/build/textBoxPrimitives.js +6 -4
  41. package/dist/display-list/build/textDecorations.d.ts +15 -1
  42. package/dist/display-list/build/textDecorations.js +15 -1
  43. package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
  44. package/dist/display-list/primitives.d.ts +13 -2
  45. package/dist/display-list/primitives.js +36 -1
  46. package/dist/display-list/types.d.ts +17 -0
  47. package/dist/document-operations.js +2 -1
  48. package/dist/docx/attributeRemainder.d.ts +76 -0
  49. package/dist/docx/attributeRemainder.js +111 -0
  50. package/dist/docx/blockContentParser.d.ts +3 -1
  51. package/dist/docx/blockContentParser.js +102 -106
  52. package/dist/docx/blockPlainText.d.ts +3 -4
  53. package/dist/docx/blockPlainText.js +3 -0
  54. package/dist/docx/borderParser.js +26 -11
  55. package/dist/docx/builtInStyles.d.ts +8 -16
  56. package/dist/docx/builtInStyles.js +54 -17
  57. package/dist/docx/commentAnchorIndex.d.ts +30 -0
  58. package/dist/docx/commentAnchorIndex.js +50 -0
  59. package/dist/docx/commentParser.d.ts +1 -1
  60. package/dist/docx/commentParser.js +56 -39
  61. package/dist/docx/commentRangeIntegrity.d.ts +16 -1
  62. package/dist/docx/commentRangeIntegrity.js +42 -1
  63. package/dist/docx/commentRangeJoin.d.ts +9 -0
  64. package/dist/docx/commentRangeJoin.js +33 -0
  65. package/dist/docx/commentReferenceCompletion.d.ts +9 -0
  66. package/dist/docx/commentReferenceCompletion.js +47 -0
  67. package/dist/docx/commentReferenceNormalization.js +3 -1
  68. package/dist/docx/commentReplyMarkers.js +11 -19
  69. package/dist/docx/compatibility.js +56 -41
  70. package/dist/docx/containerChildren.d.ts +208 -0
  71. package/dist/docx/containerChildren.gen.d.ts +43 -0
  72. package/dist/docx/containerChildren.gen.js +263 -0
  73. package/dist/docx/containerChildren.js +153 -0
  74. package/dist/docx/diagramPreview.d.ts +14 -2
  75. package/dist/docx/diagramPreview.js +81 -169
  76. package/dist/docx/documentParser.d.ts +1 -1
  77. package/dist/docx/documentParser.js +7 -4
  78. package/dist/docx/drawingAnchor.d.ts +87 -0
  79. package/dist/docx/drawingAnchor.js +201 -0
  80. package/dist/docx/drawingUtils.d.ts +43 -38
  81. package/dist/docx/drawingUtils.js +205 -118
  82. package/dist/docx/ensureParaIds.js +17 -7
  83. package/dist/docx/fieldParser.d.ts +1 -1
  84. package/dist/docx/fieldParser.js +4 -4
  85. package/dist/docx/fieldState.d.ts +26 -0
  86. package/dist/docx/fieldState.js +53 -0
  87. package/dist/docx/fontTableParser.js +102 -41
  88. package/dist/docx/footnoteParser.d.ts +1 -1
  89. package/dist/docx/footnoteParser.js +10 -6
  90. package/dist/docx/graphicFrameLocks.d.ts +16 -4
  91. package/dist/docx/graphicFrameLocks.js +19 -6
  92. package/dist/docx/groupDrawingParser.js +4 -3
  93. package/dist/docx/headerFooterParser.js +1 -1
  94. package/dist/docx/headerFooterReferenceNormalization.js +1 -0
  95. package/dist/docx/hyperlinkParser.d.ts +66 -9
  96. package/dist/docx/hyperlinkParser.js +153 -26
  97. package/dist/docx/imageParser.js +160 -115
  98. package/dist/docx/index.d.ts +2 -1
  99. package/dist/docx/index.js +2 -1
  100. package/dist/docx/inlineContentRemovals.d.ts +28 -0
  101. package/dist/docx/inlineContentRemovals.js +46 -0
  102. package/dist/docx/inlineWrapperContent.d.ts +166 -0
  103. package/dist/docx/inlineWrapperContent.js +165 -0
  104. package/dist/docx/inlineWrapperParser.d.ts +11 -0
  105. package/dist/docx/inlineWrapperParser.js +60 -0
  106. package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
  107. package/dist/docx/normalizeBaseDirection.js +12 -1
  108. package/dist/docx/numberingParser.d.ts +25 -2
  109. package/dist/docx/numberingParser.js +264 -361
  110. package/dist/docx/numberingReference.d.ts +9 -16
  111. package/dist/docx/numberingReference.js +17 -16
  112. package/dist/docx/numberingReferenceNormalization.js +7 -7
  113. package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
  114. package/dist/docx/ooxmlCounterFormatter.js +4 -1
  115. package/dist/docx/paraIdAttribute.d.ts +111 -0
  116. package/dist/docx/paraIdAttribute.js +142 -0
  117. package/dist/docx/paragraphParser.d.ts +10 -25
  118. package/dist/docx/paragraphParser.js +421 -496
  119. package/dist/docx/paragraphProperties.d.ts +23 -0
  120. package/dist/docx/paragraphProperties.js +279 -0
  121. package/dist/docx/paragraphPropertySource.js +7 -1
  122. package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
  123. package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
  124. package/dist/docx/paragraphTraversal.d.ts +14 -10
  125. package/dist/docx/paragraphTraversal.js +53 -52
  126. package/dist/docx/parseWarningMessage.js +5 -1
  127. package/dist/docx/parserEnums.d.ts +6 -8
  128. package/dist/docx/parserEnums.js +4 -6
  129. package/dist/docx/preservedRunContent.d.ts +32 -0
  130. package/dist/docx/preservedRunContent.js +96 -0
  131. package/dist/docx/previewBudget.d.ts +44 -23
  132. package/dist/docx/previewBudget.js +61 -30
  133. package/dist/docx/propertyElementAttributes.d.ts +178 -0
  134. package/dist/docx/propertyElementAttributes.js +114 -0
  135. package/dist/docx/renderedPageBreakNormalization.js +4 -6
  136. package/dist/docx/rezip.d.ts +28 -2
  137. package/dist/docx/rezip.js +152 -27
  138. package/dist/docx/runConsolidator.d.ts +42 -2
  139. package/dist/docx/runConsolidator.js +60 -6
  140. package/dist/docx/runParser.d.ts +55 -19
  141. package/dist/docx/runParser.js +394 -306
  142. package/dist/docx/runPayload.d.ts +5 -0
  143. package/dist/docx/runPayload.js +4 -0
  144. package/dist/docx/sdtProperties.d.ts +39 -5
  145. package/dist/docx/sdtProperties.js +205 -84
  146. package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
  147. package/dist/docx/sdtPropertiesPatch.js +68 -112
  148. package/dist/docx/sectionParser.d.ts +1 -2
  149. package/dist/docx/sectionParser.js +241 -238
  150. package/dist/docx/selectiveSave.js +3 -2
  151. package/dist/docx/selectiveXmlPatch.d.ts +66 -3
  152. package/dist/docx/selectiveXmlPatch.js +276 -133
  153. package/dist/docx/serializer/blockSdtSerializer.js +2 -96
  154. package/dist/docx/serializer/borderSerializer.d.ts +5 -5
  155. package/dist/docx/serializer/borderSerializer.js +12 -10
  156. package/dist/docx/serializer/commentSerializer.js +5 -7
  157. package/dist/docx/serializer/documentSerializer.js +11 -11
  158. package/dist/docx/serializer/fontTableSerializer.js +31 -3
  159. package/dist/docx/serializer/headerFooterSerializer.js +10 -9
  160. package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
  161. package/dist/docx/serializer/markupRangeAttributes.js +9 -1
  162. package/dist/docx/serializer/noteSerializer.js +11 -8
  163. package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
  164. package/dist/docx/serializer/numberingSerializer.js +81 -79
  165. package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
  166. package/dist/docx/serializer/paragraphSerializer.js +156 -236
  167. package/dist/docx/serializer/runSerializer.d.ts +1 -5
  168. package/dist/docx/serializer/runSerializer.js +134 -75
  169. package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
  170. package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
  171. package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
  172. package/dist/docx/serializer/settingsSerializer.js +6 -4
  173. package/dist/docx/serializer/stylesSerializer.js +8 -11
  174. package/dist/docx/serializer/tableSerializer.js +283 -105
  175. package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
  176. package/dist/docx/serializer/textFormattingSerializer.js +111 -101
  177. package/dist/docx/serializer/xmlUtils.d.ts +1 -1
  178. package/dist/docx/serializer/xmlUtils.js +1 -1
  179. package/dist/docx/server/createBilingualDocument.js +20 -16
  180. package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
  181. package/dist/docx/server/materializeYjsDocx.js +9 -1
  182. package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
  183. package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
  184. package/dist/docx/settingsParser.js +7 -4
  185. package/dist/docx/shadingParser.d.ts +2 -1
  186. package/dist/docx/shadingParser.js +43 -7
  187. package/dist/docx/shapeParser.js +13 -8
  188. package/dist/docx/strictNames.d.ts +11 -0
  189. package/dist/docx/strictNames.gen.d.ts +45 -0
  190. package/dist/docx/strictNames.gen.js +50 -0
  191. package/dist/docx/strictNames.js +43 -0
  192. package/dist/docx/strictValueEncodings.gen.js +133 -131
  193. package/dist/docx/styleParser.js +17 -349
  194. package/dist/docx/tableParser.d.ts +11 -2
  195. package/dist/docx/tableParser.js +665 -220
  196. package/dist/docx/textBoxParser.d.ts +28 -3
  197. package/dist/docx/textBoxParser.js +69 -9
  198. package/dist/docx/themeColorAttribute.d.ts +13 -0
  199. package/dist/docx/themeColorAttribute.js +24 -0
  200. package/dist/docx/trackedMoveRangeNormalization.js +2 -1
  201. package/dist/docx/unzip.js +5 -4
  202. package/dist/docx/vmlImageParser.d.ts +30 -5
  203. package/dist/docx/vmlImageParser.js +91 -32
  204. package/dist/docx/vmlPreview.js +2 -2
  205. package/dist/docx/wrapPolygon.d.ts +30 -0
  206. package/dist/docx/wrapPolygon.js +70 -0
  207. package/dist/docx/xmlEncoding.d.ts +5 -0
  208. package/dist/docx/xmlEncoding.js +12 -0
  209. package/dist/docx/xmlParser.d.ts +23 -1
  210. package/dist/docx/xmlParser.js +31 -2
  211. package/dist/fonts/embeddedFonts.js +3 -3
  212. package/dist/headless-layout.js +12 -1
  213. package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
  214. package/dist/i18n/messages/catalogs.gen.js +102 -34
  215. package/dist/i18n/messages/messages.gen.d.ts +4 -0
  216. package/dist/index.d.ts +2 -1
  217. package/dist/index.js +2 -1
  218. package/dist/internal/headlessRevisionResolution.js +9 -0
  219. package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
  220. package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
  221. package/dist/internal/paragraphFormattingSerialization.js +118 -83
  222. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  223. package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
  224. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  225. package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
  226. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
  227. package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
  228. package/dist/layout-engine/index.d.ts +2 -2
  229. package/dist/layout-engine/index.js +53 -17
  230. package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
  231. package/dist/layout-engine/measure/measureBlocks.js +6 -10
  232. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  233. package/dist/layout-engine/measure/tableCellFloating.js +2 -0
  234. package/dist/layout-engine/measure/tableCellGrid.js +2 -1
  235. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
  236. package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
  237. package/dist/layout-engine/paragraphSequence.js +3 -2
  238. package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
  239. package/dist/layout-engine/section-breaks.d.ts +49 -2
  240. package/dist/layout-engine/section-breaks.js +55 -4
  241. package/dist/layout-engine/types.d.ts +69 -17
  242. package/dist/layout-engine/types.js +16 -1
  243. package/dist/layout-painter/borderStroke.d.ts +18 -4
  244. package/dist/layout-painter/renderImage.d.ts +5 -1
  245. package/dist/layout-painter/renderImage.js +10 -3
  246. package/dist/layout-painter/renderPage.d.ts +2 -0
  247. package/dist/layout-painter/renderPage.js +10 -4
  248. package/dist/layout-painter/renderParagraph.d.ts +14 -1
  249. package/dist/layout-painter/renderParagraph.js +34 -28
  250. package/dist/layout-painter/renderTable.d.ts +4 -1
  251. package/dist/layout-painter/renderTable.js +22 -22
  252. package/dist/layout-painter/renderTextBox.js +5 -3
  253. package/dist/managers/autoSaveCodec.d.ts +9 -1
  254. package/dist/managers/autoSaveCodec.js +12 -4
  255. package/dist/markdown/renderBlock.js +3 -0
  256. package/dist/markdown/renderRuns.d.ts +1 -1
  257. package/dist/markdown/renderRuns.js +34 -6
  258. package/dist/markdown/renderTable.js +24 -6
  259. package/dist/markdown/trailers.js +4 -1
  260. package/dist/model.d.ts +3 -3
  261. package/dist/model.js +2 -2
  262. package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
  263. package/dist/paged-layout/sectionBlockWidths.js +26 -4
  264. package/dist/pdf/images.js +142 -6
  265. package/dist/prosemirror/attrs/index.d.ts +34 -5
  266. package/dist/prosemirror/attrs/index.js +639 -48
  267. package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
  268. package/dist/prosemirror/authoredTransformAttrs.js +64 -0
  269. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
  270. package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
  271. package/dist/prosemirror/commands/comments.js +68 -53
  272. package/dist/prosemirror/commands/contentControls.js +33 -20
  273. package/dist/prosemirror/commands/image.d.ts +10 -3
  274. package/dist/prosemirror/commands/image.js +46 -29
  275. package/dist/prosemirror/commands/pageBreak.js +1 -1
  276. package/dist/prosemirror/commands/paragraph.d.ts +2 -1
  277. package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
  278. package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
  279. package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
  280. package/dist/prosemirror/commands/sectionBreak.js +187 -11
  281. package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
  282. package/dist/prosemirror/commentReferenceAttrs.js +33 -0
  283. package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
  284. package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
  285. package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
  286. package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
  287. package/dist/prosemirror/conversion/index.d.ts +2 -2
  288. package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
  289. package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
  290. package/dist/prosemirror/conversion/runShadingMark.js +14 -1
  291. package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
  292. package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
  293. package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
  294. package/dist/prosemirror/conversion/toProseDoc.js +801 -411
  295. package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
  296. package/dist/prosemirror/emptyRangeAnchor.js +158 -0
  297. package/dist/prosemirror/extensions/StarterKit.js +14 -58
  298. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  299. package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
  300. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
  301. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
  302. package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
  303. package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
  304. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
  305. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
  306. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
  307. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
  308. package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
  309. package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
  310. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
  311. package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
  312. package/dist/prosemirror/extensions/markRegistry.js +138 -0
  313. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
  314. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
  315. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
  316. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
  317. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
  318. package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
  319. package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
  320. package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
  321. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
  322. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
  323. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
  324. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
  325. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
  326. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
  327. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
  328. package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
  329. package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
  330. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
  331. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
  332. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
  333. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
  334. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
  335. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
  336. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
  337. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
  338. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
  339. package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
  340. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
  341. package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
  342. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
  343. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
  344. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
  345. package/dist/prosemirror/extensions/types.d.ts +12 -3
  346. package/dist/prosemirror/index.d.ts +4 -2
  347. package/dist/prosemirror/index.js +2 -1
  348. package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
  349. package/dist/prosemirror/inlineWrapperStack.js +92 -0
  350. package/dist/prosemirror/listMarker.d.ts +2 -2
  351. package/dist/prosemirror/listMarker.js +7 -8
  352. package/dist/prosemirror/listRenderingAttrs.js +11 -1
  353. package/dist/prosemirror/listState.d.ts +62 -0
  354. package/dist/prosemirror/listState.js +49 -0
  355. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
  356. package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
  357. package/dist/prosemirror/numberedRefFields.js +4 -4
  358. package/dist/prosemirror/numberingAttr.d.ts +55 -0
  359. package/dist/prosemirror/numberingAttr.js +74 -0
  360. package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
  361. package/dist/prosemirror/outlineLevelAttr.js +42 -0
  362. package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
  363. package/dist/prosemirror/pageBreakRunProjection.js +19 -9
  364. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
  365. package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
  366. package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
  367. package/dist/prosemirror/plugins/selectionTracker.js +3 -10
  368. package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
  369. package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
  370. package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
  371. package/dist/prosemirror/replacedAnnotations.js +183 -0
  372. package/dist/prosemirror/revisionCarriers.d.ts +86 -2
  373. package/dist/prosemirror/revisionCarriers.js +86 -60
  374. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
  375. package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
  376. package/dist/prosemirror/runIdentity.d.ts +28 -0
  377. package/dist/prosemirror/runIdentity.js +36 -0
  378. package/dist/prosemirror/runStyleFormatting.js +1 -1
  379. package/dist/prosemirror/schema/index.d.ts +3 -3
  380. package/dist/prosemirror/schema/marks.d.ts +47 -4
  381. package/dist/prosemirror/schema/nodes.d.ts +309 -26
  382. package/dist/prosemirror/schema/nodes.js +16 -1
  383. package/dist/prosemirror/sectionCarrier.d.ts +37 -0
  384. package/dist/prosemirror/sectionCarrier.js +40 -0
  385. package/dist/prosemirror/selectionState.d.ts +3 -0
  386. package/dist/prosemirror/selectionState.js +4 -1
  387. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
  388. package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
  389. package/dist/prosemirror/tableResize.js +5 -6
  390. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
  391. package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
  392. package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
  393. package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
  394. package/dist/prosemirror/validation.js +31 -6
  395. package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
  396. package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
  397. package/dist/prosemirror/zeroWidthAnchors.js +6 -0
  398. package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
  399. package/dist/render-dom/commentAnchorAttributes.js +54 -0
  400. package/dist/server.d.ts +3 -1
  401. package/dist/server.js +3 -1
  402. package/dist/style-sets/extract.js +4 -4
  403. package/dist/style-sets/stellaStyle.js +36 -23
  404. package/dist/types/colors.d.ts +2 -2
  405. package/dist/types/content.d.ts +2 -2
  406. package/dist/types/documentEnumValues.d.ts +53 -26
  407. package/dist/types/documentEnumValues.js +72 -174
  408. package/dist/types/formatting.d.ts +2 -2
  409. package/dist/types/index.d.ts +9 -2
  410. package/dist/utils/borderCss.d.ts +246 -0
  411. package/dist/utils/borderCss.js +325 -0
  412. package/dist/utils/clipboard.d.ts +9 -1
  413. package/dist/utils/clipboard.js +27 -1
  414. package/dist/utils/colorResolver.d.ts +4 -3
  415. package/dist/utils/colorResolver.js +45 -76
  416. package/dist/utils/createDocument.js +24 -6
  417. package/dist/utils/findReplace.js +52 -10
  418. package/dist/utils/formatToStyle.d.ts +84 -2
  419. package/dist/utils/formatToStyle.js +133 -52
  420. package/dist/utils/headingCollector.js +3 -2
  421. package/dist/utils/imageLuminance.d.ts +15 -0
  422. package/dist/utils/imageLuminance.js +32 -0
  423. package/dist/utils/mergeDocumentContent.js +12 -20
  424. package/dist/utils/paragraphFormattingMerge.js +27 -6
  425. package/dist/utils/replaceText.js +1 -0
  426. package/dist/utils/tableOperations.d.ts +5 -3
  427. package/dist/utils/tableOperations.js +14 -1
  428. package/dist/utils/tablePlacement.d.ts +7 -0
  429. package/dist/utils/tablePlacement.js +14 -0
  430. package/dist/utils/textDirectionFlow.d.ts +15 -0
  431. package/dist/utils/textDirectionFlow.js +38 -0
  432. package/dist/utils/textFormattingMerge.js +16 -4
  433. package/package.json +10 -10
  434. package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
  435. package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
  436. package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
  437. package/dist/compare/__fixtures__/body-sequence.js +0 -225
  438. package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
  439. package/dist/compare/__fixtures__/nested-table.js +0 -50
  440. package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
  441. package/dist/compare/__fixtures__/numbered-list.js +0 -85
  442. package/dist/docx/blockRangeMarkers.d.ts +0 -36
  443. package/dist/docx/blockRangeMarkers.js +0 -59
  444. package/dist/docx/bookmarkPlacement.d.ts +0 -9
  445. package/dist/docx/bookmarkPlacement.js +0 -50
  446. package/dist/fonts/embeddedFontTable.d.ts +0 -45
  447. package/dist/fonts/embeddedFontTable.js +0 -80
  448. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
  449. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
  450. package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
  451. package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
@@ -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((child) => child.type === "run" ? getRunSearchProjection(child) : getHyperlinkSearchProjection(child)));
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) => {
@@ -36,6 +36,88 @@ declare function borderToStyle(border: document_d_exports.BorderSpec | undefined
36
36
  * @returns CSS color string or empty string
37
37
  */
38
38
  declare function resolveShadingFill(shading: document_d_exports.ShadingProperties | undefined | null, theme?: document_d_exports.Theme | null): string;
39
+ /** The CSS `text-decoration-style` keywords folio paints an underline with. */
40
+ type CssTextDecorationStyle = "solid" | "double" | "dotted" | "dashed" | "wavy";
41
+ /**
42
+ * What an authored underline paints as, in CSS.
43
+ *
44
+ * `decorationStyle` is absent for the member that paints no line at all; the
45
+ * caller decides whether that means "omit the decoration" or "inherit".
46
+ * `decorationThickness` is absent wherever the font's own underline weight is
47
+ * what Word draws.
48
+ */
49
+ type UnderlineDecorationCss = {
50
+ readonly decorationStyle?: CssTextDecorationStyle;
51
+ readonly decorationThickness?: string;
52
+ };
53
+ /**
54
+ * The underline every DOM backend draws when the author named no member.
55
+ *
56
+ * It is also what an underline CSS cannot spell parses back as; see
57
+ * `underlineStyleFromCssDecoration`.
58
+ */
59
+ declare const PLAIN_UNDERLINE = "single";
60
+ /**
61
+ * Every `ST_Underline` member's CSS line. The one table: the ProseMirror mark's
62
+ * `toDOM`, the DOM painter and `textToStyle` all render a run from this, so a
63
+ * member cannot paint one line in the editor and another on the page.
64
+ *
65
+ * `none` cancels an underline inherited from the style chain rather than
66
+ * naming a line style, and `text-decoration-style: none` is not a CSS keyword,
67
+ * so that member names no keyword and carries no declarations at all.
68
+ *
69
+ * Where CSS has no keyword for what Word draws, the member is approximated and
70
+ * the approximation is stated here rather than at a call site: `words`
71
+ * underlines the spaces between words too (`text-decoration-skip-ink` skips
72
+ * descender ink, not spaces, and `text-decoration-skip: spaces` never
73
+ * shipped); `wavyDouble` draws two straight lines rather than two wavy ones;
74
+ * `dashLong`, `dotDash` and `dotDotDash` draw the single dash pattern CSS has.
75
+ * The `*Heavy` members and `thick` differ from their plain counterparts in
76
+ * weight only, which the thickness carries, so the line they name is their
77
+ * plain counterpart's.
78
+ */
79
+ declare const UNDERLINE_DECORATION_STYLES: {
80
+ readonly none: undefined;
81
+ readonly single: "solid";
82
+ readonly words: "solid";
83
+ readonly double: "double";
84
+ readonly thick: "solid";
85
+ readonly dotted: "dotted";
86
+ readonly dottedHeavy: "dotted";
87
+ readonly dash: "dashed";
88
+ readonly dashedHeavy: "dashed";
89
+ readonly dashLong: "dashed";
90
+ readonly dashLongHeavy: "dashed";
91
+ readonly dotDash: "dashed";
92
+ readonly dashDotHeavy: "dashed";
93
+ readonly dotDotDash: "dashed";
94
+ readonly dashDotDotHeavy: "dashed";
95
+ readonly wave: "wavy";
96
+ readonly wavyHeavy: "wavy";
97
+ readonly wavyDouble: "double";
98
+ };
99
+ /**
100
+ * The CSS an authored underline paints with.
101
+ *
102
+ * CSS has no heavy keyword, so a weight is stated as a length: the plain ratio
103
+ * the display list strokes with, times the weight the member's own row carries
104
+ * (`display-list/build/strokes.ts`). Both backends therefore scale the same way
105
+ * with the font size, and which members are heavy is read off the row rather
106
+ * than listed again here, so the page and the editor cannot disagree about it.
107
+ */
108
+ declare const underlineDecorationCss: (style: document_d_exports.UnderlineStyle) => UnderlineDecorationCss;
109
+ /**
110
+ * The `ST_Underline` member an authored `text-decoration` or
111
+ * `text-decoration-style` value parses back as.
112
+ *
113
+ * The table is many-to-one, so the inverse cannot be: several members share
114
+ * every keyword. It resolves each keyword to that keyword's canonical author,
115
+ * the plain member whose own CSS is exactly the keyword, so a member folio
116
+ * cannot spell in CSS comes back as the sibling it is drawn as: `dottedHeavy`
117
+ * as `dotted`, `words` and `thick` as `single`, `wavyDouble` as `double`. A
118
+ * value naming no keyword folio writes parses as the plain underline.
119
+ */
120
+ declare const underlineStyleFromCssDecoration: (value: string) => document_d_exports.UnderlineStyle;
39
121
  /**
40
122
  * Merge multiple CSSProperties objects
41
123
  *
@@ -54,7 +136,7 @@ declare function mergeStyles(...styles: (CSSProperties | undefined | null)[]): C
54
136
  */
55
137
  declare function tableCellToStyle(formatting: {
56
138
  verticalAlign?: "top" | "center" | "bottom";
57
- textDirection?: string;
139
+ textDirection?: document_d_exports.TextDirection;
58
140
  shading?: document_d_exports.ShadingProperties;
59
141
  borders?: {
60
142
  top?: document_d_exports.BorderSpec;
@@ -99,4 +181,4 @@ declare function sectionToStyle(sectionProps: {
99
181
  };
100
182
  } | undefined | null, theme?: document_d_exports.Theme | null): CSSProperties;
101
183
  //#endregion
102
- export { borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle };
184
+ export { CssTextDecorationStyle, PLAIN_UNDERLINE, UNDERLINE_DECORATION_STYLES, UnderlineDecorationCss, borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle, underlineDecorationCss, underlineStyleFromCssDecoration };
@@ -1,7 +1,13 @@
1
+ import { UNDERLINE_STROKES } from "../display-list/build/strokes.js";
2
+ import { UNDERLINE_THICKNESS_RATIO } from "../display-list/build/textDecorations.js";
3
+ import { UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
4
+ import { cssBorderStyle } from "./borderCss.js";
1
5
  import { resolveColor, resolveHighlightToCss, resolveShadingColor } from "./colorResolver.js";
2
6
  import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
3
7
  import { getHorizontalScaleFactor, normalizeHorizontalScalePercent } from "./horizontalScale.js";
8
+ import { textFlowCss } from "./textDirectionFlow.js";
4
9
  import { AUTO_PARAGRAPH_SPACING_PX, eighthsToPixels, formatPx, halfPointsToPixels, halfPointsToPoints, twipsToPixels } from "./units.js";
10
+ import { statesNoBorder } from "@stll/docx-core/model";
5
11
  //#region src/utils/formatToStyle.ts
6
12
  /**
7
13
  * Convert TextFormatting to CSS properties for a run/span
@@ -31,10 +37,12 @@ function textToStyle(formatting, theme) {
31
37
  const decorations = [];
32
38
  const decorationStyles = [];
33
39
  const decorationColors = [];
40
+ let decorationThickness;
34
41
  if (formatting.underline && formatting.underline.style !== "none") {
35
42
  decorations.push("underline");
36
- const underlineStyle = mapUnderlineStyle(formatting.underline.style);
37
- if (underlineStyle !== "solid") decorationStyles.push(underlineStyle);
43
+ const underline = underlineDecorationCss(formatting.underline.style);
44
+ if (underline.decorationStyle !== void 0 && underline.decorationStyle !== "solid") decorationStyles.push(underline.decorationStyle);
45
+ decorationThickness = underline.decorationThickness;
38
46
  if (formatting.underline.color) decorationColors.push(resolveColor(formatting.underline.color, theme));
39
47
  }
40
48
  if (formatting.strike) decorations.push("line-through");
@@ -43,6 +51,7 @@ function textToStyle(formatting, theme) {
43
51
  style.textDecoration = decorations.join(" ");
44
52
  if (decorationStyles.length > 0) style.textDecorationStyle = decorationStyles[0];
45
53
  if (decorationColors.length > 0) style.textDecorationColor = decorationColors[0];
54
+ if (decorationThickness !== void 0) style.textDecorationThickness = decorationThickness;
46
55
  }
47
56
  if (formatting.vertAlign) switch (formatting.vertAlign) {
48
57
  case "superscript":
@@ -90,7 +99,7 @@ function textToStyle(formatting, theme) {
90
99
  function paragraphToStyle(formatting, theme) {
91
100
  if (!formatting) return {};
92
101
  const style = {};
93
- if (formatting.alignment) style.textAlign = mapAlignment(formatting.alignment);
102
+ if (formatting.alignment) style.textAlign = CSS_TEXT_ALIGN_BY_PARAGRAPH_ALIGNMENT[formatting.alignment];
94
103
  if (formatting.beforeAutospacing) style.marginTop = formatPx(AUTO_PARAGRAPH_SPACING_PX);
95
104
  else if (formatting.spaceBefore !== void 0) style.marginTop = formatPx(twipsToPixels(formatting.spaceBefore));
96
105
  if (formatting.afterAutospacing) style.marginBottom = formatPx(AUTO_PARAGRAPH_SPACING_PX);
@@ -136,11 +145,11 @@ function paragraphToStyle(formatting, theme) {
136
145
  * @returns Partial CSSProperties with border styles
137
146
  */
138
147
  function borderToStyle(border, side = "", theme) {
139
- if (!border || border.style === "none" || border.style === "nil") return {};
148
+ if (!border || statesNoBorder(border.style)) return {};
140
149
  const style = {};
141
150
  const widthPx = border.size !== void 0 && border.size !== 0 ? eighthsToPixels(border.size) : 1;
142
151
  const color = border.color ? resolveColor(border.color, theme) : "#000000";
143
- const cssStyle = mapBorderStyle(border.style);
152
+ const cssStyle = cssBorderStyle(border.style);
144
153
  const widthKey = `border${side}Width`;
145
154
  const styleKey = `border${side}Style`;
146
155
  const colorKey = `border${side}Color`;
@@ -211,58 +220,126 @@ function resolveShadingFill(shading, theme) {
211
220
  return "";
212
221
  }
213
222
  /**
214
- * Map OOXML underline style to CSS text-decoration-style
223
+ * The underline every DOM backend draws when the author named no member.
224
+ *
225
+ * It is also what an underline CSS cannot spell parses back as; see
226
+ * `underlineStyleFromCssDecoration`.
215
227
  */
216
- function mapUnderlineStyle(underlineStyle) {
217
- switch (underlineStyle) {
218
- case "double": return "double";
219
- case "dotted":
220
- case "dottedHeavy": return "dotted";
221
- case "dash":
222
- case "dashedHeavy":
223
- case "dashLong":
224
- case "dashLongHeavy":
225
- case "dotDash":
226
- case "dashDotHeavy":
227
- case "dotDotDash":
228
- case "dashDotDotHeavy": return "dashed";
229
- case "wave":
230
- case "wavyHeavy":
231
- case "wavyDouble": return "wavy";
232
- default: return "solid";
233
- }
234
- }
228
+ const PLAIN_UNDERLINE = "single";
235
229
  /**
236
- * Map OOXML paragraph alignment to CSS text-align
230
+ * Every `ST_Underline` member's CSS line. The one table: the ProseMirror mark's
231
+ * `toDOM`, the DOM painter and `textToStyle` all render a run from this, so a
232
+ * member cannot paint one line in the editor and another on the page.
233
+ *
234
+ * `none` cancels an underline inherited from the style chain rather than
235
+ * naming a line style, and `text-decoration-style: none` is not a CSS keyword,
236
+ * so that member names no keyword and carries no declarations at all.
237
+ *
238
+ * Where CSS has no keyword for what Word draws, the member is approximated and
239
+ * the approximation is stated here rather than at a call site: `words`
240
+ * underlines the spaces between words too (`text-decoration-skip-ink` skips
241
+ * descender ink, not spaces, and `text-decoration-skip: spaces` never
242
+ * shipped); `wavyDouble` draws two straight lines rather than two wavy ones;
243
+ * `dashLong`, `dotDash` and `dotDotDash` draw the single dash pattern CSS has.
244
+ * The `*Heavy` members and `thick` differ from their plain counterparts in
245
+ * weight only, which the thickness carries, so the line they name is their
246
+ * plain counterpart's.
237
247
  */
238
- function mapAlignment(alignment) {
239
- switch (alignment) {
240
- case "center": return "center";
241
- case "right": return "right";
242
- case "both":
243
- case "distribute": return "justify";
244
- default: return "left";
248
+ const UNDERLINE_DECORATION_STYLES = {
249
+ none: void 0,
250
+ single: "solid",
251
+ words: "solid",
252
+ double: "double",
253
+ thick: "solid",
254
+ dotted: "dotted",
255
+ dottedHeavy: "dotted",
256
+ dash: "dashed",
257
+ dashedHeavy: "dashed",
258
+ dashLong: "dashed",
259
+ dashLongHeavy: "dashed",
260
+ dotDash: "dashed",
261
+ dashDotHeavy: "dashed",
262
+ dotDotDash: "dashed",
263
+ dashDotDotHeavy: "dashed",
264
+ wave: "wavy",
265
+ wavyHeavy: "wavy",
266
+ wavyDouble: "double"
267
+ };
268
+ /**
269
+ * The CSS an authored underline paints with.
270
+ *
271
+ * CSS has no heavy keyword, so a weight is stated as a length: the plain ratio
272
+ * the display list strokes with, times the weight the member's own row carries
273
+ * (`display-list/build/strokes.ts`). Both backends therefore scale the same way
274
+ * with the font size, and which members are heavy is read off the row rather
275
+ * than listed again here, so the page and the editor cannot disagree about it.
276
+ */
277
+ const underlineDecorationCss = (style) => {
278
+ const decorationStyle = UNDERLINE_DECORATION_STYLES[style];
279
+ if (decorationStyle === void 0) return {};
280
+ const { weight } = UNDERLINE_STROKES[style];
281
+ if (weight === 1) return { decorationStyle };
282
+ return {
283
+ decorationStyle,
284
+ decorationThickness: `${(UNDERLINE_THICKNESS_RATIO * weight).toFixed(4)}em`
285
+ };
286
+ };
287
+ /**
288
+ * Each CSS keyword's canonical author, derived from the one table: the first
289
+ * member in enumeration order that paints exactly that keyword at the font's
290
+ * own weight.
291
+ */
292
+ const CANONICAL_UNDERLINE_STYLE_BY_CSS = (() => {
293
+ const canonical = /* @__PURE__ */ new Map();
294
+ for (const style of UNDERLINE_STYLE_VALUES) {
295
+ const { decorationStyle, decorationThickness } = underlineDecorationCss(style);
296
+ if (decorationStyle === void 0 || decorationThickness !== void 0) continue;
297
+ if (!canonical.has(decorationStyle)) canonical.set(decorationStyle, style);
245
298
  }
246
- }
299
+ return canonical;
300
+ })();
247
301
  /**
248
- * Map OOXML border style to CSS border-style
302
+ * The `ST_Underline` member an authored `text-decoration` or
303
+ * `text-decoration-style` value parses back as.
304
+ *
305
+ * The table is many-to-one, so the inverse cannot be: several members share
306
+ * every keyword. It resolves each keyword to that keyword's canonical author,
307
+ * the plain member whose own CSS is exactly the keyword, so a member folio
308
+ * cannot spell in CSS comes back as the sibling it is drawn as: `dottedHeavy`
309
+ * as `dotted`, `words` and `thick` as `single`, `wavyDouble` as `double`. A
310
+ * value naming no keyword folio writes parses as the plain underline.
249
311
  */
250
- function mapBorderStyle(borderStyle) {
251
- switch (borderStyle) {
252
- case "none":
253
- case "nil": return "none";
254
- case "double":
255
- case "triple": return "double";
256
- case "dotted": return "dotted";
257
- case "dashed":
258
- case "dashSmallGap": return "dashed";
259
- case "threeDEmboss": return "ridge";
260
- case "threeDEngrave": return "groove";
261
- case "outset": return "outset";
262
- case "inset": return "inset";
263
- default: return "solid";
312
+ const underlineStyleFromCssDecoration = (value) => {
313
+ for (const token of value.toLowerCase().split(/[\s,]+/u)) {
314
+ const style = CANONICAL_UNDERLINE_STYLE_BY_CSS.get(token);
315
+ if (style !== void 0) return style;
264
316
  }
265
- }
317
+ return PLAIN_UNDERLINE;
318
+ };
319
+ /**
320
+ * Every `ST_Jc` member, and the CSS `text-align` that renders it.
321
+ *
322
+ * `start` and `end` carry straight over: CSS spells the direction-aware edges
323
+ * the same way and resolves them against the element's direction, as Word
324
+ * does. The Kashida justifications and `distribute` all render as `justify`,
325
+ * which is as close as CSS gets. `numTab` aligns to the list number's tab
326
+ * stop, which CSS cannot express, so it renders at the start edge — where a
327
+ * numbered paragraph without one sits.
328
+ */
329
+ const CSS_TEXT_ALIGN_BY_PARAGRAPH_ALIGNMENT = {
330
+ start: "start",
331
+ end: "end",
332
+ numTab: "start",
333
+ left: "left",
334
+ center: "center",
335
+ right: "right",
336
+ both: "justify",
337
+ distribute: "justify",
338
+ mediumKashida: "justify",
339
+ highKashida: "justify",
340
+ lowKashida: "justify",
341
+ thaiDistribute: "justify"
342
+ };
266
343
  /**
267
344
  * Merge multiple CSSProperties objects
268
345
  *
@@ -287,7 +364,11 @@ function tableCellToStyle(formatting, theme) {
287
364
  if (!formatting) return {};
288
365
  const style = {};
289
366
  if (formatting.verticalAlign) style.verticalAlign = formatting.verticalAlign;
290
- if (formatting.textDirection && (formatting.textDirection.includes("rl") || formatting.textDirection.includes("Rl"))) style.direction = "rtl";
367
+ if (formatting.textDirection) {
368
+ const flow = textFlowCss(formatting.textDirection);
369
+ if (flow.writingMode !== "horizontal-tb") style.writingMode = flow.writingMode;
370
+ if (flow.rotateDegrees !== void 0) style.transform = `rotate(${String(flow.rotateDegrees)}deg)`;
371
+ }
291
372
  if (formatting.shading) {
292
373
  const bgColor = resolveShadingFill(formatting.shading, theme);
293
374
  if (bgColor) style.backgroundColor = bgColor;
@@ -328,4 +409,4 @@ function sectionToStyle(sectionProps, theme) {
328
409
  return style;
329
410
  }
330
411
  //#endregion
331
- export { borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle };
412
+ export { PLAIN_UNDERLINE, UNDERLINE_DECORATION_STYLES, borderToStyle, mergeStyles, paragraphToStyle, resolveShadingFill, sectionToStyle, tableCellToStyle, textToStyle, underlineDecorationCss, underlineStyleFromCssDecoration };
@@ -1,4 +1,5 @@
1
1
  import { resolveHeadingLevel } from "../docx/builtInStyles.js";
2
+ import { readOutlineLevelAttr } from "../prosemirror/outlineLevelAttr.js";
2
3
  //#region src/utils/headingCollector.ts
3
4
  /**
4
5
  * Collect all headings from a ProseMirror document, in document order.
@@ -14,8 +15,8 @@ function collectHeadings(doc, styles) {
14
15
  doc.descendants((node, pos) => {
15
16
  if (node.type.name !== "paragraph") return;
16
17
  const level = resolveHeadingLevel({
17
- outlineLevel: node.attrs["outlineLevel"],
18
- styleId: node.attrs["styleId"]
18
+ outlineLevel: readOutlineLevelAttr(node.attrs["outlineLevel"]),
19
+ styleId: typeof node.attrs["styleId"] === "string" ? node.attrs["styleId"] : null
19
20
  }, styles);
20
21
  if (level === void 0) return;
21
22
  let text = "";
@@ -0,0 +1,15 @@
1
+ //#region src/utils/imageLuminance.d.ts
2
+ type ImageLuminance = {
3
+ brightness?: number | null;
4
+ contrast?: number | null;
5
+ };
6
+ /** Clamp a finite percentage to the range accepted by DrawingML `a:lum`. */
7
+ declare const normalizeImageLuminancePercent: (value: number) => number;
8
+ /**
9
+ * Convert DrawingML brightness and contrast percentages into Word's single
10
+ * linear per-channel transfer, expressed as CSS filters without an
11
+ * intermediate clamp changing the result.
12
+ */
13
+ declare const imageLuminanceFilter: ({ brightness, contrast }: ImageLuminance) => string | undefined;
14
+ //#endregion
15
+ export { ImageLuminance, imageLuminanceFilter, normalizeImageLuminancePercent };
@@ -0,0 +1,32 @@
1
+ //#region src/utils/imageLuminance.ts
2
+ const MAX_PERCENT = 100;
3
+ const HARD_STEP_SLOPE = 1e3;
4
+ /** Clamp a finite percentage to the range accepted by DrawingML `a:lum`. */
5
+ const normalizeImageLuminancePercent = (value) => Math.max(-100, Math.min(MAX_PERCENT, value));
6
+ const finitePercent = (value) => value == null || !Number.isFinite(value) ? 0 : normalizeImageLuminancePercent(value);
7
+ const styleNumber = (value) => {
8
+ const rounded = Math.round(value * 1e6) / 1e6;
9
+ return String(Object.is(rounded, -0) ? 0 : rounded);
10
+ };
11
+ /**
12
+ * Convert DrawingML brightness and contrast percentages into Word's single
13
+ * linear per-channel transfer, expressed as CSS filters without an
14
+ * intermediate clamp changing the result.
15
+ */
16
+ const imageLuminanceFilter = ({ brightness, contrast }) => {
17
+ const bright = finitePercent(brightness) / MAX_PERCENT;
18
+ const contrastAmount = finitePercent(contrast) / MAX_PERCENT;
19
+ if (bright === 0 && contrastAmount === 0) return;
20
+ const slope = contrastAmount >= 0 ? Math.min(HARD_STEP_SLOPE, 1 / (1 - contrastAmount)) : Math.max(0, 1 + contrastAmount);
21
+ const pivot = .5 - bright / 2;
22
+ const intercept = pivot + bright - slope * pivot;
23
+ if (intercept >= 0) {
24
+ const brightnessAmount = slope + 2 * intercept;
25
+ if (brightnessAmount <= 0) return "brightness(0)";
26
+ return `contrast(${styleNumber(slope / brightnessAmount)}) brightness(${styleNumber(brightnessAmount)})`;
27
+ }
28
+ const contrastFactor = 1 - 2 * intercept;
29
+ return `brightness(${styleNumber(slope / contrastFactor)}) contrast(${styleNumber(contrastFactor)})`;
30
+ };
31
+ //#endregion
32
+ export { imageLuminanceFilter, normalizeImageLuminancePercent };
@@ -1,3 +1,4 @@
1
+ import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
1
2
  import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
2
3
  //#region src/utils/mergeDocumentContent.ts
3
4
  /**
@@ -91,6 +92,12 @@ function remapBlock(block, numIdRemap, abstractNumIdRemap) {
91
92
  };
92
93
  return block;
93
94
  }
95
+ /** A cell holds no content control, so the walk stays inside its own union. */
96
+ function remapCellBlock(block, numIdRemap, abstractNumIdRemap) {
97
+ if (block.type === "paragraph") return remapParagraph(block, numIdRemap, abstractNumIdRemap);
98
+ if (block.type === "table") return remapTable(block, numIdRemap, abstractNumIdRemap);
99
+ return block;
100
+ }
94
101
  function remapTable(table, numIdRemap, abstractNumIdRemap) {
95
102
  return {
96
103
  ...table,
@@ -98,36 +105,21 @@ function remapTable(table, numIdRemap, abstractNumIdRemap) {
98
105
  ...row,
99
106
  cells: row.cells.map((cell) => ({
100
107
  ...cell,
101
- content: cell.content.map((item) => remapCellItem(item, numIdRemap, abstractNumIdRemap))
108
+ content: cell.content.map((item) => remapCellBlock(item, numIdRemap, abstractNumIdRemap))
102
109
  }))
103
110
  }))
104
111
  };
105
112
  }
106
- /**
107
- * `TableCell.content` is typed as `(Paragraph | Table)[]` — narrower than
108
- * `BlockContent` — because folio's own DOCX parser flattens a `w:sdt` inside
109
- * a cell into its `sdtContent` children (see `tableParser.ts`) rather than
110
- * keeping a `blockSdt` wrapper. A hand-built `Document` is not bound by that
111
- * invariant, so delegate to `remapBlock` (which fully handles paragraph,
112
- * table, and container blocks, including nested tables) and only accept its
113
- * result back into the cell when it is still a `Paragraph | Table` — an
114
- * anomalous `blockSdt` (or any other shape `remapBlock` had to pass through
115
- * unchanged) is left as-is rather than smuggled into a field the type system
116
- * says can't hold it.
117
- */
118
- function remapCellItem(item, numIdRemap, abstractNumIdRemap) {
119
- const remapped = remapBlock(item, numIdRemap, abstractNumIdRemap);
120
- return remapped.type === "blockSdt" ? item : remapped;
121
- }
122
113
  function remapParagraph(paragraph, numIdRemap, abstractNumIdRemap) {
123
- const numId = paragraph.formatting?.numPr?.numId;
114
+ const numPr = paragraph.formatting?.numPr;
115
+ const numId = paragraphNumberingReferenceId(numPr);
124
116
  const remappedNumId = numId === void 0 ? void 0 : numIdRemap.get(numId);
125
- if (remappedNumId === void 0) return paragraph;
117
+ if (remappedNumId === void 0 || numPr?.kind !== "reference") return paragraph;
126
118
  return cloneParagraphWithoutPropertySource(paragraph, {
127
119
  formatting: {
128
120
  ...paragraph.formatting,
129
121
  numPr: {
130
- ...paragraph.formatting?.numPr,
122
+ ...numPr,
131
123
  numId: remappedNumId
132
124
  }
133
125
  },
@@ -1,4 +1,5 @@
1
1
  import { mergeTextFormatting } from "./textFormattingMerge.js";
2
+ import { mergeParagraphNumbering } from "@stll/docx-core/model";
2
3
  //#region src/utils/paragraphFormattingMerge.ts
3
4
  const PARAGRAPH_REPLACE_KEYS = [
4
5
  "alignment",
@@ -41,6 +42,28 @@ function mergeParagraphTabStops(inherited, direct) {
41
42
  return [...stopsByPosition.values()].toSorted((a, b) => a.position - b.position);
42
43
  }
43
44
  /**
45
+ * A resolved cascade carries no captured bytes.
46
+ *
47
+ * `preserved` holds the markup of the one element it was read from, and the
48
+ * two attribute remainders beside it hold the attributes of the `w:ind` and
49
+ * `w:spacing` that element carried. A style's `w:pPr` is not a paragraph's
50
+ * direct formatting, and a merge that let a spread carry either would write
51
+ * the same bytes at two tiers and make an inherited value outrank the tier it
52
+ * came from — the rule #873 states for every other inherited `w:pPr` value.
53
+ * Every caller of the merge below builds a resolved cascade rather than a
54
+ * saved element, so the drop is unconditional and belongs here, where a new
55
+ * field cannot slip past it in a spread.
56
+ *
57
+ * The remainders inside `borders`, `shading` and `tabs` are not dropped, and
58
+ * that is the same rule rather than an exception: those records replace
59
+ * wholesale, so an inherited one is written back only where the whole record
60
+ * is, and the attributes the author wrote on it belong with it.
61
+ */
62
+ const withoutPreservedMarkup = (formatting) => {
63
+ const { preserved: _preserved, indentPreservedAttributes: _indentPreservedAttributes, spacingPreservedAttributes: _spacingPreservedAttributes, ...resolved } = formatting;
64
+ return resolved;
65
+ };
66
+ /**
44
67
  * Merge paragraph properties for OOXML style cascade resolution.
45
68
  *
46
69
  * The source is the higher-priority layer. Most `w:pPr` properties replace an
@@ -51,11 +74,11 @@ function mergeParagraphTabStops(inherited, direct) {
51
74
  function mergeParagraphFormatting(target, source) {
52
75
  if (!source) return target;
53
76
  if (!target) {
54
- const result = { ...source };
77
+ const result = withoutPreservedMarkup(source);
55
78
  if (source.tabs !== void 0) result.tabs = [...source.tabs];
56
79
  return result;
57
80
  }
58
- const result = { ...target };
81
+ const result = withoutPreservedMarkup(target);
59
82
  for (const key of PARAGRAPH_REPLACE_KEYS) copyDefinedParagraphProperty(result, source, key);
60
83
  if (source.indentFirstLine !== void 0) result.hangingIndent = source.hangingIndent === true;
61
84
  const mergedRunProperties = mergeTextFormatting(result.runProperties, source.runProperties);
@@ -64,10 +87,8 @@ function mergeParagraphFormatting(target, source) {
64
87
  ...result.borders,
65
88
  ...source.borders
66
89
  };
67
- if (source.numPr !== void 0) result.numPr = {
68
- ...result.numPr,
69
- ...source.numPr
70
- };
90
+ const mergedNumbering = mergeParagraphNumbering(result.numPr, source.numPr);
91
+ if (mergedNumbering !== void 0) result.numPr = mergedNumbering;
71
92
  if (source.frame !== void 0) result.frame = {
72
93
  ...result.frame,
73
94
  ...source.frame
@@ -49,6 +49,7 @@ function getParagraphByIndex(body, paragraphIndex) {
49
49
  }
50
50
  continue;
51
51
  }
52
+ if (block.type !== "blockSdt") continue;
52
53
  const found = walkBlocks(block.content);
53
54
  if (found !== null) return found;
54
55
  }
@@ -3,8 +3,10 @@ import { document_d_exports } from "../types/document.js";
3
3
  type TablePropertiesCommand = {
4
4
  width?: number | null;
5
5
  widthType?: document_d_exports.TableWidthType | null;
6
- justification?: "left" | "center" | "right" | null;
6
+ justification?: document_d_exports.TableAlignment | null;
7
7
  };
8
+ declare const TABLE_PROPERTY_JUSTIFICATIONS: readonly ("start" | "center" | "end" | "left" | "right")[];
9
+ declare const toTablePropertyJustification: (value: string | null | undefined) => NonNullable<TablePropertiesCommand["justification"]>;
8
10
  type TableAction = "addRowAbove" | "addRowBelow" | "addColumnLeft" | "addColumnRight" | "deleteRow" | "deleteColumn" | "mergeCells" | "splitCell" | "deleteTable" | "selectTable" | "selectRow" | "selectColumn" | "borderAll" | "borderOutside" | "borderInside" | "borderNone" | "borderTop" | "borderBottom" | "borderLeft" | "borderRight" | {
9
11
  type: "cellFillColor";
10
12
  color: string | null;
@@ -17,7 +19,7 @@ type TableAction = "addRowAbove" | "addRowBelow" | "addColumnLeft" | "addColumnR
17
19
  } | {
18
20
  type: "cellBorder";
19
21
  side: "top" | "bottom" | "left" | "right" | "all";
20
- style: string;
22
+ style: document_d_exports.BorderStyle;
21
23
  size: number;
22
24
  color: string;
23
25
  } | {
@@ -84,4 +86,4 @@ declare const deleteColumn: (table: document_d_exports.Table, columnIndex: numbe
84
86
  declare const mergeCells: (table: document_d_exports.Table, selection: TableSelection) => document_d_exports.Table;
85
87
  declare const splitCell: (table: document_d_exports.Table, rowIndex: number, columnIndex: number) => document_d_exports.Table;
86
88
  //#endregion
87
- export { TableAction, TableContext, TablePropertiesCommand, TableSelection, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell };
89
+ export { TABLE_PROPERTY_JUSTIFICATIONS, TableAction, TableContext, TablePropertiesCommand, TableSelection, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell, toTablePropertyJustification };