@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,58 +1,164 @@
1
1
  import { resolveCssBorderStroke } from "../../layout-painter/borderStroke.js";
2
2
  import { parseDisplayColor } from "./colors.js";
3
+ import "./textDecorations.js";
3
4
  //#region src/display-list/build/strokes.ts
4
5
  /**
5
- * Border and rule strokes.
6
+ * Every CSS `border-style` folio paints, as a display-list pattern.
6
7
  *
7
- * One deliberate divergence from `layout-painter/borderStroke.ts`: that helper
8
- * encodes a sub-pixel border width as a `color-mix` alpha because CSS quantizes
9
- * a fractional border to one device pixel. A display list has no device pixel,
10
- * and a PDF strokes 0.4pt natively, so the authored fractional width and the
11
- * plain colour survive here. Everything else (colour/style/width defaults) is
12
- * taken from the painter's helper so the two cannot drift.
8
+ * The bevelled keywords have no display-list pattern, and Word draws
9
+ * `threeDEmboss`/`threeDEngrave` as a plain line where the shading is
10
+ * unavailable, so they stroke solid.
13
11
  */
14
- /**
15
- * CSS `border-style` and the raw OOXML `w:val` names both reach
16
- * `BorderStyle.style` (the bridge maps most, `renderParagraph` maps the rest),
17
- * so both vocabularies are resolved here. Everything decorative that folio does
18
- * not draw degrades to a plain line, matching how Word degrades on a platform
19
- * without the specialised glyphs.
20
- */
21
- const STROKE_PATTERN_BY_STYLE = {
12
+ const CSS_BORDER_STROKE_PATTERNS = {
22
13
  none: "none",
23
- nil: "none",
24
- hidden: "none",
25
14
  solid: "solid",
26
- single: "solid",
27
- thick: "solid",
28
- inset: "solid",
29
- outset: "solid",
30
- ridge: "solid",
31
- groove: "solid",
32
15
  double: "double",
33
16
  dotted: "dotted",
34
- dotdash: "dashed",
35
- dotdotdash: "dashed",
36
17
  dashed: "dashed",
37
- dash: "dashed",
38
- dashsmallgap: "dashed",
39
- dashlong: "dashed",
40
- wavy: "wavy",
41
- wave: "wavy",
42
- wavydouble: "double"
18
+ groove: "solid",
19
+ ridge: "solid",
20
+ inset: "solid",
21
+ outset: "solid"
43
22
  };
44
- const DEFAULT_PATTERN = "solid";
45
- const strokePatternForStyle = (style) => {
46
- if (style === void 0) return DEFAULT_PATTERN;
47
- return STROKE_PATTERN_BY_STYLE[style.trim().toLowerCase()] ?? DEFAULT_PATTERN;
23
+ /**
24
+ * Every `ST_PresetLineDashVal` member, as a display-list pattern.
25
+ *
26
+ * DrawingML distinguishes dash length (`lgDash`) and the system patterns
27
+ * (`sysDash`) from the plain ones; a display list has three periodic patterns,
28
+ * so the distinction collapses to dotted or dashed. It collapses here, once,
29
+ * rather than at whichever consumer happened to know the spelling.
30
+ */
31
+ const PRESET_DASH_STROKE_PATTERNS = {
32
+ solid: "solid",
33
+ dot: "dotted",
34
+ dash: "dashed",
35
+ lgDash: "dashed",
36
+ dashDot: "dashed",
37
+ lgDashDot: "dashed",
38
+ lgDashDotDot: "dashed",
39
+ sysDash: "dashed",
40
+ sysDot: "dotted",
41
+ sysDashDot: "dashed",
42
+ sysDashDotDot: "dashed"
48
43
  };
49
44
  /**
50
- * Turn an authored border into a paintable stroke. `undefined` stroke means
51
- * "draw nothing": an explicit `none`/`nil` style, a non-positive width, or a
52
- * colour this producer cannot resolve.
45
+ * Every `ST_Underline` member the model carries, one row per member.
46
+ *
47
+ * The three fields are one decision and belong on one line: `wavyDouble` is
48
+ * Word's two waves, which is the `wavy` pattern drawn twice rather than the
49
+ * `double` pattern, so a reader who has the pattern without the count has half
50
+ * the member. `double` is one stroke, because the display list's `double`
51
+ * pattern already carries the second rule and the gap between them. CSS can
52
+ * draw neither two waves nor `words`, so the editor approximates them; the page
53
+ * and the PDF do not have to.
54
+ *
55
+ * Word draws `thick` and the seven `*Heavy` members at twice the rule the font
56
+ * asks for, and the rest at the plain rule. Without the weight the display list
57
+ * strokes every member at the plain thickness, so `dottedHeavy` and `dotted`
58
+ * come out as the same line on the page and in the PDF while the editor draws
59
+ * them apart. The DOM spells this same weight as a
60
+ * `text-decoration-thickness` length (`utils/formatToStyle.ts`), so which
61
+ * members are heavy is decided here and nowhere else.
62
+ *
63
+ * `none` states no decoration: a run whose underline says so paints nothing,
64
+ * and its weight and stroke count are the plain ones by default rather than by
65
+ * decision.
53
66
  */
54
- const resolveBorderStroke = (border) => {
55
- const pattern = strokePatternForStyle(border.style);
67
+ const UNDERLINE_STROKES = {
68
+ none: {
69
+ pattern: "none",
70
+ weight: 1,
71
+ strokes: 1
72
+ },
73
+ single: {
74
+ pattern: "solid",
75
+ weight: 1,
76
+ strokes: 1
77
+ },
78
+ words: {
79
+ pattern: "solid",
80
+ weight: 1,
81
+ strokes: 1
82
+ },
83
+ double: {
84
+ pattern: "double",
85
+ weight: 1,
86
+ strokes: 1
87
+ },
88
+ thick: {
89
+ pattern: "solid",
90
+ weight: 2,
91
+ strokes: 1
92
+ },
93
+ dotted: {
94
+ pattern: "dotted",
95
+ weight: 1,
96
+ strokes: 1
97
+ },
98
+ dottedHeavy: {
99
+ pattern: "dotted",
100
+ weight: 2,
101
+ strokes: 1
102
+ },
103
+ dash: {
104
+ pattern: "dashed",
105
+ weight: 1,
106
+ strokes: 1
107
+ },
108
+ dashedHeavy: {
109
+ pattern: "dashed",
110
+ weight: 2,
111
+ strokes: 1
112
+ },
113
+ dashLong: {
114
+ pattern: "dashed",
115
+ weight: 1,
116
+ strokes: 1
117
+ },
118
+ dashLongHeavy: {
119
+ pattern: "dashed",
120
+ weight: 2,
121
+ strokes: 1
122
+ },
123
+ dotDash: {
124
+ pattern: "dashed",
125
+ weight: 1,
126
+ strokes: 1
127
+ },
128
+ dashDotHeavy: {
129
+ pattern: "dashed",
130
+ weight: 2,
131
+ strokes: 1
132
+ },
133
+ dotDotDash: {
134
+ pattern: "dashed",
135
+ weight: 1,
136
+ strokes: 1
137
+ },
138
+ dashDotDotHeavy: {
139
+ pattern: "dashed",
140
+ weight: 2,
141
+ strokes: 1
142
+ },
143
+ wave: {
144
+ pattern: "wavy",
145
+ weight: 1,
146
+ strokes: 1
147
+ },
148
+ wavyHeavy: {
149
+ pattern: "wavy",
150
+ weight: 2,
151
+ strokes: 1
152
+ },
153
+ wavyDouble: {
154
+ pattern: "wavy",
155
+ weight: 1,
156
+ strokes: 2
157
+ }
158
+ };
159
+ /** What a border with a width but no style paints: the CSS initial. */
160
+ const DEFAULT_PATTERN = "solid";
161
+ const strokeWith = (border, pattern) => {
56
162
  if (pattern === "none") return {};
57
163
  const css = resolveCssBorderStroke(border);
58
164
  const isSubPixelEncoded = css.color.startsWith("color-mix");
@@ -68,11 +174,25 @@ const resolveBorderStroke = (border) => {
68
174
  pattern
69
175
  } };
70
176
  };
71
- /** CSS `text-decoration-style` → the display list's stroke patterns. */
72
- const decorationPatternForStyle = (style) => {
73
- if (style === void 0) return DEFAULT_PATTERN;
74
- const pattern = STROKE_PATTERN_BY_STYLE[style.trim().toLowerCase()];
75
- return pattern === void 0 || pattern === "none" ? DEFAULT_PATTERN : pattern;
76
- };
177
+ /**
178
+ * Turn an authored CSS border into a paintable stroke. `undefined` stroke means
179
+ * "draw nothing": an explicit `none` style, a non-positive width, or a colour
180
+ * this producer cannot resolve.
181
+ */
182
+ const resolveBorderStroke = (border) => strokeWith(border, border.style === void 0 ? DEFAULT_PATTERN : CSS_BORDER_STROKE_PATTERNS[border.style]);
183
+ /** Turn a shape or text-box outline into a paintable stroke. */
184
+ const resolveOutlineStroke = (outline) => strokeWith({
185
+ color: outline.color,
186
+ width: outline.width
187
+ }, outline.dash === void 0 ? DEFAULT_PATTERN : PRESET_DASH_STROKE_PATTERNS[outline.dash]);
188
+ /**
189
+ * An authored underline's row. An undefined member is a `w:u` with no `w:val`,
190
+ * which Word draws as the plain single rule, so it resolves to that member's
191
+ * row rather than to a default per field.
192
+ */
193
+ const underlineStrokes = (style) => style === void 0 ? UNDERLINE_STROKES.single : UNDERLINE_STROKES[style];
194
+ const underlinePattern = (style) => underlineStrokes(style).pattern;
195
+ const underlineWeight = (style) => underlineStrokes(style).weight;
196
+ const underlineStrokeCount = (style) => underlineStrokes(style).strokes;
77
197
  //#endregion
78
- export { decorationPatternForStyle, resolveBorderStroke };
198
+ export { CSS_BORDER_STROKE_PATTERNS, PRESET_DASH_STROKE_PATTERNS, UNDERLINE_STROKES, resolveBorderStroke, resolveOutlineStroke, underlinePattern, underlineStrokeCount, underlineWeight };
@@ -2,6 +2,8 @@ import { createTableCellFlowState, placeTableCellBlock } from "../../layout-engi
2
2
  import { buildTableCellGrid, buildTableCellPlacements, getSourceCellAt } from "../../layout-engine/measure/tableCellGrid.js";
3
3
  import { tableFragmentBottomBorders } from "../../layout-engine/measure/tableFragmentBorderGeometry.js";
4
4
  import { resolveTableCellPadding } from "../../layout-engine/types.js";
5
+ import { cellTextRotationDegrees } from "../../layout-painter/renderTable.js";
6
+ import { paintsCssBorder } from "../../utils/borderCss.js";
5
7
  import { HIT_REGION_KINDS } from "../primitives.js";
6
8
  import { parseDisplayColor } from "./colors.js";
7
9
  import { paintImageFragment } from "./imagePrimitives.js";
@@ -25,7 +27,7 @@ import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
25
27
  * engineering a gradient.
26
28
  */
27
29
  /** A cell edge is "visible" for collapse purposes on style alone, as the painter decides it. */
28
- const hasVisibleBorder = (border) => border !== void 0 && border.style !== "none" && border.style !== "nil";
30
+ const hasVisibleBorder = (border) => border !== void 0 && paintsCssBorder(border.style);
29
31
  const strokeFor = (border, context, label) => {
30
32
  if (!hasVisibleBorder(border) || !border) return;
31
33
  const { stroke, unresolvedColor } = resolveBorderStroke(border);
@@ -97,7 +99,7 @@ const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, si
97
99
  const contentXPx = box.xPx + widths.left + padding.left;
98
100
  const contentYPx = box.yPx + widths.top + padding.top;
99
101
  const contentWidthPx = Math.max(0, cellMeasure.width - padding.left - padding.right);
100
- if (cell.textDirection === "btLr" || cell.textDirection === "tbRl") context.unsupported.report(UNSUPPORTED_CONSTRUCT.verticalCellText, context.pageIndex, `w:textDirection ${cell.textDirection} paints horizontally`);
102
+ if (cellTextRotationDegrees(cell.textDirection) !== 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.verticalCellText, context.pageIndex, `w:textDirection ${cell.textDirection} paints horizontally`);
101
103
  composer.push(primitives);
102
104
  primitives.length = 0;
103
105
  paintCellBlocks({
@@ -1,11 +1,12 @@
1
1
  import { layoutTextBoxContent } from "../../layout-engine/measure/textBoxParagraphLayout.js";
2
2
  import { DEFAULT_TEXTBOX_MARGINS } from "../../layout-engine/types.js";
3
+ import { presetDashForOutlineAttr } from "../../types/documentEnumValues.js";
3
4
  import { hasHorizontalFlip, hasVerticalFlip, parseRotationDegrees } from "../../utils/rotationBoundingBox.js";
4
5
  import { HIT_REGION_KINDS } from "../primitives.js";
5
6
  import { parseDisplayColor } from "./colors.js";
6
7
  import { paintParagraphFragment } from "./paragraphPrimitives.js";
7
8
  import { blockRegion, createPageComposer } from "./regions.js";
8
- import { resolveBorderStroke } from "./strokes.js";
9
+ import { resolveOutlineStroke } from "./strokes.js";
9
10
  import { paintTableBlock } from "./tablePrimitives.js";
10
11
  import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
11
12
  //#region src/display-list/build/textBoxPrimitives.ts
@@ -65,10 +66,11 @@ const paintUnrotatedTextBoxFragment = ({ composer, fragment, block, measure, con
65
66
  else context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `text box fill ${block.fillColor}`);
66
67
  }
67
68
  let outlineWidthPx = 0;
68
- if (block.outlineWidth !== void 0 && block.outlineWidth > 0) {
69
- const { stroke, unresolvedColor } = resolveBorderStroke({
69
+ const outlineDash = presetDashForOutlineAttr(block.outlineStyle) ?? "solid";
70
+ if (block.outlineWidth !== void 0 && block.outlineWidth > 0 && outlineDash !== "none") {
71
+ const { stroke, unresolvedColor } = resolveOutlineStroke({
70
72
  width: block.outlineWidth,
71
- style: block.outlineStyle ?? "solid",
73
+ dash: outlineDash,
72
74
  color: block.outlineColor ?? "#000000"
73
75
  });
74
76
  if (unresolvedColor !== void 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `text box outline ${unresolvedColor}`);
@@ -20,10 +20,24 @@ declare const UNDERLINE_OFFSET_RATIO = 0.1;
20
20
  /** Underline thickness as a fraction of the em, floored so a hairline stays visible. */
21
21
  declare const UNDERLINE_THICKNESS_RATIO: number;
22
22
  declare const MIN_DECORATION_THICKNESS_PX = 1;
23
+ /**
24
+ * What an underline member's thickness is a multiple of the plain one.
25
+ *
26
+ * `thick` and the `*Heavy` members differ from their plain counterparts in
27
+ * weight only, and Word draws that weight as twice the plain rule. The number
28
+ * lives here rather than at either renderer because both read it: a member's
29
+ * row states it (`strokes.ts:UNDERLINE_STROKES`), the display list multiplies
30
+ * the stroke by it and the DOM spells the same row's weight as a
31
+ * `text-decoration-thickness` length
32
+ * (`formatToStyle.ts:underlineDecorationCss`). Two copies would let the page
33
+ * and the editor draw the same member at two weights.
34
+ */
35
+ declare const PLAIN_UNDERLINE_WEIGHT = 1;
36
+ declare const HEAVY_UNDERLINE_WEIGHT = 2;
23
37
  /** Distance above the baseline to the centre of the strikethrough, as a fraction of the em. */
24
38
  declare const STRIKETHROUGH_OFFSET_RATIO = 0.28;
25
39
  declare const underlineThicknessPx: (fontSizePx: number) => number;
26
40
  declare const underlineCenterYPx: (baselineYPx: number, fontSizePx: number) => number;
27
41
  declare const strikethroughCenterYPx: (baselineYPx: number, fontSizePx: number) => number;
28
42
  //#endregion
29
- export { MIN_DECORATION_THICKNESS_PX, STRIKETHROUGH_OFFSET_RATIO, UNDERLINE_OFFSET_RATIO, UNDERLINE_THICKNESS_RATIO, strikethroughCenterYPx, underlineCenterYPx, underlineThicknessPx };
43
+ export { HEAVY_UNDERLINE_WEIGHT, MIN_DECORATION_THICKNESS_PX, PLAIN_UNDERLINE_WEIGHT, STRIKETHROUGH_OFFSET_RATIO, UNDERLINE_OFFSET_RATIO, UNDERLINE_THICKNESS_RATIO, strikethroughCenterYPx, underlineCenterYPx, underlineThicknessPx };
@@ -20,10 +20,24 @@ const UNDERLINE_OFFSET_RATIO = .1;
20
20
  /** Underline thickness as a fraction of the em, floored so a hairline stays visible. */
21
21
  const UNDERLINE_THICKNESS_RATIO = 1 / 14;
22
22
  const MIN_DECORATION_THICKNESS_PX = 1;
23
+ /**
24
+ * What an underline member's thickness is a multiple of the plain one.
25
+ *
26
+ * `thick` and the `*Heavy` members differ from their plain counterparts in
27
+ * weight only, and Word draws that weight as twice the plain rule. The number
28
+ * lives here rather than at either renderer because both read it: a member's
29
+ * row states it (`strokes.ts:UNDERLINE_STROKES`), the display list multiplies
30
+ * the stroke by it and the DOM spells the same row's weight as a
31
+ * `text-decoration-thickness` length
32
+ * (`formatToStyle.ts:underlineDecorationCss`). Two copies would let the page
33
+ * and the editor draw the same member at two weights.
34
+ */
35
+ const PLAIN_UNDERLINE_WEIGHT = 1;
36
+ const HEAVY_UNDERLINE_WEIGHT = 2;
23
37
  /** Distance above the baseline to the centre of the strikethrough, as a fraction of the em. */
24
38
  const STRIKETHROUGH_OFFSET_RATIO = .28;
25
39
  const underlineThicknessPx = (fontSizePx) => Math.max(1, fontSizePx * UNDERLINE_THICKNESS_RATIO);
26
40
  const underlineCenterYPx = (baselineYPx, fontSizePx) => baselineYPx + fontSizePx * UNDERLINE_OFFSET_RATIO;
27
41
  const strikethroughCenterYPx = (baselineYPx, fontSizePx) => baselineYPx - fontSizePx * STRIKETHROUGH_OFFSET_RATIO;
28
42
  //#endregion
29
- export { MIN_DECORATION_THICKNESS_PX, STRIKETHROUGH_OFFSET_RATIO, UNDERLINE_OFFSET_RATIO, UNDERLINE_THICKNESS_RATIO, strikethroughCenterYPx, underlineCenterYPx, underlineThicknessPx };
43
+ export { HEAVY_UNDERLINE_WEIGHT, MIN_DECORATION_THICKNESS_PX, PLAIN_UNDERLINE_WEIGHT, STRIKETHROUGH_OFFSET_RATIO, UNDERLINE_OFFSET_RATIO, UNDERLINE_THICKNESS_RATIO, strikethroughCenterYPx, underlineCenterYPx, underlineThicknessPx };
@@ -1,6 +1,8 @@
1
+ import { writeCommentAnchorIds } from "../../render-dom/commentAnchorAttributes.js";
1
2
  import { bytesToDataUrl } from "../../utils/base64.js";
3
+ import { imageLuminanceFilter } from "../../utils/imageLuminance.js";
2
4
  import { anchorTargetAttrs } from "../../utils/urlSecurity.js";
3
- import { STROKE_DASH_FACTORS, walkRegions } from "../primitives.js";
5
+ import { STROKE_DASH_FACTORS, strokeCrossExtentPx, walkRegions } from "../primitives.js";
4
6
  import { panic } from "better-result";
5
7
  //#region src/display-list/dom/renderDisplayListToDom.ts
6
8
  /**
@@ -160,24 +162,6 @@ const VERTICAL_BAR_AXES = {
160
162
  main: "to bottom",
161
163
  cross: "to right"
162
164
  };
163
- /**
164
- * How far a stroke reaches across its path. A dash pattern stays within the
165
- * thickness; `double` spans two lines plus the shared gap, and `wavy` the peak
166
- * to peak amplitude plus the thickness the curve itself is drawn with.
167
- */
168
- const strokeCrossExtentPx = (stroke) => {
169
- switch (stroke.pattern) {
170
- case "solid":
171
- case "dashed":
172
- case "dotted": return stroke.thicknessPx;
173
- case "double": return stroke.thicknessPx * 3;
174
- case "wavy": return stroke.thicknessPx * 3;
175
- default: {
176
- const unreachable = stroke.pattern;
177
- panic(`renderDisplayListToDom: unhandled stroke pattern ${JSON.stringify(unreachable)}`);
178
- }
179
- }
180
- };
181
165
  const repeatingBars = (color, axis, barPx, gapPx) => `repeating-linear-gradient(${axis}, ${color} 0px, ${color} ${barPx}px, transparent ${barPx}px, transparent ${barPx + gapPx}px)`;
182
166
  const strokeBackground = (stroke, axes) => {
183
167
  const color = cssColor(stroke.color);
@@ -310,6 +294,7 @@ const paintGlyphRun = (run, context) => {
310
294
  span.style.fontStyle = face.italic ? "italic" : "normal";
311
295
  span.style.color = cssColor(run.color);
312
296
  span.style.direction = run.direction;
297
+ if (run.unicodeBidi !== void 0) span.style.unicodeBidi = run.unicodeBidi;
313
298
  if (run.stroke !== void 0) span.style.webkitTextStroke = `${px(run.stroke.thicknessPx)} ${cssColor(run.stroke.color)}`;
314
299
  span.style.fontKerning = run.kerning ? "normal" : "none";
315
300
  if (run.smallCaps) span.style.fontVariant = "small-caps";
@@ -387,13 +372,18 @@ const paintRect = ({ rect, fill, stroke }, context) => {
387
372
  default: panic(`renderDisplayListToDom: unhandled rect stroke painter ${JSON.stringify(painter)}`);
388
373
  }
389
374
  };
390
- const paintImage = ({ image, rect, crop, opacity }, context) => {
375
+ const paintImage = ({ image, rect, crop, opacity, brightness, contrast }, context) => {
391
376
  const source = resolveImage(image, context.images);
392
377
  const clip = createAbsoluteDiv(context, rect);
393
378
  clip.style.overflow = "hidden";
394
379
  const element = context.doc.createElement("img");
395
380
  element.style.position = "absolute";
396
381
  element.style.opacity = String(opacity);
382
+ const filter = imageLuminanceFilter({
383
+ ...brightness === void 0 ? {} : { brightness },
384
+ ...contrast === void 0 ? {} : { contrast }
385
+ });
386
+ if (filter !== void 0) element.style.filter = filter;
397
387
  element.style.left = "0px";
398
388
  element.style.top = "0px";
399
389
  element.style.width = px(rect.widthPx);
@@ -549,7 +539,7 @@ const applyRegionModel = (element, region) => {
549
539
  element.dataset["pmEnd"] = String(model.pmRange.end);
550
540
  }
551
541
  if (model.blockId !== void 0) element.dataset["blockId"] = model.blockId;
552
- if (model.commentIds !== void 0 && model.commentIds.length > 0) element.dataset["commentId"] = String(model.commentIds[0]);
542
+ if (model.commentIds !== void 0) writeCommentAnchorIds(element, model.commentIds);
553
543
  if (model.rowIndex !== void 0) element.dataset["rowIndex"] = String(model.rowIndex);
554
544
  if (model.columnIndex !== void 0) element.dataset["columnIndex"] = String(model.columnIndex);
555
545
  const story = model.story ?? model.pmRange?.story;
@@ -1,4 +1,4 @@
1
- import { DisplayColor, DisplayGlyphRun, DisplayHitRegion, DisplayPrimitive } from "./types.js";
1
+ import { DisplayColor, DisplayGlyphRun, DisplayHitRegion, DisplayPrimitive, DisplayStroke } from "./types.js";
2
2
  import { hasCursiveLetter, joinsAcrossBoundary } from "../utils/cursiveJoining.js";
3
3
  import { hasComplexScript, isComplexScriptCodePoint } from "../utils/scriptSegments.js";
4
4
  //#region src/display-list/primitives.d.ts
@@ -56,6 +56,17 @@ declare const DOUBLE_STROKE_GAP_FACTOR = 1;
56
56
  */
57
57
  declare const WAVY_STROKE_PERIOD_FACTOR = 6;
58
58
  declare const WAVY_STROKE_AMPLITUDE_FACTOR = 2;
59
+ /**
60
+ * How far a stroke reaches across its path: the band it occupies, centred on
61
+ * the path. A dash pattern stays within the thickness; `double` spans two rules
62
+ * plus the gap between them, and `wavy` the peak-to-peak amplitude plus the
63
+ * thickness the curve itself is drawn with.
64
+ *
65
+ * The DOM backend sizes an element with it and the producer stacks `wavyDouble`
66
+ * with it, so two strokes meant to clear each other are pushed apart by exactly
67
+ * the band the backend then paints.
68
+ */
69
+ declare const strokeCrossExtentPx: (stroke: DisplayStroke) => number;
59
70
  declare const BLACK: DisplayColor;
60
71
  declare const WHITE: DisplayColor;
61
72
  /**
@@ -93,4 +104,4 @@ type RegionVisitor = {
93
104
  };
94
105
  declare const walkRegions: (primitives: readonly DisplayPrimitive[], regions: readonly DisplayHitRegion[], visitor: RegionVisitor) => void;
95
106
  //#endregion
96
- export { BLACK, DISPLAY_PRIMITIVE_KINDS, DOUBLE_STROKE_GAP_FACTOR, HIT_REGION_KINDS, RegionVisitor, STROKE_DASH_FACTORS, WAVY_STROKE_AMPLITUDE_FACTOR, WAVY_STROKE_PERIOD_FACTOR, WHITE, glyphCellOffsetsPx, hasComplexScript, hasCursiveLetter, isComplexScriptCodePoint, joinsAcrossBoundary, walkRegions };
107
+ export { BLACK, DISPLAY_PRIMITIVE_KINDS, DOUBLE_STROKE_GAP_FACTOR, HIT_REGION_KINDS, RegionVisitor, STROKE_DASH_FACTORS, WAVY_STROKE_AMPLITUDE_FACTOR, WAVY_STROKE_PERIOD_FACTOR, WHITE, glyphCellOffsetsPx, hasComplexScript, hasCursiveLetter, isComplexScriptCodePoint, joinsAcrossBoundary, strokeCrossExtentPx, walkRegions };
@@ -1,7 +1,19 @@
1
1
  import { hasCursiveLetter, joinsAcrossBoundary } from "../utils/cursiveJoining.js";
2
2
  import { hasComplexScript, isComplexScriptCodePoint } from "../utils/scriptSegments.js";
3
+ import { panic } from "better-result";
3
4
  //#region src/display-list/primitives.ts
4
5
  /**
6
+ * Runtime companions of the paint IR.
7
+ *
8
+ * `types.ts` is pure data by rule, so what a backend needs at runtime lives
9
+ * here instead: the discriminator list a coverage test enumerates, the two
10
+ * colours every producer resolves a theme variable to, the stroke geometry
11
+ * both backends draw from, and the rule that turns a run's advances into a
12
+ * position per code point. A rule two backends must agree on belongs in one
13
+ * module, not in one copy each. Nothing here carries a layout fact, which is
14
+ * why a backend may take a runtime edge to it and not to `types.ts`.
15
+ */
16
+ /**
5
17
  * Left edge of every code point of a run, as an offset from the run's `xPx`.
6
18
  *
7
19
  * One implementation for both backends. The ordering rule is prose in
@@ -71,6 +83,29 @@ const DOUBLE_STROKE_GAP_FACTOR = 1;
71
83
  */
72
84
  const WAVY_STROKE_PERIOD_FACTOR = 6;
73
85
  const WAVY_STROKE_AMPLITUDE_FACTOR = 2;
86
+ /**
87
+ * How far a stroke reaches across its path: the band it occupies, centred on
88
+ * the path. A dash pattern stays within the thickness; `double` spans two rules
89
+ * plus the gap between them, and `wavy` the peak-to-peak amplitude plus the
90
+ * thickness the curve itself is drawn with.
91
+ *
92
+ * The DOM backend sizes an element with it and the producer stacks `wavyDouble`
93
+ * with it, so two strokes meant to clear each other are pushed apart by exactly
94
+ * the band the backend then paints.
95
+ */
96
+ const strokeCrossExtentPx = (stroke) => {
97
+ switch (stroke.pattern) {
98
+ case "solid":
99
+ case "dashed":
100
+ case "dotted": return stroke.thicknessPx;
101
+ case "double": return stroke.thicknessPx * 3;
102
+ case "wavy": return stroke.thicknessPx * 3;
103
+ default: {
104
+ const unreachable = stroke.pattern;
105
+ panic(`strokeCrossExtentPx: unhandled stroke pattern ${JSON.stringify(unreachable)}`);
106
+ }
107
+ }
108
+ };
74
109
  const BLACK = {
75
110
  r: 0,
76
111
  g: 0,
@@ -124,4 +159,4 @@ const walkRegions = (primitives, regions, visitor) => {
124
159
  visit(0, primitives.length, regions);
125
160
  };
126
161
  //#endregion
127
- export { BLACK, DISPLAY_PRIMITIVE_KINDS, DOUBLE_STROKE_GAP_FACTOR, HIT_REGION_KINDS, STROKE_DASH_FACTORS, WAVY_STROKE_AMPLITUDE_FACTOR, WAVY_STROKE_PERIOD_FACTOR, WHITE, glyphCellOffsetsPx, hasComplexScript, hasCursiveLetter, isComplexScriptCodePoint, joinsAcrossBoundary, walkRegions };
162
+ export { BLACK, DISPLAY_PRIMITIVE_KINDS, DOUBLE_STROKE_GAP_FACTOR, HIT_REGION_KINDS, STROKE_DASH_FACTORS, WAVY_STROKE_AMPLITUDE_FACTOR, WAVY_STROKE_PERIOD_FACTOR, WHITE, glyphCellOffsetsPx, hasComplexScript, hasCursiveLetter, isComplexScriptCodePoint, joinsAcrossBoundary, strokeCrossExtentPx, walkRegions };
@@ -215,6 +215,19 @@ type DisplayGlyphRun = {
215
215
  readonly text: string;
216
216
  readonly advancesPx: readonly number[];
217
217
  readonly direction: "ltr" | "rtl";
218
+ /**
219
+ * How a backend that resolves bidirectional text itself must treat the run.
220
+ *
221
+ * `direction` alone is the base direction, and a backend that hands the text
222
+ * to such a resolver gets the ordinary algorithm: a Latin word inside an
223
+ * `rtl` run reads forwards. That is an embedding, and it is wrong for the
224
+ * run the author wrapped in an override (`w:bdo`), where every character is
225
+ * laid out in `direction` whatever its own script. Absent is the ordinary
226
+ * run, whose base direction the paragraph or the run itself decided; a
227
+ * backend that positions every glyph from `advancesPx` reorders nothing and
228
+ * ignores this.
229
+ */
230
+ readonly unicodeBidi?: "embed" | "bidi-override";
218
231
  /**
219
232
  * Whether the glyphs kern.
220
233
  *
@@ -299,6 +312,10 @@ type DisplayImagePrimitive = {
299
312
  readonly b: number;
300
313
  };
301
314
  readonly opacity: number;
315
+ /** DrawingML picture brightness as a signed percentage. */
316
+ readonly brightness?: number;
317
+ /** DrawingML picture contrast as a signed percentage. */
318
+ readonly contrast?: number;
302
319
  };
303
320
  /** Clips its children to `rect`. Used for cropped images and cell overflow. */
304
321
  type DisplayClipGroup = {
@@ -1,4 +1,5 @@
1
1
  import { applyFolioAIEditOperations, previewFolioAIEditOperations } from "./ai-edits/apply.js";
2
+ import { isNumberingReference } from "./docx/numberingReference.js";
2
3
  import { LINE_SPACING_RULE_VALUES, PARAGRAPH_ALIGNMENT_VALUES } from "./types/documentEnumValues.js";
3
4
  import { TaggedError } from "better-result";
4
5
  import { sanitizeXmlCharacters } from "@stll/docx-core";
@@ -299,7 +300,7 @@ const readClearableNumbering = ({ value, key, path }) => {
299
300
  if (!isPlainObject(candidate)) return invalidBatch(numberingPath, "expected an object or null when provided");
300
301
  assertAllowedKeys(candidate, numberingPath, ["numId", "level"]);
301
302
  const numId = readNonNegativeInteger(candidate, "numId", numberingPath);
302
- if (numId === 0) return invalidBatch(`${numberingPath}.numId`, "expected a positive integer");
303
+ if (!isNumberingReference(numId)) return invalidBatch(`${numberingPath}.numId`, "expected a positive integer");
303
304
  return {
304
305
  numId,
305
306
  level: readNonNegativeInteger(candidate, "level", numberingPath)
@@ -0,0 +1,76 @@
1
+ import { ModelledAttributes } from "./propertyElementAttributes.js";
2
+ import { XmlElement } from "./xmlParser.js";
3
+ import { PreservedAttribute } from "@stll/docx-core/model";
4
+ //#region src/docx/attributeRemainder.d.ts
5
+ declare const InvalidPreservedAttributeError_base: import("better-result").TaggedErrorClass<"InvalidPreservedAttributeError">;
6
+ declare class InvalidPreservedAttributeError extends InvalidPreservedAttributeError_base<{
7
+ message: string;
8
+ name: string;
9
+ }> {}
10
+ /** Whether an attribute remainder can be emitted under a bound canonical name. */
11
+ declare const isSerializablePreservedAttribute: ({ namespace, name }: Pick<PreservedAttribute, "namespace" | "name">) => boolean;
12
+ /**
13
+ * The modelled set of an element whose serializer writes no attribute at all.
14
+ *
15
+ * `w:r`, `w:tr` and `w:sectPr` are rebuilt as bare start tags, so everything
16
+ * their source wrote is the remainder. Named rather than spelled `new Set()`
17
+ * at each call site, so the claim is visible and one place has to change when
18
+ * one of them gains a modelled attribute.
19
+ */
20
+ declare const NO_MODELLED_ATTRIBUTES: ReadonlySet<string>;
21
+ /**
22
+ * What a part's root element states rather than carries, so the remainder skips it.
23
+ *
24
+ * `mc:Ignorable` is a projection of the root's own `xmlns:*` bindings — it
25
+ * lists which of them a consumer may skip — and `serializePartElement` derives
26
+ * both from the prefixes the rebuilt body actually uses. Replaying the
27
+ * source's would name prefixes the rebuilt root does not bind, which no
28
+ * consumer accepts, and the writer appends its own, so the part would carry
29
+ * the attribute twice. This is the same rule namespace declarations already
30
+ * follow, one attribute further on.
31
+ */
32
+ declare const DERIVED_PART_ROOT_ATTRIBUTES: ReadonlySet<string>;
33
+ type AttributeRemainderOptions = {
34
+ /** The element, as the source wrote it. */
35
+ element: XmlElement;
36
+ /**
37
+ * Local names this element's own parser reads.
38
+ *
39
+ * Local names rather than qualified ones, because folio's attribute readers
40
+ * fall back to a local-name match across prefixes: an attribute the parser
41
+ * would read under any binding has to be out of the remainder, or the save
42
+ * writes the value twice under two spellings.
43
+ */
44
+ modelled: ReadonlySet<string>;
45
+ };
46
+ /**
47
+ * Every attribute on the element the model has no field for.
48
+ *
49
+ * @returns the remainder, or `undefined` when the parser read them all — an
50
+ * empty list is never written, so a fully modelled element stays identical
51
+ * in the model.
52
+ */
53
+ declare const attributeRemainder: ({ element, modelled }: AttributeRemainderOptions) => PreservedAttribute[] | undefined;
54
+ /**
55
+ * The remainder of an attribute bag, with the modelled set derived from the
56
+ * record's own fields.
57
+ *
58
+ * `w:ind`, `w:spacing`, `w:framePr`, `w:tab`, a border side and `w:shd` are
59
+ * bags rather than containers: the child dispatcher decides each of them
60
+ * whole, so an attribute the record has no field for is kept only while the
61
+ * reader takes nothing from the element at all. Passing the record's table
62
+ * from `propertyElementAttributes.ts` rather than a set spelled at the call
63
+ * site is what keeps the predicate derived from the model: a field added
64
+ * without an attribute to name does not compile.
65
+ */
66
+ declare const readAttributeBag: (element: XmlElement, modelled: ModelledAttributes<string>) => PreservedAttribute[] | undefined;
67
+ /**
68
+ * The element's attributes, modelled first and the remainder after them.
69
+ *
70
+ * @param modelled the fragments the serializer is about to emit, already
71
+ * spelled — they win a collision, because the model is the editable copy
72
+ * @returns the fragments to write, so an element with neither writes nothing
73
+ */
74
+ declare const serializePreservedAttributes: (modelled: readonly string[], preserved: readonly PreservedAttribute[] | undefined) => string[];
75
+ //#endregion
76
+ export { DERIVED_PART_ROOT_ATTRIBUTES, InvalidPreservedAttributeError, NO_MODELLED_ATTRIBUTES, attributeRemainder, isSerializablePreservedAttribute, readAttributeBag, serializePreservedAttributes };