@stll/folio-core 0.0.1-placeholder.0 → 0.1.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 (683) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE.md +29 -0
  3. package/README.md +41 -0
  4. package/dist/_virtual/_rolldown/runtime.js +13 -0
  5. package/dist/ai-edits/apply.d.ts +35 -0
  6. package/dist/ai-edits/apply.js +683 -0
  7. package/dist/ai-edits/clean-text.d.ts +28 -0
  8. package/dist/ai-edits/clean-text.js +23 -0
  9. package/dist/ai-edits/headless.d.ts +225 -0
  10. package/dist/ai-edits/headless.js +513 -0
  11. package/dist/ai-edits/index.d.ts +6 -0
  12. package/dist/ai-edits/index.js +5 -0
  13. package/dist/ai-edits/inline-emphasis.d.ts +38 -0
  14. package/dist/ai-edits/inline-emphasis.js +78 -0
  15. package/dist/ai-edits/snapshot.d.ts +9 -0
  16. package/dist/ai-edits/snapshot.js +195 -0
  17. package/dist/ai-edits/types.d.ts +156 -0
  18. package/dist/ai-edits/types.js +0 -0
  19. package/dist/ai-edits/word-diff.d.ts +20 -0
  20. package/dist/ai-edits/word-diff.js +77 -0
  21. package/dist/ai-suggestions/apply.d.ts +17 -0
  22. package/dist/ai-suggestions/apply.js +64 -0
  23. package/dist/ai-suggestions/conflict.d.ts +22 -0
  24. package/dist/ai-suggestions/conflict.js +67 -0
  25. package/dist/ai-suggestions/text-positions.d.ts +21 -0
  26. package/dist/ai-suggestions/text-positions.js +48 -0
  27. package/dist/ai-suggestions/types.d.ts +199 -0
  28. package/dist/ai-suggestions/types.js +59 -0
  29. package/dist/content-controls/errors.d.ts +52 -0
  30. package/dist/content-controls/errors.js +36 -0
  31. package/dist/content-controls/findContentControls.d.ts +55 -0
  32. package/dist/content-controls/findContentControls.js +75 -0
  33. package/dist/content-controls/index.d.ts +4 -0
  34. package/dist/content-controls/index.js +4 -0
  35. package/dist/content-controls/mutateContentControls.d.ts +51 -0
  36. package/dist/content-controls/mutateContentControls.js +377 -0
  37. package/dist/controller/folioEditor.d.ts +21 -0
  38. package/dist/controller/folioEditor.js +29 -0
  39. package/dist/controller/folioEditorEvents.d.ts +23 -0
  40. package/dist/controller/folioEditorEvents.js +24 -0
  41. package/dist/controller/hiddenEditorApi.d.ts +35 -0
  42. package/dist/controller/hiddenEditorApi.js +112 -0
  43. package/dist/controller/hiddenEditorManager.d.ts +93 -0
  44. package/dist/controller/hiddenEditorManager.js +308 -0
  45. package/dist/controller/layoutPipeline.d.ts +63 -0
  46. package/dist/controller/layoutPipeline.js +406 -0
  47. package/dist/controller/layoutScheduler.d.ts +41 -0
  48. package/dist/controller/layoutScheduler.js +59 -0
  49. package/dist/controller/layoutSession.d.ts +24 -0
  50. package/dist/controller/layoutSession.js +13 -0
  51. package/dist/docx/blockContentParser.d.ts +13 -0
  52. package/dist/docx/blockContentParser.js +289 -0
  53. package/dist/docx/bookmarkParser.d.ts +178 -0
  54. package/dist/docx/bookmarkParser.js +246 -0
  55. package/dist/docx/bookmarkPlacement.d.ts +10 -0
  56. package/dist/docx/bookmarkPlacement.js +50 -0
  57. package/dist/docx/bulletMarkers.d.ts +4 -0
  58. package/dist/docx/bulletMarkers.js +42 -0
  59. package/dist/docx/commentParser.d.ts +34 -0
  60. package/dist/docx/commentParser.js +127 -0
  61. package/dist/docx/commentReferenceNormalization.d.ts +25 -0
  62. package/dist/docx/commentReferenceNormalization.js +97 -0
  63. package/dist/docx/commentReplyMarkers.d.ts +20 -0
  64. package/dist/docx/commentReplyMarkers.js +123 -0
  65. package/dist/docx/compatibility.d.ts +12 -0
  66. package/dist/docx/compatibility.js +77 -0
  67. package/dist/docx/documentParser.d.ts +65 -0
  68. package/dist/docx/documentParser.js +209 -0
  69. package/dist/docx/drawingUtils.d.ts +56 -0
  70. package/dist/docx/drawingUtils.js +305 -0
  71. package/dist/docx/fieldParser.d.ts +228 -0
  72. package/dist/docx/fieldParser.js +559 -0
  73. package/dist/docx/footnoteParser.d.ts +109 -0
  74. package/dist/docx/footnoteParser.js +270 -0
  75. package/dist/docx/headerFooterParser.d.ts +119 -0
  76. package/dist/docx/headerFooterParser.js +266 -0
  77. package/dist/docx/headerFooterRefParser.d.ts +22 -0
  78. package/dist/docx/headerFooterRefParser.js +52 -0
  79. package/dist/docx/headerFooterReferenceNormalization.d.ts +19 -0
  80. package/dist/docx/headerFooterReferenceNormalization.js +64 -0
  81. package/dist/docx/hyperlinkParser.d.ts +108 -0
  82. package/dist/docx/hyperlinkParser.js +230 -0
  83. package/dist/docx/imageParser.d.ts +93 -0
  84. package/dist/docx/imageParser.js +522 -0
  85. package/dist/docx/mathToMathml.d.ts +15 -0
  86. package/dist/docx/mathToMathml.js +357 -0
  87. package/dist/docx/modelValidation.d.ts +13 -0
  88. package/dist/docx/modelValidation.js +21 -0
  89. package/dist/docx/normalizeBaseDirection.d.ts +12 -0
  90. package/dist/docx/normalizeBaseDirection.js +81 -0
  91. package/dist/docx/notePropertiesParser.d.ts +16 -0
  92. package/dist/docx/notePropertiesParser.js +99 -0
  93. package/dist/docx/numberingParser.d.ts +86 -0
  94. package/dist/docx/numberingParser.js +735 -0
  95. package/dist/docx/numberingReferenceNormalization.d.ts +25 -0
  96. package/dist/docx/numberingReferenceNormalization.js +22 -0
  97. package/dist/docx/paragraphParser.d.ts +86 -0
  98. package/dist/docx/paragraphParser.js +1132 -0
  99. package/dist/docx/paragraphTraversal.d.ts +19 -0
  100. package/dist/docx/paragraphTraversal.js +76 -0
  101. package/dist/docx/parser.d.ts +67 -0
  102. package/dist/docx/parser.js +391 -0
  103. package/dist/docx/parserEnums.d.ts +45 -0
  104. package/dist/docx/parserEnums.js +70 -0
  105. package/dist/docx/relsParser.d.ts +160 -0
  106. package/dist/docx/relsParser.js +235 -0
  107. package/dist/docx/replyToComment.d.ts +29 -0
  108. package/dist/docx/replyToComment.js +73 -0
  109. package/dist/docx/rezip.d.ts +166 -0
  110. package/dist/docx/rezip.js +1194 -0
  111. package/dist/docx/runConsolidator.d.ts +57 -0
  112. package/dist/docx/runConsolidator.js +224 -0
  113. package/dist/docx/runParser.d.ts +78 -0
  114. package/dist/docx/runParser.js +661 -0
  115. package/dist/docx/sdtProperties.d.ts +15 -0
  116. package/dist/docx/sdtProperties.js +290 -0
  117. package/dist/docx/sdtPropertiesPatch.d.ts +16 -0
  118. package/dist/docx/sdtPropertiesPatch.js +144 -0
  119. package/dist/docx/sectionParser.d.ts +95 -0
  120. package/dist/docx/sectionParser.js +534 -0
  121. package/dist/docx/selectiveSave.d.ts +25 -0
  122. package/dist/docx/selectiveSave.js +247 -0
  123. package/dist/docx/selectiveSaveFlags.d.ts +33 -0
  124. package/dist/docx/selectiveSaveFlags.js +11 -0
  125. package/dist/docx/selectiveSaveTripwire.d.ts +33 -0
  126. package/dist/docx/selectiveSaveTripwire.js +79 -0
  127. package/dist/docx/selectiveXmlPatch.d.ts +103 -0
  128. package/dist/docx/selectiveXmlPatch.js +493 -0
  129. package/dist/docx/serializer/blockSdtSerializer.d.ts +6 -0
  130. package/dist/docx/serializer/blockSdtSerializer.js +88 -0
  131. package/dist/docx/serializer/borderSerializer.d.ts +25 -0
  132. package/dist/docx/serializer/borderSerializer.js +44 -0
  133. package/dist/docx/serializer/commentSerializer.d.ts +31 -0
  134. package/dist/docx/serializer/commentSerializer.js +184 -0
  135. package/dist/docx/serializer/documentSerializer.d.ts +65 -0
  136. package/dist/docx/serializer/documentSerializer.js +199 -0
  137. package/dist/docx/serializer/headerFooterSerializer.d.ts +12 -0
  138. package/dist/docx/serializer/headerFooterSerializer.js +84 -0
  139. package/dist/docx/serializer/noteSerializer.d.ts +19 -0
  140. package/dist/docx/serializer/noteSerializer.js +70 -0
  141. package/dist/docx/serializer/numberingSerializer.d.ts +12 -0
  142. package/dist/docx/serializer/numberingSerializer.js +93 -0
  143. package/dist/docx/serializer/paragraphSerializer.d.ts +48 -0
  144. package/dist/docx/serializer/paragraphSerializer.js +559 -0
  145. package/dist/docx/serializer/runSerializer.d.ts +56 -0
  146. package/dist/docx/serializer/runSerializer.js +621 -0
  147. package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +6 -0
  148. package/dist/docx/serializer/sectionPropertiesSerializer.js +187 -0
  149. package/dist/docx/serializer/tableSerializer.d.ts +79 -0
  150. package/dist/docx/serializer/tableSerializer.js +422 -0
  151. package/dist/docx/serializer/xmlUtils.d.ts +20 -0
  152. package/dist/docx/serializer/xmlUtils.js +25 -0
  153. package/dist/docx/settingsParser.d.ts +8 -0
  154. package/dist/docx/settingsParser.js +36 -0
  155. package/dist/docx/shapeParser.d.ts +20 -0
  156. package/dist/docx/shapeParser.js +272 -0
  157. package/dist/docx/styleParser.d.ts +50 -0
  158. package/dist/docx/styleParser.js +905 -0
  159. package/dist/docx/tableParser.d.ts +202 -0
  160. package/dist/docx/tableParser.js +811 -0
  161. package/dist/docx/textBoxParser.d.ts +117 -0
  162. package/dist/docx/textBoxParser.js +262 -0
  163. package/dist/docx/themeParser.d.ts +77 -0
  164. package/dist/docx/themeParser.js +330 -0
  165. package/dist/docx/trackedMoveRangeNormalization.d.ts +22 -0
  166. package/dist/docx/trackedMoveRangeNormalization.js +100 -0
  167. package/dist/docx/unzip.d.ts +118 -0
  168. package/dist/docx/unzip.js +383 -0
  169. package/dist/docx/vmlImageParser.d.ts +16 -0
  170. package/dist/docx/vmlImageParser.js +100 -0
  171. package/dist/docx/watermarkParser.d.ts +45 -0
  172. package/dist/docx/watermarkParser.js +348 -0
  173. package/dist/docx/wrapTypes.d.ts +29 -0
  174. package/dist/docx/wrapTypes.js +48 -0
  175. package/dist/docx/xmlParser.d.ts +297 -0
  176. package/dist/docx/xmlParser.js +527 -0
  177. package/dist/fields/bookmarkPages.d.ts +13 -0
  178. package/dist/fields/bookmarkPages.js +66 -0
  179. package/dist/fields/bookmarkText.d.ts +16 -0
  180. package/dist/fields/bookmarkText.js +61 -0
  181. package/dist/fields/evaluateField.d.ts +23 -0
  182. package/dist/fields/evaluateField.js +77 -0
  183. package/dist/fields/fieldContext.d.ts +21 -0
  184. package/dist/fields/fieldContext.js +0 -0
  185. package/dist/fields/resolveFieldValues.d.ts +44 -0
  186. package/dist/fields/resolveFieldValues.js +204 -0
  187. package/dist/fields/sectionPageCounts.d.ts +11 -0
  188. package/dist/fields/sectionPageCounts.js +16 -0
  189. package/dist/fields/seqValues.d.ts +14 -0
  190. package/dist/fields/seqValues.js +36 -0
  191. package/dist/fonts/embeddedFontTable.d.ts +42 -0
  192. package/dist/fonts/embeddedFontTable.js +80 -0
  193. package/dist/fonts/embeddedFonts.d.ts +46 -0
  194. package/dist/fonts/embeddedFonts.js +112 -0
  195. package/dist/fonts/fontDeobfuscation.d.ts +30 -0
  196. package/dist/fonts/fontDeobfuscation.js +57 -0
  197. package/dist/index.d.ts +28 -0
  198. package/dist/index.js +23 -0
  199. package/dist/layout-bridge/convert/footnoteLayout.d.ts +57 -0
  200. package/dist/layout-bridge/convert/footnoteLayout.js +316 -0
  201. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +74 -0
  202. package/dist/layout-bridge/convert/headerFooterLayout.js +432 -0
  203. package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +36 -0
  204. package/dist/layout-bridge/convert/templatePreviewFlow.js +176 -0
  205. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +65 -0
  206. package/dist/layout-bridge/convert/toFlowBlocks.js +1309 -0
  207. package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +17 -0
  208. package/dist/layout-bridge/convert/wrapEditorViewAsSurface.js +36 -0
  209. package/dist/layout-bridge/dom/clickToPositionDom.d.ts +66 -0
  210. package/dist/layout-bridge/dom/clickToPositionDom.js +304 -0
  211. package/dist/layout-bridge/dom/findBodyPmSpans.d.ts +7 -0
  212. package/dist/layout-bridge/dom/findBodyPmSpans.js +17 -0
  213. package/dist/layout-bridge/dom/findHfPmSpans.d.ts +62 -0
  214. package/dist/layout-bridge/dom/findHfPmSpans.js +197 -0
  215. package/dist/layout-bridge/engine/clickToPosition.d.ts +66 -0
  216. package/dist/layout-bridge/engine/clickToPosition.js +403 -0
  217. package/dist/layout-bridge/engine/hitTest.d.ts +135 -0
  218. package/dist/layout-bridge/engine/hitTest.js +375 -0
  219. package/dist/layout-bridge/engine/measuring/index.d.ts +10 -0
  220. package/dist/layout-bridge/engine/measuring/index.js +9 -0
  221. package/dist/layout-bridge/engine/selectionRects.d.ts +59 -0
  222. package/dist/layout-bridge/engine/selectionRects.js +485 -0
  223. package/dist/layout-bridge/engine/tableWidthUtils.d.ts +7 -0
  224. package/dist/layout-bridge/engine/tableWidthUtils.js +25 -0
  225. package/dist/layout-engine/index.d.ts +44 -0
  226. package/dist/layout-engine/index.js +691 -0
  227. package/dist/layout-engine/keep-together.d.ts +43 -0
  228. package/dist/layout-engine/keep-together.js +98 -0
  229. package/dist/layout-engine/layoutInstrumentation.d.ts +50 -0
  230. package/dist/layout-engine/layoutInstrumentation.js +43 -0
  231. package/dist/layout-engine/lineFlow.d.ts +8 -0
  232. package/dist/layout-engine/lineFlow.js +17 -0
  233. package/dist/layout-engine/measure/cache.d.ts +93 -0
  234. package/dist/layout-engine/measure/cache.js +245 -0
  235. package/dist/layout-engine/measure/clampFloatingWrapMargins.d.ts +20 -0
  236. package/dist/layout-engine/measure/clampFloatingWrapMargins.js +29 -0
  237. package/dist/layout-engine/measure/featureFlags.d.ts +44 -0
  238. package/dist/layout-engine/measure/featureFlags.js +19 -0
  239. package/dist/layout-engine/measure/floatingZones.d.ts +89 -0
  240. package/dist/layout-engine/measure/floatingZones.js +152 -0
  241. package/dist/layout-engine/measure/font-metrics.worker.d.ts +17 -0
  242. package/dist/layout-engine/measure/font-metrics.worker.js +104 -0
  243. package/dist/layout-engine/measure/index.d.ts +9 -0
  244. package/dist/layout-engine/measure/index.js +8 -0
  245. package/dist/layout-engine/measure/listMarkerWidth.d.ts +40 -0
  246. package/dist/layout-engine/measure/listMarkerWidth.js +76 -0
  247. package/dist/layout-engine/measure/measureBlocks.d.ts +25 -0
  248. package/dist/layout-engine/measure/measureBlocks.js +450 -0
  249. package/dist/layout-engine/measure/measureContainer.d.ts +24 -0
  250. package/dist/layout-engine/measure/measureContainer.js +280 -0
  251. package/dist/layout-engine/measure/measureHelpers.d.ts +82 -0
  252. package/dist/layout-engine/measure/measureHelpers.js +156 -0
  253. package/dist/layout-engine/measure/measureParagraph.d.ts +61 -0
  254. package/dist/layout-engine/measure/measureParagraph.js +724 -0
  255. package/dist/layout-engine/measure/measureProvider.d.ts +23 -0
  256. package/dist/layout-engine/measure/measureProvider.js +35 -0
  257. package/dist/layout-engine/measure/measureTypes.d.ts +61 -0
  258. package/dist/layout-engine/measure/measureTypes.js +0 -0
  259. package/dist/layout-engine/measure/measureWorker.d.ts +54 -0
  260. package/dist/layout-engine/measure/measureWorker.js +249 -0
  261. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +88 -0
  262. package/dist/layout-engine/measure/measureWorkerProtocol.js +20 -0
  263. package/dist/layout-engine/measure/tableCellFloating.d.ts +26 -0
  264. package/dist/layout-engine/measure/tableCellFloating.js +99 -0
  265. package/dist/layout-engine/paginator.d.ts +84 -0
  266. package/dist/layout-engine/paginator.js +348 -0
  267. package/dist/layout-engine/paragraphFragmentRange.d.ts +9 -0
  268. package/dist/layout-engine/paragraphFragmentRange.js +40 -0
  269. package/dist/layout-engine/section-breaks.d.ts +78 -0
  270. package/dist/layout-engine/section-breaks.js +182 -0
  271. package/dist/layout-engine/tableRowBreak.d.ts +23 -0
  272. package/dist/layout-engine/tableRowBreak.js +147 -0
  273. package/dist/layout-engine/textBoxFlow.d.ts +50 -0
  274. package/dist/layout-engine/textBoxFlow.js +160 -0
  275. package/dist/layout-engine/types.d.ts +1031 -0
  276. package/dist/layout-engine/types.js +100 -0
  277. package/dist/layout-painter/documentColors.d.ts +4 -0
  278. package/dist/layout-painter/documentColors.js +40 -0
  279. package/dist/layout-painter/index.d.ts +110 -0
  280. package/dist/layout-painter/index.js +182 -0
  281. package/dist/layout-painter/registry/modules/image.d.ts +6 -0
  282. package/dist/layout-painter/registry/modules/image.js +17 -0
  283. package/dist/layout-painter/registry/modules/paragraph.d.ts +6 -0
  284. package/dist/layout-painter/registry/modules/paragraph.js +18 -0
  285. package/dist/layout-painter/registry/modules/table.d.ts +6 -0
  286. package/dist/layout-painter/registry/modules/table.js +16 -0
  287. package/dist/layout-painter/registry/modules/textBox.d.ts +6 -0
  288. package/dist/layout-painter/registry/modules/textBox.js +13 -0
  289. package/dist/layout-painter/registry/modules.d.ts +6 -0
  290. package/dist/layout-painter/registry/modules.js +26 -0
  291. package/dist/layout-painter/registry/registry.d.ts +24 -0
  292. package/dist/layout-painter/registry/registry.js +53 -0
  293. package/dist/layout-painter/registry/types.d.ts +61 -0
  294. package/dist/layout-painter/registry/types.js +0 -0
  295. package/dist/layout-painter/renderFragment.d.ts +32 -0
  296. package/dist/layout-painter/renderFragment.js +114 -0
  297. package/dist/layout-painter/renderImage.d.ts +88 -0
  298. package/dist/layout-painter/renderImage.js +130 -0
  299. package/dist/layout-painter/renderPage.d.ts +264 -0
  300. package/dist/layout-painter/renderPage.js +1795 -0
  301. package/dist/layout-painter/renderParagraph.d.ts +93 -0
  302. package/dist/layout-painter/renderParagraph.js +1300 -0
  303. package/dist/layout-painter/renderTable.d.ts +36 -0
  304. package/dist/layout-painter/renderTable.js +432 -0
  305. package/dist/layout-painter/renderTextBox.d.ts +22 -0
  306. package/dist/layout-painter/renderTextBox.js +67 -0
  307. package/dist/layout-painter/renderUtils.d.ts +42 -0
  308. package/dist/layout-painter/renderUtils.js +30 -0
  309. package/dist/layout-painter/renderWatermark.d.ts +16 -0
  310. package/dist/layout-painter/renderWatermark.js +61 -0
  311. package/dist/layout-painter/sdtBoundary.d.ts +6 -0
  312. package/dist/layout-painter/sdtBoundary.js +28 -0
  313. package/dist/managers/ContextMenuManager.d.ts +28 -0
  314. package/dist/managers/ContextMenuManager.js +48 -0
  315. package/dist/managers/DocumentLoaderManager.d.ts +47 -0
  316. package/dist/managers/DocumentLoaderManager.js +69 -0
  317. package/dist/managers/EditorModeManager.d.ts +28 -0
  318. package/dist/managers/EditorModeManager.js +50 -0
  319. package/dist/managers/ErrorManager.d.ts +26 -0
  320. package/dist/managers/ErrorManager.js +85 -0
  321. package/dist/managers/FindReplaceManager.d.ts +54 -0
  322. package/dist/managers/FindReplaceManager.js +104 -0
  323. package/dist/managers/HistoryManager.d.ts +92 -0
  324. package/dist/managers/HistoryManager.js +193 -0
  325. package/dist/managers/Subscribable.d.ts +34 -0
  326. package/dist/managers/Subscribable.js +46 -0
  327. package/dist/managers/TableSelectionManager.d.ts +74 -0
  328. package/dist/managers/TableSelectionManager.js +225 -0
  329. package/dist/managers/editorShortcuts.d.ts +42 -0
  330. package/dist/managers/editorShortcuts.js +60 -0
  331. package/dist/managers/types.d.ts +41 -0
  332. package/dist/managers/types.js +0 -0
  333. package/dist/markdown/annotations.d.ts +14 -0
  334. package/dist/markdown/annotations.js +42 -0
  335. package/dist/markdown/escape.d.ts +36 -0
  336. package/dist/markdown/escape.js +59 -0
  337. package/dist/markdown/fromMarkdown.d.ts +11 -0
  338. package/dist/markdown/fromMarkdown.js +223 -0
  339. package/dist/markdown/headings.d.ts +13 -0
  340. package/dist/markdown/headings.js +20 -0
  341. package/dist/markdown/images.d.ts +13 -0
  342. package/dist/markdown/images.js +63 -0
  343. package/dist/markdown/index.d.ts +18 -0
  344. package/dist/markdown/index.js +33 -0
  345. package/dist/markdown/internals.d.ts +15 -0
  346. package/dist/markdown/internals.js +35 -0
  347. package/dist/markdown/renderBlock.d.ts +7 -0
  348. package/dist/markdown/renderBlock.js +68 -0
  349. package/dist/markdown/renderParagraph.d.ts +11 -0
  350. package/dist/markdown/renderParagraph.js +64 -0
  351. package/dist/markdown/renderRuns.d.ts +11 -0
  352. package/dist/markdown/renderRuns.js +265 -0
  353. package/dist/markdown/renderTable.d.ts +8 -0
  354. package/dist/markdown/renderTable.js +229 -0
  355. package/dist/markdown/trailers.d.ts +13 -0
  356. package/dist/markdown/trailers.js +54 -0
  357. package/dist/markdown/types.d.ts +118 -0
  358. package/dist/markdown/types.js +0 -0
  359. package/dist/model.d.ts +13 -0
  360. package/dist/model.js +4 -0
  361. package/dist/paged-layout/LayoutSelectionGate.d.ts +80 -0
  362. package/dist/paged-layout/LayoutSelectionGate.js +131 -0
  363. package/dist/paged-layout/headerFooterMargins.d.ts +73 -0
  364. package/dist/paged-layout/headerFooterMargins.js +120 -0
  365. package/dist/paged-layout/hiddenEditorScroll.d.ts +4 -0
  366. package/dist/paged-layout/hiddenEditorScroll.js +4 -0
  367. package/dist/paged-layout/incrementalMeasure.d.ts +33 -0
  368. package/dist/paged-layout/incrementalMeasure.js +56 -0
  369. package/dist/paged-layout/rangeProjection.d.ts +51 -0
  370. package/dist/paged-layout/rangeProjection.js +153 -0
  371. package/dist/paged-layout/readOnlyEditAttempt.d.ts +5 -0
  372. package/dist/paged-layout/readOnlyEditAttempt.js +22 -0
  373. package/dist/paged-layout/scrollNavigation.d.ts +23 -0
  374. package/dist/paged-layout/scrollNavigation.js +31 -0
  375. package/dist/paged-layout/scrollPageInfo.d.ts +41 -0
  376. package/dist/paged-layout/scrollPageInfo.js +34 -0
  377. package/dist/paged-layout/scrollToPmPosition.d.ts +17 -0
  378. package/dist/paged-layout/scrollToPmPosition.js +95 -0
  379. package/dist/paged-layout/sectionBlockWidths.d.ts +35 -0
  380. package/dist/paged-layout/sectionBlockWidths.js +52 -0
  381. package/dist/paged-layout/sectionGeometry.d.ts +21 -0
  382. package/dist/paged-layout/sectionGeometry.js +36 -0
  383. package/dist/paged-layout/selectionViewportRect.d.ts +29 -0
  384. package/dist/paged-layout/selectionViewportRect.js +55 -0
  385. package/dist/paged-layout/tableColumnResize.d.ts +19 -0
  386. package/dist/paged-layout/tableColumnResize.js +28 -0
  387. package/dist/paged-layout/tableInsertButtonGeometry.d.ts +15 -0
  388. package/dist/paged-layout/tableInsertButtonGeometry.js +15 -0
  389. package/dist/paged-layout/transactionDirtyRange.d.ts +7 -0
  390. package/dist/paged-layout/transactionDirtyRange.js +27 -0
  391. package/dist/paged-layout/zoomScrollAnchor.d.ts +40 -0
  392. package/dist/paged-layout/zoomScrollAnchor.js +25 -0
  393. package/dist/prosemirror/attrs/index.d.ts +80 -0
  394. package/dist/prosemirror/attrs/index.js +1218 -0
  395. package/dist/prosemirror/autospacingBase.d.ts +11 -0
  396. package/dist/prosemirror/autospacingBase.js +16 -0
  397. package/dist/prosemirror/commands/comments.d.ts +93 -0
  398. package/dist/prosemirror/commands/comments.js +435 -0
  399. package/dist/prosemirror/commands/contentControls.d.ts +45 -0
  400. package/dist/prosemirror/commands/contentControls.js +294 -0
  401. package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +15 -0
  402. package/dist/prosemirror/commands/contentControlsBlockFill.js +19 -0
  403. package/dist/prosemirror/commands/formatPainter.d.ts +31 -0
  404. package/dist/prosemirror/commands/formatPainter.js +130 -0
  405. package/dist/prosemirror/commands/formatting.d.ts +32 -0
  406. package/dist/prosemirror/commands/formatting.js +45 -0
  407. package/dist/prosemirror/commands/hyperlink.d.ts +31 -0
  408. package/dist/prosemirror/commands/hyperlink.js +79 -0
  409. package/dist/prosemirror/commands/image.d.ts +59 -0
  410. package/dist/prosemirror/commands/image.js +219 -0
  411. package/dist/prosemirror/commands/index.d.ts +13 -0
  412. package/dist/prosemirror/commands/index.js +13 -0
  413. package/dist/prosemirror/commands/pageBreak.d.ts +10 -0
  414. package/dist/prosemirror/commands/pageBreak.js +47 -0
  415. package/dist/prosemirror/commands/paragraph.d.ts +39 -0
  416. package/dist/prosemirror/commands/paragraph.js +64 -0
  417. package/dist/prosemirror/commands/pastePlainText.d.ts +39 -0
  418. package/dist/prosemirror/commands/pastePlainText.js +67 -0
  419. package/dist/prosemirror/commands/table.d.ts +83 -0
  420. package/dist/prosemirror/commands/table.js +105 -0
  421. package/dist/prosemirror/conversion/fromProseDoc.d.ts +27 -0
  422. package/dist/prosemirror/conversion/fromProseDoc.js +1550 -0
  423. package/dist/prosemirror/conversion/index.d.ts +4 -0
  424. package/dist/prosemirror/conversion/index.js +4 -0
  425. package/dist/prosemirror/conversion/runShadingMark.d.ts +16 -0
  426. package/dist/prosemirror/conversion/runShadingMark.js +39 -0
  427. package/dist/prosemirror/conversion/toProseDoc.d.ts +39 -0
  428. package/dist/prosemirror/conversion/toProseDoc.js +1404 -0
  429. package/dist/prosemirror/extensions/ExtensionManager.d.ts +43 -0
  430. package/dist/prosemirror/extensions/ExtensionManager.js +86 -0
  431. package/dist/prosemirror/extensions/StarterKit.d.ts +16 -0
  432. package/dist/prosemirror/extensions/StarterKit.js +132 -0
  433. package/dist/prosemirror/extensions/core/DocExtension.d.ts +9 -0
  434. package/dist/prosemirror/extensions/core/DocExtension.js +12 -0
  435. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +13 -0
  436. package/dist/prosemirror/extensions/core/HistoryExtension.js +28 -0
  437. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +25 -0
  438. package/dist/prosemirror/extensions/core/ParagraphExtension.js +619 -0
  439. package/dist/prosemirror/extensions/core/TextExtension.d.ts +9 -0
  440. package/dist/prosemirror/extensions/core/TextExtension.js +12 -0
  441. package/dist/prosemirror/extensions/create.d.ts +17 -0
  442. package/dist/prosemirror/extensions/create.js +129 -0
  443. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +23 -0
  444. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +106 -0
  445. package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +8 -0
  446. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +172 -0
  447. package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +16 -0
  448. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +38 -0
  449. package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +16 -0
  450. package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +21 -0
  451. package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +12 -0
  452. package/dist/prosemirror/extensions/features/DropCursorExtension.js +20 -0
  453. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -0
  454. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +44 -0
  455. package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +19 -0
  456. package/dist/prosemirror/extensions/features/GapCursorExtension.js +24 -0
  457. package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +15 -0
  458. package/dist/prosemirror/extensions/features/ImageDragExtension.js +66 -0
  459. package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +12 -0
  460. package/dist/prosemirror/extensions/features/ImagePasteExtension.js +91 -0
  461. package/dist/prosemirror/extensions/features/ListExtension.d.ts +14 -0
  462. package/dist/prosemirror/extensions/features/ListExtension.js +340 -0
  463. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -0
  464. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +60 -0
  465. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +35 -0
  466. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +188 -0
  467. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +20 -0
  468. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +34 -0
  469. package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +20 -0
  470. package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +145 -0
  471. package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +10 -0
  472. package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +17 -0
  473. package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +31 -0
  474. package/dist/prosemirror/extensions/features/bidiShortcutController.js +27 -0
  475. package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +31 -0
  476. package/dist/prosemirror/extensions/features/pasteCleanup.js +159 -0
  477. package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +9 -0
  478. package/dist/prosemirror/extensions/marks/AllCapsExtension.js +24 -0
  479. package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +9 -0
  480. package/dist/prosemirror/extensions/marks/BoldExtension.js +41 -0
  481. package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +14 -0
  482. package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +64 -0
  483. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +23 -0
  484. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +47 -0
  485. package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +12 -0
  486. package/dist/prosemirror/extensions/marks/CommentExtension.js +38 -0
  487. package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +9 -0
  488. package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +55 -0
  489. package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +9 -0
  490. package/dist/prosemirror/extensions/marks/FontSizeExtension.js +47 -0
  491. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +11 -0
  492. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +92 -0
  493. package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +23 -0
  494. package/dist/prosemirror/extensions/marks/HiddenTextExtension.js +35 -0
  495. package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +10 -0
  496. package/dist/prosemirror/extensions/marks/HighlightExtension.js +115 -0
  497. package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +13 -0
  498. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +146 -0
  499. package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +9 -0
  500. package/dist/prosemirror/extensions/marks/ItalicExtension.js +34 -0
  501. package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +6 -0
  502. package/dist/prosemirror/extensions/marks/RtlExtension.js +21 -0
  503. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -0
  504. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +75 -0
  505. package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +6 -0
  506. package/dist/prosemirror/extensions/marks/RunShadingExtension.js +38 -0
  507. package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +9 -0
  508. package/dist/prosemirror/extensions/marks/SmallCapsExtension.js +24 -0
  509. package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +9 -0
  510. package/dist/prosemirror/extensions/marks/StrikeExtension.js +33 -0
  511. package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +9 -0
  512. package/dist/prosemirror/extensions/marks/SubscriptExtension.js +25 -0
  513. package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +9 -0
  514. package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +25 -0
  515. package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +9 -0
  516. package/dist/prosemirror/extensions/marks/TextColorExtension.js +50 -0
  517. package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +6 -0
  518. package/dist/prosemirror/extensions/marks/TextEffectExtension.js +35 -0
  519. package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +31 -0
  520. package/dist/prosemirror/extensions/marks/TextEffectsExtensions.js +134 -0
  521. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +22 -0
  522. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +113 -0
  523. package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +9 -0
  524. package/dist/prosemirror/extensions/marks/UnderlineExtension.js +60 -0
  525. package/dist/prosemirror/extensions/marks/markUtils.d.ts +34 -0
  526. package/dist/prosemirror/extensions/marks/markUtils.js +233 -0
  527. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +22 -0
  528. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +122 -0
  529. package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +12 -0
  530. package/dist/prosemirror/extensions/nodes/FieldExtension.js +87 -0
  531. package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +9 -0
  532. package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +38 -0
  533. package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +9 -0
  534. package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.js +18 -0
  535. package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +9 -0
  536. package/dist/prosemirror/extensions/nodes/ImageExtension.js +132 -0
  537. package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +13 -0
  538. package/dist/prosemirror/extensions/nodes/MathExtension.js +56 -0
  539. package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +9 -0
  540. package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +20 -0
  541. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +12 -0
  542. package/dist/prosemirror/extensions/nodes/SdtExtension.js +107 -0
  543. package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +30 -0
  544. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +502 -0
  545. package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +9 -0
  546. package/dist/prosemirror/extensions/nodes/TabExtension.js +27 -0
  547. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +34 -0
  548. package/dist/prosemirror/extensions/nodes/TableExtension.js +1972 -0
  549. package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +34 -0
  550. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +150 -0
  551. package/dist/prosemirror/extensions/types.d.ts +101 -0
  552. package/dist/prosemirror/extensions/types.js +10 -0
  553. package/dist/prosemirror/findReplaceSelection.d.ts +23 -0
  554. package/dist/prosemirror/findReplaceSelection.js +86 -0
  555. package/dist/prosemirror/index.d.ts +25 -0
  556. package/dist/prosemirror/index.js +23 -0
  557. package/dist/prosemirror/insertOperations.d.ts +12 -0
  558. package/dist/prosemirror/insertOperations.js +19 -0
  559. package/dist/prosemirror/paragraphDirection.d.ts +42 -0
  560. package/dist/prosemirror/paragraphDirection.js +33 -0
  561. package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +40 -0
  562. package/dist/prosemirror/plugins/aiCitationDecorations.js +90 -0
  563. package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +42 -0
  564. package/dist/prosemirror/plugins/aiSuggestionDecorations.js +135 -0
  565. package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +60 -0
  566. package/dist/prosemirror/plugins/anonymizationDecorations.js +120 -0
  567. package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +123 -0
  568. package/dist/prosemirror/plugins/autocompleteSuggestion.js +283 -0
  569. package/dist/prosemirror/plugins/contentControlWidgets.d.ts +56 -0
  570. package/dist/prosemirror/plugins/contentControlWidgets.js +192 -0
  571. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +37 -0
  572. package/dist/prosemirror/plugins/createDocScanPlugin.js +55 -0
  573. package/dist/prosemirror/plugins/documentStyles.d.ts +18 -0
  574. package/dist/prosemirror/plugins/documentStyles.js +46 -0
  575. package/dist/prosemirror/plugins/index.d.ts +3 -0
  576. package/dist/prosemirror/plugins/index.js +3 -0
  577. package/dist/prosemirror/plugins/pmTextScan.d.ts +19 -0
  578. package/dist/prosemirror/plugins/pmTextScan.js +39 -0
  579. package/dist/prosemirror/plugins/selectionTracker.d.ts +43 -0
  580. package/dist/prosemirror/plugins/selectionTracker.js +179 -0
  581. package/dist/prosemirror/plugins/suggestionMode.d.ts +70 -0
  582. package/dist/prosemirror/plugins/suggestionMode.js +489 -0
  583. package/dist/prosemirror/plugins/templateDirectives.d.ts +25 -0
  584. package/dist/prosemirror/plugins/templateDirectives.js +67 -0
  585. package/dist/prosemirror/plugins/templatePreviewValues.d.ts +49 -0
  586. package/dist/prosemirror/plugins/templatePreviewValues.js +117 -0
  587. package/dist/prosemirror/plugins/templateSlashMenu.d.ts +57 -0
  588. package/dist/prosemirror/plugins/templateSlashMenu.js +184 -0
  589. package/dist/prosemirror/schema/index.d.ts +15 -0
  590. package/dist/prosemirror/schema/index.js +20 -0
  591. package/dist/prosemirror/schema/marks.d.ts +118 -0
  592. package/dist/prosemirror/schema/marks.js +0 -0
  593. package/dist/prosemirror/schema/nodes.d.ts +389 -0
  594. package/dist/prosemirror/schema/nodes.js +0 -0
  595. package/dist/prosemirror/selectionState.d.ts +23 -0
  596. package/dist/prosemirror/selectionState.js +111 -0
  597. package/dist/prosemirror/styles/index.d.ts +2 -0
  598. package/dist/prosemirror/styles/index.js +2 -0
  599. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +32 -0
  600. package/dist/prosemirror/styles/resolvedStyleAttrs.js +108 -0
  601. package/dist/prosemirror/styles/styleResolver.d.ts +94 -0
  602. package/dist/prosemirror/styles/styleResolver.js +200 -0
  603. package/dist/prosemirror/utils/findParagraphByParaId.d.ts +26 -0
  604. package/dist/prosemirror/utils/findParagraphByParaId.js +37 -0
  605. package/dist/prosemirror/utils/tabCalculator.d.ts +110 -0
  606. package/dist/prosemirror/utils/tabCalculator.js +137 -0
  607. package/dist/prosemirror/validation.d.ts +20 -0
  608. package/dist/prosemirror/validation.js +177 -0
  609. package/dist/server.d.ts +7 -0
  610. package/dist/server.js +6 -0
  611. package/dist/style-engine/index.d.ts +3 -0
  612. package/dist/style-engine/index.js +2 -0
  613. package/dist/style-engine/styleEngine.d.ts +67 -0
  614. package/dist/style-engine/styleEngine.js +70 -0
  615. package/dist/types/block-id.d.ts +58 -0
  616. package/dist/types/block-id.js +61 -0
  617. package/dist/types/colors.d.ts +2 -0
  618. package/dist/types/colors.js +0 -0
  619. package/dist/types/content.d.ts +2 -0
  620. package/dist/types/content.js +0 -0
  621. package/dist/types/document.d.ts +7 -0
  622. package/dist/types/document.js +0 -0
  623. package/dist/types/documentEnumValues.d.ts +89 -0
  624. package/dist/types/documentEnumValues.js +693 -0
  625. package/dist/types/formatting.d.ts +2 -0
  626. package/dist/types/formatting.js +0 -0
  627. package/dist/types/index.d.ts +107 -0
  628. package/dist/types/index.js +0 -0
  629. package/dist/utils/authorColors.d.ts +16 -0
  630. package/dist/utils/authorColors.js +30 -0
  631. package/dist/utils/baseDirection.d.ts +23 -0
  632. package/dist/utils/baseDirection.js +34 -0
  633. package/dist/utils/clipboard.d.ts +126 -0
  634. package/dist/utils/clipboard.js +622 -0
  635. package/dist/utils/colorResolver.d.ts +158 -0
  636. package/dist/utils/colorResolver.js +557 -0
  637. package/dist/utils/createDocument.d.ts +50 -0
  638. package/dist/utils/createDocument.js +262 -0
  639. package/dist/utils/documentLoaderBehavior.d.ts +22 -0
  640. package/dist/utils/documentLoaderBehavior.js +14 -0
  641. package/dist/utils/docxInput.d.ts +22 -0
  642. package/dist/utils/docxInput.js +16 -0
  643. package/dist/utils/domGuards.d.ts +59 -0
  644. package/dist/utils/domGuards.js +82 -0
  645. package/dist/utils/fontFamilyMerge.d.ts +7 -0
  646. package/dist/utils/fontFamilyMerge.js +31 -0
  647. package/dist/utils/fontLoader.d.ts +50 -0
  648. package/dist/utils/fontLoader.js +177 -0
  649. package/dist/utils/fontResolver.d.ts +61 -0
  650. package/dist/utils/fontResolver.js +651 -0
  651. package/dist/utils/fontWeights.d.ts +4 -0
  652. package/dist/utils/fontWeights.js +4 -0
  653. package/dist/utils/formatToStyle.d.ts +103 -0
  654. package/dist/utils/formatToStyle.js +289 -0
  655. package/dist/utils/headerFooter.d.ts +74 -0
  656. package/dist/utils/headerFooter.js +257 -0
  657. package/dist/utils/headingCollector.d.ts +22 -0
  658. package/dist/utils/headingCollector.js +36 -0
  659. package/dist/utils/hexId.d.ts +33 -0
  660. package/dist/utils/hexId.js +37 -0
  661. package/dist/utils/imageValidation.d.ts +5 -0
  662. package/dist/utils/imageValidation.js +31 -0
  663. package/dist/utils/paragraphFormattingMerge.d.ts +14 -0
  664. package/dist/utils/paragraphFormattingMerge.js +68 -0
  665. package/dist/utils/replaceText.d.ts +17 -0
  666. package/dist/utils/replaceText.js +161 -0
  667. package/dist/utils/rotationBoundingBox.d.ts +12 -0
  668. package/dist/utils/rotationBoundingBox.js +36 -0
  669. package/dist/utils/scriptSegments.d.ts +36 -0
  670. package/dist/utils/scriptSegments.js +52 -0
  671. package/dist/utils/tableOperations.d.ts +87 -0
  672. package/dist/utils/tableOperations.js +259 -0
  673. package/dist/utils/textFormattingMerge.d.ts +6 -0
  674. package/dist/utils/textFormattingMerge.js +31 -0
  675. package/dist/utils/tiffConverter.d.ts +18 -0
  676. package/dist/utils/tiffConverter.js +83 -0
  677. package/dist/utils/units.d.ts +99 -0
  678. package/dist/utils/units.js +139 -0
  679. package/dist/utils/urlSecurity.d.ts +7 -0
  680. package/dist/utils/urlSecurity.js +65 -0
  681. package/dist/watermark/index.d.ts +39 -0
  682. package/dist/watermark/index.js +149 -0
  683. package/package.json +122 -2
@@ -0,0 +1,1404 @@
1
+ import { emuToPixels } from "../../utils/units.js";
2
+ import { resolveColor } from "../../utils/colorResolver.js";
3
+ import { directionFromBidi } from "../paragraphDirection.js";
4
+ import { setAutospacingBaseValue } from "../autospacingBase.js";
5
+ import { shadingToRunShadingAttrs } from "./runShadingMark.js";
6
+ import { assertValidProseMirrorDocument } from "../validation.js";
7
+ import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
8
+ import { marksToTextFormatting } from "./fromProseDoc.js";
9
+ import { createStyleEngine } from "../../style-engine/styleEngine.js";
10
+ import { buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
11
+ import { schema } from "../schema/index.js";
12
+ //#region src/prosemirror/conversion/toProseDoc.ts
13
+ /**
14
+ * Convert a Document to a ProseMirror document
15
+ *
16
+ * @param document - The Document to convert
17
+ * @param options - Conversion options including style definitions
18
+ */
19
+ function toProseDoc(document, options) {
20
+ const paragraphs = document.package.document.content;
21
+ const nodes = [];
22
+ const styleResolver = createStyleEngine(options?.styles ?? document.package.styles);
23
+ const theme = options?.theme ?? document.package.theme ?? null;
24
+ let textBoxGroupIndex = 0;
25
+ const convertBodyBlocks = (blocks) => {
26
+ const out = [];
27
+ for (const block of blocks) if (block.type === "paragraph") {
28
+ const pbPos = paragraphPageBreakPosition(block);
29
+ if (pbPos === "before") out.push(schema.node("pageBreak"));
30
+ out.push(...convertParagraphWithTextBoxes(block, styleResolver, String(textBoxGroupIndex)));
31
+ textBoxGroupIndex += 1;
32
+ if (pbPos === "after") out.push(schema.node("pageBreak"));
33
+ } else if (block.type === "table") out.push(convertTable(block, styleResolver, theme));
34
+ else out.push(convertBlockSdt(block, convertBodyBlocks));
35
+ return out;
36
+ };
37
+ nodes.push(...convertBodyBlocks(paragraphs));
38
+ if (nodes.length === 0) nodes.push(schema.node("paragraph", {}, []));
39
+ const pmDoc = schema.node("doc", null, nodes);
40
+ assertValidProseMirrorDocument(pmDoc, "Document conversion produced an invalid ProseMirror document");
41
+ return pmDoc;
42
+ }
43
+ /**
44
+ * Convert a `BlockSdt` model node into a `blockSdt` PM node, recursively
45
+ * converting its children with the caller-supplied block converter. Pass
46
+ * `rawPropertiesXml` / `rawEndPropertiesXml` through as attrs so the
47
+ * serializer can replay them verbatim after a save.
48
+ */
49
+ function convertBlockSdt(blockSdt, convertBlocks) {
50
+ const props = blockSdt.properties;
51
+ const attrs = {
52
+ sdtType: props.sdtType,
53
+ alias: props.alias ?? null,
54
+ tag: props.tag ?? null,
55
+ id: props.id ?? null,
56
+ lock: props.lock ?? null,
57
+ placeholder: props.placeholder ?? null,
58
+ showingPlaceholder: props.showingPlaceholder ?? false,
59
+ dateFormat: props.dateFormat ?? null,
60
+ dateValueISO: props.dateValueISO ?? null,
61
+ listItems: props.listItems ? JSON.stringify(props.listItems) : null,
62
+ dropdownLastValue: props.dropdownLastValue ?? null,
63
+ checked: props.checked ?? null,
64
+ _originallyEmpty: blockSdt.content.length === 0,
65
+ rawPropertiesXml: props.rawPropertiesXml ?? null,
66
+ rawEndPropertiesXml: props.rawEndPropertiesXml ?? null,
67
+ rawSdtChildrenBeforeContent: props.rawSdtChildrenBeforeContent ?? null,
68
+ rawSdtChildrenAfterContent: props.rawSdtChildrenAfterContent ?? null
69
+ };
70
+ const children = convertBlocks(blockSdt.content);
71
+ if (children.length === 0) children.push(schema.node("paragraph", {}, []));
72
+ return schema.node("blockSdt", attrs, children);
73
+ }
74
+ /**
75
+ * Convert a Paragraph to a ProseMirror paragraph node
76
+ *
77
+ * Resolves style-based text formatting and passes it to runs so that
78
+ * paragraph styles (like Heading1) apply their font size, color, etc.
79
+ */
80
+ function convertParagraph(paragraph, styleResolver, activeCommentIds, extraRunFormatting) {
81
+ const attrs = paragraphFormattingToAttrs(paragraph, styleResolver);
82
+ const inlineNodes = [];
83
+ let inlineOffset = 0;
84
+ let bookmarksArr;
85
+ let emptyHyperlinks;
86
+ let hyperlinkIndex = 0;
87
+ const commentIds = activeCommentIds ?? /* @__PURE__ */ new Set();
88
+ const emitInlineNodes = (nodes) => {
89
+ if (nodes.length === 0) return;
90
+ const markedNodes = applyCommentMarks(nodes, commentIds);
91
+ inlineNodes.push(...markedNodes);
92
+ for (const node of markedNodes) inlineOffset += node.nodeSize;
93
+ };
94
+ const emitInlineNode = (node) => {
95
+ if (!node) return;
96
+ emitInlineNodes([node]);
97
+ };
98
+ let styleRunFormatting;
99
+ if (styleResolver) styleRunFormatting = styleResolver.resolveParagraphStyle(paragraph.formatting?.styleId).runFormatting;
100
+ const paragraphRunFormatting = paragraph.formatting?.runProperties ? resolveTextFormatting(paragraph.formatting.runProperties, styleResolver) : void 0;
101
+ const inheritableParagraphRunFormatting = paragraphRunFormatting ? stripParagraphMarkOnlyFormatting(paragraphRunFormatting) : void 0;
102
+ const baseRunFormatting = mergeTextFormatting(styleRunFormatting, extraRunFormatting);
103
+ const defaultRunFormatting = mergeTextFormatting(baseRunFormatting, inheritableParagraphRunFormatting);
104
+ const getInheritedRunFormatting = (formatting) => {
105
+ if (!hasDirectRunFormatting(formatting)) return defaultRunFormatting;
106
+ return suppressParagraphMarkFormatting(baseRunFormatting, inheritableParagraphRunFormatting, formatting);
107
+ };
108
+ const emitTrackedChange = (change, markType, moveKind) => {
109
+ emitInlineNodes(convertTrackedChange(change, markType, getInheritedRunFormatting, styleResolver, moveKind));
110
+ };
111
+ for (const content of paragraph.content) {
112
+ if (content.type === "commentRangeStart") commentIds.add(content.id);
113
+ else if (content.type === "commentRangeEnd") commentIds.delete(content.id);
114
+ else if (content.type === "commentReference") anchorPointComment(inlineNodes, content.id);
115
+ else if (content.type === "run") emitInlineNodes(convertRun(content, getInheritedRunFormatting(content.formatting), styleResolver));
116
+ else if (content.type === "hyperlink") {
117
+ const currentHyperlinkIndex = hyperlinkIndex;
118
+ hyperlinkIndex += 1;
119
+ const linkNodes = convertHyperlink(content, getInheritedRunFormatting, styleResolver, currentHyperlinkIndex);
120
+ if (linkNodes.length === 0) {
121
+ emptyHyperlinks ??= [];
122
+ emptyHyperlinks.push({
123
+ offset: inlineOffset,
124
+ ...content.href !== void 0 ? { href: content.href } : {},
125
+ ...content.anchor !== void 0 ? { anchor: content.anchor } : {},
126
+ ...content.tooltip !== void 0 ? { tooltip: content.tooltip } : {},
127
+ ...content.rId !== void 0 ? { rId: content.rId } : {}
128
+ });
129
+ continue;
130
+ }
131
+ emitInlineNodes(linkNodes);
132
+ } else if (content.type === "simpleField" || content.type === "complexField") emitInlineNode(convertField(content, getInheritedRunFormatting, styleResolver));
133
+ else if (content.type === "inlineSdt") emitInlineNode(convertInlineSdt(content, getInheritedRunFormatting, styleResolver));
134
+ else if (content.type === "insertion" || content.type === "moveTo") emitTrackedChange(content, "insertion", content.type === "moveTo" ? "moveTo" : null);
135
+ else if (content.type === "deletion" || content.type === "moveFrom") emitTrackedChange(content, "deletion", content.type === "moveFrom" ? "moveFrom" : null);
136
+ else if (content.type === "mathEquation") emitInlineNode(convertMathEquation(content));
137
+ if (content.type === "bookmarkStart") {
138
+ if (!bookmarksArr) bookmarksArr = [];
139
+ bookmarksArr.push({
140
+ id: content.id,
141
+ name: content.name
142
+ });
143
+ }
144
+ }
145
+ if (bookmarksArr) attrs.bookmarks = bookmarksArr;
146
+ if (emptyHyperlinks) attrs._emptyHyperlinks = emptyHyperlinks;
147
+ return schema.node("paragraph", attrs, inlineNodes);
148
+ }
149
+ /**
150
+ * Apply comment marks to PM nodes within a comment range.
151
+ * Only the first active comment ID is used (comments don't overlap visually).
152
+ */
153
+ function applyCommentMarks(nodes, commentIds) {
154
+ if (commentIds.size === 0) return nodes;
155
+ const commentId = [...commentIds][0];
156
+ const commentMark = schema.marks["comment"].create({ commentId });
157
+ return nodes.map((node) => {
158
+ if (node.isText || node.isInline && node.type.allowsMarkType(commentMark.type)) return node.mark(commentMark.addToSet(node.marks));
159
+ return node;
160
+ });
161
+ }
162
+ function anchorPointComment(nodes, commentId) {
163
+ const commentMark = schema.marks["comment"]?.create({ commentId });
164
+ if (!commentMark) return;
165
+ for (let index = nodes.length - 1; index >= 0; index--) {
166
+ const node = nodes[index];
167
+ if (!node?.isText) continue;
168
+ nodes[index] = node.mark(commentMark.addToSet(node.marks));
169
+ return;
170
+ }
171
+ }
172
+ /**
173
+ * Convert tracked change (insertion or deletion) content to PM nodes with
174
+ * an insertion/deletion mark applied.
175
+ */
176
+ function convertTrackedChange(change, markType, getInheritedRunFormatting, styleResolver, moveKind = null) {
177
+ const nodes = [];
178
+ let hyperlinkIndex = 0;
179
+ for (const item of change.content) if (item.type === "run") nodes.push(...convertRun(item, getInheritedRunFormatting(item.formatting), styleResolver));
180
+ else {
181
+ const currentHyperlinkIndex = hyperlinkIndex;
182
+ hyperlinkIndex += 1;
183
+ nodes.push(...convertHyperlink(item, getInheritedRunFormatting, styleResolver, currentHyperlinkIndex));
184
+ }
185
+ const mark = schema.marks[markType].create({
186
+ revisionId: change.info.id,
187
+ author: change.info.author,
188
+ date: change.info.date ?? null,
189
+ moveKind
190
+ });
191
+ return nodes.map((node) => {
192
+ if (canCarryTrackedRunMark(node, mark.type)) return node.mark(mark.addToSet(node.marks));
193
+ return node;
194
+ });
195
+ }
196
+ function canCarryTrackedRunMark(node, markType) {
197
+ return node.isText || node.isInline && node.type.allowsMarkType(markType) && (node.type.name === "image" || node.type.name === "shape" || node.type.name === "hardBreak" || node.type.name === "tab");
198
+ }
199
+ /**
200
+ * Convert ParagraphFormatting to ProseMirror paragraph attrs
201
+ *
202
+ * If a styleResolver is provided, resolves style-based formatting and merges
203
+ * with inline formatting. Inline formatting takes precedence.
204
+ */
205
+ function paragraphFormattingToAttrs(paragraph, styleResolver) {
206
+ const formatting = paragraph.formatting;
207
+ const styleId = formatting?.styleId;
208
+ const attrs = {};
209
+ if (paragraph.paraId) attrs.paraId = paragraph.paraId;
210
+ if (paragraph.textId) attrs.textId = paragraph.textId;
211
+ if (styleId) attrs.styleId = styleId;
212
+ if (formatting?.numPr) attrs.numPr = formatting.numPr;
213
+ if (formatting?.numPrFromStyle) attrs.numPrFromStyle = formatting.numPrFromStyle;
214
+ if (paragraph.listRendering?.numFmt) attrs.listNumFmt = paragraph.listRendering.numFmt;
215
+ if (paragraph.listRendering?.isBullet) attrs.listIsBullet = paragraph.listRendering.isBullet;
216
+ if (paragraph.listRendering?.isLegal) attrs.listIsLegal = paragraph.listRendering.isLegal;
217
+ if (paragraph.listRendering?.marker) attrs.listMarker = paragraph.listRendering.marker;
218
+ if (paragraph.listRendering?.markerHidden) attrs.listMarkerHidden = paragraph.listRendering.markerHidden;
219
+ if (paragraph.listRendering?.markerFontFamily) attrs.listMarkerFontFamily = paragraph.listRendering.markerFontFamily;
220
+ if (paragraph.listRendering?.markerFontSize) attrs.listMarkerFontSize = paragraph.listRendering.markerFontSize;
221
+ if (paragraph.listRendering?.markerSuffix) attrs.listMarkerSuffix = paragraph.listRendering.markerSuffix;
222
+ if (paragraph.listRendering?.markerAllCaps) attrs.listMarkerAllCaps = paragraph.listRendering.markerAllCaps;
223
+ if (paragraph.listRendering?.implicitChildLevelAdvances !== void 0) attrs.listImplicitChildLevelAdvances = paragraph.listRendering.implicitChildLevelAdvances;
224
+ if (paragraph.listRendering?.markerSecondSlotOffsetTwips !== void 0) attrs.listMarkerSecondSlotOffsetTwips = paragraph.listRendering.markerSecondSlotOffsetTwips;
225
+ if (paragraph.listRendering?.levelNumFmts) attrs.listLevelNumFmts = paragraph.listRendering.levelNumFmts;
226
+ if (paragraph.listRendering?.abstractNumId !== void 0) attrs.listAbstractNumId = paragraph.listRendering.abstractNumId;
227
+ if (paragraph.listRendering?.startOverride !== void 0) attrs.listStartOverride = paragraph.listRendering.startOverride;
228
+ if (formatting) attrs._originalFormatting = formatting;
229
+ if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = [...paragraph.propertyChanges];
230
+ if (paragraph.pPrMark) attrs.pPrMark = paragraph.pPrMark;
231
+ const set = (key, val) => {
232
+ if (val !== void 0) attrs[key] = val;
233
+ };
234
+ let stylePpr;
235
+ if (styleResolver) {
236
+ stylePpr = styleResolver.resolveParagraphStyle(styleId).paragraphFormatting;
237
+ set("alignment", formatting?.alignment ?? stylePpr?.alignment);
238
+ set("spaceBefore", formatting?.spaceBefore ?? stylePpr?.spaceBefore);
239
+ set("spaceAfter", formatting?.spaceAfter ?? stylePpr?.spaceAfter);
240
+ set("lineSpacing", formatting?.lineSpacing ?? stylePpr?.lineSpacing);
241
+ set("lineSpacingRule", formatting?.lineSpacingRule ?? stylePpr?.lineSpacingRule);
242
+ set("spacingExplicit", formatting?.spacingExplicit);
243
+ set("indentLeft", formatting?.indentLeft ?? stylePpr?.indentLeft);
244
+ set("indentRight", formatting?.indentRight ?? stylePpr?.indentRight);
245
+ const styleFirstLine = formatting?.numPr?.numId === 0 && stylePpr?.numPr !== void 0 && stylePpr.numPr.numId !== 0 ? void 0 : stylePpr;
246
+ set("indentFirstLine", formatting?.indentFirstLine ?? styleFirstLine?.indentFirstLine);
247
+ set("hangingIndent", formatting?.hangingIndent ?? styleFirstLine?.hangingIndent);
248
+ set("borders", formatting?.borders ?? stylePpr?.borders);
249
+ set("shading", formatting?.shading ?? stylePpr?.shading);
250
+ set("tabs", formatting?.tabs ?? stylePpr?.tabs);
251
+ set("pageBreakBefore", formatting?.pageBreakBefore ?? stylePpr?.pageBreakBefore);
252
+ set("keepNext", formatting?.keepNext ?? stylePpr?.keepNext);
253
+ set("keepLines", formatting?.keepLines ?? stylePpr?.keepLines);
254
+ set("contextualSpacing", formatting?.contextualSpacing ?? stylePpr?.contextualSpacing);
255
+ set("runInWithNext", formatting?.runInWithNext ?? stylePpr?.runInWithNext);
256
+ set("outlineLevel", formatting?.outlineLevel ?? stylePpr?.outlineLevel);
257
+ set("direction", directionFromBidi(formatting?.bidi ?? stylePpr?.bidi));
258
+ set("defaultTextFormatting", resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver));
259
+ if (!formatting?.numPr && stylePpr?.numPr && stylePpr.numPr.numId !== 0) {
260
+ attrs.numPr = stylePpr.numPr;
261
+ attrs.numPrFromStyle = stylePpr.numPr;
262
+ }
263
+ } else {
264
+ set("alignment", formatting?.alignment);
265
+ set("spaceBefore", formatting?.spaceBefore);
266
+ set("spaceAfter", formatting?.spaceAfter);
267
+ set("lineSpacing", formatting?.lineSpacing);
268
+ set("lineSpacingRule", formatting?.lineSpacingRule);
269
+ set("spacingExplicit", formatting?.spacingExplicit);
270
+ set("indentLeft", formatting?.indentLeft);
271
+ set("indentRight", formatting?.indentRight);
272
+ set("indentFirstLine", formatting?.indentFirstLine);
273
+ set("hangingIndent", formatting?.hangingIndent);
274
+ set("borders", formatting?.borders);
275
+ set("shading", formatting?.shading);
276
+ set("tabs", formatting?.tabs);
277
+ set("pageBreakBefore", formatting?.pageBreakBefore);
278
+ set("keepNext", formatting?.keepNext);
279
+ set("keepLines", formatting?.keepLines);
280
+ set("runInWithNext", formatting?.runInWithNext);
281
+ set("outlineLevel", formatting?.outlineLevel);
282
+ set("direction", directionFromBidi(formatting?.bidi));
283
+ set("defaultTextFormatting", resolveTextFormatting(formatting?.runProperties, styleResolver));
284
+ }
285
+ if (paragraph.sectionProperties) {
286
+ attrs._sectionProperties = paragraph.sectionProperties;
287
+ const st = paragraph.sectionProperties.sectionStart;
288
+ if (st === "nextPage" || st === "continuous" || st === "oddPage" || st === "evenPage") attrs.sectionBreakType = st;
289
+ }
290
+ if (paragraph.renderedPageBreakBefore) attrs.renderedPageBreakBefore = true;
291
+ const beforeAutospacing = formatting?.beforeAutospacing ?? stylePpr?.beforeAutospacing;
292
+ const afterAutospacing = formatting?.afterAutospacing ?? stylePpr?.afterAutospacing;
293
+ if (beforeAutospacing || afterAutospacing) {
294
+ const base = {};
295
+ if (beforeAutospacing) setAutospacingBaseValue(base, "before", attrs.spaceBefore);
296
+ if (afterAutospacing) setAutospacingBaseValue(base, "after", attrs.spaceAfter);
297
+ attrs._autospacingBase = base;
298
+ }
299
+ return attrs;
300
+ }
301
+ /**
302
+ * Resolve table style conditional formatting
303
+ */
304
+ function resolveTableStyleConditional(styleResolver, tableStyleId, conditionType) {
305
+ if (!styleResolver || !tableStyleId) return;
306
+ const style = styleResolver.getStyle(tableStyleId);
307
+ if (!style?.tblStylePr) return;
308
+ const conditional = style.tblStylePr.find((p) => p.type === conditionType);
309
+ if (!conditional) return;
310
+ const mergedRunProps = mergeTextFormatting(conditional.pPr?.runProperties ? resolveTextFormatting(conditional.pPr.runProperties, styleResolver) : void 0, conditional.rPr ? resolveTextFormatting(conditional.rPr, styleResolver) : void 0);
311
+ const result = {};
312
+ if (conditional.tcPr) result.tcPr = conditional.tcPr;
313
+ if (mergedRunProps) result.rPr = mergedRunProps;
314
+ return result;
315
+ }
316
+ function resolveTableBaseStyle(styleResolver, tableStyleId) {
317
+ if (!styleResolver || !tableStyleId) return;
318
+ const style = styleResolver.getStyle(tableStyleId);
319
+ if (!style) return;
320
+ const mergedRunProps = mergeTextFormatting(style.pPr?.runProperties ? resolveTextFormatting(style.pPr.runProperties, styleResolver) : void 0, style.rPr ? resolveTextFormatting(style.rPr, styleResolver) : void 0);
321
+ const result = {};
322
+ if (style.tcPr) result.tcPr = style.tcPr;
323
+ if (mergedRunProps) result.rPr = mergedRunProps;
324
+ return result.tcPr || result.rPr ? result : void 0;
325
+ }
326
+ function mergeConditionalStyles(base, override) {
327
+ if (!base && !override) return;
328
+ if (!base) return override;
329
+ if (!override) return base;
330
+ const merged = {};
331
+ const baseTcPr = base.tcPr;
332
+ const overrideTcPr = override.tcPr;
333
+ if (baseTcPr || overrideTcPr) {
334
+ const tcPr = {
335
+ ...baseTcPr,
336
+ ...overrideTcPr
337
+ };
338
+ if (baseTcPr?.borders || overrideTcPr?.borders) tcPr.borders = {
339
+ ...baseTcPr?.borders,
340
+ ...overrideTcPr?.borders
341
+ };
342
+ if (baseTcPr?.shading || overrideTcPr?.shading) tcPr.shading = {
343
+ ...baseTcPr?.shading,
344
+ ...overrideTcPr?.shading
345
+ };
346
+ if (baseTcPr?.margins || overrideTcPr?.margins) tcPr.margins = {
347
+ ...baseTcPr?.margins,
348
+ ...overrideTcPr?.margins
349
+ };
350
+ merged.tcPr = tcPr;
351
+ }
352
+ const mergedRPr = mergeTextFormatting(base.rPr, override.rPr);
353
+ if (mergedRPr) merged.rPr = mergedRPr;
354
+ return merged;
355
+ }
356
+ function hasDirectRunFormatting(formatting) {
357
+ if (!formatting) return false;
358
+ return Object.entries(formatting).some(([key, value]) => key !== "styleId" && value !== void 0);
359
+ }
360
+ function stripParagraphMarkOnlyFormatting(formatting) {
361
+ const { highlight: _h, shading: _s, ...rest } = formatting;
362
+ return Object.keys(rest).length > 0 ? rest : void 0;
363
+ }
364
+ function suppressParagraphMarkFormatting(base, paragraphMark, direct) {
365
+ if (!paragraphMark) return base;
366
+ const result = { ...base };
367
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "bold");
368
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "italic");
369
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "strike");
370
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "doubleStrike");
371
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "allCaps");
372
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "smallCaps");
373
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "hidden");
374
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "emboss");
375
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "imprint");
376
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "shadow");
377
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "outline");
378
+ suppressBooleanParagraphMark(result, paragraphMark, direct, "rtl");
379
+ if (paragraphMark.underline !== void 0 && direct?.underline === void 0) result.underline = { style: "none" };
380
+ return Object.keys(result).length > 0 ? result : void 0;
381
+ }
382
+ function suppressBooleanParagraphMark(result, paragraphMark, direct, key) {
383
+ if (paragraphMark[key] === void 0 || direct?.[key] !== void 0) return;
384
+ result[key] = false;
385
+ }
386
+ function resolveTextFormatting(formatting, styleResolver) {
387
+ if (!formatting) return styleResolver?.resolveRunStyle(null);
388
+ if (!styleResolver) return formatting;
389
+ return mergeTextFormatting(styleResolver.resolveRunStyle(formatting.styleId), formatting);
390
+ }
391
+ function resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver) {
392
+ const style = styleId ? styleResolver.getStyle(styleId) ?? styleResolver.getDefaultParagraphStyle() : styleResolver.getDefaultParagraphStyle();
393
+ const paragraphStyleRpr = style?.type === "paragraph" ? style.rPr : void 0;
394
+ const rawParagraphMarkRpr = formatting?.runProperties;
395
+ const characterStyleRpr = rawParagraphMarkRpr?.styleId !== void 0 ? styleResolver.getRunStyleOwnProperties(rawParagraphMarkRpr.styleId) : void 0;
396
+ const paragraphRunProperties = rawParagraphMarkRpr ? stripParagraphMarkOnlyFormatting(mergeTextFormatting(characterStyleRpr, rawParagraphMarkRpr) ?? {}) : void 0;
397
+ return mergeTextFormatting(mergeTextFormatting(mergeTextFormatting(styleResolver.getDocDefaults()?.rPr, styleResolver.getDefaultCharacterStyle()?.rPr), paragraphStyleRpr), paragraphRunProperties);
398
+ }
399
+ function calculateRowSpans(table) {
400
+ const result = /* @__PURE__ */ new Map();
401
+ const numRows = table.rows.length;
402
+ const activeMerges = /* @__PURE__ */ new Map();
403
+ for (let rowIndex = 0; rowIndex < numRows; rowIndex++) {
404
+ const row = table.rows[rowIndex];
405
+ if (row.cells.length === 0) {
406
+ clearActiveVerticalMerges(activeMerges, result);
407
+ continue;
408
+ }
409
+ let colIndex = 0;
410
+ const rowCells = row.cells.map((cell) => {
411
+ const colspan = cell.formatting?.gridSpan ?? 1;
412
+ const vMerge = cell.formatting?.vMerge;
413
+ const startRow = vMerge === "continue" ? activeMerges.get(colIndex) : void 0;
414
+ const info = {
415
+ cell,
416
+ colIndex,
417
+ colspan,
418
+ vMerge,
419
+ startRow,
420
+ hasMeaningfulContent: tableCellHasMeaningfulContent(cell),
421
+ shouldSkip: vMerge === "continue" && startRow !== void 0
422
+ };
423
+ colIndex += colspan;
424
+ return info;
425
+ });
426
+ const rowWouldBeEmpty = rowCells.length > 0 && rowCells.every((cell) => cell.shouldSkip);
427
+ for (const cellInfo of rowCells) {
428
+ const { colIndex: cellColIndex, vMerge, startRow, hasMeaningfulContent } = cellInfo;
429
+ const key = `${rowIndex}-${cellColIndex}`;
430
+ if (vMerge === "restart") {
431
+ activeMerges.set(cellColIndex, rowIndex);
432
+ result.set(key, {
433
+ rowSpan: 1,
434
+ skip: false
435
+ });
436
+ } else if (vMerge === "continue") {
437
+ if (startRow === void 0 || rowWouldBeEmpty || hasMeaningfulContent) {
438
+ result.set(key, {
439
+ rowSpan: 1,
440
+ skip: false
441
+ });
442
+ if ((rowWouldBeEmpty || hasMeaningfulContent) && startRow !== void 0) {
443
+ const restartCell = result.get(`${startRow}-${cellColIndex}`);
444
+ if (restartCell) restartCell.preserveVMergeRestart = true;
445
+ activeMerges.delete(cellColIndex);
446
+ }
447
+ continue;
448
+ }
449
+ const startKey = `${startRow}-${cellColIndex}`;
450
+ const startCell = result.get(startKey);
451
+ if (startCell) {
452
+ startCell.rowSpan++;
453
+ startCell.continuationCells ??= [];
454
+ startCell.continuationCells.push(cellInfo.cell);
455
+ }
456
+ result.set(key, {
457
+ rowSpan: 1,
458
+ skip: true
459
+ });
460
+ } else {
461
+ activeMerges.delete(cellColIndex);
462
+ result.set(key, {
463
+ rowSpan: 1,
464
+ skip: false
465
+ });
466
+ }
467
+ }
468
+ }
469
+ return result;
470
+ }
471
+ function clearActiveVerticalMerges(activeMerges, result) {
472
+ for (const [colIndex, startRow] of activeMerges) {
473
+ const restartCell = result.get(`${startRow}-${colIndex}`);
474
+ if (restartCell) restartCell.preserveVMergeRestart = true;
475
+ }
476
+ activeMerges.clear();
477
+ }
478
+ function tableCellHasMeaningfulContent(cell) {
479
+ return cell.content.some(blockHasMeaningfulContent);
480
+ }
481
+ function blockHasMeaningfulContent(block) {
482
+ if (block.type === "table") return block.rows.some((row) => row.cells.some((cell) => tableCellHasMeaningfulContent(cell)));
483
+ return block.content.some(paragraphContentHasMeaningfulContent);
484
+ }
485
+ function paragraphContentHasMeaningfulContent(content) {
486
+ if (content.type === "run") return content.content.length > 0;
487
+ if (content.type === "hyperlink") return content.children.some(paragraphContentHasMeaningfulContent);
488
+ if (content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo") return content.content.some(paragraphContentHasMeaningfulContent);
489
+ return true;
490
+ }
491
+ function convertTable(table, styleResolver, theme) {
492
+ const rowSpanMap = calculateRowSpans(table);
493
+ const columnWidths = table.columnWidths;
494
+ const totalWidth = columnWidths?.reduce((sum, w) => sum + w, 0) ?? 0;
495
+ const tableStyleId = table.formatting?.styleId;
496
+ const look = table.formatting?.look;
497
+ const tableStyle = tableStyleId ? styleResolver?.getStyle(tableStyleId) : void 0;
498
+ const defaultTableStyle = styleResolver?.getDefaultTableStyle();
499
+ const fallbackTableStyle = tableStyleId ? void 0 : defaultTableStyle;
500
+ const conditionalTableStyleId = tableStyle?.styleId ?? fallbackTableStyle?.styleId;
501
+ const resolvedTableBorders = table.formatting?.borders ?? tableStyle?.tblPr?.borders ?? fallbackTableStyle?.tblPr?.borders;
502
+ const tableCellMargins = table.formatting?.cellMargins ?? tableStyle?.tblPr?.cellMargins ?? fallbackTableStyle?.tblPr?.cellMargins;
503
+ let cellMarginsAttr;
504
+ if (tableCellMargins) {
505
+ const m = {};
506
+ if (tableCellMargins.top?.value !== void 0) m.top = tableCellMargins.top.value;
507
+ if (tableCellMargins.bottom?.value !== void 0) m.bottom = tableCellMargins.bottom.value;
508
+ if (tableCellMargins.left?.value !== void 0) m.left = tableCellMargins.left.value;
509
+ if (tableCellMargins.right?.value !== void 0) m.right = tableCellMargins.right.value;
510
+ cellMarginsAttr = m;
511
+ }
512
+ const attrs = {};
513
+ if (table.formatting?.styleId) attrs.styleId = table.formatting.styleId;
514
+ if (table.formatting?.width?.value !== void 0) attrs.width = table.formatting.width.value;
515
+ if (table.formatting?.width?.type) attrs.widthType = table.formatting.width.type;
516
+ if (table.formatting?.justification) attrs.justification = table.formatting.justification;
517
+ if (columnWidths) attrs.columnWidths = columnWidths;
518
+ if (table.formatting?.floating) attrs.floating = table.formatting.floating;
519
+ if (cellMarginsAttr) attrs.cellMargins = cellMarginsAttr;
520
+ if (table.formatting?.look) attrs.look = table.formatting.look;
521
+ if (table.formatting?.borders) attrs.borders = table.formatting.borders;
522
+ if (table.formatting) attrs._originalFormatting = table.formatting;
523
+ const conditionalStyles = {};
524
+ const setCS = (key, type) => {
525
+ const val = resolveTableStyleConditional(styleResolver, conditionalTableStyleId, type);
526
+ if (val) conditionalStyles[key] = val;
527
+ };
528
+ setCS("wholeTable", "wholeTable");
529
+ const wholeTableStyle = mergeConditionalStyles(resolveTableBaseStyle(styleResolver, conditionalTableStyleId), conditionalStyles.wholeTable);
530
+ if (wholeTableStyle) conditionalStyles.wholeTable = wholeTableStyle;
531
+ setCS("firstRow", "firstRow");
532
+ setCS("lastRow", "lastRow");
533
+ setCS("firstCol", "firstCol");
534
+ setCS("lastCol", "lastCol");
535
+ setCS("band1Horz", "band1Horz");
536
+ setCS("band2Horz", "band2Horz");
537
+ setCS("band1Vert", "band1Vert");
538
+ setCS("band2Vert", "band2Vert");
539
+ setCS("nwCell", "nwCell");
540
+ setCS("neCell", "neCell");
541
+ setCS("swCell", "swCell");
542
+ setCS("seCell", "seCell");
543
+ const bandingEnabledH = look?.noHBand !== true;
544
+ const bandingEnabledV = look?.noVBand !== true;
545
+ let dataRowIndex = 0;
546
+ const totalRows = table.rows.length;
547
+ const gridColumnCount = columnWidths?.length ?? 0;
548
+ const totalColumns = gridColumnCount > 0 ? gridColumnCount : countTableColumns(table.rows);
549
+ const rows = table.rows.map((row, rowIndex) => {
550
+ const isFirstRowStyled = rowIndex === 0 && !!look?.firstRow;
551
+ const isLastRow = rowIndex === totalRows - 1 && !!look?.lastRow;
552
+ const rowBandStyle = (() => {
553
+ if (bandingEnabledH && !isFirstRowStyled && !isLastRow) return (() => {
554
+ if (dataRowIndex % 2 === 0) return conditionalStyles.band1Horz;
555
+ return conditionalStyles.band2Horz;
556
+ })();
557
+ })();
558
+ if (bandingEnabledH && !isFirstRowStyled && !isLastRow) dataRowIndex++;
559
+ return convertTableRow(row, styleResolver, isFirstRowStyled, columnWidths, totalWidth, conditionalStyles, rowBandStyle, bandingEnabledV, look, resolvedTableBorders, rowIndex, totalRows, totalColumns, rowSpanMap, cellMarginsAttr, theme);
560
+ });
561
+ return schema.node("table", attrs, rows);
562
+ }
563
+ function countTableColumns(rows) {
564
+ let maxColumns = 0;
565
+ for (const row of rows) {
566
+ let rowColumns = 0;
567
+ for (const cell of row.cells) rowColumns += cell.formatting?.gridSpan ?? 1;
568
+ maxColumns = Math.max(maxColumns, rowColumns);
569
+ }
570
+ return maxColumns;
571
+ }
572
+ /**
573
+ * Convert a TableRow to a ProseMirror table row node
574
+ */
575
+ function convertTableRow(row, styleResolver, isHeaderRow, columnWidths, totalWidth, conditionalStyles, rowBandStyle, bandingEnabledV, tableLook, tableBorders, rowIndex, totalRows, totalColumns, rowSpanMap, defaultCellMargins, theme) {
576
+ const attrs = { isHeader: !!row.formatting?.header };
577
+ if (row.formatting?.height?.value !== void 0) attrs.height = row.formatting.height.value;
578
+ if (row.formatting?.heightRule) attrs.heightRule = row.formatting.heightRule;
579
+ if (row.formatting) attrs._originalFormatting = row.formatting;
580
+ const numCells = row.cells.length;
581
+ const isFirstRow = rowIndex === 0;
582
+ const isLastRow = rowIndex === (totalRows ?? 1) - 1;
583
+ const rowCnf = row.formatting?.conditionalFormat;
584
+ const rowIsFirstRow = rowCnf?.firstRow ?? isFirstRow;
585
+ const rowIsLastRow = rowCnf?.lastRow ?? isLastRow;
586
+ const totalCols = totalColumns != null && totalColumns > 0 ? totalColumns : Math.max(numCells, 1);
587
+ let effectiveCells = row.cells;
588
+ if (effectiveCells.length === 0) {
589
+ const fallback = {
590
+ type: "tableCell",
591
+ content: [{
592
+ type: "paragraph",
593
+ content: []
594
+ }]
595
+ };
596
+ if (totalCols > 1) fallback.formatting = { gridSpan: totalCols };
597
+ effectiveCells = [fallback];
598
+ }
599
+ let colIndex = 0;
600
+ const cells = [];
601
+ for (const cellIndex_item of effectiveCells) {
602
+ const cell = cellIndex_item;
603
+ const colspan = cell.formatting?.gridSpan ?? 1;
604
+ const rowSpanKey = `${rowIndex ?? 0}-${colIndex}`;
605
+ const rowSpanInfo = rowSpanMap?.get(rowSpanKey);
606
+ const shouldSkip = rowSpanInfo?.skip ?? false;
607
+ const calculatedRowSpan = rowSpanInfo?.rowSpan ?? 1;
608
+ const preserveVMergeRestart = rowSpanInfo?.preserveVMergeRestart ?? false;
609
+ let gridWidth;
610
+ if (columnWidths && totalWidth && totalWidth > 0) {
611
+ let cellWidthTwips = 0;
612
+ for (let i = 0; i < colspan && colIndex + i < columnWidths.length; i++) cellWidthTwips += columnWidths[colIndex + i] ?? 0;
613
+ gridWidth = Math.round(cellWidthTwips / totalWidth * 100);
614
+ }
615
+ colIndex += colspan;
616
+ if (shouldSkip) continue;
617
+ const isFirstCol = colIndex - colspan === 0;
618
+ const isLastCol = colIndex === totalCols;
619
+ const cellCnf = cell.formatting?.conditionalFormat;
620
+ const cellIsFirstRow = cellCnf?.firstRow ?? rowIsFirstRow;
621
+ const cellIsLastRow = cellCnf?.lastRow ?? rowIsLastRow;
622
+ const cellIsFirstCol = cellCnf?.firstColumn ?? isFirstCol;
623
+ const cellIsLastCol = cellCnf?.lastColumn ?? isLastCol;
624
+ let vertBandStyle;
625
+ if (bandingEnabledV) {
626
+ const firstColOffset = tableLook?.firstColumn ? 1 : 0;
627
+ const bandColIndex = colIndex - colspan - firstColOffset;
628
+ if (bandColIndex >= 0 && !(tableLook?.lastColumn && cellIsLastCol) && !(tableLook?.firstColumn && cellIsFirstCol)) vertBandStyle = bandColIndex % 2 === 0 ? conditionalStyles?.band1Vert : conditionalStyles?.band2Vert;
629
+ }
630
+ if (cellCnf?.oddVBand) vertBandStyle = conditionalStyles?.band1Vert;
631
+ else if (cellCnf?.evenVBand) vertBandStyle = conditionalStyles?.band2Vert;
632
+ let effectiveRowBandStyle = rowBandStyle;
633
+ if (rowCnf?.oddHBand) effectiveRowBandStyle = conditionalStyles?.band1Horz;
634
+ else if (rowCnf?.evenHBand) effectiveRowBandStyle = conditionalStyles?.band2Horz;
635
+ if (cellCnf?.oddHBand) effectiveRowBandStyle = conditionalStyles?.band1Horz;
636
+ else if (cellCnf?.evenHBand) effectiveRowBandStyle = conditionalStyles?.band2Horz;
637
+ let cellConditionalStyle = conditionalStyles?.wholeTable;
638
+ cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, effectiveRowBandStyle);
639
+ cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, vertBandStyle);
640
+ if (cellIsFirstRow && (tableLook?.firstRow || rowCnf?.firstRow || cellCnf?.firstRow)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.firstRow);
641
+ if (cellIsLastRow && (tableLook?.lastRow || rowCnf?.lastRow || cellCnf?.lastRow)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.lastRow);
642
+ if (cellIsFirstCol && (tableLook?.firstColumn || rowCnf?.firstColumn || cellCnf?.firstColumn)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.firstCol);
643
+ if (cellIsLastCol && (tableLook?.lastColumn || rowCnf?.lastColumn || cellCnf?.lastColumn)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.lastCol);
644
+ if (cellIsFirstRow && cellIsFirstCol && (tableLook?.firstRow || rowCnf?.firstRow || cellCnf?.firstRow) && (tableLook?.firstColumn || rowCnf?.firstColumn || cellCnf?.firstColumn)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.nwCell);
645
+ if (cellIsFirstRow && cellIsLastCol && (tableLook?.firstRow || rowCnf?.firstRow || cellCnf?.firstRow) && (tableLook?.lastColumn || rowCnf?.lastColumn || cellCnf?.lastColumn)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.neCell);
646
+ if (cellIsLastRow && cellIsFirstCol && (tableLook?.lastRow || rowCnf?.lastRow || cellCnf?.lastRow) && (tableLook?.firstColumn || rowCnf?.firstColumn || cellCnf?.firstColumn)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.swCell);
647
+ if (cellIsLastRow && cellIsLastCol && (tableLook?.lastRow || rowCnf?.lastRow || cellCnf?.lastRow) && (tableLook?.lastColumn || rowCnf?.lastColumn || cellCnf?.lastColumn)) cellConditionalStyle = mergeConditionalStyles(cellConditionalStyle, conditionalStyles?.seCell);
648
+ cells.push(convertTableCell(cell, styleResolver, isHeaderRow, gridWidth, cellConditionalStyle, tableBorders, isFirstRow, isLastRow, isFirstCol, isLastCol, calculatedRowSpan, preserveVMergeRestart, rowSpanInfo?.continuationCells, defaultCellMargins, theme));
649
+ }
650
+ return schema.node("tableRow", attrs, cells);
651
+ }
652
+ const TABLE_BORDER_SIDES = [
653
+ "top",
654
+ "bottom",
655
+ "left",
656
+ "right",
657
+ "insideH",
658
+ "insideV"
659
+ ];
660
+ function resolveThemedBorderColors(borders, theme) {
661
+ if (!borders || !theme?.colorScheme) return borders;
662
+ let resolved;
663
+ for (const side of TABLE_BORDER_SIDES) {
664
+ const border = borders[side];
665
+ if (!border?.color?.themeColor || border.color.auto) continue;
666
+ resolved ??= { ...borders };
667
+ resolved[side] = {
668
+ ...border,
669
+ color: { rgb: resolveColor(border.color, theme).replace(/^#/u, "") }
670
+ };
671
+ }
672
+ return resolved ?? borders;
673
+ }
674
+ /**
675
+ * Convert a TableCell to a ProseMirror table cell node
676
+ */
677
+ function convertTableCell(cell, styleResolver, isHeader, gridWidthPercent, conditionalStyle, tableBorders, isFirstRow, isLastRow, isFirstCol, isLastCol, calculatedRowSpan, preserveVMergeRestart, vMergeContinuationCells, defaultCellMargins, theme) {
678
+ const formatting = cell.formatting;
679
+ const rowspan = calculatedRowSpan ?? 1;
680
+ let width = formatting?.width?.value;
681
+ let widthType = formatting?.width?.type;
682
+ if (width === void 0 && gridWidthPercent !== void 0) {
683
+ width = gridWidthPercent;
684
+ widthType = "pct";
685
+ }
686
+ const backgroundColor = formatting?.shading?.fill?.rgb ?? conditionalStyle?.tcPr?.shading?.fill?.rgb;
687
+ const baseBorders = (() => {
688
+ if (tableBorders) return {
689
+ top: isFirstRow ? tableBorders.top : tableBorders.insideH,
690
+ bottom: isLastRow ? tableBorders.bottom : tableBorders.insideH,
691
+ left: isFirstCol ? tableBorders.left : tableBorders.insideV,
692
+ right: isLastCol ? tableBorders.right : tableBorders.insideV
693
+ };
694
+ })();
695
+ const conditionalBorders = conditionalStyle?.tcPr?.borders;
696
+ const cellBorders = formatting?.borders;
697
+ const borders = resolveThemedBorderColors(baseBorders || conditionalBorders || cellBorders ? {
698
+ ...baseBorders,
699
+ ...conditionalBorders,
700
+ ...cellBorders
701
+ } : void 0, theme);
702
+ const buildMarginsAttr = (src) => {
703
+ const m = {};
704
+ if (src.top?.value !== void 0) m.top = src.top.value;
705
+ if (src.bottom?.value !== void 0) m.bottom = src.bottom.value;
706
+ if (src.left?.value !== void 0) m.left = src.left.value;
707
+ if (src.right?.value !== void 0) m.right = src.right.value;
708
+ return m;
709
+ };
710
+ const attrs = {
711
+ colspan: formatting?.gridSpan ?? 1,
712
+ rowspan
713
+ };
714
+ if (width !== void 0) attrs.width = width;
715
+ if (widthType) attrs.widthType = widthType;
716
+ if (formatting?.verticalAlign) attrs.verticalAlign = formatting.verticalAlign;
717
+ if (backgroundColor) attrs.backgroundColor = backgroundColor;
718
+ if (formatting?.textDirection) attrs.textDirection = formatting.textDirection;
719
+ if (formatting?.noWrap !== void 0) attrs.noWrap = formatting.noWrap;
720
+ if (borders) attrs.borders = borders;
721
+ if (formatting?.margins) attrs.margins = buildMarginsAttr(formatting.margins);
722
+ else if (conditionalStyle?.tcPr?.margins) attrs.margins = buildMarginsAttr(conditionalStyle.tcPr.margins);
723
+ else if (defaultCellMargins) attrs.margins = defaultCellMargins;
724
+ if (formatting) attrs._originalFormatting = formatting;
725
+ if (preserveVMergeRestart) attrs._preserveVMergeRestart = true;
726
+ if (vMergeContinuationCells && vMergeContinuationCells.length > 0) attrs._docxVMergeContinuationCells = vMergeContinuationCells;
727
+ const contentNodes = [];
728
+ for (const content of cell.content) if (content.type === "paragraph") contentNodes.push(convertParagraph(content, styleResolver, void 0, conditionalStyle?.rPr));
729
+ else contentNodes.push(convertTable(content, styleResolver, theme));
730
+ if (contentNodes.length === 0) contentNodes.push(schema.node("paragraph", {}, []));
731
+ const nodeType = isHeader ? "tableHeader" : "tableCell";
732
+ return schema.node(nodeType, attrs, contentNodes);
733
+ }
734
+ /**
735
+ * Convert a SimpleField or ComplexField to a ProseMirror field node.
736
+ * Preserves run formatting (bold, fontSize, color, etc.) as PM marks.
737
+ * Accepts a run formatting resolver so fields inherit paragraph-level
738
+ * formatting the same way regular text runs do.
739
+ */
740
+ function convertField(field, getInheritedRunFormatting, styleResolver) {
741
+ let displayText = "";
742
+ let fieldFormatting;
743
+ const runs = field.type === "simpleField" ? field.content : field.fieldResult;
744
+ for (const r of runs) if (r.type === "run") {
745
+ for (const c of r.content) if (c.type === "text") displayText += c.text;
746
+ if (!fieldFormatting && r.formatting) fieldFormatting = r.formatting;
747
+ }
748
+ if (!fieldFormatting && field.type === "complexField" && field.fieldResult.length === 0) fieldFormatting = field.formatting;
749
+ const inheritedFormatting = getInheritedRunFormatting(fieldFormatting);
750
+ const { marks } = buildRunMarks(fieldFormatting, inheritedFormatting, styleResolver);
751
+ return schema.node("field", {
752
+ fieldType: field.fieldType,
753
+ instruction: field.instruction,
754
+ displayText,
755
+ fieldKind: field.type === "simpleField" ? "simple" : "complex",
756
+ fldLock: field.fldLock ?? false,
757
+ dirty: field.dirty ?? false
758
+ }, void 0, marks);
759
+ }
760
+ /**
761
+ * Convert a MathEquation to a ProseMirror math node.
762
+ */
763
+ function convertMathEquation(math) {
764
+ return schema.node("math", {
765
+ display: math.display,
766
+ ommlXml: math.ommlXml,
767
+ plainText: math.plainText || ""
768
+ });
769
+ }
770
+ /**
771
+ * Convert an InlineSdt to a ProseMirror sdt node with inline content.
772
+ */
773
+ function convertInlineSdt(sdt, getInheritedRunFormatting, styleResolver) {
774
+ const props = sdt.properties;
775
+ const inlineNodes = [];
776
+ let hyperlinkIndex = 0;
777
+ for (const content of sdt.content) if (content.type === "run") {
778
+ const runNodes = convertRun(content, getInheritedRunFormatting(content.formatting), styleResolver);
779
+ inlineNodes.push(...runNodes);
780
+ } else if (content.type === "hyperlink") {
781
+ const currentHyperlinkIndex = hyperlinkIndex;
782
+ hyperlinkIndex += 1;
783
+ const linkNodes = convertHyperlink(content, getInheritedRunFormatting, styleResolver, currentHyperlinkIndex);
784
+ inlineNodes.push(...linkNodes);
785
+ } else if (content.type === "simpleField" || content.type === "complexField") {
786
+ const fieldNode = convertField(content, getInheritedRunFormatting, styleResolver);
787
+ if (fieldNode) inlineNodes.push(fieldNode);
788
+ } else if (content.type === "inlineSdt") {
789
+ const nestedSdt = convertInlineSdt(content, getInheritedRunFormatting, styleResolver);
790
+ if (nestedSdt) inlineNodes.push(nestedSdt);
791
+ } else {
792
+ const mathNode = convertMathEquation(content);
793
+ if (mathNode) inlineNodes.push(mathNode);
794
+ }
795
+ return schema.node("sdt", {
796
+ sdtType: props.sdtType,
797
+ alias: props.alias ?? null,
798
+ tag: props.tag ?? null,
799
+ id: props.id ?? null,
800
+ lock: props.lock ?? null,
801
+ placeholder: props.placeholder ?? null,
802
+ showingPlaceholder: props.showingPlaceholder ?? false,
803
+ dateFormat: props.dateFormat ?? null,
804
+ dateValueISO: props.dateValueISO ?? null,
805
+ listItems: props.listItems ? JSON.stringify(props.listItems) : null,
806
+ dropdownLastValue: props.dropdownLastValue ?? null,
807
+ checked: props.checked ?? null,
808
+ rawPropertiesXml: props.rawPropertiesXml ?? null,
809
+ rawEndPropertiesXml: props.rawEndPropertiesXml ?? null
810
+ }, inlineNodes.length > 0 ? inlineNodes : void 0);
811
+ }
812
+ /**
813
+ * Convert a Run to ProseMirror text nodes with marks
814
+ *
815
+ * @param run - The run to convert
816
+ * @param styleFormatting - Text formatting from the paragraph's style (e.g., Heading1's font size/color)
817
+ */
818
+ function convertRun(run, styleFormatting, styleResolver) {
819
+ const nodes = [];
820
+ const { marks, mergedFormatting } = buildRunMarks(run.formatting, styleFormatting, styleResolver);
821
+ for (const content of run.content) {
822
+ const contentNodes = convertRunContent(content, marks, mergedFormatting);
823
+ nodes.push(...contentNodes);
824
+ }
825
+ return nodes;
826
+ }
827
+ function buildRunMarks(runFormatting, inheritedFormatting, styleResolver) {
828
+ const styleId = runFormatting?.styleId;
829
+ const runStyleFormatting = styleId ? styleResolver?.getRunStyleOwnProperties(styleId) : void 0;
830
+ const mergedFormatting = mergeTextFormatting(mergeTextFormatting(inheritedFormatting, runStyleFormatting), runFormatting);
831
+ const marks = textFormattingToMarks(mergedFormatting);
832
+ if (styleId) {
833
+ const styleRPr = runStyleFormatting ? marksToTextFormatting(textFormattingToMarks(runStyleFormatting)) : void 0;
834
+ marks.push(schema.mark("characterStyle", {
835
+ styleId,
836
+ _styleRPr: styleRPr && Object.keys(styleRPr).length > 0 ? styleRPr : null
837
+ }));
838
+ }
839
+ return {
840
+ marks,
841
+ mergedFormatting
842
+ };
843
+ }
844
+ /**
845
+ * Convert RunContent to ProseMirror nodes
846
+ */
847
+ function convertRunContent(content, marks, formatting) {
848
+ switch (content.type) {
849
+ case "text":
850
+ if (content.text) return [schema.text(content.text, marks)];
851
+ return [];
852
+ case "break":
853
+ if (content.breakType === "textWrapping" || !content.breakType) return [withHyperlinkBoundaryMarks(schema.node("hardBreak"), marks)];
854
+ if (content.breakType === "column") return [withHyperlinkBoundaryMarks(schema.node("hardBreak", { breakType: "column" }), marks)];
855
+ return [];
856
+ case "tab": return [schema.node("tab").mark(marks)];
857
+ case "drawing": return [withHyperlinkBoundaryMarks(convertImage(content.image, content.rawXml), marks)];
858
+ case "shape": {
859
+ const shp = content.shape;
860
+ if (shp.textBody) return [];
861
+ return [withHyperlinkBoundaryMarks(convertShape(shp), marks)];
862
+ }
863
+ case "footnoteRef": {
864
+ const footnoteMark = schema.mark("footnoteRef", {
865
+ id: content.id.toString(),
866
+ noteType: "footnote",
867
+ vertAlign: formatting?.vertAlign === "baseline" || formatting?.vertAlign === "superscript" ? formatting.vertAlign : null
868
+ });
869
+ return [schema.text(content.id.toString(), [...marks, footnoteMark])];
870
+ }
871
+ case "endnoteRef": {
872
+ const endnoteMark = schema.mark("footnoteRef", {
873
+ id: content.id.toString(),
874
+ noteType: "endnote",
875
+ vertAlign: formatting?.vertAlign === "baseline" || formatting?.vertAlign === "superscript" ? formatting.vertAlign : null
876
+ });
877
+ return [schema.text(content.id.toString(), [...marks, endnoteMark])];
878
+ }
879
+ case "fieldChar":
880
+ case "instrText": return [];
881
+ case "noBreakHyphen": return [schema.text("‑", marks)];
882
+ case "softHyphen": return [schema.text("­", marks)];
883
+ case "symbol": return content.char ? [schema.text(content.char, marks)] : [];
884
+ }
885
+ }
886
+ function withHyperlinkBoundaryMarks(node, marks) {
887
+ if (!marks.some((mark) => mark.type.name === "hyperlink")) return node;
888
+ return node.mark(marks);
889
+ }
890
+ function convertImage(image, rawXml) {
891
+ const imageSize = image.size;
892
+ const widthPx = imageSize?.width ? emuToPixels(imageSize.width) : void 0;
893
+ const heightPx = imageSize?.height ? emuToPixels(imageSize.height) : void 0;
894
+ const wrapType = image.wrap.type;
895
+ const wrapText = image.wrap.wrapText;
896
+ const imagePosition = image.position;
897
+ const hAlign = imagePosition?.horizontal?.alignment;
898
+ let cssFloat;
899
+ if (wrapType === "inline") cssFloat = "none";
900
+ else if (wrapType === "topAndBottom") cssFloat = "none";
901
+ else if (wrapType === "square" || wrapType === "tight" || wrapType === "through") if (wrapText === "left") cssFloat = "right";
902
+ else if (wrapText === "right") cssFloat = "left";
903
+ else if (hAlign === "left") cssFloat = "left";
904
+ else if (hAlign === "right") cssFloat = "right";
905
+ else cssFloat = "none";
906
+ else cssFloat = "none";
907
+ let displayMode;
908
+ if (wrapType === "inline") displayMode = "inline";
909
+ else if (wrapType === "topAndBottom") displayMode = "block";
910
+ else if (wrapType === "behind" || wrapType === "inFront") displayMode = "float";
911
+ else if (cssFloat !== "none") displayMode = "float";
912
+ else displayMode = "block";
913
+ let transform;
914
+ if (image.transform) {
915
+ const transforms = [];
916
+ if (image.transform.rotation) transforms.push(`rotate(${image.transform.rotation}deg)`);
917
+ if (image.transform.flipH) transforms.push("scaleX(-1)");
918
+ if (image.transform.flipV) transforms.push("scaleY(-1)");
919
+ if (transforms.length > 0) transform = transforms.join(" ");
920
+ }
921
+ const distTop = image.wrap.distT != null ? emuToPixels(image.wrap.distT) : void 0;
922
+ const distBottom = image.wrap.distB != null ? emuToPixels(image.wrap.distB) : void 0;
923
+ const distLeft = image.wrap.distL != null ? emuToPixels(image.wrap.distL) : void 0;
924
+ const distRight = image.wrap.distR != null ? emuToPixels(image.wrap.distR) : void 0;
925
+ let position;
926
+ if (imagePosition) {
927
+ position = {};
928
+ if (imagePosition.horizontal) {
929
+ const h = { relativeTo: imagePosition.horizontal.relativeTo };
930
+ if (imagePosition.horizontal.posOffset !== void 0) h.posOffset = imagePosition.horizontal.posOffset;
931
+ if (imagePosition.horizontal.alignment) h.align = imagePosition.horizontal.alignment;
932
+ position.horizontal = h;
933
+ }
934
+ if (imagePosition.vertical) {
935
+ const v = { relativeTo: imagePosition.vertical.relativeTo };
936
+ if (imagePosition.vertical.posOffset !== void 0) v.posOffset = imagePosition.vertical.posOffset;
937
+ if (imagePosition.vertical.alignment) v.align = imagePosition.vertical.alignment;
938
+ position.vertical = v;
939
+ }
940
+ }
941
+ let borderWidth;
942
+ let borderColor;
943
+ let borderStyle;
944
+ if (image.outline && image.outline.width) {
945
+ borderWidth = Math.round(image.outline.width / 914400 * 96 * 100) / 100;
946
+ if (image.outline.color?.rgb) borderColor = `#${image.outline.color.rgb}`;
947
+ borderStyle = image.outline.style ? {
948
+ solid: "solid",
949
+ dot: "dotted",
950
+ dash: "dashed",
951
+ lgDash: "dashed",
952
+ dashDot: "dashed",
953
+ lgDashDot: "dashed",
954
+ lgDashDotDot: "dashed",
955
+ sysDot: "dotted",
956
+ sysDash: "dashed",
957
+ sysDashDot: "dashed",
958
+ sysDashDotDot: "dashed"
959
+ }[image.outline.style] || "solid" : "solid";
960
+ }
961
+ return schema.node("image", {
962
+ src: image.src || "",
963
+ alt: image.alt,
964
+ title: image.title,
965
+ width: widthPx,
966
+ height: heightPx,
967
+ rId: image.rId,
968
+ wrapType,
969
+ displayMode,
970
+ cssFloat,
971
+ transform,
972
+ opacity: image.opacity,
973
+ distTop,
974
+ distBottom,
975
+ distLeft,
976
+ distRight,
977
+ cropTop: image.crop?.top,
978
+ cropRight: image.crop?.right,
979
+ cropBottom: image.crop?.bottom,
980
+ cropLeft: image.crop?.left,
981
+ position,
982
+ borderWidth,
983
+ borderColor,
984
+ borderStyle,
985
+ wrapText,
986
+ hlinkHref: image.hlinkHref,
987
+ _docxRawXml: rawXml
988
+ });
989
+ }
990
+ /**
991
+ * Convert a Hyperlink to ProseMirror nodes with link mark
992
+ *
993
+ * @param hyperlink - The hyperlink to convert
994
+ * @param getInheritedRunFormatting - Formatting inherited by each child run
995
+ */
996
+ function convertHyperlink(hyperlink, getInheritedRunFormatting, styleResolver, hyperlinkIndex) {
997
+ const nodes = [];
998
+ const href = hyperlink.href || (hyperlink.anchor ? `#${hyperlink.anchor}` : "");
999
+ const linkMark = schema.mark("hyperlink", {
1000
+ href,
1001
+ tooltip: hyperlink.tooltip,
1002
+ rId: hyperlink.rId,
1003
+ _docxHyperlinkIndex: hyperlinkIndex
1004
+ });
1005
+ for (const child of hyperlink.children) if (child.type === "run") {
1006
+ const inheritedFormatting = getInheritedRunFormatting(child.formatting);
1007
+ const { marks: runMarks, mergedFormatting } = buildRunMarks(child.formatting, inheritedFormatting, styleResolver);
1008
+ const allMarks = [...runMarks, linkMark];
1009
+ for (const content of child.content) nodes.push(...convertRunContent(content, allMarks, mergedFormatting));
1010
+ }
1011
+ return nodes;
1012
+ }
1013
+ /**
1014
+ * Convert TextFormatting to ProseMirror marks
1015
+ */
1016
+ function textFormattingToMarks(formatting) {
1017
+ if (!formatting) return [];
1018
+ const marks = [];
1019
+ const overrideAttrs = buildRunFormattingOverrideAttrs(formatting);
1020
+ if (overrideAttrs) marks.push(schema.mark("runFormattingOverride", overrideAttrs));
1021
+ if (formatting.bold) marks.push(schema.mark("bold"));
1022
+ if (formatting.italic) marks.push(schema.mark("italic"));
1023
+ if (formatting.underline && formatting.underline.style !== "none") marks.push(schema.mark("underline", {
1024
+ style: formatting.underline.style,
1025
+ color: formatting.underline.color
1026
+ }));
1027
+ if (formatting.strike || formatting.doubleStrike) marks.push(schema.mark("strike", { double: formatting.doubleStrike || false }));
1028
+ if (formatting.color && !formatting.color.auto) marks.push(schema.mark("textColor", {
1029
+ rgb: formatting.color.rgb,
1030
+ themeColor: formatting.color.themeColor,
1031
+ themeTint: formatting.color.themeTint,
1032
+ themeShade: formatting.color.themeShade
1033
+ }));
1034
+ if (formatting.highlight && formatting.highlight !== "none") marks.push(schema.mark("highlight", { color: formatting.highlight }));
1035
+ const runShadingMarkAttrs = shadingToRunShadingAttrs(formatting.shading);
1036
+ if (runShadingMarkAttrs) marks.push(schema.mark("runShading", runShadingMarkAttrs));
1037
+ if (formatting.fontSize) marks.push(schema.mark("fontSize", { size: formatting.fontSize }));
1038
+ if (formatting.fontFamily) marks.push(schema.mark("fontFamily", {
1039
+ ascii: formatting.fontFamily.ascii,
1040
+ hAnsi: formatting.fontFamily.hAnsi,
1041
+ eastAsia: formatting.fontFamily.eastAsia,
1042
+ cs: formatting.fontFamily.cs,
1043
+ asciiTheme: formatting.fontFamily.asciiTheme,
1044
+ hAnsiTheme: formatting.fontFamily.hAnsiTheme,
1045
+ eastAsiaTheme: formatting.fontFamily.eastAsiaTheme,
1046
+ csTheme: formatting.fontFamily.csTheme
1047
+ }));
1048
+ if (formatting.vertAlign === "superscript") marks.push(schema.mark("superscript"));
1049
+ else if (formatting.vertAlign === "subscript") marks.push(schema.mark("subscript"));
1050
+ if (formatting.allCaps) marks.push(schema.mark("allCaps"));
1051
+ if (formatting.smallCaps) marks.push(schema.mark("smallCaps"));
1052
+ const spacing = typeof formatting.spacing === "number" ? formatting.spacing : null;
1053
+ const position = typeof formatting.position === "number" ? formatting.position : null;
1054
+ const scale = typeof formatting.scale === "number" ? formatting.scale : null;
1055
+ const kerning = typeof formatting.kerning === "number" ? formatting.kerning : null;
1056
+ if (spacing !== null || position !== null || scale !== null || kerning !== null) marks.push(schema.mark("characterSpacing", {
1057
+ spacing,
1058
+ position,
1059
+ scale,
1060
+ kerning
1061
+ }));
1062
+ if (formatting.hidden === true) marks.push(schema.mark("hidden"));
1063
+ if (formatting.emboss) marks.push(schema.mark("emboss"));
1064
+ if (formatting.imprint) marks.push(schema.mark("imprint"));
1065
+ if (formatting.shadow) marks.push(schema.mark("textShadow"));
1066
+ if (formatting.emphasisMark && formatting.emphasisMark !== "none") marks.push(schema.mark("emphasisMark", { type: formatting.emphasisMark }));
1067
+ if (formatting.outline) marks.push(schema.mark("textOutline"));
1068
+ if (formatting.rtl) marks.push(schema.mark("rtl"));
1069
+ if (formatting.effect && formatting.effect !== "none") marks.push(schema.mark("textEffect", { effect: formatting.effect }));
1070
+ return marks;
1071
+ }
1072
+ /**
1073
+ * Convert a Shape to a ProseMirror shape node (inline SVG)
1074
+ */
1075
+ function convertShape(shape) {
1076
+ const shapeSize = shape.size;
1077
+ const widthPx = shapeSize?.width ? emuToPixels(shapeSize.width) : 100;
1078
+ const heightPx = shapeSize?.height ? emuToPixels(shapeSize.height) : 80;
1079
+ const shapeAttrs = shape;
1080
+ let fillColor;
1081
+ let fillType = "solid";
1082
+ let gradientType;
1083
+ let gradientAngle;
1084
+ let gradientStops;
1085
+ if (shape.fill) {
1086
+ fillType = shape.fill.type;
1087
+ if (shape.fill.color?.rgb) fillColor = `#${shape.fill.color.rgb}`;
1088
+ if (shape.fill.type === "gradient" && shape.fill.gradient) {
1089
+ const g = shape.fill.gradient;
1090
+ gradientType = g.type;
1091
+ gradientAngle = g.angle;
1092
+ gradientStops = JSON.stringify(g.stops.map((s) => ({
1093
+ position: s.position,
1094
+ color: s.color.rgb ? `#${s.color.rgb}` : "#000000"
1095
+ })));
1096
+ }
1097
+ }
1098
+ let outlineWidth;
1099
+ let outlineColor;
1100
+ let outlineStyle = "none";
1101
+ let outlineCap;
1102
+ let outlineHeadEnd;
1103
+ let outlineTailEnd;
1104
+ if (shape.outline) {
1105
+ if (shape.outline.width) outlineWidth = Math.round(shape.outline.width / 914400 * 96 * 100) / 100;
1106
+ if (shape.outline.color?.rgb) outlineColor = `#${shape.outline.color.rgb}`;
1107
+ outlineStyle = shape.outline.style || "solid";
1108
+ outlineCap = shape.outline.cap;
1109
+ outlineHeadEnd = shape.outline.headEnd;
1110
+ outlineTailEnd = shape.outline.tailEnd;
1111
+ } else outlineWidth = 0;
1112
+ let transform;
1113
+ if (shape.transform) {
1114
+ const transforms = [];
1115
+ if (shape.transform.rotation) transforms.push(`rotate(${shape.transform.rotation}deg)`);
1116
+ if (shape.transform.flipH) transforms.push("scaleX(-1)");
1117
+ if (shape.transform.flipV) transforms.push("scaleY(-1)");
1118
+ if (transforms.length > 0) transform = transforms.join(" ");
1119
+ }
1120
+ const wrapType = shape.wrap?.type ?? "inline";
1121
+ const displayMode = wrapType === "inline" ? "inline" : "float";
1122
+ let cssFloat = "none";
1123
+ if (shape.wrap?.wrapText === "left") cssFloat = "right";
1124
+ else if (shape.wrap?.wrapText === "right") cssFloat = "left";
1125
+ let position;
1126
+ if (shape.position) position = {
1127
+ horizontal: {
1128
+ relativeTo: shape.position.horizontal.relativeTo,
1129
+ ...shape.position.horizontal.posOffset !== void 0 ? { posOffset: shape.position.horizontal.posOffset } : {},
1130
+ ...shape.position.horizontal.alignment ? { align: shape.position.horizontal.alignment } : {}
1131
+ },
1132
+ vertical: {
1133
+ relativeTo: shape.position.vertical.relativeTo,
1134
+ ...shape.position.vertical.posOffset !== void 0 ? { posOffset: shape.position.vertical.posOffset } : {},
1135
+ ...shape.position.vertical.alignment ? { align: shape.position.vertical.alignment } : {}
1136
+ }
1137
+ };
1138
+ return schema.node("shape", {
1139
+ shapeType: shapeAttrs.shapeType ?? "rect",
1140
+ shapeId: shape.id,
1141
+ width: widthPx,
1142
+ height: heightPx,
1143
+ fillColor,
1144
+ fillType,
1145
+ gradientType,
1146
+ gradientAngle,
1147
+ gradientStops,
1148
+ outlineWidth,
1149
+ outlineColor,
1150
+ outlineStyle,
1151
+ outlineCap,
1152
+ outlineHeadEnd,
1153
+ outlineTailEnd,
1154
+ transform,
1155
+ displayMode,
1156
+ cssFloat,
1157
+ wrapType,
1158
+ wrapText: shape.wrap?.wrapText,
1159
+ distTop: shape.wrap?.distT !== void 0 ? emuToPixels(shape.wrap.distT) : void 0,
1160
+ distBottom: shape.wrap?.distB !== void 0 ? emuToPixels(shape.wrap.distB) : void 0,
1161
+ distLeft: shape.wrap?.distL !== void 0 ? emuToPixels(shape.wrap.distL) : void 0,
1162
+ distRight: shape.wrap?.distR !== void 0 ? emuToPixels(shape.wrap.distR) : void 0,
1163
+ position
1164
+ });
1165
+ }
1166
+ /**
1167
+ * Convert a paragraph block to PM nodes, extracting text boxes as sibling nodes.
1168
+ * Skips ghost empty paragraphs that only contained text box drawings.
1169
+ */
1170
+ function convertParagraphWithTextBoxes(block, styleResolver, textBoxGroupId) {
1171
+ const textBoxes = extractTextBoxesFromParagraph(block);
1172
+ const pmParagraph = convertParagraph(block, styleResolver);
1173
+ const nodes = [];
1174
+ const isEmptyAfterExtraction = textBoxes.length > 0 && pmParagraph.content.size === 0;
1175
+ const keepWrapperParagraph = isEmptyAfterExtraction && hasParagraphBoundaryPayload(block, pmParagraph);
1176
+ if (!isEmptyAfterExtraction || keepWrapperParagraph) nodes.push(pmParagraph);
1177
+ for (const tb of textBoxes) nodes.push(convertTextBox(tb, styleResolver, {
1178
+ placement: isEmptyAfterExtraction && !keepWrapperParagraph ? "standalone" : "inlineWithPrevious",
1179
+ groupId: textBoxGroupId
1180
+ }));
1181
+ return nodes;
1182
+ }
1183
+ function hasParagraphBoundaryPayload(block, pmParagraph) {
1184
+ const bookmarks = pmParagraph.attrs["bookmarks"];
1185
+ const emptyHyperlinks = pmParagraph.attrs["_emptyHyperlinks"];
1186
+ return Boolean(block.sectionProperties || block.propertyChanges?.length || Array.isArray(bookmarks) && bookmarks.length > 0 || Array.isArray(emptyHyperlinks) && emptyHyperlinks.length > 0);
1187
+ }
1188
+ /**
1189
+ * Extract text boxes from paragraph runs.
1190
+ * Text boxes appear as ShapeContent where the shape has textBody,
1191
+ * or as DrawingContent that contains a text box instead of an image.
1192
+ */
1193
+ function extractTextBoxesFromParagraph(paragraph) {
1194
+ const textBoxes = [];
1195
+ for (const content of paragraph.content) if (content.type === "run") {
1196
+ for (const rc of content.content) if (rc.type === "shape") {
1197
+ const shape = rc.shape;
1198
+ if (shape.textBody) {
1199
+ const textBox = {
1200
+ type: "textBox",
1201
+ size: shape.size,
1202
+ content: shape.textBody.content
1203
+ };
1204
+ if (shape.id) textBox.id = shape.id;
1205
+ if (shape.position) textBox.position = shape.position;
1206
+ if (shape.wrap) textBox.wrap = shape.wrap;
1207
+ if (shape.fill) textBox.fill = shape.fill;
1208
+ if (shape.outline) textBox.outline = shape.outline;
1209
+ if (shape.textBody.margins) textBox.margins = shape.textBody.margins;
1210
+ textBoxes.push(textBox);
1211
+ }
1212
+ }
1213
+ }
1214
+ return textBoxes;
1215
+ }
1216
+ /**
1217
+ * Convert a TextBox to a ProseMirror textBox node
1218
+ */
1219
+ function convertTextBox(textBox, styleResolver, options = {}) {
1220
+ const textBoxSize = textBox.size;
1221
+ const widthPx = textBoxSize?.width ? emuToPixels(textBoxSize.width) : 200;
1222
+ const heightPx = textBoxSize?.height ? emuToPixels(textBoxSize.height) : void 0;
1223
+ let fillColor;
1224
+ if (textBox.fill?.color?.rgb) fillColor = `#${textBox.fill.color.rgb}`;
1225
+ let outlineWidth;
1226
+ let outlineColor;
1227
+ let outlineStyle;
1228
+ if (textBox.outline && textBox.outline.width) {
1229
+ outlineWidth = Math.round(textBox.outline.width / 914400 * 96 * 100) / 100;
1230
+ if (textBox.outline.color?.rgb) outlineColor = `#${textBox.outline.color.rgb}`;
1231
+ outlineStyle = textBox.outline.style || "solid";
1232
+ }
1233
+ const marginTop = textBox.margins?.top !== void 0 ? emuToPixels(textBox.margins.top) : 4;
1234
+ const marginBottom = textBox.margins?.bottom !== void 0 ? emuToPixels(textBox.margins.bottom) : 4;
1235
+ const marginLeft = textBox.margins?.left !== void 0 ? emuToPixels(textBox.margins.left) : 7;
1236
+ const marginRight = textBox.margins?.right !== void 0 ? emuToPixels(textBox.margins.right) : 7;
1237
+ const contentNodes = [];
1238
+ for (const para of textBox.content) contentNodes.push(convertParagraph(para, styleResolver));
1239
+ if (contentNodes.length === 0) contentNodes.push(schema.node("paragraph", {}, []));
1240
+ const wrapType = textBox.wrap?.type;
1241
+ const wrapText = textBox.wrap?.wrapText;
1242
+ const hAlign = textBox.position?.horizontal.alignment;
1243
+ let position;
1244
+ if (textBox.position) position = {
1245
+ horizontal: {
1246
+ relativeTo: textBox.position.horizontal.relativeTo,
1247
+ ...textBox.position.horizontal.posOffset !== void 0 ? { posOffset: textBox.position.horizontal.posOffset } : {},
1248
+ ...textBox.position.horizontal.alignment ? { align: textBox.position.horizontal.alignment } : {}
1249
+ },
1250
+ vertical: {
1251
+ relativeTo: textBox.position.vertical.relativeTo,
1252
+ ...textBox.position.vertical.posOffset !== void 0 ? { posOffset: textBox.position.vertical.posOffset } : {},
1253
+ ...textBox.position.vertical.alignment ? { align: textBox.position.vertical.alignment } : {}
1254
+ }
1255
+ };
1256
+ let cssFloat;
1257
+ if (wrapType === void 0 || wrapType === "inline") cssFloat = "none";
1258
+ else if (wrapType === "topAndBottom") cssFloat = "none";
1259
+ else if (wrapType === "square" || wrapType === "tight" || wrapType === "through") if (wrapText === "left") cssFloat = "right";
1260
+ else if (wrapText === "right") cssFloat = "left";
1261
+ else if (hAlign === "left") cssFloat = "left";
1262
+ else if (hAlign === "right") cssFloat = "right";
1263
+ else cssFloat = "none";
1264
+ else cssFloat = "none";
1265
+ let displayMode;
1266
+ if (wrapType === void 0 || wrapType === "inline") displayMode = "inline";
1267
+ else if (wrapType === "topAndBottom") displayMode = "block";
1268
+ else if (wrapType === "behind" || wrapType === "inFront") displayMode = "float";
1269
+ else if (cssFloat !== "none") displayMode = "float";
1270
+ else displayMode = "block";
1271
+ const distTop = textBox.wrap?.distT ? emuToPixels(textBox.wrap.distT) : void 0;
1272
+ const distBottom = textBox.wrap?.distB ? emuToPixels(textBox.wrap.distB) : void 0;
1273
+ const distLeft = textBox.wrap?.distL ? emuToPixels(textBox.wrap.distL) : void 0;
1274
+ const distRight = textBox.wrap?.distR ? emuToPixels(textBox.wrap.distR) : void 0;
1275
+ return schema.node("textBox", {
1276
+ width: widthPx,
1277
+ height: heightPx,
1278
+ textBoxId: textBox.id,
1279
+ fillColor,
1280
+ outlineWidth,
1281
+ outlineColor,
1282
+ outlineStyle,
1283
+ marginTop,
1284
+ marginBottom,
1285
+ marginLeft,
1286
+ marginRight,
1287
+ displayMode,
1288
+ cssFloat,
1289
+ wrapType: wrapType ?? "inline",
1290
+ wrapText,
1291
+ distTop,
1292
+ distBottom,
1293
+ distLeft,
1294
+ distRight,
1295
+ position,
1296
+ _docxPlacement: options.placement,
1297
+ _docxGroupId: options.groupId
1298
+ }, contentNodes);
1299
+ }
1300
+ /**
1301
+ * Convert HeaderFooter content (array of Paragraph/Table blocks) to a ProseMirror document.
1302
+ * Used for editing headers/footers in their own ProseMirror editor and for
1303
+ * the unified header/footer render pipeline (see
1304
+ * `core/layout-bridge/headerFooterLayout.ts`). `theme` lives in
1305
+ * `ToProseDocOptions` for future themeColor cell-shading resolution; folio's
1306
+ * `convertTable` does not yet thread it (orthogonal upstream divergence).
1307
+ */
1308
+ function headerFooterToProseDoc(content, options) {
1309
+ const nodes = [];
1310
+ const styleResolver = options?.styles ? createStyleEngine(options.styles) : null;
1311
+ const theme = options?.theme ?? null;
1312
+ let textBoxGroupIndex = 0;
1313
+ const convertBlocks = (blocks) => {
1314
+ const out = [];
1315
+ for (const block of blocks) if (block.type === "paragraph") {
1316
+ out.push(...convertParagraphWithTextBoxes(block, styleResolver, String(textBoxGroupIndex)));
1317
+ textBoxGroupIndex += 1;
1318
+ } else if (block.type === "table") out.push(convertTable(block, styleResolver, theme));
1319
+ else out.push(convertBlockSdt(block, convertBlocks));
1320
+ return out;
1321
+ };
1322
+ nodes.push(...convertBlocks(content));
1323
+ if (nodes.length === 0) nodes.push(schema.node("paragraph", {}, []));
1324
+ const pmDoc = schema.node("doc", null, nodes);
1325
+ assertValidProseMirrorDocument(pmDoc, "Header/footer conversion produced an invalid ProseMirror document");
1326
+ return pmDoc;
1327
+ }
1328
+ function footnoteToProseDoc(content, options) {
1329
+ return headerFooterToProseDoc(content, options);
1330
+ }
1331
+ /**
1332
+ * Determine where a page break appears inside a paragraph.
1333
+ *
1334
+ * Per ECMA-376 §17.3.3.1, `<w:br w:type="page"/>` is always a forced break,
1335
+ * including in a paragraph whose only content is the break itself. We previously
1336
+ * searched only top-level runs and missed breaks nested in hyperlinks, tracked
1337
+ * changes, or fields — so those paragraphs silently dropped their forced break
1338
+ * and the following content collapsed onto the previous page (common on legal
1339
+ * signature pages and exhibit covers).
1340
+ * See eigenpal docx-editor #409 (break-only page break sub-fix).
1341
+ *
1342
+ * Returns:
1343
+ * "before" — the break appears before any visible content; the paragraph's
1344
+ * content belongs on the NEXT page.
1345
+ * "after" — the break follows some visible content; the paragraph stays
1346
+ * on the current page and the next block starts a new page.
1347
+ * null — no page break found.
1348
+ */
1349
+ function paragraphPageBreakPosition(paragraph) {
1350
+ const state = { seenVisibleContent: false };
1351
+ function isPageBreak(content) {
1352
+ return content.type === "break" && content.breakType === "page";
1353
+ }
1354
+ function isVisibleRunContent(content) {
1355
+ return content.type === "text" && content.text.length > 0 || content.type === "tab" || content.type === "drawing" || content.type === "shape" || content.type === "symbol" || content.type === "fieldChar" || content.type === "instrText" || content.type === "footnoteRef" || content.type === "endnoteRef" || content.type === "noBreakHyphen" || content.type === "softHyphen";
1356
+ }
1357
+ function visitRun(run) {
1358
+ for (const content of run.content) {
1359
+ if (isPageBreak(content)) return true;
1360
+ if (isVisibleRunContent(content)) state.seenVisibleContent = true;
1361
+ }
1362
+ return false;
1363
+ }
1364
+ function visitHyperlinkChildren(hyperlink) {
1365
+ for (const child of hyperlink.children) if (child.type === "run" && visitRun(child)) return true;
1366
+ return false;
1367
+ }
1368
+ function visitRunOrHyperlinkList(children) {
1369
+ for (const child of children) {
1370
+ if (child.type === "run" && visitRun(child)) return true;
1371
+ if (child.type === "hyperlink" && visitHyperlinkChildren(child)) return true;
1372
+ }
1373
+ return false;
1374
+ }
1375
+ function visitItem(item) {
1376
+ if (item.type === "run") return visitRun(item);
1377
+ if (item.type === "hyperlink") return visitHyperlinkChildren(item);
1378
+ if (item.type === "insertion" || item.type === "deletion" || item.type === "moveFrom" || item.type === "moveTo") return visitRunOrHyperlinkList(item.content);
1379
+ if (item.type === "simpleField") return visitRunOrHyperlinkList(item.content);
1380
+ if (item.type === "complexField") {
1381
+ for (const run of item.fieldResult) if (visitRun(run)) return true;
1382
+ return false;
1383
+ }
1384
+ if (item.type === "inlineSdt") {
1385
+ for (const child of item.content) if (visitItem(child)) return true;
1386
+ return false;
1387
+ }
1388
+ if (item.type === "mathEquation") {
1389
+ state.seenVisibleContent = true;
1390
+ return false;
1391
+ }
1392
+ return false;
1393
+ }
1394
+ for (const item of paragraph.content) if (visitItem(item)) return state.seenVisibleContent ? "after" : "before";
1395
+ return null;
1396
+ }
1397
+ /**
1398
+ * Create an empty ProseMirror document
1399
+ */
1400
+ function createEmptyDoc() {
1401
+ return schema.node("doc", null, [schema.node("paragraph", {}, [])]);
1402
+ }
1403
+ //#endregion
1404
+ export { createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, textFormattingToMarks, toProseDoc };