@beyondwork/docx-react-component 1.0.29 → 1.0.30

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 (381) hide show
  1. package/package.json +65 -96
  2. package/src/README.md +85 -0
  3. package/src/api/README.md +26 -0
  4. package/src/api/public-types.ts +1952 -0
  5. package/src/api/session-state.ts +62 -0
  6. package/src/compare/diff-engine.ts +623 -0
  7. package/src/compare/export-redlines.ts +280 -0
  8. package/src/compare/index.ts +25 -0
  9. package/src/compare/snapshot.ts +97 -0
  10. package/src/component-inventory.md +99 -0
  11. package/src/core/README.md +10 -0
  12. package/src/core/commands/README.md +3 -0
  13. package/{dist/chunk-TJBP2K4T.js → src/core/commands/formatting-commands.ts} +536 -196
  14. package/src/core/commands/image-commands.ts +373 -0
  15. package/src/core/commands/index.ts +1879 -0
  16. package/src/core/commands/list-commands.ts +565 -0
  17. package/src/core/commands/paragraph-layout-commands.ts +339 -0
  18. package/src/core/commands/review-commands.ts +108 -0
  19. package/{dist/core/commands/section-layout-commands.cjs → src/core/commands/section-layout-commands.ts} +340 -137
  20. package/src/core/commands/structural-helpers.ts +309 -0
  21. package/{dist/core/commands/style-commands.cjs → src/core/commands/style-commands.ts} +113 -65
  22. package/src/core/commands/table-structure-commands.ts +854 -0
  23. package/{dist/chunk-UZXBISGO.js → src/core/commands/text-commands.ts} +142 -86
  24. package/src/core/schema/README.md +3 -0
  25. package/src/core/schema/text-schema.ts +516 -0
  26. package/src/core/search/search-text.ts +357 -0
  27. package/src/core/selection/README.md +3 -0
  28. package/src/core/selection/mapping.ts +289 -0
  29. package/src/core/selection/review-anchors.ts +183 -0
  30. package/src/core/state/README.md +3 -0
  31. package/src/core/state/editor-state.ts +892 -0
  32. package/src/core/state/text-transaction.ts +869 -0
  33. package/src/formats/xlsx/io/parse-shared-strings.ts +41 -0
  34. package/src/formats/xlsx/io/parse-sheet.ts +459 -0
  35. package/src/formats/xlsx/io/parse-styles.ts +59 -0
  36. package/src/formats/xlsx/io/parse-workbook.ts +75 -0
  37. package/src/formats/xlsx/io/serialize-shared-strings.ts +72 -0
  38. package/src/formats/xlsx/io/serialize-sheet.ts +333 -0
  39. package/src/formats/xlsx/io/serialize-styles.ts +98 -0
  40. package/src/formats/xlsx/io/serialize-workbook.ts +429 -0
  41. package/src/formats/xlsx/io/xlsx-session.ts +314 -0
  42. package/src/formats/xlsx/model/cell.ts +189 -0
  43. package/src/formats/xlsx/model/sheet.ts +326 -0
  44. package/src/formats/xlsx/model/styles.ts +118 -0
  45. package/src/formats/xlsx/model/workbook.ts +453 -0
  46. package/src/formats/xlsx/runtime/cell-commands.ts +567 -0
  47. package/src/formats/xlsx/runtime/sheet-commands.ts +206 -0
  48. package/src/formats/xlsx/runtime/workbook-runtime.ts +177 -0
  49. package/src/formats/xlsx/runtime/workbook-transaction.ts +822 -0
  50. package/src/index.ts +142 -0
  51. package/src/io/README.md +10 -0
  52. package/src/io/docx-session.ts +3175 -0
  53. package/src/io/export/README.md +3 -0
  54. package/src/io/export/export-session.ts +220 -0
  55. package/src/io/export/minimal-docx.ts +115 -0
  56. package/src/io/export/reattach-preserved-parts.ts +54 -0
  57. package/src/io/export/serialize-comments.ts +947 -0
  58. package/src/io/export/serialize-footnotes.ts +394 -0
  59. package/src/io/export/serialize-headers-footers.ts +368 -0
  60. package/src/io/export/serialize-main-document.ts +1342 -0
  61. package/src/io/export/serialize-numbering.ts +218 -0
  62. package/src/io/export/serialize-revisions.ts +389 -0
  63. package/src/io/export/serialize-runtime-revisions.ts +463 -0
  64. package/src/io/export/serialize-tables.ts +174 -0
  65. package/src/io/export/split-review-boundaries.ts +356 -0
  66. package/src/io/export/split-story-blocks-for-runtime-revisions.ts +252 -0
  67. package/src/io/export/table-properties-xml.ts +318 -0
  68. package/src/io/normalize/README.md +3 -0
  69. package/src/io/normalize/normalize-text.ts +670 -0
  70. package/src/io/ooxml/README.md +3 -0
  71. package/src/io/ooxml/highlight-colors.ts +39 -0
  72. package/src/io/ooxml/numbering-sentinels.ts +44 -0
  73. package/src/io/ooxml/parse-comments.ts +852 -0
  74. package/src/io/ooxml/parse-complex-content.ts +287 -0
  75. package/src/io/ooxml/parse-fields.ts +834 -0
  76. package/src/io/ooxml/parse-footnotes.ts +952 -0
  77. package/src/io/ooxml/parse-headers-footers.ts +1212 -0
  78. package/src/io/ooxml/parse-inline-media.ts +461 -0
  79. package/src/io/ooxml/parse-main-document.ts +2947 -0
  80. package/src/io/ooxml/parse-numbering.ts +747 -0
  81. package/src/io/ooxml/parse-revisions.ts +1045 -0
  82. package/src/io/ooxml/parse-settings.ts +184 -0
  83. package/src/io/ooxml/parse-shapes.ts +296 -0
  84. package/src/io/ooxml/parse-styles.ts +639 -0
  85. package/src/io/ooxml/parse-tables.ts +627 -0
  86. package/src/io/ooxml/parse-theme.ts +346 -0
  87. package/src/io/ooxml/part-manifest.ts +136 -0
  88. package/src/io/ooxml/revision-boundaries.ts +475 -0
  89. package/src/io/ooxml/workflow-payload.ts +544 -0
  90. package/src/io/opc/README.md +3 -0
  91. package/src/io/opc/corrupt-package.ts +166 -0
  92. package/src/io/opc/docx-package.ts +74 -0
  93. package/src/io/opc/package-reader.ts +325 -0
  94. package/src/io/opc/package-writer.ts +273 -0
  95. package/src/io/source-package-provenance.ts +241 -0
  96. package/{dist/chunk-RMH72RZI.js → src/legal/bookmarks.ts} +130 -44
  97. package/src/legal/cross-references.ts +414 -0
  98. package/src/legal/defined-terms.ts +203 -0
  99. package/src/legal/index.ts +32 -0
  100. package/src/legal/signature-blocks.ts +259 -0
  101. package/src/model/README.md +3 -0
  102. package/src/model/canonical-document.ts +2722 -0
  103. package/src/model/cds-1.0.0.ts +212 -0
  104. package/src/model/snapshot.ts +760 -0
  105. package/src/preservation/README.md +3 -0
  106. package/src/preservation/markup-compatibility.ts +48 -0
  107. package/src/preservation/opaque-fragment-store.ts +89 -0
  108. package/src/preservation/opaque-region.ts +233 -0
  109. package/src/preservation/package-preservation.ts +113 -0
  110. package/src/preservation/preserved-part-manifest.ts +56 -0
  111. package/src/preservation/relationship-retention.ts +57 -0
  112. package/src/preservation/store.ts +255 -0
  113. package/src/review/README.md +16 -0
  114. package/src/review/store/README.md +3 -0
  115. package/src/review/store/comment-anchors.ts +70 -0
  116. package/src/review/store/comment-remapping.ts +154 -0
  117. package/src/review/store/comment-store.ts +349 -0
  118. package/src/review/store/comment-thread.ts +109 -0
  119. package/src/review/store/revision-actions.ts +423 -0
  120. package/src/review/store/revision-store.ts +323 -0
  121. package/src/review/store/revision-types.ts +182 -0
  122. package/src/review/store/runtime-comment-store.ts +43 -0
  123. package/src/runtime/README.md +3 -0
  124. package/src/runtime/ai-action-policy.ts +764 -0
  125. package/src/runtime/context-analytics.ts +824 -0
  126. package/src/runtime/document-layout.ts +332 -0
  127. package/src/runtime/document-locations.ts +521 -0
  128. package/src/runtime/document-navigation.ts +616 -0
  129. package/src/runtime/document-outline.ts +440 -0
  130. package/src/runtime/document-runtime.ts +4055 -0
  131. package/src/runtime/document-search.ts +145 -0
  132. package/src/runtime/event-refresh-hints.ts +137 -0
  133. package/src/runtime/numbering-prefix.ts +244 -0
  134. package/src/runtime/page-layout-estimation.ts +305 -0
  135. package/src/runtime/read-only-diagnostics-runtime.ts +241 -0
  136. package/src/runtime/resolved-numbering-geometry.ts +293 -0
  137. package/src/runtime/review-runtime.ts +44 -0
  138. package/src/runtime/revision-runtime.ts +107 -0
  139. package/src/runtime/session-capabilities.ts +192 -0
  140. package/src/runtime/story-context.ts +164 -0
  141. package/src/runtime/story-targeting.ts +162 -0
  142. package/src/runtime/suggestions-snapshot.ts +137 -0
  143. package/src/runtime/surface-projection.ts +1553 -0
  144. package/src/runtime/table-commands.ts +173 -0
  145. package/src/runtime/table-schema.ts +309 -0
  146. package/src/runtime/table-style-resolver.ts +409 -0
  147. package/src/runtime/view-state.ts +493 -0
  148. package/src/runtime/virtualized-rendering.ts +258 -0
  149. package/src/runtime/workflow-markup.ts +393 -0
  150. package/src/ui/README.md +30 -0
  151. package/src/ui/WordReviewEditor.tsx +5268 -0
  152. package/src/ui/browser-export.ts +52 -0
  153. package/src/ui/comments/README.md +3 -0
  154. package/src/ui/compatibility/README.md +3 -0
  155. package/src/ui/editor-command-bag.ts +127 -0
  156. package/src/ui/editor-runtime-boundary.ts +1558 -0
  157. package/src/ui/editor-shell-view.tsx +144 -0
  158. package/src/ui/editor-surface/README.md +3 -0
  159. package/src/ui/editor-surface-controller.tsx +66 -0
  160. package/src/ui/headless/comment-decoration-model.ts +124 -0
  161. package/src/ui/headless/preserve-editor-selection.ts +5 -0
  162. package/src/ui/headless/revision-decoration-model.ts +128 -0
  163. package/src/ui/headless/selection-helpers.ts +54 -0
  164. package/src/ui/headless/selection-tool-context.ts +19 -0
  165. package/src/ui/headless/selection-tool-resolver.ts +752 -0
  166. package/src/ui/headless/selection-tool-types.ts +129 -0
  167. package/src/ui/headless/selection-toolbar-model.ts +11 -0
  168. package/src/ui/headless/use-editor-keyboard.ts +103 -0
  169. package/src/ui/review/README.md +3 -0
  170. package/src/ui/runtime-shortcut-dispatch.ts +365 -0
  171. package/src/ui/runtime-snapshot-selectors.ts +197 -0
  172. package/src/ui/shared/revision-filters.ts +31 -0
  173. package/src/ui/status/README.md +3 -0
  174. package/src/ui/theme/README.md +3 -0
  175. package/src/ui/toolbar/README.md +3 -0
  176. package/src/ui/workflow-surface-blocked-rails.ts +94 -0
  177. package/src/ui-tailwind/chrome/chrome-preset-model.ts +107 -0
  178. package/src/ui-tailwind/chrome/chrome-preset-toolbar.tsx +15 -0
  179. package/src/ui-tailwind/chrome/review-queue-bar.tsx +97 -0
  180. package/src/ui-tailwind/chrome/tw-alert-banner.tsx +64 -0
  181. package/src/ui-tailwind/chrome/tw-context-analytics-summary.tsx +122 -0
  182. package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +121 -0
  183. package/src/ui-tailwind/chrome/tw-layout-panel.tsx +114 -0
  184. package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +30 -0
  185. package/src/ui-tailwind/chrome/tw-page-ruler.tsx +365 -0
  186. package/src/ui-tailwind/chrome/tw-selection-tool-blocked.tsx +23 -0
  187. package/src/ui-tailwind/chrome/tw-selection-tool-comment.tsx +35 -0
  188. package/src/ui-tailwind/chrome/tw-selection-tool-formatting.tsx +37 -0
  189. package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +298 -0
  190. package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +116 -0
  191. package/src/ui-tailwind/chrome/tw-selection-tool-suggestion.tsx +29 -0
  192. package/src/ui-tailwind/chrome/tw-selection-tool-workflow.tsx +27 -0
  193. package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +186 -0
  194. package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +139 -0
  195. package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +200 -0
  196. package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +58 -0
  197. package/src/ui-tailwind/chrome/use-before-unload.ts +20 -0
  198. package/src/ui-tailwind/editor-surface/perf-probe.ts +179 -0
  199. package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +189 -0
  200. package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +31 -0
  201. package/src/ui-tailwind/editor-surface/pm-decorations.ts +411 -0
  202. package/src/ui-tailwind/editor-surface/pm-position-map.ts +123 -0
  203. package/src/ui-tailwind/editor-surface/pm-schema.ts +927 -0
  204. package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +567 -0
  205. package/src/ui-tailwind/editor-surface/search-plugin.ts +168 -0
  206. package/src/ui-tailwind/editor-surface/surface-build-keys.ts +65 -0
  207. package/src/ui-tailwind/editor-surface/tw-caret.tsx +12 -0
  208. package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +150 -0
  209. package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +129 -0
  210. package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +58 -0
  211. package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +151 -0
  212. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +1047 -0
  213. package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +111 -0
  214. package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +503 -0
  215. package/src/ui-tailwind/index.ts +62 -0
  216. package/src/ui-tailwind/page-chrome-model.ts +27 -0
  217. package/src/ui-tailwind/review/tw-comment-sidebar.tsx +406 -0
  218. package/src/ui-tailwind/review/tw-health-panel.tsx +149 -0
  219. package/src/ui-tailwind/review/tw-review-rail.tsx +122 -0
  220. package/src/ui-tailwind/review/tw-revision-sidebar.tsx +164 -0
  221. package/src/ui-tailwind/status/tw-status-bar.tsx +65 -0
  222. package/{dist → src}/ui-tailwind/theme/editor-theme.css +58 -40
  223. package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +52 -0
  224. package/src/ui-tailwind/toolbar/tw-toolbar.tsx +1133 -0
  225. package/src/ui-tailwind/tw-review-workspace.tsx +1460 -0
  226. package/src/validation/README.md +3 -0
  227. package/src/validation/compatibility-engine.ts +878 -0
  228. package/src/validation/compatibility-report.ts +161 -0
  229. package/src/validation/diagnostics.ts +204 -0
  230. package/src/validation/docx-comment-proof.ts +720 -0
  231. package/src/validation/import-diagnostics.ts +128 -0
  232. package/src/validation/low-priority-word-surfaces.ts +373 -0
  233. package/dist/canonical-document-BLEbzL2J.d.cts +0 -844
  234. package/dist/canonical-document-BLEbzL2J.d.ts +0 -844
  235. package/dist/chunk-2FJS5GZM.js +0 -763
  236. package/dist/chunk-2FJS5GZM.js.map +0 -1
  237. package/dist/chunk-2OQBZS3F.js +0 -446
  238. package/dist/chunk-2OQBZS3F.js.map +0 -1
  239. package/dist/chunk-2S7W4KFO.js +0 -127
  240. package/dist/chunk-2S7W4KFO.js.map +0 -1
  241. package/dist/chunk-2TG72QSW.js +0 -3874
  242. package/dist/chunk-2TG72QSW.js.map +0 -1
  243. package/dist/chunk-36QNIZBO.js +0 -532
  244. package/dist/chunk-36QNIZBO.js.map +0 -1
  245. package/dist/chunk-4AQOYAW4.js +0 -3069
  246. package/dist/chunk-4AQOYAW4.js.map +0 -1
  247. package/dist/chunk-4D5EWJ3P.js +0 -77
  248. package/dist/chunk-4D5EWJ3P.js.map +0 -1
  249. package/dist/chunk-5FN54NDH.js +0 -2257
  250. package/dist/chunk-5FN54NDH.js.map +0 -1
  251. package/dist/chunk-BOYGQYRQ.js +0 -7306
  252. package/dist/chunk-BOYGQYRQ.js.map +0 -1
  253. package/dist/chunk-CN3XMECL.js +0 -212
  254. package/dist/chunk-CN3XMECL.js.map +0 -1
  255. package/dist/chunk-EBI3BX6U.js +0 -164
  256. package/dist/chunk-EBI3BX6U.js.map +0 -1
  257. package/dist/chunk-EILUG3VB.js +0 -1275
  258. package/dist/chunk-EILUG3VB.js.map +0 -1
  259. package/dist/chunk-FUDY333O.js +0 -70
  260. package/dist/chunk-FUDY333O.js.map +0 -1
  261. package/dist/chunk-GBVOWFIK.js +0 -1237
  262. package/dist/chunk-GBVOWFIK.js.map +0 -1
  263. package/dist/chunk-H4TQ3H3Y.js +0 -262
  264. package/dist/chunk-H4TQ3H3Y.js.map +0 -1
  265. package/dist/chunk-JGB3IXZO.js +0 -189
  266. package/dist/chunk-JGB3IXZO.js.map +0 -1
  267. package/dist/chunk-KD2QRQPY.js +0 -4342
  268. package/dist/chunk-KD2QRQPY.js.map +0 -1
  269. package/dist/chunk-KLMXQVYK.js +0 -369
  270. package/dist/chunk-KLMXQVYK.js.map +0 -1
  271. package/dist/chunk-KZUG5KFQ.js +0 -214
  272. package/dist/chunk-KZUG5KFQ.js.map +0 -1
  273. package/dist/chunk-QDAQ4CJU.js +0 -345
  274. package/dist/chunk-QDAQ4CJU.js.map +0 -1
  275. package/dist/chunk-RMH72RZI.js.map +0 -1
  276. package/dist/chunk-SWKWQZXM.js +0 -117
  277. package/dist/chunk-SWKWQZXM.js.map +0 -1
  278. package/dist/chunk-TJBP2K4T.js.map +0 -1
  279. package/dist/chunk-TLCEAQDQ.js +0 -542
  280. package/dist/chunk-TLCEAQDQ.js.map +0 -1
  281. package/dist/chunk-UZXBISGO.js.map +0 -1
  282. package/dist/chunk-WGBAKP3Q.js +0 -3220
  283. package/dist/chunk-WGBAKP3Q.js.map +0 -1
  284. package/dist/compare/index.cjs +0 -5475
  285. package/dist/compare/index.cjs.map +0 -1
  286. package/dist/compare/index.d.cts +0 -114
  287. package/dist/compare/index.d.ts +0 -114
  288. package/dist/compare/index.js +0 -731
  289. package/dist/compare/index.js.map +0 -1
  290. package/dist/core/commands/formatting-commands.cjs +0 -828
  291. package/dist/core/commands/formatting-commands.cjs.map +0 -1
  292. package/dist/core/commands/formatting-commands.d.cts +0 -63
  293. package/dist/core/commands/formatting-commands.d.ts +0 -63
  294. package/dist/core/commands/formatting-commands.js +0 -37
  295. package/dist/core/commands/formatting-commands.js.map +0 -1
  296. package/dist/core/commands/image-commands.cjs +0 -2023
  297. package/dist/core/commands/image-commands.cjs.map +0 -1
  298. package/dist/core/commands/image-commands.d.cts +0 -58
  299. package/dist/core/commands/image-commands.d.ts +0 -58
  300. package/dist/core/commands/image-commands.js +0 -18
  301. package/dist/core/commands/image-commands.js.map +0 -1
  302. package/dist/core/commands/section-layout-commands.cjs.map +0 -1
  303. package/dist/core/commands/section-layout-commands.d.cts +0 -62
  304. package/dist/core/commands/section-layout-commands.d.ts +0 -62
  305. package/dist/core/commands/section-layout-commands.js +0 -21
  306. package/dist/core/commands/section-layout-commands.js.map +0 -1
  307. package/dist/core/commands/style-commands.cjs.map +0 -1
  308. package/dist/core/commands/style-commands.d.cts +0 -13
  309. package/dist/core/commands/style-commands.d.ts +0 -13
  310. package/dist/core/commands/style-commands.js +0 -9
  311. package/dist/core/commands/style-commands.js.map +0 -1
  312. package/dist/core/commands/table-structure-commands.cjs +0 -1883
  313. package/dist/core/commands/table-structure-commands.cjs.map +0 -1
  314. package/dist/core/commands/table-structure-commands.d.cts +0 -59
  315. package/dist/core/commands/table-structure-commands.d.ts +0 -59
  316. package/dist/core/commands/table-structure-commands.js +0 -12
  317. package/dist/core/commands/table-structure-commands.js.map +0 -1
  318. package/dist/core/commands/text-commands.cjs +0 -2391
  319. package/dist/core/commands/text-commands.cjs.map +0 -1
  320. package/dist/core/commands/text-commands.d.cts +0 -24
  321. package/dist/core/commands/text-commands.d.ts +0 -24
  322. package/dist/core/commands/text-commands.js +0 -28
  323. package/dist/core/commands/text-commands.js.map +0 -1
  324. package/dist/core/selection/mapping.cjs +0 -200
  325. package/dist/core/selection/mapping.cjs.map +0 -1
  326. package/dist/core/selection/mapping.d.cts +0 -2
  327. package/dist/core/selection/mapping.d.ts +0 -2
  328. package/dist/core/selection/mapping.js +0 -31
  329. package/dist/core/selection/mapping.js.map +0 -1
  330. package/dist/core/state/editor-state.cjs +0 -2278
  331. package/dist/core/state/editor-state.cjs.map +0 -1
  332. package/dist/core/state/editor-state.d.cts +0 -2
  333. package/dist/core/state/editor-state.d.ts +0 -2
  334. package/dist/core/state/editor-state.js +0 -26
  335. package/dist/core/state/editor-state.js.map +0 -1
  336. package/dist/index.cjs +0 -38553
  337. package/dist/index.cjs.map +0 -1
  338. package/dist/index.d.cts +0 -15
  339. package/dist/index.d.ts +0 -15
  340. package/dist/index.js +0 -7856
  341. package/dist/index.js.map +0 -1
  342. package/dist/io/docx-session.cjs +0 -16236
  343. package/dist/io/docx-session.cjs.map +0 -1
  344. package/dist/io/docx-session.d.cts +0 -21
  345. package/dist/io/docx-session.d.ts +0 -21
  346. package/dist/io/docx-session.js +0 -18
  347. package/dist/io/docx-session.js.map +0 -1
  348. package/dist/legal/index.cjs +0 -3900
  349. package/dist/legal/index.cjs.map +0 -1
  350. package/dist/legal/index.d.cts +0 -86
  351. package/dist/legal/index.d.ts +0 -86
  352. package/dist/legal/index.js +0 -616
  353. package/dist/legal/index.js.map +0 -1
  354. package/dist/public-types-7ZL_94cz.d.ts +0 -1573
  355. package/dist/public-types-CeMaDueh.d.cts +0 -1573
  356. package/dist/public-types.cjs +0 -19
  357. package/dist/public-types.cjs.map +0 -1
  358. package/dist/public-types.d.cts +0 -2
  359. package/dist/public-types.d.ts +0 -2
  360. package/dist/public-types.js +0 -1
  361. package/dist/public-types.js.map +0 -1
  362. package/dist/runtime/document-runtime.cjs +0 -11140
  363. package/dist/runtime/document-runtime.cjs.map +0 -1
  364. package/dist/runtime/document-runtime.d.cts +0 -231
  365. package/dist/runtime/document-runtime.d.ts +0 -231
  366. package/dist/runtime/document-runtime.js +0 -21
  367. package/dist/runtime/document-runtime.js.map +0 -1
  368. package/dist/structural-helpers-CilgOVhh.d.cts +0 -10
  369. package/dist/structural-helpers-q0Gd-eBN.d.ts +0 -10
  370. package/dist/ui-tailwind/editor-surface/search-plugin.cjs +0 -313
  371. package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +0 -1
  372. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +0 -67
  373. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +0 -67
  374. package/dist/ui-tailwind/editor-surface/search-plugin.js +0 -23
  375. package/dist/ui-tailwind/editor-surface/search-plugin.js.map +0 -1
  376. package/dist/ui-tailwind/index.cjs +0 -4833
  377. package/dist/ui-tailwind/index.cjs.map +0 -1
  378. package/dist/ui-tailwind/index.d.cts +0 -617
  379. package/dist/ui-tailwind/index.d.ts +0 -617
  380. package/dist/ui-tailwind/index.js +0 -575
  381. package/dist/ui-tailwind/index.js.map +0 -1
@@ -1,1275 +0,0 @@
1
- import {
2
- describeOpaqueFragment,
3
- getOpaqueFragment
4
- } from "./chunk-SWKWQZXM.js";
5
-
6
- // src/runtime/story-context.ts
7
- function collectSectionContexts(document) {
8
- const sections = [];
9
- let sectionIndex = 0;
10
- for (const block of document.content.children) {
11
- if (block.type !== "section_break") {
12
- continue;
13
- }
14
- sections.push({
15
- index: sectionIndex,
16
- properties: block.sectionProperties
17
- });
18
- sectionIndex += 1;
19
- }
20
- sections.push({
21
- index: sectionIndex,
22
- properties: document.subParts?.finalSectionProperties
23
- });
24
- return sections;
25
- }
26
- function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
27
- if (explicitReferences && explicitReferences.length > 0) {
28
- return explicitReferences.map((ref) => ({
29
- variant: ref.variant,
30
- relationshipId: ref.relationshipId
31
- }));
32
- }
33
- return documents.filter(
34
- (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
35
- ).map((entry) => ({
36
- variant: entry.variant,
37
- relationshipId: entry.relationshipId
38
- }));
39
- }
40
- function findHeaderFooterDocumentEntry(document, target) {
41
- const documents = target.kind === "header" ? document.subParts?.headers ?? [] : document.subParts?.footers ?? [];
42
- const matches = documents.filter(
43
- (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
44
- );
45
- if (matches.length === 0) {
46
- return void 0;
47
- }
48
- if (target.sectionIndex !== void 0) {
49
- return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
50
- }
51
- return matches[0];
52
- }
53
- function sectionSupportsStoryTarget(document, sectionIndex, target) {
54
- if (!findHeaderFooterDocumentEntry(document, target)) {
55
- return false;
56
- }
57
- const section = collectSectionContexts(document).find(
58
- (candidate) => candidate.index === sectionIndex
59
- );
60
- if (!section) {
61
- return false;
62
- }
63
- const variants = resolveSectionVariants(
64
- target.kind,
65
- sectionIndex,
66
- target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
67
- target.kind === "header" ? document.subParts?.headers ?? [] : document.subParts?.footers ?? []
68
- );
69
- return variants.some(
70
- (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
71
- );
72
- }
73
- function normalizeHeaderFooterTarget(document, target, preferredSectionIndex) {
74
- if (!findHeaderFooterDocumentEntry(document, target)) {
75
- return void 0;
76
- }
77
- if (target.sectionIndex !== void 0) {
78
- return sectionSupportsStoryTarget(document, target.sectionIndex, target) ? target : void 0;
79
- }
80
- const candidateIndexes = collectSectionContexts(document).map((section) => section.index).filter(
81
- (sectionIndex) => sectionSupportsStoryTarget(document, sectionIndex, target)
82
- );
83
- if (candidateIndexes.length === 0) {
84
- return void 0;
85
- }
86
- const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
87
- return {
88
- ...target,
89
- sectionIndex: resolvedSectionIndex
90
- };
91
- }
92
-
93
- // src/runtime/story-targeting.ts
94
- function storyTargetKey(target) {
95
- switch (target.kind) {
96
- case "main":
97
- return "main";
98
- case "header":
99
- return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
100
- case "footer":
101
- return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
102
- case "footnote":
103
- return `footnote:${target.noteId}`;
104
- case "endnote":
105
- return `endnote:${target.noteId}`;
106
- }
107
- }
108
- function getStoryBlocks(document, target) {
109
- if (target.kind === "main") {
110
- return document.content.children;
111
- }
112
- const subParts = document.subParts;
113
- if (!subParts) {
114
- return [];
115
- }
116
- switch (target.kind) {
117
- case "header": {
118
- const resolvedTarget = normalizeHeaderFooterTarget(document, target);
119
- return (resolvedTarget && findHeaderFooterDocumentEntry(document, resolvedTarget)?.blocks) ?? [];
120
- }
121
- case "footer": {
122
- const resolvedTarget = normalizeHeaderFooterTarget(document, target);
123
- return (resolvedTarget && findHeaderFooterDocumentEntry(document, resolvedTarget)?.blocks) ?? [];
124
- }
125
- case "footnote":
126
- return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
127
- case "endnote":
128
- return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
129
- }
130
- }
131
- function replaceStoryBlocks(document, target, blocks) {
132
- if (target.kind === "main") {
133
- return {
134
- ...document,
135
- content: {
136
- ...document.content,
137
- children: [...blocks]
138
- }
139
- };
140
- }
141
- if (!document.subParts) {
142
- return document;
143
- }
144
- switch (target.kind) {
145
- case "header": {
146
- const resolvedTarget = normalizeHeaderFooterTarget(document, target);
147
- const matchedEntry = resolvedTarget ? findHeaderFooterDocumentEntry(document, resolvedTarget) : void 0;
148
- if (!matchedEntry) {
149
- return document;
150
- }
151
- return {
152
- ...document,
153
- subParts: {
154
- ...document.subParts,
155
- headers: document.subParts.headers.map(
156
- (header) => header.relationshipId === matchedEntry.relationshipId && header.variant === matchedEntry.variant && header.partPath === matchedEntry.partPath ? { ...header, blocks: [...blocks] } : header
157
- )
158
- }
159
- };
160
- }
161
- case "footer": {
162
- const resolvedTarget = normalizeHeaderFooterTarget(document, target);
163
- const matchedEntry = resolvedTarget ? findHeaderFooterDocumentEntry(document, resolvedTarget) : void 0;
164
- if (!matchedEntry) {
165
- return document;
166
- }
167
- return {
168
- ...document,
169
- subParts: {
170
- ...document.subParts,
171
- footers: document.subParts.footers.map(
172
- (footer) => footer.relationshipId === matchedEntry.relationshipId && footer.variant === matchedEntry.variant && footer.partPath === matchedEntry.partPath ? { ...footer, blocks: [...blocks] } : footer
173
- )
174
- }
175
- };
176
- }
177
- case "footnote":
178
- return !document.subParts.footnoteCollection?.footnotes[target.noteId] ? document : {
179
- ...document,
180
- subParts: {
181
- ...document.subParts,
182
- footnoteCollection: {
183
- ...document.subParts.footnoteCollection,
184
- footnotes: {
185
- ...document.subParts.footnoteCollection.footnotes,
186
- [target.noteId]: {
187
- ...document.subParts.footnoteCollection.footnotes[target.noteId],
188
- blocks: [...blocks]
189
- }
190
- }
191
- }
192
- }
193
- };
194
- case "endnote":
195
- return !document.subParts.footnoteCollection?.endnotes[target.noteId] ? document : {
196
- ...document,
197
- subParts: {
198
- ...document.subParts,
199
- footnoteCollection: {
200
- ...document.subParts.footnoteCollection,
201
- endnotes: {
202
- ...document.subParts.footnoteCollection.endnotes,
203
- [target.noteId]: {
204
- ...document.subParts.footnoteCollection.endnotes[target.noteId],
205
- blocks: [...blocks]
206
- }
207
- }
208
- }
209
- }
210
- };
211
- }
212
- }
213
-
214
- // src/runtime/numbering-prefix.ts
215
- var DEFAULT_START_AT = 1;
216
- function createNumberingPrefixResolver(catalog) {
217
- const sequenceStates = /* @__PURE__ */ new Map();
218
- function resolveInternal(numbering) {
219
- if (!numbering) {
220
- return null;
221
- }
222
- const instance = catalog.instances[numbering.numberingInstanceId];
223
- if (!instance) {
224
- return null;
225
- }
226
- const definition = catalog.abstractDefinitions[instance.abstractNumberingId];
227
- if (!definition) {
228
- return null;
229
- }
230
- const levelDefinitions = new Map(
231
- definition.levels.map((level) => [level.level, level])
232
- );
233
- const levelDefinition = levelDefinitions.get(numbering.level);
234
- if (!levelDefinition || levelDefinition.format === "none") {
235
- return null;
236
- }
237
- const sequenceState = getSequenceState(sequenceStates, numbering.numberingInstanceId);
238
- advanceSequence(sequenceState, numbering.level, levelDefinitions, instance.overrides);
239
- const effectiveLevelDefs = levelDefinition.isLegalNumbering ? new Map(Array.from(levelDefinitions.entries()).map(([k, v]) => [k, { ...v, format: "decimal" }])) : levelDefinitions;
240
- const text = renderLevelText(levelDefinition.text, sequenceState.counters, effectiveLevelDefs);
241
- if (text === null) return null;
242
- return { text, suffix: levelDefinition.suffix };
243
- }
244
- return {
245
- resolve(numbering) {
246
- const result = resolveInternal(numbering);
247
- return result?.text ?? null;
248
- },
249
- resolveDetailed(numbering) {
250
- return resolveInternal(numbering);
251
- }
252
- };
253
- }
254
- function getSequenceState(states, numberingInstanceId) {
255
- const existing = states.get(numberingInstanceId);
256
- if (existing) {
257
- return existing;
258
- }
259
- const created = {
260
- counters: [],
261
- lastLevel: null
262
- };
263
- states.set(numberingInstanceId, created);
264
- return created;
265
- }
266
- function advanceSequence(state, currentLevel, levelDefinitions, overrides) {
267
- if (state.lastLevel !== null && currentLevel <= state.lastLevel) {
268
- state.counters.length = currentLevel + 1;
269
- }
270
- const startAt = getLevelStartAt(currentLevel, levelDefinitions, overrides);
271
- const currentValue = state.counters[currentLevel];
272
- state.counters[currentLevel] = currentValue === void 0 ? startAt : currentValue + 1;
273
- state.lastLevel = currentLevel;
274
- }
275
- function getLevelStartAt(level, levelDefinitions, overrides) {
276
- const override = overrides.find((entry) => entry.level === level);
277
- if (override?.startAt !== void 0) {
278
- return override.startAt;
279
- }
280
- return levelDefinitions.get(level)?.startAt ?? DEFAULT_START_AT;
281
- }
282
- function renderLevelText(text, counters, levelDefinitions) {
283
- if (!text) {
284
- return null;
285
- }
286
- if (!text.includes("%")) {
287
- return text;
288
- }
289
- const rendered = text.replace(/%([1-9])/g, (_match, token) => {
290
- const level = Number.parseInt(token, 10) - 1;
291
- const counter = counters[level];
292
- if (counter === void 0) {
293
- return "";
294
- }
295
- const format = levelDefinitions.get(level)?.format ?? "decimal";
296
- return formatCounter(counter, format);
297
- });
298
- return rendered.trim().length > 0 ? rendered : null;
299
- }
300
- function formatCounter(value, format) {
301
- switch (format) {
302
- case "decimal":
303
- return String(value);
304
- case "decimalZero":
305
- return String(value).padStart(2, "0");
306
- case "upperLetter":
307
- return toAlphabetic(value).toUpperCase();
308
- case "lowerLetter":
309
- return toAlphabetic(value).toLowerCase();
310
- case "upperRoman":
311
- return toRoman(value).toUpperCase();
312
- case "lowerRoman":
313
- return toRoman(value).toLowerCase();
314
- case "none":
315
- return "";
316
- default:
317
- return String(value);
318
- }
319
- }
320
- function toAlphabetic(value) {
321
- if (value <= 0) {
322
- return String(value);
323
- }
324
- let remainder = value;
325
- let result = "";
326
- while (remainder > 0) {
327
- remainder -= 1;
328
- result = String.fromCharCode(65 + remainder % 26) + result;
329
- remainder = Math.floor(remainder / 26);
330
- }
331
- return result;
332
- }
333
- function toRoman(value) {
334
- if (value <= 0 || value >= 4e3) {
335
- return String(value);
336
- }
337
- const numerals = [
338
- [1e3, "M"],
339
- [900, "CM"],
340
- [500, "D"],
341
- [400, "CD"],
342
- [100, "C"],
343
- [90, "XC"],
344
- [50, "L"],
345
- [40, "XL"],
346
- [10, "X"],
347
- [9, "IX"],
348
- [5, "V"],
349
- [4, "IV"],
350
- [1, "I"]
351
- ];
352
- let remaining = value;
353
- let result = "";
354
- for (const [amount, numeral] of numerals) {
355
- while (remaining >= amount) {
356
- remaining -= amount;
357
- result += numeral;
358
- }
359
- }
360
- return result;
361
- }
362
-
363
- // src/runtime/surface-projection.ts
364
- function createEditorSurfaceSnapshot(document, _selection, activeStory = { kind: "main" }) {
365
- const root = normalizeDocumentRoot({
366
- type: "doc",
367
- children: [...getStoryBlocks(document, activeStory)]
368
- });
369
- const blocks = [];
370
- const lockedFragmentIds = [];
371
- const numberingPrefixResolver = createNumberingPrefixResolver(document.numbering);
372
- let cursor = 0;
373
- const counters = {
374
- paragraph: 0,
375
- table: 0,
376
- opaque: 0,
377
- sdt: 0,
378
- customXml: 0,
379
- altChunk: 0
380
- };
381
- for (let index = 0; index < root.children.length; index += 1) {
382
- const surfaceBlock = createSurfaceBlock(
383
- root.children[index],
384
- document,
385
- cursor,
386
- counters,
387
- numberingPrefixResolver
388
- );
389
- blocks.push(surfaceBlock.block);
390
- lockedFragmentIds.push(...surfaceBlock.lockedFragmentIds);
391
- cursor = surfaceBlock.nextCursor;
392
- if (index < root.children.length - 1 && root.children[index + 1]?.type === "paragraph") {
393
- cursor += 1;
394
- }
395
- }
396
- const secondaryStories = createSecondaryStorySurfaces(document);
397
- return {
398
- storySize: cursor,
399
- plainText: createPlainText(blocks),
400
- blocks,
401
- lockedFragmentIds,
402
- secondaryStories
403
- };
404
- }
405
- function createSurfaceBlock(block, document, cursor, counters, numberingPrefixResolver) {
406
- if (block.type === "opaque_block") {
407
- const fragment = getOpaqueFragment(document.preservation, block.fragmentId);
408
- const descriptor = fragment ? describeOpaqueFragment(fragment) : null;
409
- const blockId = `opaque-${counters.opaque}`;
410
- counters.opaque += 1;
411
- return {
412
- block: {
413
- blockId,
414
- kind: "opaque_block",
415
- from: cursor,
416
- to: cursor + 1,
417
- fragmentId: block.fragmentId,
418
- warningId: block.warningId,
419
- label: descriptor?.label ?? "Unsupported OOXML fragment",
420
- detail: descriptor?.detail ?? "Locked whole-unit to keep unsupported OOXML intact through export.",
421
- state: "locked-preserve-only"
422
- },
423
- lockedFragmentIds: [block.fragmentId],
424
- nextCursor: cursor + 1
425
- };
426
- }
427
- if (block.type === "table") {
428
- const tableIndex = counters.table;
429
- counters.table += 1;
430
- return createTableBlock(
431
- tableIndex,
432
- block,
433
- document,
434
- cursor,
435
- counters,
436
- numberingPrefixResolver
437
- );
438
- }
439
- if (block.type === "sdt") {
440
- const sdtIndex = counters.sdt;
441
- counters.sdt += 1;
442
- return createSdtBlock(
443
- sdtIndex,
444
- block,
445
- document,
446
- cursor,
447
- counters,
448
- numberingPrefixResolver
449
- );
450
- }
451
- if (block.type === "custom_xml") {
452
- const blockId = `custom-xml-${counters.customXml}`;
453
- counters.customXml += 1;
454
- return {
455
- block: {
456
- blockId,
457
- kind: "opaque_block",
458
- from: cursor,
459
- to: cursor + 1,
460
- fragmentId: blockId,
461
- warningId: blockId,
462
- label: "Custom XML block",
463
- detail: block.uri || block.element ? `Custom XML wrapper ${[block.element, block.uri].filter(Boolean).join(" ")} preserved as a read-only block.` : "Custom XML wrapper preserved as a read-only block.",
464
- state: "locked-preserve-only"
465
- },
466
- lockedFragmentIds: [],
467
- nextCursor: cursor + 1
468
- };
469
- }
470
- if (block.type === "alt_chunk") {
471
- const blockId = `alt-chunk-${counters.altChunk}`;
472
- counters.altChunk += 1;
473
- return {
474
- block: {
475
- blockId,
476
- kind: "opaque_block",
477
- from: cursor,
478
- to: cursor + 1,
479
- fragmentId: blockId,
480
- warningId: blockId,
481
- label: "AltChunk import",
482
- detail: `Alternate content import remains read-only through relationship ${block.relationshipId}.`,
483
- state: "locked-preserve-only"
484
- },
485
- lockedFragmentIds: [],
486
- nextCursor: cursor + 1
487
- };
488
- }
489
- if (block.type === "section_break") {
490
- const blockId = `section-break-${counters.opaque}`;
491
- counters.opaque += 1;
492
- return {
493
- block: {
494
- blockId,
495
- kind: "opaque_block",
496
- from: cursor,
497
- to: cursor + 1,
498
- fragmentId: blockId,
499
- warningId: blockId,
500
- label: "Section break",
501
- detail: "Section properties preserved as a read-only boundary.",
502
- state: "locked-preserve-only"
503
- },
504
- lockedFragmentIds: [],
505
- nextCursor: cursor + 1
506
- };
507
- }
508
- const paragraphIndex = counters.paragraph;
509
- counters.paragraph += 1;
510
- return createParagraphBlock(
511
- paragraphIndex,
512
- block,
513
- document,
514
- cursor,
515
- numberingPrefixResolver
516
- );
517
- }
518
- function createTableBlock(tableIndex, table, document, cursor, counters, numberingPrefixResolver) {
519
- const lockedFragmentIds = [];
520
- let innerCursor = cursor;
521
- const rows = [];
522
- const rowSpans = computeTableRowSpans(table);
523
- for (const [rowIndex, row] of table.rows.entries()) {
524
- const cells = [];
525
- for (const [cellIndex, cell] of row.cells.entries()) {
526
- const cellContent = [];
527
- for (const child of cell.children) {
528
- const result = createSurfaceBlock(
529
- child,
530
- document,
531
- innerCursor,
532
- counters,
533
- numberingPrefixResolver
534
- );
535
- cellContent.push(result.block);
536
- lockedFragmentIds.push(...result.lockedFragmentIds);
537
- innerCursor = result.nextCursor;
538
- }
539
- const cellBorders = resolveCellBorderStyles(cell.borders);
540
- cells.push({
541
- gridSpan: cell.gridSpan ?? 1,
542
- verticalMerge: cell.verticalMerge ?? null,
543
- colspan: cell.gridSpan ?? 1,
544
- rowspan: rowSpans.get(`${rowIndex}:${cellIndex}`) ?? 1,
545
- ...cell.shading?.fill ? { backgroundColor: `#${cell.shading.fill}` } : {},
546
- ...cell.verticalAlign ? { verticalAlign: cell.verticalAlign } : {},
547
- ...cellBorders.borderTop ? { borderTop: cellBorders.borderTop } : {},
548
- ...cellBorders.borderRight ? { borderRight: cellBorders.borderRight } : {},
549
- ...cellBorders.borderBottom ? { borderBottom: cellBorders.borderBottom } : {},
550
- ...cellBorders.borderLeft ? { borderLeft: cellBorders.borderLeft } : {},
551
- content: cellContent
552
- });
553
- }
554
- rows.push({
555
- cells,
556
- ...row.gridBefore !== void 0 ? { gridBefore: row.gridBefore } : {},
557
- ...row.gridAfter !== void 0 ? { gridAfter: row.gridAfter } : {},
558
- ...row.height !== void 0 ? { height: row.height } : {},
559
- ...row.heightRule ? { heightRule: row.heightRule } : {},
560
- ...row.isHeader ? { isHeader: row.isHeader } : {}
561
- });
562
- }
563
- return {
564
- block: {
565
- blockId: `table-${tableIndex}`,
566
- kind: "table",
567
- from: cursor,
568
- to: innerCursor,
569
- styleId: table.styleId,
570
- gridColumns: table.gridColumns,
571
- ...table.alignment ? { alignment: table.alignment } : {},
572
- ...table.tblLook ? { tblLook: table.tblLook } : {},
573
- rows
574
- },
575
- lockedFragmentIds,
576
- nextCursor: innerCursor
577
- };
578
- }
579
- function computeTableRowSpans(table) {
580
- const positionedRows = table.rows.map((row) => {
581
- let startColumn = 0;
582
- return row.cells.map((cell, cellIndex) => {
583
- const width = cell.gridSpan ?? 1;
584
- const positionedCell = {
585
- cell,
586
- cellIndex,
587
- startColumn,
588
- endColumn: startColumn + width - 1
589
- };
590
- startColumn += width;
591
- return positionedCell;
592
- });
593
- });
594
- const rowSpans = /* @__PURE__ */ new Map();
595
- for (const [rowIndex, row] of positionedRows.entries()) {
596
- for (const positionedCell of row) {
597
- if (positionedCell.cell.verticalMerge !== "restart") {
598
- rowSpans.set(`${rowIndex}:${positionedCell.cellIndex}`, 1);
599
- continue;
600
- }
601
- let rowspan = 1;
602
- for (let nextRowIndex = rowIndex + 1; nextRowIndex < positionedRows.length; nextRowIndex += 1) {
603
- const continuedCell = positionedRows[nextRowIndex]?.find(
604
- (candidate) => candidate.cell.verticalMerge === "continue" && candidate.startColumn === positionedCell.startColumn && candidate.endColumn === positionedCell.endColumn
605
- );
606
- if (!continuedCell) {
607
- break;
608
- }
609
- rowspan += 1;
610
- }
611
- rowSpans.set(`${rowIndex}:${positionedCell.cellIndex}`, rowspan);
612
- }
613
- }
614
- return rowSpans;
615
- }
616
- function resolveCellBorderStyles(borders) {
617
- if (!borders) return {};
618
- const result = {};
619
- const sides = [["top", "borderTop"], ["right", "borderRight"], ["bottom", "borderBottom"], ["left", "borderLeft"]];
620
- for (const [side, key] of sides) {
621
- const spec = borders[side];
622
- if (!spec || spec.value === "none" || spec.value === "nil") continue;
623
- const width = spec.size ? `${Math.max(1, Math.round(spec.size / 8))}px` : "1px";
624
- const style = spec.value === "double" ? "double" : spec.value === "dashed" || spec.value === "dashSmallGap" ? "dashed" : spec.value === "dotted" ? "dotted" : "solid";
625
- const color = spec.color && spec.color !== "auto" ? `#${spec.color}` : "currentColor";
626
- result[key] = `${width} ${style} ${color}`;
627
- }
628
- return result;
629
- }
630
- function createSdtBlock(sdtIndex, block, document, cursor, counters, numberingPrefixResolver) {
631
- const children = [];
632
- const lockedFragmentIds = [];
633
- let innerCursor = cursor;
634
- for (const child of block.children) {
635
- const result = createSurfaceBlock(
636
- child,
637
- document,
638
- innerCursor,
639
- counters,
640
- numberingPrefixResolver
641
- );
642
- children.push(result.block);
643
- lockedFragmentIds.push(...result.lockedFragmentIds);
644
- innerCursor = result.nextCursor;
645
- }
646
- return {
647
- block: {
648
- blockId: `sdt-${sdtIndex}`,
649
- kind: "sdt_block",
650
- from: cursor,
651
- to: innerCursor,
652
- ...block.properties.sdtType ? { sdtType: block.properties.sdtType } : {},
653
- ...block.properties.alias ? { alias: block.properties.alias } : {},
654
- ...block.properties.tag ? { tag: block.properties.tag } : {},
655
- ...block.properties.lock ? { lock: block.properties.lock } : {},
656
- ...block.properties.checkbox ? { checkboxChecked: block.properties.checkbox.checked } : {},
657
- ...block.properties.datePicker?.fullDate ? { dateValue: block.properties.datePicker.fullDate } : {},
658
- ...block.properties.dropdownList ? { dropdownItems: block.properties.dropdownList } : {},
659
- ...block.properties.comboBox ? { comboBoxItems: block.properties.comboBox } : {},
660
- ...block.properties.showingPlcHdr ? { showingPlcHdr: true } : {},
661
- children
662
- },
663
- lockedFragmentIds,
664
- nextCursor: innerCursor
665
- };
666
- }
667
- function createParagraphBlock(paragraphIndex, paragraph, document, start, numberingPrefixResolver) {
668
- const accumulator = {
669
- blockId: `paragraph-${paragraphIndex}`,
670
- kind: "paragraph",
671
- from: start,
672
- to: start,
673
- ...paragraph.styleId ? { styleId: paragraph.styleId } : {},
674
- ...paragraph.numbering ? { numbering: paragraph.numbering } : {},
675
- ...paragraph.numbering ? (() => {
676
- const detailed = numberingPrefixResolver.resolveDetailed(paragraph.numbering);
677
- return detailed ? {
678
- numberingPrefix: detailed.text,
679
- ...detailed.suffix ? { numberingSuffix: detailed.suffix } : {}
680
- } : {};
681
- })() : {},
682
- ...paragraph.alignment ? { alignment: paragraph.alignment } : {},
683
- ...paragraph.spacing ? { spacing: paragraph.spacing } : {},
684
- ...paragraph.contextualSpacing !== void 0 ? { contextualSpacing: paragraph.contextualSpacing } : {},
685
- ...paragraph.indentation ? { indentation: paragraph.indentation } : {},
686
- ...paragraph.borders ? { borders: paragraph.borders } : {},
687
- ...paragraph.shading ? { shading: paragraph.shading } : {},
688
- ...paragraph.tabStops && paragraph.tabStops.length > 0 ? { tabStops: paragraph.tabStops.map((tabStop) => toSurfaceTabStop(tabStop)) } : {},
689
- ...paragraph.keepNext ? { keepNext: true } : {},
690
- ...paragraph.keepLines ? { keepLines: true } : {},
691
- ...paragraph.pageBreakBefore ? { pageBreakBefore: true } : {},
692
- ...paragraph.outlineLevel !== void 0 ? { outlineLevel: paragraph.outlineLevel } : {},
693
- ...paragraph.bidi ? { bidi: true } : {},
694
- ...paragraph.suppressLineNumbers ? { suppressLineNumbers: true } : {},
695
- segments: []
696
- };
697
- const lockedFragmentIds = [];
698
- let cursor = start;
699
- const children = Array.isArray(paragraph.children) ? paragraph.children : [];
700
- for (const child of children) {
701
- const result = appendInlineSegments(accumulator, child, document, cursor);
702
- cursor = result.nextCursor;
703
- lockedFragmentIds.push(...result.lockedFragmentIds);
704
- }
705
- accumulator.to = cursor;
706
- return {
707
- block: accumulator,
708
- nextCursor: cursor,
709
- lockedFragmentIds
710
- };
711
- }
712
- function appendInlineSegments(paragraph, node, document, start, hyperlinkHref) {
713
- switch (node.type) {
714
- case "text":
715
- paragraph.segments.push({
716
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
717
- kind: "text",
718
- from: start,
719
- to: start + Array.from(node.text).length,
720
- text: node.text,
721
- ...node.marks ? (() => {
722
- const result = cloneMarks(node.marks);
723
- return {
724
- ...result.marks.length > 0 ? { marks: result.marks } : {},
725
- ...result.markAttrs ? { markAttrs: result.markAttrs } : {}
726
- };
727
- })() : {},
728
- ...hyperlinkHref ? { hyperlinkHref } : {}
729
- });
730
- return { nextCursor: start + Array.from(node.text).length, lockedFragmentIds: [] };
731
- case "tab":
732
- paragraph.segments.push({
733
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
734
- kind: "tab",
735
- from: start,
736
- to: start + 1,
737
- ...hyperlinkHref ? { hyperlinkHref } : {}
738
- });
739
- return { nextCursor: start + 1, lockedFragmentIds: [] };
740
- case "hard_break":
741
- paragraph.segments.push({
742
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
743
- kind: "hard_break",
744
- from: start,
745
- to: start + 1,
746
- ...hyperlinkHref ? { hyperlinkHref } : {}
747
- });
748
- return { nextCursor: start + 1, lockedFragmentIds: [] };
749
- case "hyperlink": {
750
- let cursor = start;
751
- for (const child of node.children) {
752
- const result = appendInlineSegments(paragraph, child, document, cursor, node.href);
753
- cursor = result.nextCursor;
754
- }
755
- return { nextCursor: cursor, lockedFragmentIds: [] };
756
- }
757
- case "image":
758
- paragraph.segments.push({
759
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
760
- kind: "image",
761
- from: start,
762
- to: start + 1,
763
- mediaId: node.mediaId,
764
- altText: node.altText,
765
- state: hasMediaItem(document.media, node.mediaId) ? "editable" : "missing",
766
- ...node.display ? { display: node.display } : {},
767
- detail: node.display === "floating" ? createFloatingImageDetail(node.altText, node.floating) : node.altText ? `Alt text ${node.altText}.` : "Inline image remains a whole-unit render surface."
768
- });
769
- return { nextCursor: start + 1, lockedFragmentIds: [] };
770
- case "opaque_inline": {
771
- const fragment = getOpaqueFragment(document.preservation, node.fragmentId);
772
- const descriptor = fragment ? describeOpaqueFragment(fragment) : null;
773
- const preview = fragment ? describePreservedInlinePreview(fragment.payloadReference) : null;
774
- paragraph.segments.push({
775
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
776
- kind: "opaque_inline",
777
- from: start,
778
- to: start + 1,
779
- fragmentId: node.fragmentId,
780
- warningId: node.warningId,
781
- label: preview?.label ?? descriptor?.label ?? "Unsupported inline OOXML",
782
- detail: preview?.detail ?? descriptor?.detail ?? "Locked whole-unit to keep unsupported inline OOXML intact through export.",
783
- ...preview?.presentation ? { presentation: preview.presentation } : {},
784
- state: "locked-preserve-only"
785
- });
786
- return { nextCursor: start + 1, lockedFragmentIds: [node.fragmentId] };
787
- }
788
- case "chart_preview":
789
- return appendComplexPreviewSegment(paragraph, node, start, "Embedded chart", createChartDetail(node));
790
- case "smartart_preview":
791
- return appendComplexPreviewSegment(paragraph, node, start, "SmartArt diagram", createSmartArtDetail(node));
792
- case "shape":
793
- return appendComplexPreviewSegment(
794
- paragraph,
795
- node,
796
- start,
797
- node.isTextBox ? "Text box" : "Drawing shape",
798
- createShapeDetail(node)
799
- );
800
- case "wordart":
801
- return appendComplexPreviewSegment(paragraph, node, start, "WordArt", createWordArtDetail(node));
802
- case "vml_shape":
803
- return appendComplexPreviewSegment(paragraph, node, start, "Legacy VML drawing", createVmlDetail(node));
804
- case "symbol":
805
- paragraph.segments.push({
806
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
807
- kind: "text",
808
- from: start,
809
- to: start + 1,
810
- text: node.char ? String.fromCodePoint(parseInt(node.char, 16)) : "\uFFFD"
811
- });
812
- return { nextCursor: start + 1, lockedFragmentIds: [] };
813
- case "column_break":
814
- paragraph.segments.push({
815
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
816
- kind: "opaque_inline",
817
- from: start,
818
- to: start + 1,
819
- fragmentId: "",
820
- warningId: "",
821
- label: "Column break",
822
- detail: "Column break marker preserved for export.",
823
- state: "locked-preserve-only"
824
- });
825
- return { nextCursor: start + 1, lockedFragmentIds: [] };
826
- case "footnote_ref":
827
- paragraph.segments.push({
828
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
829
- kind: "note_ref",
830
- from: start,
831
- to: start + 1,
832
- noteKind: node.noteKind ?? "footnote",
833
- noteId: node.noteId ?? "",
834
- label: node.noteId ?? "*"
835
- });
836
- return { nextCursor: start + 1, lockedFragmentIds: [] };
837
- case "field": {
838
- const isSupportedField = node.fieldFamily === "REF" || node.fieldFamily === "PAGEREF" || node.fieldFamily === "NOTEREF" || node.fieldFamily === "TOC";
839
- if (node.children && node.children.length > 0) {
840
- let cursor = start;
841
- const lockedIds = [];
842
- for (const child of node.children) {
843
- const result = appendInlineSegments(paragraph, child, document, cursor);
844
- cursor = result.nextCursor;
845
- lockedIds.push(...result.lockedFragmentIds);
846
- }
847
- return { nextCursor: cursor, lockedFragmentIds: lockedIds };
848
- }
849
- if (isSupportedField) {
850
- const fieldLabel = node.fieldFamily === "TOC" ? "Table of Contents" : `${node.fieldFamily ?? "Field"}: ${node.fieldTarget ?? node.instruction.trim()}`;
851
- paragraph.segments.push({
852
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
853
- kind: "field_ref",
854
- from: start,
855
- to: start + 1,
856
- fieldFamily: node.fieldFamily,
857
- fieldTarget: node.fieldTarget,
858
- instruction: node.instruction,
859
- refreshStatus: node.refreshStatus ?? "stale",
860
- label: fieldLabel
861
- });
862
- return { nextCursor: start + 1, lockedFragmentIds: [] };
863
- }
864
- paragraph.segments.push({
865
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
866
- kind: "opaque_inline",
867
- from: start,
868
- to: start + 1,
869
- fragmentId: "",
870
- warningId: "",
871
- label: "Field",
872
- detail: `Preserve-only field: ${node.instruction.trim()}`,
873
- state: "locked-preserve-only"
874
- });
875
- return { nextCursor: start + 1, lockedFragmentIds: [] };
876
- }
877
- case "bookmark_start":
878
- case "bookmark_end":
879
- return { nextCursor: start, lockedFragmentIds: [] };
880
- default:
881
- return { nextCursor: start + 1, lockedFragmentIds: [] };
882
- }
883
- }
884
- function appendComplexPreviewSegment(paragraph, node, start, label, detail) {
885
- paragraph.segments.push({
886
- segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
887
- kind: "opaque_inline",
888
- from: start,
889
- to: start + 1,
890
- fragmentId: `complex:${label.replace(/\s/g, "-").toLowerCase()}:${start}`,
891
- warningId: `warning:complex-preview:${start}`,
892
- label,
893
- detail,
894
- state: "locked-preserve-only"
895
- });
896
- return { nextCursor: start + 1, lockedFragmentIds: [] };
897
- }
898
- function createChartDetail(node) {
899
- const parts = ["Embedded chart."];
900
- if (node.previewMediaId) {
901
- parts.push(`Preview available via fallback image (${node.previewMediaId}).`);
902
- } else {
903
- parts.push("No fallback preview image found; chart data preserved in package.");
904
- }
905
- parts.push("Edit in Word to modify chart data. Original DrawingML preserved for lossless export.");
906
- return parts.join(" ");
907
- }
908
- function createSmartArtDetail(node) {
909
- const parts = ["SmartArt diagram."];
910
- if (node.previewMediaId) {
911
- parts.push(`Preview available via fallback image (${node.previewMediaId}).`);
912
- } else {
913
- parts.push("No fallback preview image found; diagram structure preserved in package.");
914
- }
915
- parts.push("Edit in Word to modify diagram layout and content. Original DrawingML preserved for lossless export.");
916
- return parts.join(" ");
917
- }
918
- function createShapeDetail(node) {
919
- if (node.isTextBox) {
920
- const parts2 = ["Text box."];
921
- if (node.text) parts2.push(`Content: "${node.text}".`);
922
- parts2.push("Text content is visible; formatting and geometry preserved for export.");
923
- return parts2.join(" ");
924
- }
925
- const parts = ["Drawing shape."];
926
- if (node.geometry) parts.push(`Geometry: ${node.geometry}.`);
927
- if (node.text) parts.push(`Text content: "${node.text}".`);
928
- parts.push("Visual geometry is preview-only. Original DrawingML preserved for export.");
929
- return parts.join(" ");
930
- }
931
- function createWordArtDetail(node) {
932
- const parts = ["WordArt decorative text."];
933
- if (node.text) parts.push(`Text: "${node.text}".`);
934
- if (node.geometry) parts.push(`Effect: ${node.geometry}.`);
935
- parts.push("Text effect is preview-only. Edit in Word for full formatting. Original DrawingML preserved for export.");
936
- return parts.join(" ");
937
- }
938
- function createVmlDetail(node) {
939
- const parts = ["Legacy VML drawing."];
940
- if (node.shapeType) parts.push(`Type: ${node.shapeType}.`);
941
- if (node.text) parts.push(`Text content: "${node.text}".`);
942
- parts.push("VML content is preview-only. Edit in Word for full control. Original VML XML preserved for export.");
943
- return parts.join(" ");
944
- }
945
- function createPlainText(blocks) {
946
- const text = [];
947
- for (const block of blocks) {
948
- if (block.kind === "opaque_block") {
949
- if (block.fragmentId.startsWith("preview:")) {
950
- continue;
951
- }
952
- text.push("\uFFFA");
953
- continue;
954
- }
955
- if (block.kind === "table") {
956
- for (const row of block.rows) {
957
- for (const cell of row.cells) {
958
- text.push(createPlainText(cell.content));
959
- }
960
- }
961
- continue;
962
- }
963
- if (block.kind === "sdt_block") {
964
- text.push(createPlainText(block.children));
965
- continue;
966
- }
967
- for (const segment of block.segments) {
968
- switch (segment.kind) {
969
- case "text":
970
- text.push(segment.text);
971
- break;
972
- case "tab":
973
- text.push(" ");
974
- break;
975
- case "hard_break":
976
- text.push("\n");
977
- break;
978
- case "image":
979
- text.push("\uFFFC");
980
- break;
981
- case "opaque_inline":
982
- text.push("\uFFF9");
983
- break;
984
- }
985
- }
986
- }
987
- return text.join("");
988
- }
989
- function createSecondaryStorySurfaces(document) {
990
- const surfaces = [];
991
- const subParts = document.subParts;
992
- if (!subParts) {
993
- return surfaces;
994
- }
995
- const numberingPrefixResolver = createNumberingPrefixResolver(document.numbering);
996
- for (const section of collectSectionContexts(document)) {
997
- const headerVariants = resolveSectionVariants(
998
- "header",
999
- section.index,
1000
- section.properties?.headerReferences,
1001
- subParts.headers ?? []
1002
- );
1003
- for (const headerVariant of headerVariants) {
1004
- const target = {
1005
- kind: "header",
1006
- relationshipId: headerVariant.relationshipId,
1007
- variant: headerVariant.variant,
1008
- sectionIndex: section.index
1009
- };
1010
- const header = findHeaderFooterDocumentEntry(document, target);
1011
- if (!header) {
1012
- continue;
1013
- }
1014
- surfaces.push(
1015
- createStorySurface(
1016
- target,
1017
- `Header \xB7 ${headerVariant.variant}`,
1018
- header.blocks,
1019
- document,
1020
- numberingPrefixResolver
1021
- )
1022
- );
1023
- }
1024
- const footerVariants = resolveSectionVariants(
1025
- "footer",
1026
- section.index,
1027
- section.properties?.footerReferences,
1028
- subParts.footers ?? []
1029
- );
1030
- for (const footerVariant of footerVariants) {
1031
- const target = {
1032
- kind: "footer",
1033
- relationshipId: footerVariant.relationshipId,
1034
- variant: footerVariant.variant,
1035
- sectionIndex: section.index
1036
- };
1037
- const footer = findHeaderFooterDocumentEntry(document, target);
1038
- if (!footer) {
1039
- continue;
1040
- }
1041
- surfaces.push(
1042
- createStorySurface(
1043
- target,
1044
- `Footer \xB7 ${footerVariant.variant}`,
1045
- footer.blocks,
1046
- document,
1047
- numberingPrefixResolver
1048
- )
1049
- );
1050
- }
1051
- }
1052
- const footnotes = Object.values(subParts.footnoteCollection?.footnotes ?? {}).sort(compareNoteIds);
1053
- for (const note of footnotes) {
1054
- const target = { kind: "footnote", noteId: note.noteId };
1055
- surfaces.push(createStorySurface(target, `Footnote ${note.noteId}`, note.blocks, document, numberingPrefixResolver));
1056
- }
1057
- const endnotes = Object.values(subParts.footnoteCollection?.endnotes ?? {}).sort(compareNoteIds);
1058
- for (const note of endnotes) {
1059
- const target = { kind: "endnote", noteId: note.noteId };
1060
- surfaces.push(createStorySurface(target, `Endnote ${note.noteId}`, note.blocks, document, numberingPrefixResolver));
1061
- }
1062
- return surfaces;
1063
- }
1064
- function createStorySurface(target, label, blocks, document, numberingPrefixResolver) {
1065
- const surfaceBlocks = [];
1066
- let cursor = 0;
1067
- const counters = {
1068
- paragraph: 0,
1069
- table: 0,
1070
- opaque: 0,
1071
- sdt: 0,
1072
- customXml: 0,
1073
- altChunk: 0
1074
- };
1075
- for (let index = 0; index < blocks.length; index += 1) {
1076
- const surfaceBlock = createSurfaceBlock(
1077
- blocks[index],
1078
- document,
1079
- cursor,
1080
- counters,
1081
- numberingPrefixResolver
1082
- );
1083
- surfaceBlocks.push(surfaceBlock.block);
1084
- cursor = surfaceBlock.nextCursor;
1085
- if (index < blocks.length - 1 && blocks[index + 1]?.type === "paragraph") {
1086
- cursor += 1;
1087
- }
1088
- }
1089
- return {
1090
- target,
1091
- label,
1092
- storySize: cursor,
1093
- blocks: surfaceBlocks
1094
- };
1095
- }
1096
- function compareNoteIds(left, right) {
1097
- return Number.parseInt(left.noteId, 10) - Number.parseInt(right.noteId, 10);
1098
- }
1099
- function toSurfaceTabStop(tabStop) {
1100
- return {
1101
- pos: tabStop.position,
1102
- ...tabStop.align ? { val: tabStop.align } : {},
1103
- ...tabStop.leader ? { leader: tabStop.leader } : {}
1104
- };
1105
- }
1106
- function describePreservedInlinePreview(payloadReference) {
1107
- if (/\b(?:w:)?proofErr\b/u.test(payloadReference)) {
1108
- const proofType = /\bw:type="([^"]+)"/u.exec(payloadReference)?.[1];
1109
- return {
1110
- label: "Proofing marker",
1111
- detail: proofType && proofType.trim().length > 0 ? `Word proofing marker (${proofType}) preserved for export safety.` : "Word proofing marker preserved for export safety.",
1112
- presentation: "quiet-marker"
1113
- };
1114
- }
1115
- if (/\b(?:w:)?lastRenderedPageBreak\b/u.test(payloadReference)) {
1116
- return {
1117
- label: "Rendered page break",
1118
- detail: "Word rendered page-break marker preserved for export safety.",
1119
- presentation: "quiet-marker"
1120
- };
1121
- }
1122
- if (/\b(?:w:)?permStart\b/u.test(payloadReference)) {
1123
- const editorGroup = /\bw:edGrp="([^"]+)"/u.exec(payloadReference)?.[1];
1124
- return {
1125
- label: "Protected range start",
1126
- detail: editorGroup && editorGroup.trim().length > 0 ? `Protected range start for ${editorGroup} preserved for export safety.` : "Protected range start preserved for export safety.",
1127
- presentation: "quiet-marker"
1128
- };
1129
- }
1130
- if (/\b(?:w:)?permEnd\b/u.test(payloadReference)) {
1131
- return {
1132
- label: "Protected range end",
1133
- detail: "Protected range end preserved for export safety.",
1134
- presentation: "quiet-marker"
1135
- };
1136
- }
1137
- if (/\b(?:w:)?bookmarkStart\b/u.test(payloadReference)) {
1138
- const name = /\bw:name="([^"]+)"/u.exec(payloadReference)?.[1];
1139
- return {
1140
- label: name ? `Bookmark \xB7 ${name}` : "Bookmark",
1141
- detail: name ? `Bookmark anchor "${name}" is preserved as a read-only inline token for export safety.` : "Bookmark anchor is preserved as a read-only inline token for export safety."
1142
- };
1143
- }
1144
- if (/\b(?:w:)?bookmarkEnd\b/u.test(payloadReference)) {
1145
- return {
1146
- label: "Bookmark end",
1147
- detail: "Bookmark end marker is preserved as a read-only inline token for export safety."
1148
- };
1149
- }
1150
- if (/\b(?:w:)?fldSimple\b|\b(?:w:)?fldChar\b|\b(?:w:)?instrText\b/u.test(payloadReference)) {
1151
- const simpleInstruction = /\bw:instr="([^"]*)"/u.exec(payloadReference)?.[1];
1152
- const complexInstruction = [...payloadReference.matchAll(/<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gu)].map((match) => decodeXmlEntities(match[1] ?? "")).join("").trim();
1153
- const instruction = (simpleInstruction ?? complexInstruction ?? "").trim();
1154
- const family = /^([A-Z]+)/i.exec(instruction)?.[1]?.toUpperCase();
1155
- const label = family === "TOC" ? "Table of Contents field" : family ? `${family} field` : "Field";
1156
- return {
1157
- label,
1158
- detail: instruction.length > 0 ? `Read-only field preserved for export safety. Instruction: ${instruction}.` : "Read-only field preserved for export safety."
1159
- };
1160
- }
1161
- return null;
1162
- }
1163
- function decodeXmlEntities(text) {
1164
- return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
1165
- }
1166
- function cloneMarks(marks) {
1167
- const supported = [];
1168
- const attrs = {};
1169
- let shadingColor;
1170
- let highlightColor;
1171
- for (const mark of marks) {
1172
- switch (mark.type) {
1173
- case "bold":
1174
- case "italic":
1175
- case "underline":
1176
- case "strikethrough":
1177
- case "doubleStrikethrough":
1178
- case "vanish":
1179
- case "emboss":
1180
- case "imprint":
1181
- case "shadow":
1182
- supported.push(mark.type);
1183
- break;
1184
- case "position":
1185
- if (mark.val > 0) supported.push("superscript");
1186
- else if (mark.val < 0) supported.push("subscript");
1187
- break;
1188
- case "backgroundColor":
1189
- shadingColor = mark.color;
1190
- break;
1191
- case "highlight":
1192
- highlightColor = mark.color;
1193
- break;
1194
- case "charSpacing":
1195
- attrs.charSpacing = mark.val;
1196
- break;
1197
- case "kerning":
1198
- attrs.kerning = mark.val;
1199
- break;
1200
- case "textFill":
1201
- attrs.textFill = mark.xml;
1202
- break;
1203
- case "fontFamily":
1204
- attrs.fontFamily = mark.val;
1205
- break;
1206
- case "fontSize":
1207
- attrs.fontSize = mark.val;
1208
- break;
1209
- case "textColor":
1210
- attrs.textColor = mark.color;
1211
- break;
1212
- case "smallCaps":
1213
- supported.push("smallCaps");
1214
- break;
1215
- case "allCaps":
1216
- supported.push("allCaps");
1217
- break;
1218
- case "lang":
1219
- break;
1220
- }
1221
- }
1222
- if (highlightColor || shadingColor) {
1223
- attrs.backgroundColor = highlightColor ?? shadingColor;
1224
- }
1225
- const hasAttrs = Object.keys(attrs).length > 0;
1226
- return hasAttrs ? { marks: supported, markAttrs: attrs } : { marks: supported };
1227
- }
1228
- function normalizeDocumentRoot(content) {
1229
- if (content && typeof content === "object" && (content.type === "doc" || content.type === "document_root")) {
1230
- return content;
1231
- }
1232
- if (Array.isArray(content)) {
1233
- return {
1234
- type: "doc",
1235
- children: content.filter(
1236
- (value) => Boolean(value) && typeof value === "object" && (value.type === "paragraph" || value.type === "table" || value.type === "sdt" || value.type === "custom_xml" || value.type === "alt_chunk" || value.type === "opaque_block")
1237
- )
1238
- };
1239
- }
1240
- return {
1241
- type: "doc",
1242
- children: [{ type: "paragraph", children: [] }]
1243
- };
1244
- }
1245
- function createFloatingImageDetail(altText, floating) {
1246
- const parts = [altText ? `Alt text ${altText}.` : "Floating image rendered inline in the editor."];
1247
- if (floating?.wrap) {
1248
- parts.push(`Wrap ${floating.wrap}.`);
1249
- }
1250
- if (floating?.horizontalPosition?.align || floating?.horizontalPosition?.offset !== void 0) {
1251
- parts.push(
1252
- `Horizontal ${floating.horizontalPosition.align ?? floating.horizontalPosition.offset}.`
1253
- );
1254
- }
1255
- if (floating?.verticalPosition?.align || floating?.verticalPosition?.offset !== void 0) {
1256
- parts.push(
1257
- `Vertical ${floating.verticalPosition.align ?? floating.verticalPosition.offset}.`
1258
- );
1259
- }
1260
- return parts.join(" ");
1261
- }
1262
- function hasMediaItem(media, mediaId) {
1263
- return mediaId in media.items;
1264
- }
1265
-
1266
- export {
1267
- resolveSectionVariants,
1268
- sectionSupportsStoryTarget,
1269
- normalizeHeaderFooterTarget,
1270
- storyTargetKey,
1271
- getStoryBlocks,
1272
- replaceStoryBlocks,
1273
- createEditorSurfaceSnapshot
1274
- };
1275
- //# sourceMappingURL=chunk-EILUG3VB.js.map