@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,49 +1,80 @@
1
1
  //#region src/docx/previewBudget.ts
2
- const VML_PREVIEW_DATA_URL_PREFIX = "data:image/svg+xml;charset=utf-8,";
3
- const MEBIBYTE = 1024 * 1024;
2
+ /** Both SVG producers encode their drawing into the URL rather than base64. */
3
+ const SVG_PREVIEW_DATA_URL_PREFIX = "data:image/svg+xml;charset=utf-8,";
4
+ /**
5
+ * Eight times what a producer may spend on one drawing, which is a package
6
+ * holding a handful of the largest previews folio will build.
7
+ */
8
+ const SVG_PREVIEW_PACKAGE_CHARACTERS = 8 * (1024 * 1024);
4
9
  const PREVIEW_KINDS = {
5
10
  /** A VML shape folio renders rather than projects (`v:shape`, `v:rect`, ...). */
6
11
  vmlShape: {
12
+ backing: "source",
7
13
  mimeType: "image/svg+xml",
8
14
  filename: "vml-shape-preview.svg",
9
- srcPrefix: VML_PREVIEW_DATA_URL_PREFIX,
10
- maxPackageCharacters: 8 * MEBIBYTE
15
+ srcPrefix: SVG_PREVIEW_DATA_URL_PREFIX,
16
+ maxPackageCharacters: SVG_PREVIEW_PACKAGE_CHARACTERS
11
17
  },
12
18
  /**
13
- * A SmartArt diagram: its extent filled with one flat rectangle per shape.
19
+ * A WordprocessingGroup (`wpg:wgp`) folio renders rather than projects.
14
20
  *
15
- * A raster rather than a vector because the display list decodes only base64
16
- * PNG and JPEG, so a vector preview would be missing from every display-list
17
- * backend (PDF among them) while still showing in the DOM. That is what
18
- * makes this preview expensive: one of them is 7.3 MB of data URL whatever
19
- * the package weighs, because its cost follows the extent the author chose
20
- * rather than anything the drawing contains.
21
+ * The group's shapes, their text and any picture they carry are drawn into
22
+ * one SVG, so a package with many groups retains as much generated text as a
23
+ * package of VML shapes does, from a producer bounded per drawing the same
24
+ * way. It was missing from this table, which is not a preview with a generous
25
+ * cap but a preview with none: the matcher below never named it, so no
26
+ * package was ever charged for one.
27
+ */
28
+ wpGroup: {
29
+ backing: "source",
30
+ mimeType: "image/svg+xml",
31
+ filename: "wordprocessing-group.svg",
32
+ srcPrefix: SVG_PREVIEW_DATA_URL_PREFIX,
33
+ maxPackageCharacters: SVG_PREVIEW_PACKAGE_CHARACTERS
34
+ },
35
+ /**
36
+ * A SmartArt diagram: its extent filled with one flat rectangle per shape.
21
37
  *
22
- * Across the public corpus, the fifty packages that produce one retain a
23
- * median of 7.3 MB and a maximum of 51.3 MB (ten previews, from a package
24
- * under a megabyte). The cap is set above that maximum: it refuses no
25
- * legitimate file in the corpus while bounding what had no bound at all, and
26
- * it is a ceiling rather than a fix. The fix is for the preview to be a
27
- * descriptor the renderer rasterizes, which needs the display-list contract
28
- * to carry one.
38
+ * It used to be a raster in `src`, because the display list decoded only
39
+ * base64 PNG and JPEG and a vector preview would have been missing from
40
+ * every backend but the DOM. That cost 7.3 MB of data URL per diagram
41
+ * whatever the package weighed, up to 51.3 MB in one corpus package, because
42
+ * it followed the extent the author chose rather than anything the drawing
43
+ * contained. It is a `PreviewDescriptor` now, which both backends draw, and
44
+ * the bound on it is the shape cap the parse applies to the description.
29
45
  */
30
- smartArt: {
31
- mimeType: "image/png",
32
- filename: "smartart-preview.png",
33
- srcPrefix: "data:image/png;base64,",
34
- maxPackageCharacters: 64 * MEBIBYTE
35
- }
46
+ smartArt: { backing: "descriptor" }
36
47
  };
37
48
  const KIND_NAMES = Object.keys(PREVIEW_KINDS);
38
49
  /**
50
+ * Whether a package charges this kind, narrowing the name to a source-backed
51
+ * one: the predicate reads the same field `SourceBackedKindName` selects on.
52
+ */
53
+ const isSourceBacked = (name) => {
54
+ const kind = PREVIEW_KINDS[name];
55
+ switch (kind.backing) {
56
+ case "source": return true;
57
+ case "descriptor": return false;
58
+ default: return kind;
59
+ }
60
+ };
61
+ const SOURCE_BACKED_KIND_NAMES = KIND_NAMES.filter(isSourceBacked);
62
+ /**
39
63
  * The kind a model image was generated as, or `undefined` for one the package
40
- * actually carries. A generated preview has no relationship behind it, so
41
- * `rId` is empty; the filename and data-URL prefix name which producer made it.
64
+ * actually carries. A generated preview has no relationship behind it; the
65
+ * filename and data-URL prefix name which producer made it.
66
+ *
67
+ * "No relationship" is read as the one spelling `RelationshipId` leaves: a
68
+ * field that is absent or `undefined`. The walk takes an unvalidated object,
69
+ * so the check stays, but it no longer has a second spelling to accept.
70
+ *
71
+ * Only a source-backed kind can be named this way. A descriptor-backed preview
72
+ * has no `src` to match, so no image the model carries can be charged to it.
42
73
  */
43
74
  const previewKindOf = (value) => {
44
- if (!("type" in value) || value.type !== "image" || !("rId" in value) || value.rId !== "" || !("src" in value) || typeof value.src !== "string" || !("mimeType" in value) || !("filename" in value)) return;
75
+ if (!("type" in value) || value.type !== "image" || "rId" in value && value.rId !== void 0 || !("src" in value) || typeof value.src !== "string" || !("mimeType" in value) || !("filename" in value)) return;
45
76
  const { src, mimeType, filename } = value;
46
- return KIND_NAMES.find((name) => {
77
+ return SOURCE_BACKED_KIND_NAMES.find((name) => {
47
78
  const kind = PREVIEW_KINDS[name];
48
79
  return mimeType === kind.mimeType && filename === kind.filename && src.startsWith(kind.srcPrefix);
49
80
  });
@@ -55,7 +86,7 @@ const previewKindOf = (value) => {
55
86
  * and never touches the preserved XML the package saves from.
56
87
  */
57
88
  const enforcePackagePreviewBudget = (root, overrides = {}) => {
58
- const remaining = new Map(KIND_NAMES.map((name) => [name, Math.max(0, overrides[name] ?? PREVIEW_KINDS[name].maxPackageCharacters)]));
89
+ const remaining = new Map(SOURCE_BACKED_KIND_NAMES.map((name) => [name, Math.max(0, overrides[name] ?? PREVIEW_KINDS[name].maxPackageCharacters)]));
59
90
  const visited = /* @__PURE__ */ new WeakSet();
60
91
  const visit = (value) => {
61
92
  if (value === null || typeof value !== "object" || visited.has(value)) return;
@@ -85,4 +116,4 @@ const enforcePackagePreviewBudget = (root, overrides = {}) => {
85
116
  visit(root);
86
117
  };
87
118
  //#endregion
88
- export { PREVIEW_KINDS, VML_PREVIEW_DATA_URL_PREFIX, enforcePackagePreviewBudget };
119
+ export { PREVIEW_KINDS, enforcePackagePreviewBudget };
@@ -0,0 +1,178 @@
1
+ //#region src/docx/propertyElementAttributes.d.ts
2
+ /**
3
+ * Which attributes of a property element the model has a field for.
4
+ *
5
+ * A property element is an attribute bag: `w:ind`, `w:spacing`, `w:framePr`,
6
+ * `w:tab`, a `w:pBdr` side, `w:shd`. The child dispatcher decides them whole —
7
+ * a handler either reads the element or hands back its bytes — and that is
8
+ * exactly as far as it goes. `<w:ind w:leftChars="100"/>` is kept entire
9
+ * because the reader took nothing from it, and `<w:ind w:left="720"
10
+ * w:leftChars="100"/>` is modelled and loses the character unit, because the
11
+ * reader took something. The census measures one attribute at a time, so the
12
+ * second case reported as surviving.
13
+ *
14
+ * The fix is the attribute remainder that `w:p`'s `w:rsid*` attributes already
15
+ * ride, applied one level down: every attribute with no model field is kept on
16
+ * the record, decided on the resolved local name, written back by
17
+ * `serializePreservedAttributes`. The remainder predicate has to be derived
18
+ * from the model rather than hand-listed, or it is a mirror of the reader and
19
+ * drifts the first time a field is added — so each table below is
20
+ * `as const satisfies ModelledAttributes<…>` over the record's own fields, and
21
+ * a field that gains no entry does not compile.
22
+ *
23
+ * The tables live together, in a module with no runtime dependencies, because
24
+ * three callers consult them: the reader (to compute the remainder), and the
25
+ * container-survival census (to state a subject attribute beside a modelled
26
+ * sibling, which is what catches a whole-or-nothing reader at all). The writer
27
+ * needs no copy: it hands the fragments it is about to emit to
28
+ * `serializePreservedAttributes`, which drops a remainder entry that would
29
+ * spell one of them again.
30
+ *
31
+ * A field may name more than one attribute. `ParagraphFormatting.indentLeft`
32
+ * is filled from `w:left` or from the Strict `w:start`, and both have to be
33
+ * out of the remainder or a save writes the same indent twice under two
34
+ * spellings.
35
+ */
36
+ /**
37
+ * The attributes one record's fields are read from, keyed by field.
38
+ *
39
+ * `Record`, never `Partial<Record>`: the key set is the record's own fields,
40
+ * so a field that has no attribute to name has to say so with an empty list
41
+ * rather than by being absent.
42
+ */
43
+ type ModelledAttributes<Field extends string> = Readonly<Record<Field, string | readonly string[]>>;
44
+ /**
45
+ * `w:ind`. `hangingIndent` is the sign of `indentFirstLine` rather than a
46
+ * value of its own, so both name the attribute pair that carries it.
47
+ */
48
+ declare const INDENTATION_ATTRIBUTES: {
49
+ readonly indentLeft: readonly ["left", "start"];
50
+ readonly indentRight: readonly ["right", "end"];
51
+ readonly indentFirstLine: readonly ["firstLine", "hanging"];
52
+ readonly hangingIndent: "hanging";
53
+ };
54
+ /**
55
+ * `w:spacing`. `spacingExplicit` records which of the two sides the paragraph
56
+ * stated itself; it is derived from them and reads no attribute of its own.
57
+ */
58
+ declare const SPACING_ATTRIBUTES: {
59
+ readonly spaceBefore: "before";
60
+ readonly spaceAfter: "after";
61
+ readonly lineSpacing: "line";
62
+ readonly lineSpacingRule: "lineRule";
63
+ readonly beforeAutospacing: "beforeAutospacing";
64
+ readonly afterAutospacing: "afterAutospacing";
65
+ readonly spacingExplicit: readonly [];
66
+ };
67
+ declare const FRAME_ATTRIBUTES: {
68
+ readonly dropCap: "dropCap";
69
+ readonly lines: "lines";
70
+ readonly width: "w";
71
+ readonly height: "h";
72
+ readonly hSpace: "hSpace";
73
+ readonly vSpace: "vSpace";
74
+ readonly hAnchor: "hAnchor";
75
+ readonly vAnchor: "vAnchor";
76
+ readonly x: "x";
77
+ readonly y: "y";
78
+ readonly xAlign: "xAlign";
79
+ readonly yAlign: "yAlign";
80
+ readonly wrap: "wrap";
81
+ };
82
+ declare const TAB_STOP_ATTRIBUTES: {
83
+ readonly position: "pos";
84
+ readonly alignment: "val";
85
+ readonly leader: "leader";
86
+ };
87
+ /**
88
+ * `CT_Border`. The five art relationship ids are in the relationships
89
+ * namespace; the remainder decides on the local name, so naming them here
90
+ * keeps a `r:topLeft` out of it.
91
+ */
92
+ declare const BORDER_ATTRIBUTES: {
93
+ readonly style: "val";
94
+ readonly color: readonly ["color", "themeColor", "themeTint", "themeShade"];
95
+ readonly size: "sz";
96
+ readonly space: "space";
97
+ readonly shadow: "shadow";
98
+ readonly frame: "frame";
99
+ readonly artRelationshipId: "id";
100
+ readonly topLeftArtRelationshipId: "topLeft";
101
+ readonly topRightArtRelationshipId: "topRight";
102
+ readonly bottomLeftArtRelationshipId: "bottomLeft";
103
+ readonly bottomRightArtRelationshipId: "bottomRight";
104
+ };
105
+ /** `CT_Shd`: direct, theme, modifier, and pattern attributes all have model fields. */
106
+ declare const SHADING_ATTRIBUTES: {
107
+ readonly color: readonly ["color", "themeColor", "themeTint", "themeShade"];
108
+ readonly fill: readonly ["fill", "themeFill", "themeFillTint", "themeFillShade"];
109
+ readonly pattern: "val";
110
+ };
111
+ /**
112
+ * The same tables by the complex type whose attributes they answer for, in
113
+ * the order the model declares the fields.
114
+ *
115
+ * The census reads this: to catch a whole-or-nothing reader it has to state
116
+ * the subject attribute *beside* one the element models, and which one that
117
+ * is has to come from the model rather than from a list in the census. The
118
+ * first entry is the one it picks.
119
+ */
120
+ declare const PROPERTY_ELEMENT_ATTRIBUTES: {
121
+ readonly CT_Ind: {
122
+ readonly indentLeft: readonly ["left", "start"];
123
+ readonly indentRight: readonly ["right", "end"];
124
+ readonly indentFirstLine: readonly ["firstLine", "hanging"];
125
+ readonly hangingIndent: "hanging";
126
+ };
127
+ readonly CT_Spacing: {
128
+ readonly spaceBefore: "before";
129
+ readonly spaceAfter: "after";
130
+ readonly lineSpacing: "line";
131
+ readonly lineSpacingRule: "lineRule";
132
+ readonly beforeAutospacing: "beforeAutospacing";
133
+ readonly afterAutospacing: "afterAutospacing";
134
+ readonly spacingExplicit: readonly [];
135
+ };
136
+ readonly CT_FramePr: {
137
+ readonly dropCap: "dropCap";
138
+ readonly lines: "lines";
139
+ readonly width: "w";
140
+ readonly height: "h";
141
+ readonly hSpace: "hSpace";
142
+ readonly vSpace: "vSpace";
143
+ readonly hAnchor: "hAnchor";
144
+ readonly vAnchor: "vAnchor";
145
+ readonly x: "x";
146
+ readonly y: "y";
147
+ readonly xAlign: "xAlign";
148
+ readonly yAlign: "yAlign";
149
+ readonly wrap: "wrap";
150
+ };
151
+ readonly CT_TabStop: {
152
+ readonly position: "pos";
153
+ readonly alignment: "val";
154
+ readonly leader: "leader";
155
+ };
156
+ readonly CT_Border: {
157
+ readonly style: "val";
158
+ readonly color: readonly ["color", "themeColor", "themeTint", "themeShade"];
159
+ readonly size: "sz";
160
+ readonly space: "space";
161
+ readonly shadow: "shadow";
162
+ readonly frame: "frame";
163
+ readonly artRelationshipId: "id";
164
+ readonly topLeftArtRelationshipId: "topLeft";
165
+ readonly topRightArtRelationshipId: "topRight";
166
+ readonly bottomLeftArtRelationshipId: "bottomLeft";
167
+ readonly bottomRightArtRelationshipId: "bottomRight";
168
+ };
169
+ readonly CT_Shd: {
170
+ readonly color: readonly ["color", "themeColor", "themeTint", "themeShade"];
171
+ readonly fill: readonly ["fill", "themeFill", "themeFillTint", "themeFillShade"];
172
+ readonly pattern: "val";
173
+ };
174
+ };
175
+ /** Every attribute local name a table names, flattened, in field order. */
176
+ declare const modelledAttributeNames: (modelled: ModelledAttributes<string>) => readonly string[];
177
+ //#endregion
178
+ export { BORDER_ATTRIBUTES, FRAME_ATTRIBUTES, INDENTATION_ATTRIBUTES, ModelledAttributes, PROPERTY_ELEMENT_ATTRIBUTES, SHADING_ATTRIBUTES, SPACING_ATTRIBUTES, TAB_STOP_ATTRIBUTES, modelledAttributeNames };
@@ -0,0 +1,114 @@
1
+ //#region src/docx/propertyElementAttributes.ts
2
+ /**
3
+ * `w:ind`. `hangingIndent` is the sign of `indentFirstLine` rather than a
4
+ * value of its own, so both name the attribute pair that carries it.
5
+ */
6
+ const INDENTATION_ATTRIBUTES = {
7
+ indentLeft: ["left", "start"],
8
+ indentRight: ["right", "end"],
9
+ indentFirstLine: ["firstLine", "hanging"],
10
+ hangingIndent: "hanging"
11
+ };
12
+ /**
13
+ * `w:spacing`. `spacingExplicit` records which of the two sides the paragraph
14
+ * stated itself; it is derived from them and reads no attribute of its own.
15
+ */
16
+ const SPACING_ATTRIBUTES = {
17
+ spaceBefore: "before",
18
+ spaceAfter: "after",
19
+ lineSpacing: "line",
20
+ lineSpacingRule: "lineRule",
21
+ beforeAutospacing: "beforeAutospacing",
22
+ afterAutospacing: "afterAutospacing",
23
+ spacingExplicit: []
24
+ };
25
+ const FRAME_ATTRIBUTES = {
26
+ dropCap: "dropCap",
27
+ lines: "lines",
28
+ width: "w",
29
+ height: "h",
30
+ hSpace: "hSpace",
31
+ vSpace: "vSpace",
32
+ hAnchor: "hAnchor",
33
+ vAnchor: "vAnchor",
34
+ x: "x",
35
+ y: "y",
36
+ xAlign: "xAlign",
37
+ yAlign: "yAlign",
38
+ wrap: "wrap"
39
+ };
40
+ const TAB_STOP_ATTRIBUTES = {
41
+ position: "pos",
42
+ alignment: "val",
43
+ leader: "leader"
44
+ };
45
+ /**
46
+ * `CT_Border`. The five art relationship ids are in the relationships
47
+ * namespace; the remainder decides on the local name, so naming them here
48
+ * keeps a `r:topLeft` out of it.
49
+ */
50
+ const BORDER_ATTRIBUTES = {
51
+ style: "val",
52
+ color: [
53
+ "color",
54
+ "themeColor",
55
+ "themeTint",
56
+ "themeShade"
57
+ ],
58
+ size: "sz",
59
+ space: "space",
60
+ shadow: "shadow",
61
+ frame: "frame",
62
+ artRelationshipId: "id",
63
+ topLeftArtRelationshipId: "topLeft",
64
+ topRightArtRelationshipId: "topRight",
65
+ bottomLeftArtRelationshipId: "bottomLeft",
66
+ bottomRightArtRelationshipId: "bottomRight"
67
+ };
68
+ /** `CT_Shd`: direct, theme, modifier, and pattern attributes all have model fields. */
69
+ const SHADING_ATTRIBUTES = {
70
+ color: [
71
+ "color",
72
+ "themeColor",
73
+ "themeTint",
74
+ "themeShade"
75
+ ],
76
+ fill: [
77
+ "fill",
78
+ "themeFill",
79
+ "themeFillTint",
80
+ "themeFillShade"
81
+ ],
82
+ pattern: "val"
83
+ };
84
+ /**
85
+ * The same tables by the complex type whose attributes they answer for, in
86
+ * the order the model declares the fields.
87
+ *
88
+ * The census reads this: to catch a whole-or-nothing reader it has to state
89
+ * the subject attribute *beside* one the element models, and which one that
90
+ * is has to come from the model rather than from a list in the census. The
91
+ * first entry is the one it picks.
92
+ */
93
+ const PROPERTY_ELEMENT_ATTRIBUTES = {
94
+ CT_Ind: INDENTATION_ATTRIBUTES,
95
+ CT_Spacing: SPACING_ATTRIBUTES,
96
+ CT_FramePr: FRAME_ATTRIBUTES,
97
+ CT_TabStop: TAB_STOP_ATTRIBUTES,
98
+ CT_Border: BORDER_ATTRIBUTES,
99
+ CT_Shd: SHADING_ATTRIBUTES
100
+ };
101
+ /** Every attribute local name a table names, flattened, in field order. */
102
+ const modelledAttributeNames = (modelled) => {
103
+ const names = [];
104
+ for (const declared of Object.values(modelled)) {
105
+ if (typeof declared === "string") {
106
+ names.push(declared);
107
+ continue;
108
+ }
109
+ names.push(...declared);
110
+ }
111
+ return names;
112
+ };
113
+ //#endregion
114
+ export { BORDER_ATTRIBUTES, FRAME_ATTRIBUTES, INDENTATION_ATTRIBUTES, PROPERTY_ELEMENT_ATTRIBUTES, SHADING_ATTRIBUTES, SPACING_ATTRIBUTES, TAB_STOP_ATTRIBUTES, modelledAttributeNames };
@@ -30,16 +30,14 @@ const scanRun = (run, scan) => {
30
30
  };
31
31
  const scanHyperlink = (hyperlink, scan) => {
32
32
  for (const child of hyperlink.children) {
33
- if (child.type !== "run") continue;
34
- const result = scanRun(child, scan);
33
+ if (child.type !== "run" && child.type !== "inlineWrapper") continue;
34
+ const result = child.type === "run" ? scanRun(child, scan) : scanParagraphContent(child, scan);
35
35
  if (result !== void 0) return result;
36
36
  }
37
37
  };
38
38
  const scanInlineContent = (content, scan) => {
39
39
  for (const child of content) {
40
- let result;
41
- if (child.type === "run") result = scanRun(child, scan);
42
- else if (child.type === "hyperlink") result = scanHyperlink(child, scan);
40
+ const result = scanParagraphContent(child, scan);
43
41
  if (result !== void 0) return result;
44
42
  }
45
43
  };
@@ -48,7 +46,7 @@ const scanParagraphContent = (content, scan) => {
48
46
  if (content.type === "hyperlink") return scanHyperlink(content, scan);
49
47
  if (content.type === "simpleField") return scanInlineContent(content.content, scan);
50
48
  if (content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo") return scanInlineContent(content.content, scan);
51
- if (content.type === "inlineSdt") {
49
+ if (content.type === "inlineSdt" || content.type === "inlineWrapper") {
52
50
  for (const child of content.content) {
53
51
  const result = scanParagraphContent(child, scan);
54
52
  if (result !== void 0) return result;
@@ -3,9 +3,35 @@ import { BlockContent, Hyperlink } from "../types/content.js";
3
3
  import { RawDocxContent } from "./unzip.js";
4
4
  import JSZip from "jszip";
5
5
  //#region src/docx/rezip.d.ts
6
- declare class DocxPackageFidelityError extends Error {
6
+ declare const DocxPackageFidelityError_base: import("better-result").TaggedErrorClass<"DocxPackageFidelityError">;
7
+ declare class DocxPackageFidelityError extends DocxPackageFidelityError_base<{
8
+ message: string;
9
+ }> {
7
10
  constructor(message: string);
8
11
  }
12
+ /**
13
+ * Raised when a save would write a section the editor never authored.
14
+ *
15
+ * Two paragraphs holding the *same* `SectionProperties` object are one
16
+ * section's two halves, not two sections: ProseMirror copies a node's attrs
17
+ * when a command splits it, and the object is passed through by reference and
18
+ * never cloned, so identity is what tells a copy from a second authored break.
19
+ * The paragraph is named because the count alone does not say which of them the
20
+ * save invented.
21
+ */
22
+ declare class DocxDuplicateSectionCarrierError extends DocxPackageFidelityError {
23
+ /** The `w:paraId` of the duplicate carrier, when the package gave it one. */
24
+ readonly paraId: string | null;
25
+ /** Its position among the paragraph-level carriers, in document order. */
26
+ readonly carrierIndex: number;
27
+ /** The position of the carrier it duplicates. */
28
+ readonly duplicatesCarrierIndex: number;
29
+ constructor(options: {
30
+ paraId: string | null;
31
+ carrierIndex: number;
32
+ duplicatesCarrierIndex: number;
33
+ });
34
+ }
9
35
  /**
10
36
  * Find the highest rId number in a relationships XML string.
11
37
  */
@@ -216,4 +242,4 @@ declare function createEmptyDocx(properties?: DocumentPropertiesOptions): Promis
216
242
  */
217
243
  declare function createDocx(doc: document_d_exports.Document, properties?: DocumentPropertiesOptions): Promise<ArrayBuffer>;
218
244
  //#endregion
219
- export { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_CONTENT_TYPE, COMMENTS_EXTENDED_PART, COMMENTS_EXTENDED_PART_LOWER, DocumentPropertiesOptions, DocxPackageFidelityError, RepackOptions, addCommentsExtendedOverride, addCommentsExtendedRelationship, addMedia, addRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, collectHyperlinksWithoutRId, createDocx, createEmptyDocx, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, hasUnmaterializedInlineResources, isDocxBuffer, notePartRelsPath, removeCommentsExtendedOverride, removeCommentsExtendedRelationship, repackDocx, repackDocxFromRaw, updateCoreProperties, updateDocumentXml, updateMultipleFiles, updateXmlFile, validateDocx, withoutAttachedTemplate };
245
+ export { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_CONTENT_TYPE, COMMENTS_EXTENDED_PART, COMMENTS_EXTENDED_PART_LOWER, DocumentPropertiesOptions, DocxDuplicateSectionCarrierError, DocxPackageFidelityError, RepackOptions, addCommentsExtendedOverride, addCommentsExtendedRelationship, addMedia, addRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, collectHyperlinksWithoutRId, createDocx, createEmptyDocx, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, hasUnmaterializedInlineResources, isDocxBuffer, notePartRelsPath, removeCommentsExtendedOverride, removeCommentsExtendedRelationship, repackDocx, repackDocxFromRaw, updateCoreProperties, updateDocumentXml, updateMultipleFiles, updateXmlFile, validateDocx, withoutAttachedTemplate };