@stll/folio-core 0.15.0 → 0.15.2

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 (449) hide show
  1. package/dist/ai-edits/apply.d.ts +2 -2
  2. package/dist/ai-edits/blockRange.d.ts +3 -17
  3. package/dist/ai-edits/clean-text.d.ts +0 -1
  4. package/dist/ai-edits/headless.d.ts +23 -19
  5. package/dist/ai-edits/read.d.ts +8 -5
  6. package/dist/ai-edits/scoped-reading.d.ts +0 -1
  7. package/dist/ai-edits/snapshot.d.ts +1 -7
  8. package/dist/ai-edits/table-cell-mutations.d.ts +4 -31
  9. package/dist/ai-edits/table-row-column-mutations.d.ts +9 -39
  10. package/dist/ai-edits/table-targets.d.ts +0 -1
  11. package/dist/ai-edits/types.d.ts +32 -17
  12. package/dist/ai-suggestions/apply.d.ts +0 -1
  13. package/dist/ai-suggestions/conflict.d.ts +0 -1
  14. package/dist/ai-suggestions/text-positions.d.ts +2 -2
  15. package/dist/ai-suggestions/types.d.ts +27 -13
  16. package/dist/content-controls/errors.d.ts +0 -1
  17. package/dist/content-controls/findContentControls.d.ts +6 -4
  18. package/dist/content-controls/mutateContentControls.d.ts +0 -1
  19. package/dist/controller/activeEditorStory.d.ts +1 -6
  20. package/dist/controller/collaborationModules.d.ts +0 -1
  21. package/dist/controller/contentControlWidgetController.d.ts +0 -1
  22. package/dist/controller/folioEditor.d.ts +2 -2
  23. package/dist/controller/folioEditorEvents.d.ts +5 -3
  24. package/dist/controller/fontReadiness.d.ts +0 -1
  25. package/dist/controller/headerFooterEditorManager.d.ts +1 -5
  26. package/dist/controller/hiddenEditorApi.d.ts +35 -18
  27. package/dist/controller/hiddenEditorManager.d.ts +5 -3
  28. package/dist/controller/latestRequestGate.d.ts +3 -1
  29. package/dist/controller/layoutPipeline.d.ts +1 -1
  30. package/dist/controller/layoutScheduler.d.ts +8 -5
  31. package/dist/controller/layoutSession.d.ts +0 -1
  32. package/dist/controller/noteEditorManager.d.ts +0 -1
  33. package/dist/document-operations.d.ts +5 -12
  34. package/dist/document-stories.d.ts +0 -1
  35. package/dist/docx/blockContentParser.d.ts +0 -1
  36. package/dist/docx/blockContentParser.js +1 -0
  37. package/dist/docx/bookmarkParser.d.ts +5 -3
  38. package/dist/docx/bookmarkPlacement.d.ts +0 -1
  39. package/dist/docx/commentParser.d.ts +0 -1
  40. package/dist/docx/commentParser.js +30 -2
  41. package/dist/docx/commentRangeIntegrity.d.ts +0 -1
  42. package/dist/docx/commentReferenceNormalization.d.ts +1 -9
  43. package/dist/docx/commentReplyMarkers.d.ts +0 -1
  44. package/dist/docx/compatibility.d.ts +0 -1
  45. package/dist/docx/conformance.d.ts +0 -1
  46. package/dist/docx/corePropertiesParser.d.ts +0 -1
  47. package/dist/docx/documentParser.d.ts +0 -1
  48. package/dist/docx/documentParser.js +3 -1
  49. package/dist/docx/drawingIdNormalization.d.ts +5 -0
  50. package/dist/docx/drawingIdNormalization.js +35 -0
  51. package/dist/docx/drawingUtils.d.ts +24 -3
  52. package/dist/docx/drawingUtils.js +134 -28
  53. package/dist/docx/encryption/agileDecryption.d.ts +0 -1
  54. package/dist/docx/encryption/cryptoBytes.js +4 -1
  55. package/dist/docx/encryption/openEncryptedDocx.d.ts +5 -2
  56. package/dist/docx/ensureParaIds.d.ts +7 -3
  57. package/dist/docx/fieldParser.d.ts +23 -11
  58. package/dist/docx/fontTableParser.d.ts +0 -1
  59. package/dist/docx/footnoteParser.d.ts +26 -13
  60. package/dist/docx/footnoteParser.js +4 -2
  61. package/dist/docx/groupDrawingParser.d.ts +0 -1
  62. package/dist/docx/headerFooterParser.d.ts +9 -5
  63. package/dist/docx/headerFooterRefParser.d.ts +0 -1
  64. package/dist/docx/headerFooterReferenceNormalization.d.ts +1 -6
  65. package/dist/docx/headerFooterVerbatim.d.ts +4 -3
  66. package/dist/docx/headerFooterVerbatim.js +6 -1
  67. package/dist/docx/hyperlinkParser.d.ts +0 -1
  68. package/dist/docx/hyperlinkParser.js +1 -9
  69. package/dist/docx/imageParser.d.ts +0 -1
  70. package/dist/docx/imageParser.js +15 -7
  71. package/dist/docx/mathToMathml.d.ts +0 -1
  72. package/dist/docx/metadataPrivacy.d.ts +1 -3
  73. package/dist/docx/modelValidation.d.ts +0 -1
  74. package/dist/docx/newImage.d.ts +11 -0
  75. package/dist/docx/newImage.js +11 -0
  76. package/dist/docx/normalizeBaseDirection.d.ts +0 -1
  77. package/dist/docx/notePropertiesParser.d.ts +0 -1
  78. package/dist/docx/numberingParser.d.ts +10 -6
  79. package/dist/docx/numberingParser.js +4 -2
  80. package/dist/docx/numberingReferenceNormalization.d.ts +1 -9
  81. package/dist/docx/paragraphParser.d.ts +0 -1
  82. package/dist/docx/paragraphParser.js +31 -15
  83. package/dist/docx/paragraphTextBoxEnrichment.d.ts +0 -1
  84. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  85. package/dist/docx/paragraphTraversal.d.ts +5 -10
  86. package/dist/docx/paragraphTraversal.js +20 -13
  87. package/dist/docx/parser.d.ts +15 -8
  88. package/dist/docx/parser.js +22 -1
  89. package/dist/docx/parserEnums.d.ts +5 -2
  90. package/dist/docx/parserEnums.js +6 -2
  91. package/dist/docx/relsParser.d.ts +1 -0
  92. package/dist/docx/renderedPageBreakNormalization.d.ts +12 -0
  93. package/dist/docx/renderedPageBreakNormalization.js +59 -0
  94. package/dist/docx/replyToComment.d.ts +2 -2
  95. package/dist/docx/rezip.d.ts +6 -7
  96. package/dist/docx/rezip.js +136 -102
  97. package/dist/docx/runConsolidator.d.ts +0 -1
  98. package/dist/docx/runConsolidator.js +0 -1
  99. package/dist/docx/runParser.d.ts +0 -1
  100. package/dist/docx/runParser.js +25 -12
  101. package/dist/docx/sdtProperties.d.ts +0 -1
  102. package/dist/docx/sdtPropertiesPatch.d.ts +0 -1
  103. package/dist/docx/sectionParser.d.ts +0 -1
  104. package/dist/docx/selectiveSave.d.ts +5 -3
  105. package/dist/docx/selectiveSave.js +2 -2
  106. package/dist/docx/selectiveSaveFlags.d.ts +4 -2
  107. package/dist/docx/selectiveXmlPatch.js +20 -8
  108. package/dist/docx/serializer/blockSdtSerializer.d.ts +0 -1
  109. package/dist/docx/serializer/blockSdtSerializer.js +2 -1
  110. package/dist/docx/serializer/borderSerializer.d.ts +0 -1
  111. package/dist/docx/serializer/commentSerializer.d.ts +0 -1
  112. package/dist/docx/serializer/commentSerializer.js +19 -40
  113. package/dist/docx/serializer/documentSerializer.d.ts +0 -1
  114. package/dist/docx/serializer/documentSerializer.js +1 -1
  115. package/dist/docx/serializer/fontTableSerializer.d.ts +0 -1
  116. package/dist/docx/serializer/headerFooterSerializer.d.ts +0 -1
  117. package/dist/docx/serializer/headerFooterSerializer.js +1 -1
  118. package/dist/docx/serializer/noteSerializer.d.ts +0 -1
  119. package/dist/docx/serializer/noteSerializer.js +1 -1
  120. package/dist/docx/serializer/numberingSerializer.d.ts +0 -1
  121. package/dist/docx/serializer/paragraphSerializer.d.ts +0 -1
  122. package/dist/docx/serializer/paragraphSerializer.js +10 -23
  123. package/dist/docx/serializer/runSerializer.d.ts +0 -1
  124. package/dist/docx/serializer/runSerializer.js +53 -32
  125. package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +0 -1
  126. package/dist/docx/serializer/sectionPropertiesSerializer.js +7 -5
  127. package/dist/docx/serializer/settingsSerializer.d.ts +0 -1
  128. package/dist/docx/serializer/stylesSerializer.d.ts +0 -1
  129. package/dist/docx/serializer/tableSerializer.d.ts +0 -1
  130. package/dist/docx/serializer/tableSerializer.js +2 -0
  131. package/dist/docx/serializer/themeSerializer.d.ts +0 -1
  132. package/dist/docx/serializer/xmlUtils.js +10 -1
  133. package/dist/docx/server/applyDocxXmlPatchProposal.d.ts +3 -10
  134. package/dist/docx/server/docxToMarkdown.d.ts +0 -1
  135. package/dist/docx/server/evaluateDocxXmlPatchProposal.d.ts +3 -9
  136. package/dist/docx/server/inspectDocxPackage.d.ts +3 -8
  137. package/dist/docx/server/validateDocxConformance.d.ts +0 -1
  138. package/dist/docx/settingsParser.d.ts +2 -2
  139. package/dist/docx/shapeParser.d.ts +0 -1
  140. package/dist/docx/shapeParser.js +16 -123
  141. package/dist/docx/streamingXmlParser.d.ts +16 -0
  142. package/dist/docx/streamingXmlParser.js +248 -0
  143. package/dist/docx/styleParser.d.ts +0 -1
  144. package/dist/docx/styleParser.js +6 -4
  145. package/dist/docx/tableParser.d.ts +1 -2
  146. package/dist/docx/tableParser.js +11 -12
  147. package/dist/docx/textBoxParser.d.ts +1 -2
  148. package/dist/docx/textBoxParser.js +5 -2
  149. package/dist/docx/textWhitespace.d.ts +4 -0
  150. package/dist/docx/textWhitespace.js +4 -0
  151. package/dist/docx/themeParser.d.ts +0 -1
  152. package/dist/docx/trackedMoveRangeNormalization.d.ts +1 -8
  153. package/dist/docx/unzip.d.ts +6 -3
  154. package/dist/docx/unzip.js +96 -40
  155. package/dist/docx/vmlImageParser.d.ts +0 -1
  156. package/dist/docx/vmlImageParser.js +3 -1
  157. package/dist/docx/watermarkParser.d.ts +0 -1
  158. package/dist/docx/xmlParser.d.ts +21 -8
  159. package/dist/docx/xmlParser.js +126 -43
  160. package/dist/fields/bookmarkPages.d.ts +0 -1
  161. package/dist/fields/bookmarkText.d.ts +0 -1
  162. package/dist/fields/evaluateField.d.ts +5 -3
  163. package/dist/fields/fieldContext.d.ts +11 -5
  164. package/dist/fields/resolveFieldValues.d.ts +4 -3
  165. package/dist/fields/sectionPageCounts.d.ts +0 -1
  166. package/dist/fields/seqValues.d.ts +0 -1
  167. package/dist/fonts/embeddedFontTable.d.ts +5 -2
  168. package/dist/fonts/embeddedFonts.d.ts +15 -7
  169. package/dist/index.d.ts +1 -0
  170. package/dist/layout-bridge/cellSelectionHighlight.d.ts +0 -1
  171. package/dist/layout-bridge/convert/footnoteLayout.d.ts +5 -3
  172. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +2 -2
  173. package/dist/layout-bridge/convert/paragraphFrames.d.ts +0 -1
  174. package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +8 -8
  175. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +25 -13
  176. package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +3 -2
  177. package/dist/layout-bridge/dom/findHfPmSpans.d.ts +2 -1
  178. package/dist/layout-bridge/dom/noteStoryDom.d.ts +0 -1
  179. package/dist/layout-bridge/engine/clickToPosition.d.ts +5 -3
  180. package/dist/layout-bridge/engine/hitTest.d.ts +40 -19
  181. package/dist/layout-bridge/engine/selectionRects.d.ts +16 -8
  182. package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -1
  183. package/dist/layout-bridge/headerFooterLayout.d.ts +0 -1
  184. package/dist/layout-bridge/sectionColumns.d.ts +0 -1
  185. package/dist/layout-bridge/tableInsertHover.d.ts +8 -4
  186. package/dist/layout-engine/headerFooterRefs.d.ts +0 -1
  187. package/dist/layout-engine/index.d.ts +0 -1
  188. package/dist/layout-engine/justificationCompatibility.d.ts +0 -1
  189. package/dist/layout-engine/keep-together.d.ts +7 -4
  190. package/dist/layout-engine/layoutInstrumentation.d.ts +0 -1
  191. package/dist/layout-engine/lineFlow.d.ts +0 -1
  192. package/dist/layout-engine/measure/cache.d.ts +0 -1
  193. package/dist/layout-engine/measure/effectiveLineBreakPolicy.d.ts +6 -7
  194. package/dist/layout-engine/measure/floatingTablePosition.d.ts +0 -1
  195. package/dist/layout-engine/measure/floatingZones.d.ts +14 -6
  196. package/dist/layout-engine/measure/font-metrics.worker.d.ts +0 -1
  197. package/dist/layout-engine/measure/lineBreakProvider.d.ts +20 -9
  198. package/dist/layout-engine/measure/lineBreaks.d.ts +0 -1
  199. package/dist/layout-engine/measure/listMarkerWidth.d.ts +0 -1
  200. package/dist/layout-engine/measure/measureBlocks.d.ts +1 -0
  201. package/dist/layout-engine/measure/measureContainer.d.ts +0 -1
  202. package/dist/layout-engine/measure/measureHelpers.d.ts +0 -1
  203. package/dist/layout-engine/measure/measureParagraph.d.ts +3 -2
  204. package/dist/layout-engine/measure/measureParagraph.js +23 -3
  205. package/dist/layout-engine/measure/measureProvider.d.ts +0 -1
  206. package/dist/layout-engine/measure/measureTypes.d.ts +4 -2
  207. package/dist/layout-engine/measure/measureWorker.d.ts +0 -1
  208. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +0 -1
  209. package/dist/layout-engine/measure/tableCellFloating.d.ts +0 -1
  210. package/dist/layout-engine/measure/tableCellFlow.d.ts +0 -1
  211. package/dist/layout-engine/measure/tableCellGrid.d.ts +0 -1
  212. package/dist/layout-engine/measure/textBoxParagraphLayout.d.ts +0 -1
  213. package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +0 -1
  214. package/dist/layout-engine/paginator.d.ts +66 -33
  215. package/dist/layout-engine/paragraphFragmentRange.d.ts +0 -1
  216. package/dist/layout-engine/paragraphFrame.d.ts +0 -1
  217. package/dist/layout-engine/paragraphSequence.d.ts +0 -1
  218. package/dist/layout-engine/paragraphSpacing.d.ts +1 -5
  219. package/dist/layout-engine/pmPageIndex.d.ts +0 -1
  220. package/dist/layout-engine/renderedBreakReconciliation.d.ts +2 -17
  221. package/dist/layout-engine/section-breaks.d.ts +34 -17
  222. package/dist/layout-engine/tableRowBreak.d.ts +4 -3
  223. package/dist/layout-engine/textBoxFlow.d.ts +0 -1
  224. package/dist/layout-engine/textBoxGroup.d.ts +0 -1
  225. package/dist/layout-engine/types.d.ts +382 -189
  226. package/dist/layout-painter/anchoredImagePosition.d.ts +0 -1
  227. package/dist/layout-painter/borderStroke.d.ts +0 -1
  228. package/dist/layout-painter/imageLayout.d.ts +14 -7
  229. package/dist/layout-painter/index.d.ts +9 -5
  230. package/dist/layout-painter/registry/modules/image.d.ts +0 -1
  231. package/dist/layout-painter/registry/modules/paragraph.d.ts +0 -1
  232. package/dist/layout-painter/registry/modules/table.d.ts +0 -1
  233. package/dist/layout-painter/registry/modules/textBox.d.ts +0 -1
  234. package/dist/layout-painter/registry/modules.d.ts +0 -1
  235. package/dist/layout-painter/registry/registry.d.ts +0 -1
  236. package/dist/layout-painter/registry/types.d.ts +0 -1
  237. package/dist/layout-painter/renderFragment.d.ts +2 -2
  238. package/dist/layout-painter/renderImage.d.ts +0 -1
  239. package/dist/layout-painter/renderPage.d.ts +71 -42
  240. package/dist/layout-painter/renderParagraph.d.ts +28 -14
  241. package/dist/layout-painter/renderParagraph.js +6 -2
  242. package/dist/layout-painter/renderTable.d.ts +0 -1
  243. package/dist/layout-painter/renderTextBox.d.ts +0 -1
  244. package/dist/layout-painter/renderUtils.d.ts +17 -9
  245. package/dist/layout-painter/renderWatermark.d.ts +2 -2
  246. package/dist/layout-painter/sdtBoundary.d.ts +0 -1
  247. package/dist/managers/AutoSaveManager.d.ts +22 -11
  248. package/dist/managers/ClipboardManager.d.ts +0 -1
  249. package/dist/managers/ContextMenuManager.d.ts +5 -8
  250. package/dist/managers/DocumentLoaderManager.d.ts +12 -6
  251. package/dist/managers/EditorModeManager.d.ts +3 -2
  252. package/dist/managers/ErrorManager.d.ts +0 -1
  253. package/dist/managers/FindReplaceManager.d.ts +0 -1
  254. package/dist/managers/HistoryManager.d.ts +19 -9
  255. package/dist/managers/TableSelectionManager.d.ts +0 -1
  256. package/dist/managers/editorShortcuts.d.ts +4 -6
  257. package/dist/markdown/annotations.d.ts +0 -1
  258. package/dist/markdown/fromMarkdown.d.ts +0 -1
  259. package/dist/markdown/images.d.ts +0 -1
  260. package/dist/markdown/index.d.ts +0 -1
  261. package/dist/markdown/internals.d.ts +0 -1
  262. package/dist/markdown/renderBlock.d.ts +0 -1
  263. package/dist/markdown/renderParagraph.d.ts +0 -1
  264. package/dist/markdown/renderRuns.d.ts +0 -1
  265. package/dist/markdown/renderTable.d.ts +0 -1
  266. package/dist/markdown/trailers.d.ts +0 -1
  267. package/dist/markdown/types.d.ts +39 -18
  268. package/dist/model.d.ts +3 -5
  269. package/dist/model.js +2 -2
  270. package/dist/paged-layout/incrementalMeasure.d.ts +1 -10
  271. package/dist/paged-layout/pageText.d.ts +1 -1
  272. package/dist/paged-layout/paragraphFlash.d.ts +0 -1
  273. package/dist/paged-layout/paragraphFlashTypes.d.ts +5 -2
  274. package/dist/paged-layout/rangeProjection.d.ts +10 -5
  275. package/dist/paged-layout/scrollNavigation.d.ts +0 -1
  276. package/dist/paged-layout/scrollPageInfo.d.ts +12 -13
  277. package/dist/paged-layout/scrollToPmPosition.d.ts +0 -1
  278. package/dist/paged-layout/sectionBlockWidths.d.ts +2 -11
  279. package/dist/paged-layout/sectionGeometry.d.ts +0 -1
  280. package/dist/paged-layout/selectionViewportRect.d.ts +0 -1
  281. package/dist/paged-layout/transactionDirtyRange.d.ts +0 -1
  282. package/dist/paged-layout/zoomScrollAnchor.d.ts +2 -12
  283. package/dist/prosemirror/attrs/index.d.ts +6 -4
  284. package/dist/prosemirror/attrs/index.js +22 -2
  285. package/dist/prosemirror/autospacingBase.d.ts +0 -1
  286. package/dist/prosemirror/cellDragSelection.d.ts +6 -4
  287. package/dist/prosemirror/commands/comments.d.ts +6 -4
  288. package/dist/prosemirror/commands/contentControls.d.ts +5 -3
  289. package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +1 -1
  290. package/dist/prosemirror/commands/formatPainter.d.ts +0 -1
  291. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  292. package/dist/prosemirror/commands/hyperlink.d.ts +4 -9
  293. package/dist/prosemirror/commands/image.d.ts +0 -1
  294. package/dist/prosemirror/commands/pageBreak.d.ts +0 -1
  295. package/dist/prosemirror/commands/paragraph.d.ts +0 -1
  296. package/dist/prosemirror/commands/pastePlainText.d.ts +0 -1
  297. package/dist/prosemirror/commands/propertyChangeScope.d.ts +0 -1
  298. package/dist/prosemirror/commands/sectionBreak.d.ts +0 -1
  299. package/dist/prosemirror/commands/table.d.ts +0 -1
  300. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +0 -1
  301. package/dist/prosemirror/commentIdAllocator.d.ts +2 -2
  302. package/dist/prosemirror/commentOps.d.ts +0 -1
  303. package/dist/prosemirror/conversion/effectiveTableCellFormatting.d.ts +1 -10
  304. package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -1
  305. package/dist/prosemirror/conversion/fromProseDoc.js +17 -10
  306. package/dist/prosemirror/conversion/runShadingMark.d.ts +0 -1
  307. package/dist/prosemirror/conversion/sdtAttrs.d.ts +0 -1
  308. package/dist/prosemirror/conversion/toProseDoc.d.ts +3 -2
  309. package/dist/prosemirror/conversion/toProseDoc.js +17 -3
  310. package/dist/prosemirror/extensions/ExtensionManager.d.ts +0 -1
  311. package/dist/prosemirror/extensions/StarterKit.d.ts +7 -4
  312. package/dist/prosemirror/extensions/core/DocExtension.d.ts +0 -1
  313. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -1
  314. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +0 -1
  315. package/dist/prosemirror/extensions/core/TextExtension.d.ts +0 -1
  316. package/dist/prosemirror/extensions/create.d.ts +0 -1
  317. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +0 -1
  318. package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +0 -1
  319. package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +0 -1
  320. package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +0 -1
  321. package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +0 -1
  322. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +0 -1
  323. package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +0 -1
  324. package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +0 -1
  325. package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +0 -1
  326. package/dist/prosemirror/extensions/features/ListExtension.d.ts +0 -1
  327. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -1
  328. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +7 -4
  329. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +0 -1
  330. package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +0 -1
  331. package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +0 -1
  332. package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +3 -1
  333. package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +0 -1
  334. package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +0 -1
  335. package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +0 -1
  336. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +0 -1
  337. package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +0 -1
  338. package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +0 -1
  339. package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +1 -0
  340. package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +0 -1
  341. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +0 -1
  342. package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +0 -1
  343. package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +0 -1
  344. package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +0 -1
  345. package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +0 -1
  346. package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +0 -1
  347. package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +0 -1
  348. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +0 -1
  349. package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +0 -1
  350. package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +0 -1
  351. package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +0 -1
  352. package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +0 -1
  353. package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +0 -1
  354. package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +0 -1
  355. package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +0 -1
  356. package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +0 -1
  357. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +0 -1
  358. package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +0 -1
  359. package/dist/prosemirror/extensions/marks/markUtils.d.ts +0 -1
  360. package/dist/prosemirror/extensions/marks/markUtils.js +4 -1
  361. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +0 -1
  362. package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +0 -1
  363. package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +0 -1
  364. package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +0 -1
  365. package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +0 -1
  366. package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -0
  367. package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +0 -1
  368. package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +0 -1
  369. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +0 -1
  370. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +0 -1
  371. package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +0 -1
  372. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +2 -0
  373. package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +0 -1
  374. package/dist/prosemirror/extensions/nodes/TabExtension.js +32 -9
  375. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +4 -3
  376. package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +0 -1
  377. package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +53 -27
  378. package/dist/prosemirror/extensions/types.d.ts +0 -1
  379. package/dist/prosemirror/findReplaceSelection.d.ts +5 -3
  380. package/dist/prosemirror/imageCommit.d.ts +0 -1
  381. package/dist/prosemirror/index.d.ts +4 -0
  382. package/dist/prosemirror/insertOperations.d.ts +0 -1
  383. package/dist/prosemirror/paraText.d.ts +0 -1
  384. package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +2 -2
  385. package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +0 -1
  386. package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +9 -7
  387. package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +2 -2
  388. package/dist/prosemirror/plugins/contentControlWidgets.d.ts +4 -7
  389. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +3 -8
  390. package/dist/prosemirror/plugins/documentStyles.d.ts +0 -1
  391. package/dist/prosemirror/plugins/pmTextScan.d.ts +2 -2
  392. package/dist/prosemirror/plugins/revisionIds.d.ts +0 -1
  393. package/dist/prosemirror/plugins/selectionTracker.d.ts +23 -12
  394. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -1
  395. package/dist/prosemirror/plugins/templateDirectives.d.ts +10 -8
  396. package/dist/prosemirror/plugins/templatePreviewValues.d.ts +10 -5
  397. package/dist/prosemirror/plugins/templateSlashMenu.d.ts +2 -2
  398. package/dist/prosemirror/queries.d.ts +0 -1
  399. package/dist/prosemirror/schema/index.d.ts +2 -3
  400. package/dist/prosemirror/schema/marks.d.ts +8 -5
  401. package/dist/prosemirror/schema/nodes.d.ts +344 -164
  402. package/dist/prosemirror/selectionState.d.ts +13 -7
  403. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +0 -1
  404. package/dist/prosemirror/styles/styleResolver.d.ts +3 -2
  405. package/dist/prosemirror/tableCellMergeRevision.d.ts +0 -1
  406. package/dist/prosemirror/tableResize.d.ts +0 -1
  407. package/dist/prosemirror/textBoxAnchorAttrs.d.ts +0 -1
  408. package/dist/prosemirror/utils/extractTrackedChanges.d.ts +8 -5
  409. package/dist/prosemirror/utils/findParagraphByParaId.d.ts +0 -1
  410. package/dist/prosemirror/utils/tabCalculator.d.ts +18 -7
  411. package/dist/prosemirror/utils/visualLineNavigation.d.ts +0 -1
  412. package/dist/prosemirror/validation.d.ts +0 -1
  413. package/dist/prosemirror/validation.js +5 -3
  414. package/dist/redline.d.ts +16 -8
  415. package/dist/render-dom/BodySelectionOverlay.d.ts +1 -9
  416. package/dist/render-dom/HeaderFooterSelectionOverlay.d.ts +0 -1
  417. package/dist/render-dom/RemoteSelectionOverlay.d.ts +1 -8
  418. package/dist/render-dom/resolveSidebarItemPositions.d.ts +1 -9
  419. package/dist/style-engine/styleEngine.d.ts +21 -11
  420. package/dist/style-sets/extract.d.ts +4 -3
  421. package/dist/style-sets/stellaStyle.d.ts +0 -1
  422. package/dist/style-sets/types.d.ts +0 -1
  423. package/dist/symbols.d.ts +6 -2
  424. package/dist/types/block-id.d.ts +3 -6
  425. package/dist/types/content.d.ts +2 -2
  426. package/dist/types/document.d.ts +0 -3
  427. package/dist/types/documentEnumValues.d.ts +5 -1
  428. package/dist/types/documentEnumValues.js +19 -1
  429. package/dist/types/index.d.ts +2 -1
  430. package/dist/utils/clipboard.d.ts +17 -8
  431. package/dist/utils/colorResolver.d.ts +9 -5
  432. package/dist/utils/createDocument.d.ts +19 -10
  433. package/dist/utils/documentLoaderBehavior.d.ts +1 -5
  434. package/dist/utils/docxInput.js +1 -0
  435. package/dist/utils/findReplace.d.ts +0 -1
  436. package/dist/utils/fontFamilyMerge.d.ts +0 -1
  437. package/dist/utils/fontResolver.d.ts +10 -4
  438. package/dist/utils/formatToStyle.d.ts +0 -1
  439. package/dist/utils/headerFooter.d.ts +8 -16
  440. package/dist/utils/headingCollector.d.ts +7 -4
  441. package/dist/utils/mergeDocumentContent.d.ts +0 -1
  442. package/dist/utils/paragraphFormattingMerge.d.ts +0 -1
  443. package/dist/utils/replaceText.d.ts +0 -1
  444. package/dist/utils/rotationBoundingBox.d.ts +0 -1
  445. package/dist/utils/tableOperations.d.ts +0 -1
  446. package/dist/utils/textFormattingMerge.d.ts +0 -1
  447. package/dist/version-comparison.d.ts +12 -6
  448. package/dist/watermark/index.d.ts +0 -1
  449. package/package.json +3 -3
@@ -1,5 +1,4 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
-
3
2
  //#region src/docx/themeParser.d.ts
4
3
  /**
5
4
  * Parse theme1.xml content
@@ -1,5 +1,4 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
-
3
2
  //#region src/docx/trackedMoveRangeNormalization.d.ts
4
3
  type NormalizeTrackedMoveRangesInput = {
5
4
  documentBody: document_d_exports.DocumentBody;
@@ -11,12 +10,6 @@ type NormalizeTrackedMoveRangesInput = {
11
10
  type NormalizeTrackedMoveRangesResult = {
12
11
  removedUnbalancedMoveRangeMarkers: number;
13
12
  };
14
- declare const normalizeTrackedMoveRanges: ({
15
- documentBody,
16
- headers,
17
- footers,
18
- footnotes,
19
- endnotes
20
- }: NormalizeTrackedMoveRangesInput) => NormalizeTrackedMoveRangesResult;
13
+ declare const normalizeTrackedMoveRanges: ({ documentBody, headers, footers, footnotes, endnotes }: NormalizeTrackedMoveRangesInput) => NormalizeTrackedMoveRangesResult;
21
14
  //#endregion
22
15
  export { normalizeTrackedMoveRanges };
@@ -1,5 +1,4 @@
1
1
  import JSZip from "jszip";
2
-
3
2
  //#region src/docx/unzip.d.ts
4
3
  declare class DocxSecurityError extends Error {
5
4
  constructor(message: string);
@@ -14,7 +13,10 @@ type DocxUnzipLimits = {
14
13
  allowedMediaMimeTypes: ReadonlySet<string>;
15
14
  };
16
15
  type DocxUnzipOptions = Partial<Omit<DocxUnzipLimits, "allowedMediaMimeTypes">> & {
17
- allowedMediaMimeTypes?: Iterable<string>; /** Password for Agile-encrypted .docx files (Office 2010+). */
16
+ allowedMediaMimeTypes?: Iterable<string>;
17
+ /** Extract every XML part into allXml instead of only parts used by the parser. */
18
+ extractAllXml?: boolean;
19
+ /** Password for Agile-encrypted .docx files (Office 2010+). */
18
20
  password?: string | undefined;
19
21
  };
20
22
  /**
@@ -46,7 +48,8 @@ type RawDocxContent = {
46
48
  allXml: Map<string, string>;
47
49
  originalZip: JSZip;
48
50
  originalBuffer: ArrayBuffer;
49
- warnings: string[]; /** True when the input was a password-protected CFB container. */
51
+ warnings: string[];
52
+ /** True when the input was a password-protected CFB container. */
50
53
  wasEncrypted: boolean;
51
54
  };
52
55
  /**
@@ -59,6 +59,27 @@ const DEFAULT_UNZIP_LIMITS = {
59
59
  maxTotalUncompressedBytes: 250 * MEBIBYTE,
60
60
  allowedMediaMimeTypes: DEFAULT_ALLOWED_MEDIA_MIME_TYPES
61
61
  };
62
+ const PARSED_XML_PARTS = /* @__PURE__ */ new Set([
63
+ "[content_types].xml",
64
+ "_rels/.rels",
65
+ "docprops/app.xml",
66
+ "docprops/core.xml",
67
+ "docprops/custom.xml",
68
+ "word/_rels/document.xml.rels",
69
+ "word/_rels/fonttable.xml.rels",
70
+ "word/comments.xml",
71
+ "word/commentsextended.xml",
72
+ "word/commentsextensible.xml",
73
+ "word/document.xml",
74
+ "word/endnotes.xml",
75
+ "word/fonttable.xml",
76
+ "word/footnotes.xml",
77
+ "word/numbering.xml",
78
+ "word/settings.xml",
79
+ "word/styles.xml",
80
+ "word/theme/theme1.xml"
81
+ ]);
82
+ const shouldExtractXmlPart = (path) => PARSED_XML_PARTS.has(path) || path.startsWith("word/");
62
83
  const ZIP_END_OF_CENTRAL_DIRECTORY_SIGNATURE = 101010256;
63
84
  const ZIP_CENTRAL_DIRECTORY_FILE_HEADER_SIGNATURE = 33639248;
64
85
  const ZIP_END_OF_CENTRAL_DIRECTORY_SIZE = 22;
@@ -73,9 +94,10 @@ const ZIP_CENTRAL_DIRECTORY_FILE_HEADER_SIZE = 46;
73
94
  async function unzipDocx(buffer, options = {}) {
74
95
  const limits = createUnzipLimits(options);
75
96
  if (buffer.byteLength > limits.maxInputBytes) throw new DocxSecurityError("DOCX file exceeds the maximum allowed size");
76
- const zipBuffer = await openDocxBuffer(buffer, { password: options.password });
97
+ const containerType = detectDocxContainerType(buffer);
98
+ const zipBuffer = containerType === DOCX_CONTAINER_TYPES.ZIP ? buffer : await openDocxBuffer(buffer, { password: options.password });
77
99
  if (zipBuffer.byteLength > limits.maxInputBytes) throw new DocxSecurityError("DOCX file exceeds the maximum allowed size");
78
- const wasEncrypted = detectDocxContainerType(buffer) === DOCX_CONTAINER_TYPES.CFB;
100
+ const wasEncrypted = containerType === DOCX_CONTAINER_TYPES.CFB;
79
101
  const loaded = await loadDocxZip(zipBuffer, limits.maxFiles);
80
102
  if (loaded.buffer.byteLength > limits.maxInputBytes) throw new DocxSecurityError("DOCX file exceeds the maximum allowed size");
81
103
  const { zip } = loaded;
@@ -111,6 +133,7 @@ async function unzipDocx(buffer, options = {}) {
111
133
  wasEncrypted
112
134
  };
113
135
  let totalUncompressedBytes = 0;
136
+ const extractionTasks = [];
114
137
  for (const [path, file] of entries) {
115
138
  if (!isSafeDocxPath(path)) throw new DocxSecurityError("DOCX file contains an unsafe entry path");
116
139
  if (!isPreservableDocxEntry(path)) continue;
@@ -122,34 +145,16 @@ async function unzipDocx(buffer, options = {}) {
122
145
  }
123
146
  if (lowerPath.endsWith(".xml") || lowerPath.endsWith(".rels")) {
124
147
  assertEntrySize(path, declaredSize, limits.maxXmlBytes);
125
- const xmlContent = await file.async("text");
126
- assertExtractedSize(path, xmlContent.length, limits.maxXmlBytes);
127
- content.allXml.set(path, xmlContent);
128
- if (lowerPath === "word/document.xml") content.documentXml = xmlContent;
129
- else if (lowerPath === "word/styles.xml") content.stylesXml = xmlContent;
130
- else if (lowerPath === "word/theme/theme1.xml") content.themeXml = xmlContent;
131
- else if (lowerPath === "word/numbering.xml") content.numberingXml = xmlContent;
132
- else if (lowerPath === "word/fonttable.xml") content.fontTableXml = xmlContent;
133
- else if (lowerPath === "word/settings.xml") content.settingsXml = xmlContent;
134
- else if (lowerPath === "word/websettings.xml") content.webSettingsXml = xmlContent;
135
- else if (lowerPath === "word/footnotes.xml") content.footnotesXml = xmlContent;
136
- else if (lowerPath === "word/endnotes.xml") content.endnotesXml = xmlContent;
137
- else if (lowerPath === "word/comments.xml") content.commentsXml = xmlContent;
138
- else if (lowerPath === "word/commentsextensible.xml") content.commentsExtensibleXml = xmlContent;
139
- else if (lowerPath === "word/commentsextended.xml") content.commentsExtendedXml = xmlContent;
140
- else if (lowerPath === "word/_rels/document.xml.rels") content.documentRels = xmlContent;
141
- else if (lowerPath === "_rels/.rels") content.packageRels = xmlContent;
142
- else if (lowerPath === "[content_types].xml") content.contentTypesXml = xmlContent;
143
- else if (lowerPath === "docprops/core.xml") content.corePropsXml = xmlContent;
144
- else if (lowerPath === "docprops/app.xml") content.appPropsXml = xmlContent;
145
- else if (lowerPath === "docprops/custom.xml") content.customPropsXml = xmlContent;
146
- else if (/^word\/header[^/]*\.xml$/u.test(lowerPath)) {
147
- const filename = path.split("/").pop() || path;
148
- content.headers.set(filename, xmlContent);
149
- } else if (/^word\/footer[^/]*\.xml$/u.test(lowerPath)) {
150
- const filename = path.split("/").pop() || path;
151
- content.footers.set(filename, xmlContent);
152
- }
148
+ if (options.extractAllXml === false && !shouldExtractXmlPart(lowerPath)) continue;
149
+ extractionTasks.push(file.async("text").then((xmlContent) => {
150
+ assertExtractedSize(path, xmlContent.length, limits.maxXmlBytes);
151
+ return {
152
+ type: "xml",
153
+ path,
154
+ lowerPath,
155
+ content: xmlContent
156
+ };
157
+ }));
153
158
  } else if (lowerPath.startsWith("word/media/")) {
154
159
  const mimeType = getMediaMimeType(path);
155
160
  if (!limits.allowedMediaMimeTypes.has(mimeType)) continue;
@@ -157,22 +162,73 @@ async function unzipDocx(buffer, options = {}) {
157
162
  content.warnings.push(`Skipped oversized media file: ${path}; original entry preserved for round-trip.`);
158
163
  continue;
159
164
  }
160
- const binaryContent = await file.async("arraybuffer");
161
- if (binaryContent.byteLength > limits.maxMediaBytes) {
162
- content.warnings.push(`Skipped oversized media file: ${path}; original entry preserved for round-trip.`);
163
- continue;
164
- }
165
- if (!isMediaContentAllowed(binaryContent, mimeType)) continue;
166
- content.media.set(path, binaryContent);
165
+ extractionTasks.push(file.async("arraybuffer").then((binaryContent) => {
166
+ if (binaryContent.byteLength > limits.maxMediaBytes) {
167
+ content.warnings.push(`Skipped oversized media file: ${path}; original entry preserved for round-trip.`);
168
+ return null;
169
+ }
170
+ if (!isMediaContentAllowed(binaryContent, mimeType)) return null;
171
+ return {
172
+ type: "media",
173
+ path,
174
+ mimeType,
175
+ content: binaryContent
176
+ };
177
+ }));
167
178
  } else if (lowerPath.startsWith("word/fonts/")) {
168
179
  if (isEntryTooLarge(declaredSize, limits.maxFontBytes)) continue;
169
- const binaryContent = await file.async("arraybuffer");
170
- if (binaryContent.byteLength > limits.maxFontBytes) continue;
171
- content.fonts.set(path, binaryContent);
180
+ extractionTasks.push(file.async("arraybuffer").then((binaryContent) => {
181
+ if (binaryContent.byteLength > limits.maxFontBytes) return null;
182
+ return {
183
+ type: "font",
184
+ path,
185
+ content: binaryContent
186
+ };
187
+ }));
172
188
  }
173
189
  }
190
+ for (const extracted of await Promise.all(extractionTasks)) {
191
+ if (!extracted) continue;
192
+ if (extracted.type === "xml") {
193
+ assignXmlContent(content, extracted);
194
+ continue;
195
+ }
196
+ if (extracted.type === "media") {
197
+ content.media.set(extracted.path, extracted.content);
198
+ continue;
199
+ }
200
+ content.fonts.set(extracted.path, extracted.content);
201
+ }
174
202
  return content;
175
203
  }
204
+ function assignXmlContent(content, { path, lowerPath, content: xmlContent }) {
205
+ content.allXml.set(path, xmlContent);
206
+ if (lowerPath === "word/document.xml") content.documentXml = xmlContent;
207
+ else if (lowerPath === "word/styles.xml") content.stylesXml = xmlContent;
208
+ else if (lowerPath === "word/theme/theme1.xml") content.themeXml = xmlContent;
209
+ else if (lowerPath === "word/numbering.xml") content.numberingXml = xmlContent;
210
+ else if (lowerPath === "word/fonttable.xml") content.fontTableXml = xmlContent;
211
+ else if (lowerPath === "word/settings.xml") content.settingsXml = xmlContent;
212
+ else if (lowerPath === "word/websettings.xml") content.webSettingsXml = xmlContent;
213
+ else if (lowerPath === "word/footnotes.xml") content.footnotesXml = xmlContent;
214
+ else if (lowerPath === "word/endnotes.xml") content.endnotesXml = xmlContent;
215
+ else if (lowerPath === "word/comments.xml") content.commentsXml = xmlContent;
216
+ else if (lowerPath === "word/commentsextensible.xml") content.commentsExtensibleXml = xmlContent;
217
+ else if (lowerPath === "word/commentsextended.xml") content.commentsExtendedXml = xmlContent;
218
+ else if (lowerPath === "word/_rels/document.xml.rels") content.documentRels = xmlContent;
219
+ else if (lowerPath === "_rels/.rels") content.packageRels = xmlContent;
220
+ else if (lowerPath === "[content_types].xml") content.contentTypesXml = xmlContent;
221
+ else if (lowerPath === "docprops/core.xml") content.corePropsXml = xmlContent;
222
+ else if (lowerPath === "docprops/app.xml") content.appPropsXml = xmlContent;
223
+ else if (lowerPath === "docprops/custom.xml") content.customPropsXml = xmlContent;
224
+ else if (/^word\/header[^/]*\.xml$/u.test(lowerPath)) {
225
+ const filename = path.split("/").pop() || path;
226
+ content.headers.set(filename, xmlContent);
227
+ } else if (/^word\/footer[^/]*\.xml$/u.test(lowerPath)) {
228
+ const filename = path.split("/").pop() || path;
229
+ content.footers.set(filename, xmlContent);
230
+ }
231
+ }
176
232
  async function loadDocxZip(buffer, maxFiles) {
177
233
  try {
178
234
  return {
@@ -1,6 +1,5 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { XmlElement } from "./xmlParser.js";
3
-
4
3
  //#region src/docx/vmlImageParser.d.ts
5
4
  /**
6
5
  * Parse a `w:pict` element into an inline image, or null when it carries no
@@ -1,4 +1,4 @@
1
- import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
1
+ import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
2
2
  import { pixelsToEmu } from "../utils/units.js";
3
3
  import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
4
4
  import { resolveImageData } from "./imageParser.js";
@@ -136,6 +136,7 @@ const previewImage = (pictElement, svg, widthPx, heightPx, style, rootXmlns) =>
136
136
  };
137
137
  };
138
138
  const parseStandaloneShapePreview = (pictElement, shape, rootXmlns) => {
139
+ if (findDeep(shape, "v", "textbox")) return null;
139
140
  const style = parseStyleAttr(getAttribute(shape, null, "style"));
140
141
  const widthPx = cssLengthToPx(style["width"]);
141
142
  const heightPx = cssLengthToPx(style["height"]);
@@ -159,6 +160,7 @@ const parseGroupPreview = (pictElement, group, rootXmlns) => {
159
160
  if (size.first <= 0 || size.second <= 0) return null;
160
161
  const content = getChildElements(group).slice(0, MAX_VML_PREVIEW_SHAPES).map((child) => {
161
162
  const localName = getLocalName(child.name ?? "");
163
+ if (findDeep(child, "v", "textbox")) return "";
162
164
  if (localName === "line") {
163
165
  const from = coordinatePair(getAttribute(child, null, "from"));
164
166
  const to = coordinatePair(getAttribute(child, null, "to"));
@@ -1,6 +1,5 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { XmlElement } from "./xmlParser.js";
3
-
4
3
  //#region src/docx/watermarkParser.d.ts
5
4
  /**
6
5
  * Result of walking a header for its watermark. Carries the modeled
@@ -79,7 +79,7 @@ declare function parseXmlDocument(xml: string): XmlElement | null;
79
79
  * Get local name from a prefixed element name
80
80
  * e.g., "w:p" -> "p", "a:graphic" -> "graphic"
81
81
  */
82
- declare function getLocalName(name: string): string;
82
+ declare function getLocalName(name: string | undefined): string;
83
83
  /**
84
84
  * Get namespace prefix from an element name
85
85
  * e.g., "w:p" -> "w", "a:graphic" -> "a"
@@ -92,7 +92,7 @@ declare function getNamespacePrefix(name: string): string | null;
92
92
  * @param namespace - Namespace prefix (e.g., "w", "a")
93
93
  * @param localName - Local element name (e.g., "p", "r")
94
94
  */
95
- declare function matchesName(element: XmlElement, namespace: string, localName: string): boolean;
95
+ declare function matchesName(element: XmlElement, _namespace: string, localName: string): boolean;
96
96
  /**
97
97
  * Find first child element matching the given namespaced name
98
98
  *
@@ -101,7 +101,7 @@ declare function matchesName(element: XmlElement, namespace: string, localName:
101
101
  * @param localName - Local element name (e.g., "p")
102
102
  * @returns First matching child or null
103
103
  */
104
- declare function findChild(parent: XmlElement | null | undefined, namespace: string, localName: string): XmlElement | null;
104
+ declare function findChild(parent: XmlElement | null | undefined, _namespace: string, localName: string): XmlElement | null;
105
105
  /**
106
106
  * Find all child elements matching the given namespaced name
107
107
  *
@@ -110,7 +110,7 @@ declare function findChild(parent: XmlElement | null | undefined, namespace: str
110
110
  * @param localName - Local element name
111
111
  * @returns Array of matching children
112
112
  */
113
- declare function findChildren(parent: XmlElement | null | undefined, namespace: string, localName: string): XmlElement[];
113
+ declare function findChildren(parent: XmlElement | null | undefined, _namespace: string, localName: string): XmlElement[];
114
114
  /**
115
115
  * Find first child element by local name only (ignoring namespace)
116
116
  *
@@ -237,6 +237,14 @@ declare function parseColorElement(element: XmlElement | null | undefined): {
237
237
  * @returns Parsed number or undefined
238
238
  */
239
239
  declare function parseNumericAttribute(element: XmlElement | null | undefined, namespace: string | null, name: string, scale?: number): number | undefined;
240
+ /**
241
+ * Parse a zero-based numbering level reference.
242
+ *
243
+ * OOXML numbering levels cannot be negative. Some producers emit negative
244
+ * sentinel values alongside `w:numId="0"` to disable numbering; treat those
245
+ * as an omitted level instead of leaking an invalid value into the model.
246
+ */
247
+ declare function parseNumberingLevelAttribute(element: XmlElement | null | undefined): number | undefined;
240
248
  /**
241
249
  * Parse `w:w` on a table width/height element. For `w:type="pct"`, producers
242
250
  * sometimes emit human-readable percentages (`100%`) instead of 50ths-of-percent
@@ -294,10 +302,15 @@ declare function collectXmlnsDeclarations(element: XmlElement): Record<string, s
294
302
  */
295
303
  declare function mergeXmlnsDeclarations(inherited: Record<string, string>, element: XmlElement): Record<string, string>;
296
304
  /**
297
- * Return a shallow clone of `element` whose attributes carry every declaration
298
- * in `xmlnsDecls`. Existing attributes (including any namespace declarations the
299
- * element already carries) win over the injected ones.
305
+ * Return a shallow clone of `element` carrying the inherited namespace
306
+ * declarations needed by its raw subtree.
307
+ *
308
+ * Existing declarations retain their authored order. Only missing, referenced
309
+ * bindings are appended, which makes repeated detach/replay cycles idempotent
310
+ * even when the surrounding document declares a different namespace superset.
311
+ * If a producer omitted a binding for a standard OOXML prefix, use its
312
+ * canonical binding so the detached subtree is valid on its first replay.
300
313
  */
301
314
  declare function cloneWithXmlnsDeclarations(element: XmlElement, xmlnsDecls: Record<string, string>): XmlElement;
302
315
  //#endregion
303
- export { NAMESPACES, XmlElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findByFullName, findChild, findChildByLocalName, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumericAttribute, parseTableMeasurementValue, parseXml, parseXmlDocument };
316
+ export { NAMESPACES, XmlElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findByFullName, findChild, findChildByLocalName, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseTableMeasurementValue, parseXml, parseXmlDocument };
@@ -53,6 +53,8 @@ const fxpBuilder = new XMLBuilder(fxpBuilderOptions);
53
53
  const TEXT_KEY = "#text";
54
54
  /** Attribute group key used by fast-xml-parser in preserveOrder mode. */
55
55
  const ATTR_KEY = ":@";
56
+ /** Character reference required to keep carriage returns through XML end-of-line normalization. */
57
+ const XML_CARRIAGE_RETURN_REFERENCE = "&#13;";
56
58
  /**
57
59
  * Convert a fast-xml-parser preserveOrder node into an XmlElement.
58
60
  *
@@ -75,9 +77,8 @@ function fxpNodeToElement(node) {
75
77
  };
76
78
  if (attrs) element.attributes = attrs;
77
79
  if (children.length > 0) {
78
- const elements = [];
79
- for (const child of children) elements.push(fxpNodeToElement(child));
80
- element.elements = elements;
80
+ for (let index = 0; index < children.length; index += 1) children[index] = fxpNodeToElement(children[index]);
81
+ element.elements = children;
81
82
  }
82
83
  return element;
83
84
  }
@@ -89,9 +90,8 @@ function fxpNodeToElement(node) {
89
90
  * `{ elements: [...] }`.
90
91
  */
91
92
  function fxpToRootElement(nodes) {
92
- const elements = [];
93
- for (const node of nodes) elements.push(fxpNodeToElement(node));
94
- return { elements };
93
+ for (let index = 0; index < nodes.length; index += 1) nodes[index] = fxpNodeToElement(nodes[index]);
94
+ return { elements: nodes };
95
95
  }
96
96
  /**
97
97
  * Convert an XmlElement back into the fast-xml-parser preserveOrder format
@@ -123,7 +123,7 @@ function parseXml(xml) {
123
123
  */
124
124
  function elementToXml(element) {
125
125
  const fxpNode = elementToFxpNode(element);
126
- return fxpBuilder.build([fxpNode]);
126
+ return fxpBuilder.build([fxpNode]).replaceAll("\r", XML_CARRIAGE_RETURN_REFERENCE);
127
127
  }
128
128
  /**
129
129
  * Parse XML string to a more convenient format
@@ -131,7 +131,10 @@ function elementToXml(element) {
131
131
  function parseXmlDocument(xml) {
132
132
  try {
133
133
  const parsed = parseXml(xml);
134
- if (parsed.elements && parsed.elements.length > 0) return parsed.elements.find((e) => e.type === "element") ?? null;
134
+ if (parsed.elements && parsed.elements.length > 0) {
135
+ for (const element of parsed.elements) if (element.type === "element") return element;
136
+ return null;
137
+ }
135
138
  return parsed;
136
139
  } catch {
137
140
  return null;
@@ -142,6 +145,8 @@ function parseXmlDocument(xml) {
142
145
  * e.g., "w:p" -> "p", "a:graphic" -> "graphic"
143
146
  */
144
147
  function getLocalName(name) {
148
+ if (!name) return "";
149
+ if (name[1] === ":") return name.slice(2);
145
150
  const colonIndex = name.indexOf(":");
146
151
  return colonIndex !== -1 ? name.slice(colonIndex + 1) : name;
147
152
  }
@@ -150,9 +155,16 @@ function getLocalName(name) {
150
155
  * e.g., "w:p" -> "w", "a:graphic" -> "a"
151
156
  */
152
157
  function getNamespacePrefix(name) {
158
+ if (name[1] === ":") return name[0] ?? null;
153
159
  const colonIndex = name.indexOf(":");
154
160
  return colonIndex !== -1 ? name.slice(0, colonIndex) : null;
155
161
  }
162
+ function hasLocalName(name, localName) {
163
+ if (!name) return false;
164
+ if (name === localName) return true;
165
+ const localNameOffset = name.length - localName.length;
166
+ return localNameOffset > 0 && name[localNameOffset - 1] === ":" && name.endsWith(localName);
167
+ }
156
168
  /**
157
169
  * Check if an element matches a given namespaced name
158
170
  *
@@ -160,12 +172,9 @@ function getNamespacePrefix(name) {
160
172
  * @param namespace - Namespace prefix (e.g., "w", "a")
161
173
  * @param localName - Local element name (e.g., "p", "r")
162
174
  */
163
- function matchesName(element, namespace, localName) {
175
+ function matchesName(element, _namespace, localName) {
164
176
  if (!element.name) return false;
165
- const fullName = `${namespace}:${localName}`;
166
- if (element.name === fullName) return true;
167
- if (getLocalName(element.name) === localName) return true;
168
- return false;
177
+ return hasLocalName(element.name, localName);
169
178
  }
170
179
  /**
171
180
  * Find first child element matching the given namespaced name
@@ -175,13 +184,11 @@ function matchesName(element, namespace, localName) {
175
184
  * @param localName - Local element name (e.g., "p")
176
185
  * @returns First matching child or null
177
186
  */
178
- function findChild(parent, namespace, localName) {
187
+ function findChild(parent, _namespace, localName) {
179
188
  if (!parent || !parent.elements) return null;
180
- const fullName = `${namespace}:${localName}`;
181
189
  for (const child of parent.elements) {
182
190
  if (child.type !== "element") continue;
183
- if (child.name === fullName) return child;
184
- if (getLocalName(child.name || "") === localName) return child;
191
+ if (hasLocalName(child.name, localName)) return child;
185
192
  }
186
193
  return null;
187
194
  }
@@ -193,13 +200,12 @@ function findChild(parent, namespace, localName) {
193
200
  * @param localName - Local element name
194
201
  * @returns Array of matching children
195
202
  */
196
- function findChildren(parent, namespace, localName) {
203
+ function findChildren(parent, _namespace, localName) {
197
204
  if (!parent || !parent.elements) return [];
198
- const fullName = `${namespace}:${localName}`;
199
205
  const results = [];
200
206
  for (const child of parent.elements) {
201
207
  if (child.type !== "element") continue;
202
- if (child.name === fullName || getLocalName(child.name || "") === localName) results.push(child);
208
+ if (hasLocalName(child.name, localName)) results.push(child);
203
209
  }
204
210
  return results;
205
211
  }
@@ -214,7 +220,7 @@ function findChildByLocalName(parent, localName) {
214
220
  if (!parent || !parent.elements) return null;
215
221
  for (const child of parent.elements) {
216
222
  if (child.type !== "element") continue;
217
- if (getLocalName(child.name || "") === localName) return child;
223
+ if (hasLocalName(child.name, localName)) return child;
218
224
  }
219
225
  return null;
220
226
  }
@@ -227,7 +233,9 @@ function findChildByLocalName(parent, localName) {
227
233
  */
228
234
  function findChildrenByLocalName(parent, localName) {
229
235
  if (!parent || !parent.elements) return [];
230
- return parent.elements.filter((child) => child.type === "element" && getLocalName(child.name || "") === localName);
236
+ const results = [];
237
+ for (const child of parent.elements) if (child.type === "element" && hasLocalName(child.name, localName)) results.push(child);
238
+ return results;
231
239
  }
232
240
  /**
233
241
  * Find first child element by full name (including namespace prefix)
@@ -252,7 +260,9 @@ function findByFullName(parent, fullName) {
252
260
  */
253
261
  function getChildElements(parent) {
254
262
  if (!parent || !parent.elements) return [];
255
- return parent.elements.filter((child) => child.type === "element");
263
+ const results = [];
264
+ for (const child of parent.elements) if (child.type === "element") results.push(child);
265
+ return results;
256
266
  }
257
267
  /**
258
268
  * Get an attribute value from an element
@@ -277,13 +287,13 @@ function getAttribute(element, namespace, name) {
277
287
  if (!element || !element.attributes) return null;
278
288
  const attrs = element.attributes;
279
289
  if (namespace) {
280
- const prefixedName = `${namespace}:${name}`;
281
- if (prefixedName in attrs) return attrs[prefixedName] ?? null;
290
+ const prefixedValue = attrs[`${namespace}:${name}`];
291
+ if (prefixedValue !== void 0) return prefixedValue;
282
292
  }
283
- if (name in attrs) return attrs[name] ?? null;
293
+ const unprefixedValue = attrs[name];
294
+ if (unprefixedValue !== void 0) return unprefixedValue;
284
295
  if (namespace) {
285
- const suffix = `:${name}`;
286
- for (const key of Object.keys(attrs)) if (key.endsWith(suffix)) return attrs[key] ?? null;
296
+ for (const key in attrs) if (hasLocalName(key, name)) return attrs[key] ?? null;
287
297
  }
288
298
  return null;
289
299
  }
@@ -312,8 +322,11 @@ function getAttributeAnyPrefix(element, localName) {
312
322
  if (canonical !== null) return canonical;
313
323
  const attrs = element.attributes;
314
324
  if (attrs) {
315
- const suffix = `:${localName}`;
316
- for (const [key, value] of Object.entries(attrs)) if (key === localName || key.endsWith(suffix)) return value;
325
+ for (const key in attrs) if (hasLocalName(key, localName)) {
326
+ const value = attrs[key];
327
+ if (value === void 0) return null;
328
+ return typeof value === "string" ? value : String(value);
329
+ }
317
330
  }
318
331
  return null;
319
332
  }
@@ -416,6 +429,17 @@ function parseNumericAttribute(element, namespace, name, scale = 1) {
416
429
  return num * scale;
417
430
  }
418
431
  /**
432
+ * Parse a zero-based numbering level reference.
433
+ *
434
+ * OOXML numbering levels cannot be negative. Some producers emit negative
435
+ * sentinel values alongside `w:numId="0"` to disable numbering; treat those
436
+ * as an omitted level instead of leaking an invalid value into the model.
437
+ */
438
+ function parseNumberingLevelAttribute(element) {
439
+ const level = parseNumericAttribute(element, "w", "val");
440
+ return level !== void 0 && level >= 0 ? level : void 0;
441
+ }
442
+ /**
419
443
  * Parse `w:w` on a table width/height element. For `w:type="pct"`, producers
420
444
  * sometimes emit human-readable percentages (`100%`) instead of 50ths-of-percent
421
445
  * (`5000`); normalize those to the ECMA-376 unit the layout engine expects.
@@ -519,9 +543,14 @@ function collectXmlnsDeclarations(element) {
519
543
  const out = {};
520
544
  const attrs = element.attributes;
521
545
  if (!attrs) return out;
522
- for (const [key, value] of Object.entries(attrs)) {
523
- if (Object.keys(out).length >= MAX_XMLNS_DECLARATIONS_PER_ELEMENT) break;
524
- if ((key === "xmlns" || key.startsWith("xmlns:")) && value !== void 0) out[key] = String(value);
546
+ let declarationCount = 0;
547
+ for (const key in attrs) {
548
+ if (declarationCount >= MAX_XMLNS_DECLARATIONS_PER_ELEMENT) break;
549
+ const value = attrs[key];
550
+ if ((key === "xmlns" || key.startsWith("xmlns:")) && value !== void 0) {
551
+ out[key] = String(value);
552
+ declarationCount += 1;
553
+ }
525
554
  }
526
555
  return out;
527
556
  }
@@ -535,26 +564,80 @@ function collectXmlnsDeclarations(element) {
535
564
  */
536
565
  function mergeXmlnsDeclarations(inherited, element) {
537
566
  const own = collectXmlnsDeclarations(element);
538
- if (Object.keys(own).length === 0) return inherited;
539
- return {
567
+ for (const _key in own) return {
540
568
  ...inherited,
541
569
  ...own
542
570
  };
571
+ return inherited;
543
572
  }
573
+ const QNAME_VALUE_ATTRIBUTES = /* @__PURE__ */ new Set([
574
+ "Ignorable",
575
+ "PreserveAttributes",
576
+ "PreserveElements",
577
+ "ProcessContent",
578
+ "Requires"
579
+ ]);
580
+ const addPrefix = (name, prefixes) => {
581
+ const separatorIndex = name.indexOf(":");
582
+ if (separatorIndex > 0) prefixes.add(name.slice(0, separatorIndex));
583
+ };
584
+ /**
585
+ * Collect namespace prefixes whose bindings a detached raw subtree needs.
586
+ *
587
+ * Element and attribute names use prefixes directly. Markup-compatibility and
588
+ * QName-valued attributes can also refer to prefixes in their values, so keep
589
+ * those bindings even when no descendant name uses them.
590
+ */
591
+ const collectUsedNamespacePrefixes = (element, prefixes = /* @__PURE__ */ new Set()) => {
592
+ if (element.name) if (element.name.includes(":")) addPrefix(element.name, prefixes);
593
+ else prefixes.add("");
594
+ if (element.attributes) for (const [name, value] of Object.entries(element.attributes)) {
595
+ if (name === "xmlns" || name.startsWith("xmlns:")) continue;
596
+ addPrefix(name, prefixes);
597
+ const localName = name.slice(name.indexOf(":") + 1);
598
+ if (name !== "xsi:type" && !QNAME_VALUE_ATTRIBUTES.has(localName)) continue;
599
+ for (const token of String(value).split(/\s+/u)) {
600
+ const separatorIndex = token.indexOf(":");
601
+ prefixes.add(separatorIndex > 0 ? token.slice(0, separatorIndex) : token);
602
+ }
603
+ }
604
+ if (element.elements) {
605
+ for (const child of element.elements) if (child.type === "element") collectUsedNamespacePrefixes(child, prefixes);
606
+ }
607
+ return prefixes;
608
+ };
609
+ const isCanonicalNamespacePrefix = (prefix) => Object.hasOwn(NAMESPACES, prefix);
544
610
  /**
545
- * Return a shallow clone of `element` whose attributes carry every declaration
546
- * in `xmlnsDecls`. Existing attributes (including any namespace declarations the
547
- * element already carries) win over the injected ones.
611
+ * Return a shallow clone of `element` carrying the inherited namespace
612
+ * declarations needed by its raw subtree.
613
+ *
614
+ * Existing declarations retain their authored order. Only missing, referenced
615
+ * bindings are appended, which makes repeated detach/replay cycles idempotent
616
+ * even when the surrounding document declares a different namespace superset.
617
+ * If a producer omitted a binding for a standard OOXML prefix, use its
618
+ * canonical binding so the detached subtree is valid on its first replay.
548
619
  */
549
620
  function cloneWithXmlnsDeclarations(element, xmlnsDecls) {
550
- if (Object.keys(xmlnsDecls).length === 0) return element;
551
- return {
621
+ const prefixes = collectUsedNamespacePrefixes(element);
622
+ const additions = {};
623
+ const attributes = element.attributes ?? {};
624
+ for (const [name, value] of Object.entries(xmlnsDecls)) {
625
+ const prefix = name === "xmlns" ? "" : name.slice(6);
626
+ if (prefixes.has(prefix) && attributes[name] === void 0) additions[name] = value;
627
+ }
628
+ for (const prefix of prefixes) {
629
+ const name = `xmlns:${prefix}`;
630
+ if (!prefix || attributes[name] !== void 0 || additions[name] !== void 0 || !isCanonicalNamespacePrefix(prefix)) continue;
631
+ additions[name] = NAMESPACES[prefix];
632
+ }
633
+ for (const _key in additions) return {
552
634
  ...element,
553
635
  attributes: {
554
- ...xmlnsDecls,
555
- ...element.attributes
636
+ ...attributes,
637
+ ...additions
556
638
  }
557
639
  };
640
+ return element;
558
641
  }
559
642
  //#endregion
560
- export { NAMESPACES, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findByFullName, findChild, findChildByLocalName, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumericAttribute, parseTableMeasurementValue, parseXml, parseXmlDocument };
643
+ export { NAMESPACES, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findByFullName, findChild, findChildByLocalName, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseTableMeasurementValue, parseXml, parseXmlDocument };