superdoc 2.2.1 → 2.4.0-next.1

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 (689) hide show
  1. package/AGENTS.md +337 -0
  2. package/LICENSE +661 -0
  3. package/NOTICE +8 -0
  4. package/README.md +106 -0
  5. package/dist/chunks/FindReplaceSurface-BEW-1NhM.es.js +344 -0
  6. package/dist/chunks/FindReplaceSurface-Dx0llWqP.cjs +346 -0
  7. package/dist/chunks/PasswordPromptSurface-BA6HHqEa.es.js +111 -0
  8. package/dist/chunks/PasswordPromptSurface-BUUVC2ee.cjs +113 -0
  9. package/dist/chunks/PdfViewer-CNOtyS-I.es.js +531 -0
  10. package/dist/chunks/PdfViewer-qpvzwYMz.cjs +535 -0
  11. package/dist/chunks/_plugin-vue_export-helper-BTwbGDKw.cjs +11 -0
  12. package/dist/chunks/_plugin-vue_export-helper-CInC0bKI.es.js +6 -0
  13. package/dist/chunks/blank-docx-DP8RUPW-.cjs +7 -0
  14. package/dist/chunks/blank-docx-XRX6Ker2.es.js +2 -0
  15. package/dist/chunks/constants-CY3R3_kF.es.js +3 -0
  16. package/dist/chunks/constants-sbCZ2O_A.cjs +14 -0
  17. package/dist/chunks/create-super-doc-ui-D4kk9AjM.es.js +9417 -0
  18. package/dist/chunks/create-super-doc-ui-DXdWuTzm.cjs +9680 -0
  19. package/dist/chunks/eventemitter3-Bt2s0X0a.es.js +131 -0
  20. package/dist/chunks/eventemitter3-DqY4aSMf.cjs +137 -0
  21. package/dist/chunks/jszip-C8srOKAO.es.js +4650 -0
  22. package/dist/chunks/jszip-Cs9JBLlJ.cjs +4691 -0
  23. package/dist/chunks/rolldown-runtime-1Y-nnZJ3.cjs +40 -0
  24. package/dist/chunks/rolldown-runtime-D7PMmH3s.es.js +27 -0
  25. package/dist/chunks/uuid-B2Sqk-3p.es.js +32 -0
  26. package/dist/chunks/uuid-CFp0WGVU.cjs +38 -0
  27. package/dist/collaboration-upgrade-engine.cjs +37 -0
  28. package/dist/collaboration-upgrade-engine.es.js +30 -0
  29. package/dist/document-api/src/authorities/authorities.d.ts +29 -0
  30. package/dist/document-api/src/authorities/authorities.types.d.ts +113 -0
  31. package/dist/document-api/src/blocks/blocks.d.ts +29 -0
  32. package/dist/document-api/src/bookmarks/bookmarks.d.ts +15 -0
  33. package/dist/document-api/src/bookmarks/bookmarks.types.d.ts +82 -0
  34. package/dist/document-api/src/capabilities/capabilities.d.ts +82 -0
  35. package/dist/document-api/src/captions/captions.d.ts +17 -0
  36. package/dist/document-api/src/captions/captions.types.d.ts +61 -0
  37. package/dist/document-api/src/citations/citations.d.ts +39 -0
  38. package/dist/document-api/src/citations/citations.types.d.ts +151 -0
  39. package/dist/document-api/src/clear-content/clear-content.d.ts +25 -0
  40. package/dist/document-api/src/clipboard/clipboard.d.ts +11 -0
  41. package/dist/document-api/src/comments/comment-create-attribution.d.ts +2 -0
  42. package/dist/document-api/src/comments/comments.d.ts +231 -0
  43. package/dist/document-api/src/comments/comments.types.d.ts +266 -0
  44. package/dist/document-api/src/content-controls/content-controls.d.ts +136 -0
  45. package/dist/document-api/src/content-controls/content-controls.types.d.ts +455 -0
  46. package/dist/document-api/src/contract/command-catalog.d.ts +17 -0
  47. package/dist/document-api/src/contract/index.d.ts +9 -0
  48. package/dist/document-api/src/contract/metadata-types.d.ts +48 -0
  49. package/dist/document-api/src/contract/operation-definitions.d.ts +3645 -0
  50. package/dist/document-api/src/contract/operation-map.d.ts +5 -0
  51. package/dist/document-api/src/contract/operation-registry.d.ts +2002 -0
  52. package/dist/document-api/src/contract/reference-aliases.d.ts +19 -0
  53. package/dist/document-api/src/contract/reference-doc-map.d.ts +12 -0
  54. package/dist/document-api/src/contract/schemas.d.ts +35 -0
  55. package/dist/document-api/src/contract/step-op-catalog.d.ts +26 -0
  56. package/dist/document-api/src/contract/types.d.ts +31 -0
  57. package/dist/document-api/src/create/create.d.ts +27 -0
  58. package/dist/document-api/src/cross-refs/cross-refs.d.ts +15 -0
  59. package/dist/document-api/src/cross-refs/cross-refs.types.d.ts +68 -0
  60. package/dist/document-api/src/customXml/customXml.d.ts +19 -0
  61. package/dist/document-api/src/customXml/customXml.types.d.ts +148 -0
  62. package/dist/document-api/src/delete/delete.d.ts +20 -0
  63. package/dist/document-api/src/diff/diff.d.ts +14 -0
  64. package/dist/document-api/src/diff/diff.types.d.ts +83 -0
  65. package/dist/document-api/src/diff/index.d.ts +3 -0
  66. package/dist/document-api/src/errors.d.ts +11 -0
  67. package/dist/document-api/src/export/export.d.ts +10 -0
  68. package/dist/document-api/src/export/export.types.d.ts +40 -0
  69. package/dist/document-api/src/extract/extract.d.ts +15 -0
  70. package/dist/document-api/src/fields/fields.d.ts +15 -0
  71. package/dist/document-api/src/fields/fields.types.d.ts +90 -0
  72. package/dist/document-api/src/find/find.d.ts +52 -0
  73. package/dist/document-api/src/footnotes/footnotes.d.ts +17 -0
  74. package/dist/document-api/src/footnotes/footnotes.types.d.ts +104 -0
  75. package/dist/document-api/src/format/format.d.ts +92 -0
  76. package/dist/document-api/src/format/inline-run-patch.d.ts +138 -0
  77. package/dist/document-api/src/get/get.d.ts +19 -0
  78. package/dist/document-api/src/get-html/get-html.d.ts +27 -0
  79. package/dist/document-api/src/get-markdown/get-markdown.d.ts +22 -0
  80. package/dist/document-api/src/get-node/get-node.d.ts +46 -0
  81. package/dist/document-api/src/get-text/get-text.d.ts +22 -0
  82. package/dist/document-api/src/header-footers/header-footers.d.ts +37 -0
  83. package/dist/document-api/src/header-footers/header-footers.types.d.ts +116 -0
  84. package/dist/document-api/src/history/history.d.ts +38 -0
  85. package/dist/document-api/src/history/history.types.d.ts +100 -0
  86. package/dist/document-api/src/hyperlinks/hyperlinks.d.ts +17 -0
  87. package/dist/document-api/src/hyperlinks/hyperlinks.types.d.ts +112 -0
  88. package/dist/document-api/src/images/images.d.ts +63 -0
  89. package/dist/document-api/src/images/images.types.d.ts +209 -0
  90. package/dist/document-api/src/images/z-order.d.ts +10 -0
  91. package/dist/document-api/src/index/index.d.ts +29 -0
  92. package/dist/document-api/src/index/index.types.d.ts +125 -0
  93. package/dist/document-api/src/index.d.ts +560 -0
  94. package/dist/document-api/src/info/info.d.ts +19 -0
  95. package/dist/document-api/src/inline-semantics/directives.d.ts +95 -0
  96. package/dist/document-api/src/inline-semantics/error-types.d.ts +68 -0
  97. package/dist/document-api/src/inline-semantics/index.d.ts +20 -0
  98. package/dist/document-api/src/inline-semantics/property-ids.d.ts +24 -0
  99. package/dist/document-api/src/inline-semantics/token-parsers.d.ts +59 -0
  100. package/dist/document-api/src/inline-semantics/token-sets.d.ts +34 -0
  101. package/dist/document-api/src/insert/insert.d.ts +65 -0
  102. package/dist/document-api/src/invoke/invoke.d.ts +17 -0
  103. package/dist/document-api/src/lists/lists.d.ts +100 -0
  104. package/dist/document-api/src/lists/lists.types.d.ts +499 -0
  105. package/dist/document-api/src/markdown-to-fragment/markdown-to-fragment.d.ts +15 -0
  106. package/dist/document-api/src/metadata/anchored-metadata.d.ts +33 -0
  107. package/dist/document-api/src/metadata/anchored-metadata.types.d.ts +175 -0
  108. package/dist/document-api/src/paragraphs/paragraphs.d.ts +84 -0
  109. package/dist/document-api/src/paragraphs/paragraphs.types.d.ts +214 -0
  110. package/dist/document-api/src/permission-ranges/permission-ranges.d.ts +15 -0
  111. package/dist/document-api/src/permission-ranges/permission-ranges.types.d.ts +49 -0
  112. package/dist/document-api/src/plan/plan.d.ts +73 -0
  113. package/dist/document-api/src/protection/protection.d.ts +11 -0
  114. package/dist/document-api/src/protection/protection.types.d.ts +47 -0
  115. package/dist/document-api/src/ranges/index.d.ts +2 -0
  116. package/dist/document-api/src/ranges/ranges.types.d.ts +121 -0
  117. package/dist/document-api/src/ranges/resolve.d.ts +2 -0
  118. package/dist/document-api/src/receipt-bridge.d.ts +30 -0
  119. package/dist/document-api/src/replace/replace.d.ts +24 -0
  120. package/dist/document-api/src/sections/sections.d.ts +42 -0
  121. package/dist/document-api/src/sections/sections.types.d.ts +236 -0
  122. package/dist/document-api/src/selection/selection.d.ts +23 -0
  123. package/dist/document-api/src/selection/selection.types.d.ts +85 -0
  124. package/dist/document-api/src/selection-mutation.d.ts +46 -0
  125. package/dist/document-api/src/styles/apply.d.ts +142 -0
  126. package/dist/document-api/src/styles/catalog.d.ts +154 -0
  127. package/dist/document-api/src/styles/index.d.ts +14 -0
  128. package/dist/document-api/src/styles/registry.d.ts +43 -0
  129. package/dist/document-api/src/styles/schema.d.ts +9 -0
  130. package/dist/document-api/src/styles/validation.d.ts +38 -0
  131. package/dist/document-api/src/tables/color-formats.d.ts +12 -0
  132. package/dist/document-api/src/tables/tables.d.ts +83 -0
  133. package/dist/document-api/src/templates/apply.d.ts +160 -0
  134. package/dist/document-api/src/templates/index.d.ts +7 -0
  135. package/dist/document-api/src/toc/toc.d.ts +25 -0
  136. package/dist/document-api/src/toc/toc.types.d.ts +247 -0
  137. package/dist/document-api/src/track-changes/track-changes.d.ts +177 -0
  138. package/dist/document-api/src/types/adapter-result.d.ts +10 -0
  139. package/dist/document-api/src/types/address.d.ts +169 -0
  140. package/dist/document-api/src/types/base.d.ts +89 -0
  141. package/dist/document-api/src/types/blocks.types.d.ts +190 -0
  142. package/dist/document-api/src/types/clipboard.d.ts +216 -0
  143. package/dist/document-api/src/types/comments.types.d.ts +17 -0
  144. package/dist/document-api/src/types/create.types.d.ts +56 -0
  145. package/dist/document-api/src/types/discovery.d.ts +99 -0
  146. package/dist/document-api/src/types/extract.types.d.ts +163 -0
  147. package/dist/document-api/src/types/fragment.d.ts +29 -0
  148. package/dist/document-api/src/types/index.d.ts +30 -0
  149. package/dist/document-api/src/types/info.types.d.ts +109 -0
  150. package/dist/document-api/src/types/inline.types.d.ts +28 -0
  151. package/dist/document-api/src/types/media.types.d.ts +72 -0
  152. package/dist/document-api/src/types/mutation-plan.types.d.ts +264 -0
  153. package/dist/document-api/src/types/node.d.ts +9 -0
  154. package/dist/document-api/src/types/paragraph.types.d.ts +61 -0
  155. package/dist/document-api/src/types/placement.d.ts +24 -0
  156. package/dist/document-api/src/types/query-match.types.d.ts +212 -0
  157. package/dist/document-api/src/types/query.d.ts +133 -0
  158. package/dist/document-api/src/types/receipt.d.ts +191 -0
  159. package/dist/document-api/src/types/references.types.d.ts +9 -0
  160. package/dist/document-api/src/types/sd-contract.d.ts +54 -0
  161. package/dist/document-api/src/types/sd-envelope.d.ts +59 -0
  162. package/dist/document-api/src/types/sd-nodes.d.ts +375 -0
  163. package/dist/document-api/src/types/sd-objects.d.ts +144 -0
  164. package/dist/document-api/src/types/sd-props.d.ts +240 -0
  165. package/dist/document-api/src/types/sd-sections.d.ts +126 -0
  166. package/dist/document-api/src/types/sd-styles.d.ts +36 -0
  167. package/dist/document-api/src/types/step-manifest.types.d.ts +30 -0
  168. package/dist/document-api/src/types/story.types.d.ts +123 -0
  169. package/dist/document-api/src/types/structural-input.d.ts +40 -0
  170. package/dist/document-api/src/types/structured.types.d.ts +21 -0
  171. package/dist/document-api/src/types/style-policy.types.d.ts +49 -0
  172. package/dist/document-api/src/types/table-operations.types.d.ts +618 -0
  173. package/dist/document-api/src/types/tables.types.d.ts +43 -0
  174. package/dist/document-api/src/types/toc.types.d.ts +1 -0
  175. package/dist/document-api/src/types/track-changes.types.d.ts +703 -0
  176. package/dist/document-api/src/validation/create-location-validator.d.ts +2 -0
  177. package/dist/document-api/src/validation/fragment-validator.d.ts +13 -0
  178. package/dist/document-api/src/validation/selection-target-validator.d.ts +7 -0
  179. package/dist/document-api/src/validation/story-validator.d.ts +12 -0
  180. package/dist/document-api/src/validation-primitives.d.ts +29 -0
  181. package/dist/document-api/src/write/locator.d.ts +24 -0
  182. package/dist/document-api/src/write/write.d.ts +73 -0
  183. package/dist/images/altText_add.svg +3 -0
  184. package/dist/images/altText_disclaimer.svg +3 -0
  185. package/dist/images/altText_done.svg +3 -0
  186. package/dist/images/altText_spinner.svg +30 -0
  187. package/dist/images/altText_warning.svg +3 -0
  188. package/dist/images/annotation-check.svg +11 -0
  189. package/dist/images/annotation-comment.svg +16 -0
  190. package/dist/images/annotation-help.svg +26 -0
  191. package/dist/images/annotation-insert.svg +10 -0
  192. package/dist/images/annotation-key.svg +11 -0
  193. package/dist/images/annotation-newparagraph.svg +11 -0
  194. package/dist/images/annotation-noicon.svg +7 -0
  195. package/dist/images/annotation-note.svg +42 -0
  196. package/dist/images/annotation-paperclip.svg +6 -0
  197. package/dist/images/annotation-paragraph.svg +16 -0
  198. package/dist/images/annotation-pushpin.svg +7 -0
  199. package/dist/images/checkmark.svg +5 -0
  200. package/dist/images/comment-actionsButton.svg +3 -0
  201. package/dist/images/comment-closeButton.svg +3 -0
  202. package/dist/images/comment-editButton.svg +8 -0
  203. package/dist/images/comment-popup-editButton.svg +5 -0
  204. package/dist/images/cursor-editorFreeHighlight.svg +6 -0
  205. package/dist/images/cursor-editorFreeText.svg +3 -0
  206. package/dist/images/cursor-editorInk.svg +4 -0
  207. package/dist/images/cursor-editorTextHighlight.svg +8 -0
  208. package/dist/images/editor-toolbar-delete.svg +5 -0
  209. package/dist/images/editor-toolbar-edit.svg +3 -0
  210. package/dist/images/findbarButton-next.svg +3 -0
  211. package/dist/images/findbarButton-previous.svg +3 -0
  212. package/dist/images/gv-toolbarButton-download.svg +3 -0
  213. package/dist/images/loading-icon.gif +0 -0
  214. package/dist/images/loading.svg +1 -0
  215. package/dist/images/messageBar_closingButton.svg +3 -0
  216. package/dist/images/messageBar_info.svg +3 -0
  217. package/dist/images/messageBar_warning.svg +3 -0
  218. package/dist/images/pages_closeButton.svg +3 -0
  219. package/dist/images/pages_selected.svg +7 -0
  220. package/dist/images/pages_viewArrow.svg +3 -0
  221. package/dist/images/pages_viewButton.svg +3 -0
  222. package/dist/images/secondaryToolbarButton-documentProperties.svg +3 -0
  223. package/dist/images/secondaryToolbarButton-firstPage.svg +3 -0
  224. package/dist/images/secondaryToolbarButton-handTool.svg +3 -0
  225. package/dist/images/secondaryToolbarButton-lastPage.svg +3 -0
  226. package/dist/images/secondaryToolbarButton-rotateCcw.svg +3 -0
  227. package/dist/images/secondaryToolbarButton-rotateCw.svg +3 -0
  228. package/dist/images/secondaryToolbarButton-scrollHorizontal.svg +3 -0
  229. package/dist/images/secondaryToolbarButton-scrollPage.svg +3 -0
  230. package/dist/images/secondaryToolbarButton-scrollVertical.svg +3 -0
  231. package/dist/images/secondaryToolbarButton-scrollWrapped.svg +3 -0
  232. package/dist/images/secondaryToolbarButton-selectTool.svg +3 -0
  233. package/dist/images/secondaryToolbarButton-spreadEven.svg +3 -0
  234. package/dist/images/secondaryToolbarButton-spreadNone.svg +3 -0
  235. package/dist/images/secondaryToolbarButton-spreadOdd.svg +3 -0
  236. package/dist/images/toolbarButton-bookmark.svg +3 -0
  237. package/dist/images/toolbarButton-currentOutlineItem.svg +3 -0
  238. package/dist/images/toolbarButton-download.svg +4 -0
  239. package/dist/images/toolbarButton-editorFreeText.svg +5 -0
  240. package/dist/images/toolbarButton-editorHighlight.svg +6 -0
  241. package/dist/images/toolbarButton-editorInk.svg +4 -0
  242. package/dist/images/toolbarButton-editorSignature.svg +6 -0
  243. package/dist/images/toolbarButton-editorStamp.svg +8 -0
  244. package/dist/images/toolbarButton-menuArrow.svg +3 -0
  245. package/dist/images/toolbarButton-openFile.svg +3 -0
  246. package/dist/images/toolbarButton-pageDown.svg +3 -0
  247. package/dist/images/toolbarButton-pageUp.svg +3 -0
  248. package/dist/images/toolbarButton-presentationMode.svg +3 -0
  249. package/dist/images/toolbarButton-print.svg +3 -0
  250. package/dist/images/toolbarButton-search.svg +3 -0
  251. package/dist/images/toolbarButton-secondaryToolbarToggle.svg +3 -0
  252. package/dist/images/toolbarButton-viewAttachments.svg +3 -0
  253. package/dist/images/toolbarButton-viewLayers.svg +3 -0
  254. package/dist/images/toolbarButton-viewOutline.svg +3 -0
  255. package/dist/images/toolbarButton-viewThumbnail.svg +3 -0
  256. package/dist/images/toolbarButton-viewsManagerToggle.svg +3 -0
  257. package/dist/images/toolbarButton-zoomIn.svg +3 -0
  258. package/dist/images/toolbarButton-zoomOut.svg +3 -0
  259. package/dist/images/treeitem-collapsed.svg +1 -0
  260. package/dist/images/treeitem-expanded.svg +1 -0
  261. package/dist/layout-engine/contracts/src/author-colors.d.ts +56 -0
  262. package/dist/layout-engine/contracts/src/cell-spacing.d.ts +12 -0
  263. package/dist/layout-engine/contracts/src/clip-path-inset.d.ts +27 -0
  264. package/dist/layout-engine/contracts/src/column-layout.d.ts +79 -0
  265. package/dist/layout-engine/contracts/src/direction-context.d.ts +219 -0
  266. package/dist/layout-engine/contracts/src/drawing-taxonomy.d.ts +126 -0
  267. package/dist/layout-engine/contracts/src/engines/image-wrap.d.ts +54 -0
  268. package/dist/layout-engine/contracts/src/engines/index.d.ts +17 -0
  269. package/dist/layout-engine/contracts/src/engines/lists.d.ts +57 -0
  270. package/dist/layout-engine/contracts/src/engines/paragraph.d.ts +59 -0
  271. package/dist/layout-engine/contracts/src/engines/tables.d.ts +89 -0
  272. package/dist/layout-engine/contracts/src/engines/tabs.d.ts +117 -0
  273. package/dist/layout-engine/contracts/src/graphic-placement.d.ts +76 -0
  274. package/dist/layout-engine/contracts/src/header-footer-inheritance.d.ts +22 -0
  275. package/dist/layout-engine/contracts/src/header-footer-resolution.d.ts +28 -0
  276. package/dist/layout-engine/contracts/src/incremental-dependency.d.ts +10 -0
  277. package/dist/layout-engine/contracts/src/index.d.ts +2459 -0
  278. package/dist/layout-engine/contracts/src/justify-utils.d.ts +98 -0
  279. package/dist/layout-engine/contracts/src/layout-identity.d.ts +136 -0
  280. package/dist/layout-engine/contracts/src/ooxml-z-index.d.ts +46 -0
  281. package/dist/layout-engine/contracts/src/page-number-formatting.d.ts +26 -0
  282. package/dist/layout-engine/contracts/src/page-ref-anchor.d.ts +2 -0
  283. package/dist/layout-engine/contracts/src/pm-range.d.ts +45 -0
  284. package/dist/layout-engine/contracts/src/resolved-layout.d.ts +541 -0
  285. package/dist/layout-engine/contracts/src/run-helpers.d.ts +23 -0
  286. package/dist/layout-engine/contracts/src/sdt-container.d.ts +13 -0
  287. package/dist/layout-engine/contracts/src/segment-geometry.d.ts +192 -0
  288. package/dist/layout-engine/contracts/src/semantic-colors.d.ts +150 -0
  289. package/dist/layout-engine/contracts/src/table-cell-spacing.d.ts +12 -0
  290. package/dist/layout-engine/contracts/src/table-column-rescale.d.ts +13 -0
  291. package/dist/layout-engine/contracts/src/vertical-text.d.ts +43 -0
  292. package/dist/layout-engine/dom-contract/src/class-names.d.ts +62 -0
  293. package/dist/layout-engine/dom-contract/src/data-attrs.d.ts +103 -0
  294. package/dist/layout-engine/dom-contract/src/index.d.ts +18 -0
  295. package/dist/layout-engine/dom-contract/src/selectors.d.ts +47 -0
  296. package/dist/layout-engine/layout-bridge/src/cache-warmer.d.ts +73 -0
  297. package/dist/layout-engine/layout-bridge/src/cache.d.ts +143 -0
  298. package/dist/layout-engine/layout-bridge/src/cacheInvalidation.d.ts +117 -0
  299. package/dist/layout-engine/layout-bridge/src/cursor-renderer.d.ts +201 -0
  300. package/dist/layout-engine/layout-bridge/src/debounced-passes.d.ts +130 -0
  301. package/dist/layout-engine/layout-bridge/src/diff.d.ts +36 -0
  302. package/dist/layout-engine/layout-bridge/src/dirty-tracker.d.ts +128 -0
  303. package/dist/layout-engine/layout-bridge/src/dom-mapping.d.ts +80 -0
  304. package/dist/layout-engine/layout-bridge/src/featureFlags.d.ts +95 -0
  305. package/dist/layout-engine/layout-bridge/src/field-annotation-key.d.ts +2 -0
  306. package/dist/layout-engine/layout-bridge/src/focus-watchdog.d.ts +170 -0
  307. package/dist/layout-engine/layout-bridge/src/font-metrics-cache.d.ts +164 -0
  308. package/dist/layout-engine/layout-bridge/src/footnote-scorer.d.ts +63 -0
  309. package/dist/layout-engine/layout-bridge/src/headerFooterUtils.d.ts +218 -0
  310. package/dist/layout-engine/layout-bridge/src/ime-handler.d.ts +81 -0
  311. package/dist/layout-engine/layout-bridge/src/incrementalLayout.d.ts +390 -0
  312. package/dist/layout-engine/layout-bridge/src/index.d.ts +211 -0
  313. package/dist/layout-engine/layout-bridge/src/instrumentation.d.ts +245 -0
  314. package/dist/layout-engine/layout-bridge/src/layoutHeaderFooter.d.ts +123 -0
  315. package/dist/layout-engine/layout-bridge/src/list-indent-utils.d.ts +205 -0
  316. package/dist/layout-engine/layout-bridge/src/local-paragraph-layout.d.ts +93 -0
  317. package/dist/layout-engine/layout-bridge/src/neutral-hit.d.ts +142 -0
  318. package/dist/layout-engine/layout-bridge/src/neutral-segment-geometry.d.ts +32 -0
  319. package/dist/layout-engine/layout-bridge/src/page-geometry-helper.d.ts +197 -0
  320. package/dist/layout-engine/layout-bridge/src/paragraph-hash-utils.d.ts +126 -0
  321. package/dist/layout-engine/layout-bridge/src/paragraph-line-cache.d.ts +152 -0
  322. package/dist/layout-engine/layout-bridge/src/performance-metrics.d.ts +249 -0
  323. package/dist/layout-engine/layout-bridge/src/pm-dom-fallback.d.ts +188 -0
  324. package/dist/layout-engine/layout-bridge/src/pm-position-validator.d.ts +100 -0
  325. package/dist/layout-engine/layout-bridge/src/position-hit.d.ts +167 -0
  326. package/dist/layout-engine/layout-bridge/src/remeasure.d.ts +75 -0
  327. package/dist/layout-engine/layout-bridge/src/resolveHeaderFooterTokens.d.ts +76 -0
  328. package/dist/layout-engine/layout-bridge/src/rtl-text-geometry.d.ts +34 -0
  329. package/dist/layout-engine/layout-bridge/src/run-visual-marks.d.ts +12 -0
  330. package/dist/layout-engine/layout-bridge/src/safety-net.d.ts +234 -0
  331. package/dist/layout-engine/layout-bridge/src/sectionAwareHeaderFooter.d.ts +15 -0
  332. package/dist/layout-engine/layout-bridge/src/table-handler.d.ts +86 -0
  333. package/dist/layout-engine/layout-bridge/src/text-boundaries.d.ts +17 -0
  334. package/dist/layout-engine/layout-bridge/src/text-measurement.d.ts +69 -0
  335. package/dist/layout-engine/layout-bridge/src/track-changes-handler.d.ts +90 -0
  336. package/dist/layout-engine/layout-bridge/src/tracked-changes-utils.d.ts +41 -0
  337. package/dist/layout-engine/layout-engine/src/anchors.d.ts +52 -0
  338. package/dist/layout-engine/layout-engine/src/column-balancing.d.ts +255 -0
  339. package/dist/layout-engine/layout-engine/src/column-utils.d.ts +1 -0
  340. package/dist/layout-engine/layout-engine/src/floating-objects.d.ts +60 -0
  341. package/dist/layout-engine/layout-engine/src/floating-table-anchor.d.ts +21 -0
  342. package/dist/layout-engine/layout-engine/src/index.d.ts +349 -0
  343. package/dist/layout-engine/layout-engine/src/layout-drawing.d.ts +60 -0
  344. package/dist/layout-engine/layout-engine/src/layout-image.d.ts +16 -0
  345. package/dist/layout-engine/layout-engine/src/layout-paragraph.d.ts +101 -0
  346. package/dist/layout-engine/layout-engine/src/layout-table.d.ts +71 -0
  347. package/dist/layout-engine/layout-engine/src/layout-textbox.d.ts +4 -0
  348. package/dist/layout-engine/layout-engine/src/layout-utils.d.ts +104 -0
  349. package/dist/layout-engine/layout-engine/src/normalize-header-footer-fragments.d.ts +45 -0
  350. package/dist/layout-engine/layout-engine/src/pageNumbering.d.ts +73 -0
  351. package/dist/layout-engine/layout-engine/src/paginator.d.ts +131 -0
  352. package/dist/layout-engine/layout-engine/src/paragraph-layout-eligibility.d.ts +1 -0
  353. package/dist/layout-engine/layout-engine/src/resolvePageRefs.d.ts +31 -0
  354. package/dist/layout-engine/layout-engine/src/resolvePageTokens.d.ts +82 -0
  355. package/dist/layout-engine/layout-engine/src/section-breaks.d.ts +98 -0
  356. package/dist/layout-engine/layout-engine/src/section-props.d.ts +65 -0
  357. package/dist/layout-engine/layout-engine/src/table-cell-slice.d.ts +98 -0
  358. package/dist/layout-engine/painters/dom/src/_test-utils.d.ts +22 -0
  359. package/dist/layout-engine/painters/dom/src/chart-renderer.d.ts +13 -0
  360. package/dist/layout-engine/painters/dom/src/constants.d.ts +10 -0
  361. package/dist/layout-engine/painters/dom/src/css-token.d.ts +10 -0
  362. package/dist/layout-engine/painters/dom/src/features/feature-registry.d.ts +41 -0
  363. package/dist/layout-engine/painters/dom/src/features/inline-direction/index.d.ts +22 -0
  364. package/dist/layout-engine/painters/dom/src/features/inline-direction/rtl-styles.d.ts +27 -0
  365. package/dist/layout-engine/painters/dom/src/features/inline-direction/run-direction.d.ts +75 -0
  366. package/dist/layout-engine/painters/dom/src/features/math/converters/accent.d.ts +25 -0
  367. package/dist/layout-engine/painters/dom/src/features/math/converters/bar.d.ts +16 -0
  368. package/dist/layout-engine/painters/dom/src/features/math/converters/box.d.ts +38 -0
  369. package/dist/layout-engine/painters/dom/src/features/math/converters/delimiter.d.ts +13 -0
  370. package/dist/layout-engine/painters/dom/src/features/math/converters/equation-array.d.ts +19 -0
  371. package/dist/layout-engine/painters/dom/src/features/math/converters/fraction.d.ts +13 -0
  372. package/dist/layout-engine/painters/dom/src/features/math/converters/function.d.ts +16 -0
  373. package/dist/layout-engine/painters/dom/src/features/math/converters/group-character.d.ts +26 -0
  374. package/dist/layout-engine/painters/dom/src/features/math/converters/index.d.ts +27 -0
  375. package/dist/layout-engine/painters/dom/src/features/math/converters/lower-limit.d.ts +13 -0
  376. package/dist/layout-engine/painters/dom/src/features/math/converters/math-run.d.ts +47 -0
  377. package/dist/layout-engine/painters/dom/src/features/math/converters/matrix.d.ts +23 -0
  378. package/dist/layout-engine/painters/dom/src/features/math/converters/nary.d.ts +23 -0
  379. package/dist/layout-engine/painters/dom/src/features/math/converters/phantom.d.ts +17 -0
  380. package/dist/layout-engine/painters/dom/src/features/math/converters/pre-sub-superscript.d.ts +25 -0
  381. package/dist/layout-engine/painters/dom/src/features/math/converters/radical.d.ts +14 -0
  382. package/dist/layout-engine/painters/dom/src/features/math/converters/sub-superscript.d.ts +13 -0
  383. package/dist/layout-engine/painters/dom/src/features/math/converters/subscript.d.ts +13 -0
  384. package/dist/layout-engine/painters/dom/src/features/math/converters/superscript.d.ts +13 -0
  385. package/dist/layout-engine/painters/dom/src/features/math/converters/upper-limit.d.ts +13 -0
  386. package/dist/layout-engine/painters/dom/src/features/math/index.d.ts +14 -0
  387. package/dist/layout-engine/painters/dom/src/features/math/omml-to-mathml.d.ts +18 -0
  388. package/dist/layout-engine/painters/dom/src/features/math/types.d.ts +41 -0
  389. package/dist/layout-engine/painters/dom/src/images/drawing-image.d.ts +5 -0
  390. package/dist/layout-engine/painters/dom/src/images/hyperlink.d.ts +2 -0
  391. package/dist/layout-engine/painters/dom/src/images/image-block.d.ts +15 -0
  392. package/dist/layout-engine/painters/dom/src/images/image-clip-path.d.ts +17 -0
  393. package/dist/layout-engine/painters/dom/src/images/image-fragment.d.ts +34 -0
  394. package/dist/layout-engine/painters/dom/src/images/image-selectors.d.ts +9 -0
  395. package/dist/layout-engine/painters/dom/src/images/types.d.ts +2 -0
  396. package/dist/layout-engine/painters/dom/src/index.d.ts +130 -0
  397. package/dist/layout-engine/painters/dom/src/page-content.d.ts +277 -0
  398. package/dist/layout-engine/painters/dom/src/paragraph/block-version.d.ts +8 -0
  399. package/dist/layout-engine/painters/dom/src/paragraph/borders/border-layer.d.ts +59 -0
  400. package/dist/layout-engine/painters/dom/src/paragraph/borders/group-analysis.d.ts +38 -0
  401. package/dist/layout-engine/painters/dom/src/paragraph/borders/index.d.ts +18 -0
  402. package/dist/layout-engine/painters/dom/src/paragraph/frame.d.ts +3 -0
  403. package/dist/layout-engine/painters/dom/src/paragraph/indentation.d.ts +25 -0
  404. package/dist/layout-engine/painters/dom/src/paragraph/list-marker.d.ts +51 -0
  405. package/dist/layout-engine/painters/dom/src/paragraph/marker-tracked-change.d.ts +34 -0
  406. package/dist/layout-engine/painters/dom/src/paragraph/renderParagraphContent.d.ts +87 -0
  407. package/dist/layout-engine/painters/dom/src/paragraph/renderParagraphFragment.d.ts +33 -0
  408. package/dist/layout-engine/painters/dom/src/paragraph/styles.d.ts +3 -0
  409. package/dist/layout-engine/painters/dom/src/paragraph-hash-utils.d.ts +13 -0
  410. package/dist/layout-engine/painters/dom/src/persistent-page-surface.d.ts +144 -0
  411. package/dist/layout-engine/painters/dom/src/pm-position-validation.d.ts +149 -0
  412. package/dist/layout-engine/painters/dom/src/renderer.d.ts +625 -0
  413. package/dist/layout-engine/painters/dom/src/ruler/index.d.ts +41 -0
  414. package/dist/layout-engine/painters/dom/src/ruler/ruler-core.d.ts +195 -0
  415. package/dist/layout-engine/painters/dom/src/ruler/ruler-renderer.d.ts +97 -0
  416. package/dist/layout-engine/painters/dom/src/ruler/ruler-styles.d.ts +31 -0
  417. package/dist/layout-engine/painters/dom/src/runs/field-annotation-run.d.ts +14 -0
  418. package/dist/layout-engine/painters/dom/src/runs/font-synthesis.d.ts +1 -0
  419. package/dist/layout-engine/painters/dom/src/runs/formatting-marks.d.ts +3 -0
  420. package/dist/layout-engine/painters/dom/src/runs/hash.d.ts +82 -0
  421. package/dist/layout-engine/painters/dom/src/runs/image-run.d.ts +37 -0
  422. package/dist/layout-engine/painters/dom/src/runs/index.d.ts +13 -0
  423. package/dist/layout-engine/painters/dom/src/runs/links.d.ts +58 -0
  424. package/dist/layout-engine/painters/dom/src/runs/math-run.d.ts +7 -0
  425. package/dist/layout-engine/painters/dom/src/runs/render-line.d.ts +2 -0
  426. package/dist/layout-engine/painters/dom/src/runs/render-run.d.ts +12 -0
  427. package/dist/layout-engine/painters/dom/src/runs/tab-run.d.ts +66 -0
  428. package/dist/layout-engine/painters/dom/src/runs/text-run.d.ts +35 -0
  429. package/dist/layout-engine/painters/dom/src/runs/tracked-changes.d.ts +90 -0
  430. package/dist/layout-engine/painters/dom/src/runs/types.d.ts +67 -0
  431. package/dist/layout-engine/painters/dom/src/sdt/boundaries.d.ts +16 -0
  432. package/dist/layout-engine/painters/dom/src/sdt/container.d.ts +32 -0
  433. package/dist/layout-engine/painters/dom/src/sdt/dataset.d.ts +7 -0
  434. package/dist/layout-engine/painters/dom/src/sdt/inline.d.ts +9 -0
  435. package/dist/layout-engine/painters/dom/src/sdt/snapshot.d.ts +29 -0
  436. package/dist/layout-engine/painters/dom/src/styles.d.ts +71 -0
  437. package/dist/layout-engine/painters/dom/src/svg-utils.d.ts +101 -0
  438. package/dist/layout-engine/painters/dom/src/table/border-utils.d.ts +185 -0
  439. package/dist/layout-engine/painters/dom/src/table/grid-geometry.d.ts +69 -0
  440. package/dist/layout-engine/painters/dom/src/table/renderTableCell.d.ts +170 -0
  441. package/dist/layout-engine/painters/dom/src/table/renderTableFragment.d.ts +132 -0
  442. package/dist/layout-engine/painters/dom/src/table/renderTableRow.d.ts +146 -0
  443. package/dist/layout-engine/painters/dom/src/test-utils/normalize-line.d.ts +39 -0
  444. package/dist/layout-engine/painters/dom/src/utils/anchor-helpers.d.ts +3 -0
  445. package/dist/layout-engine/painters/dom/src/utils/apply-styles.d.ts +1 -0
  446. package/dist/layout-engine/painters/dom/src/utils/layout-identity.d.ts +9 -0
  447. package/dist/layout-engine/painters/dom/src/utils/source-anchor.d.ts +2 -0
  448. package/dist/layout-engine/style-engine/src/bench/resolveSdtMetadata.bench.d.ts +1 -0
  449. package/dist/layout-engine/style-engine/src/cascade.d.ts +43 -0
  450. package/dist/layout-engine/style-engine/src/index.d.ts +121 -0
  451. package/dist/layout-engine/style-engine/src/normalize/colors.d.ts +13 -0
  452. package/dist/layout-engine/style-engine/src/normalize/index.d.ts +13 -0
  453. package/dist/layout-engine/style-engine/src/normalize/paragraph-attrs.d.ts +3 -0
  454. package/dist/layout-engine/style-engine/src/normalize/run-attrs.d.ts +17 -0
  455. package/dist/layout-engine/style-engine/src/normalize/types.d.ts +36 -0
  456. package/dist/layout-engine/style-engine/src/normalize/units.d.ts +13 -0
  457. package/dist/layout-engine/style-engine/src/ooxml/index.d.ts +64 -0
  458. package/dist/layout-engine/style-engine/src/ooxml/numbering-types.d.ts +126 -0
  459. package/dist/layout-engine/style-engine/src/ooxml/styles-types.d.ts +363 -0
  460. package/dist/layout-engine/style-engine/src/ooxml/table-style-selection.d.ts +86 -0
  461. package/dist/layout-engine/style-engine/src/ooxml/types.d.ts +459 -0
  462. package/dist/layout-engine/style-engine/src/ooxml/word-style-model/parse-theme.d.ts +33 -0
  463. package/dist/layout-engine/style-engine/src/ooxml/word-style-model/parse-xml.d.ts +29 -0
  464. package/dist/public/ui-react.cjs +175 -0
  465. package/dist/public/ui-react.es.js +159 -0
  466. package/dist/public/ui.cjs +5 -0
  467. package/dist/public/ui.es.js +2 -0
  468. package/dist/shared/common/comments-types.d.ts +102 -0
  469. package/dist/shared/common/layout-constants.d.ts +7 -0
  470. package/dist/shared/common/list-marker-utils.d.ts +186 -0
  471. package/dist/shared/common/list-numbering/index.d.ts +16 -0
  472. package/dist/shared/font-system/src/activation.d.ts +64 -0
  473. package/dist/shared/font-system/src/bundled-manifest.d.ts +32 -0
  474. package/dist/shared/font-system/src/bundled.d.ts +41 -0
  475. package/dist/shared/font-system/src/document-font-options.d.ts +53 -0
  476. package/dist/shared/font-system/src/epoch.d.ts +6 -0
  477. package/dist/shared/font-system/src/font-offerings.d.ts +120 -0
  478. package/dist/shared/font-system/src/index.d.ts +35 -0
  479. package/dist/shared/font-system/src/os2.d.ts +30 -0
  480. package/dist/shared/font-system/src/registry.d.ts +188 -0
  481. package/dist/shared/font-system/src/report.d.ts +98 -0
  482. package/dist/shared/font-system/src/resolver.d.ts +215 -0
  483. package/dist/shared/font-system/src/substitution-evidence.d.ts +103 -0
  484. package/dist/shared/font-system/src/types.d.ts +128 -0
  485. package/dist/style.css +3323 -0
  486. package/dist/style.layered.css +3323 -0
  487. package/dist/superdoc/src/SuperDoc.vue.d.ts +88 -0
  488. package/dist/superdoc/src/cdn-entry.d.ts +2 -0
  489. package/dist/superdoc/src/components/CommentsLayer/CommentDialog.vue.d.ts +62 -0
  490. package/dist/superdoc/src/components/CommentsLayer/CommentHeader.vue.d.ts +26 -0
  491. package/dist/superdoc/src/components/CommentsLayer/CommentInput.vue.d.ts +19 -0
  492. package/dist/superdoc/src/components/CommentsLayer/CommentsDropdown.vue.d.ts +30 -0
  493. package/dist/superdoc/src/components/CommentsLayer/InternalDropdown.vue.d.ts +10 -0
  494. package/dist/superdoc/src/components/CommentsLayer/collect-removed-comment-ids.d.ts +1 -0
  495. package/dist/superdoc/src/components/CommentsLayer/collect-tracked-change-thread.d.ts +6 -0
  496. package/dist/superdoc/src/components/CommentsLayer/comment-schemas.d.ts +18 -0
  497. package/dist/superdoc/src/components/CommentsLayer/commentsList/commentsList.vue.d.ts +9 -0
  498. package/dist/superdoc/src/components/CommentsLayer/commentsList/super-comments-list.d.ts +21 -0
  499. package/dist/superdoc/src/components/CommentsLayer/floating-comment-positioning.d.ts +28 -0
  500. package/dist/superdoc/src/components/CommentsLayer/helpers.d.ts +7 -0
  501. package/dist/superdoc/src/components/CommentsLayer/tracked-change-threading.d.ts +2 -0
  502. package/dist/superdoc/src/components/CommentsLayer/types.d.ts +3 -0
  503. package/dist/superdoc/src/components/CommentsLayer/use-comment.d.ts +8 -0
  504. package/dist/superdoc/src/components/CommentsLayer/use-conversation.d.ts +22 -0
  505. package/dist/superdoc/src/components/CommentsLayer/use-floating-comment.d.ts +11 -0
  506. package/dist/superdoc/src/components/HtmlViewer/HtmlViewer.vue.d.ts +10 -0
  507. package/dist/superdoc/src/components/PdfViewer/PdfViewer.vue.d.ts +61 -0
  508. package/dist/superdoc/src/components/PdfViewer/PdfViewerDocument.vue.d.ts +21 -0
  509. package/dist/superdoc/src/components/PdfViewer/PdfViewerPage.vue.d.ts +24 -0
  510. package/dist/superdoc/src/components/Whiteboard/WhiteboardLayer.vue.d.ts +19 -0
  511. package/dist/superdoc/src/components/Whiteboard/WhiteboardPage.vue.d.ts +17 -0
  512. package/dist/superdoc/src/components/Whiteboard/use-whiteboard.d.ts +18 -0
  513. package/dist/superdoc/src/components/surfaces/FindReplaceSurface.vue.d.ts +19 -0
  514. package/dist/superdoc/src/components/surfaces/PasswordPromptSurface.vue.d.ts +17 -0
  515. package/dist/superdoc/src/components/surfaces/SurfaceDialog.vue.d.ts +12 -0
  516. package/dist/superdoc/src/components/surfaces/SurfaceExternalMount.vue.d.ts +19 -0
  517. package/dist/superdoc/src/components/surfaces/SurfaceFloating.vue.d.ts +10 -0
  518. package/dist/superdoc/src/components/surfaces/SurfaceHost.vue.d.ts +31 -0
  519. package/dist/superdoc/src/components/surfaces/focusable-selector.d.ts +5 -0
  520. package/dist/superdoc/src/composables/find-shortcut-owner.d.ts +32 -0
  521. package/dist/superdoc/src/composables/replace-continuation.d.ts +37 -0
  522. package/dist/superdoc/src/composables/use-ai.d.ts +10 -0
  523. package/dist/superdoc/src/composables/use-comment-small-screen.d.ts +10 -0
  524. package/dist/superdoc/src/composables/use-compact-comment-popover.d.ts +21 -0
  525. package/dist/superdoc/src/composables/use-document.d.ts +34 -0
  526. package/dist/superdoc/src/composables/use-field.d.ts +33 -0
  527. package/dist/superdoc/src/composables/use-find-replace.d.ts +83 -0
  528. package/dist/superdoc/src/composables/use-high-contrast-mode.d.ts +4 -0
  529. package/dist/superdoc/src/composables/use-link-popover.d.ts +221 -0
  530. package/dist/superdoc/src/composables/use-password-prompt.d.ts +33 -0
  531. package/dist/superdoc/src/composables/use-selected-text.d.ts +16 -0
  532. package/dist/superdoc/src/composables/use-viewport-fit.d.ts +50 -0
  533. package/dist/superdoc/src/composables/useUiFontFamily.d.ts +24 -0
  534. package/dist/superdoc/src/core/EventEmitter.d.ts +55 -0
  535. package/dist/superdoc/src/core/SuperDoc.d.ts +775 -0
  536. package/dist/superdoc/src/core/collaboration/collaboration-comments.d.ts +4 -0
  537. package/dist/superdoc/src/core/collaboration/collaboration.d.ts +28 -0
  538. package/dist/superdoc/src/core/collaboration/helpers.d.ts +8 -0
  539. package/dist/superdoc/src/core/collaboration/permissions.d.ts +19 -0
  540. package/dist/superdoc/src/core/collaboration/resolve-v2-collaboration-target.d.ts +99 -0
  541. package/dist/superdoc/src/core/collaboration/room-overwrite.d.ts +22 -0
  542. package/dist/superdoc/src/core/collaboration/v2-awareness-bridge.d.ts +57 -0
  543. package/dist/superdoc/src/core/config/merge-defined.d.ts +35 -0
  544. package/dist/superdoc/src/core/config/normalize-interaction-config.d.ts +15 -0
  545. package/dist/superdoc/src/core/config/normalize-surfaces-config.d.ts +23 -0
  546. package/dist/superdoc/src/core/config/normalize-ui-config.d.ts +62 -0
  547. package/dist/superdoc/src/core/create-app.d.ts +32 -0
  548. package/dist/superdoc/src/core/editor-runtime/conformance/fake-v2-runtime.d.ts +9 -0
  549. package/dist/superdoc/src/core/editor-runtime/editor-runtime-registry.d.ts +117 -0
  550. package/dist/superdoc/src/core/editor-runtime/index.d.ts +1 -0
  551. package/dist/superdoc/src/core/editor-runtime/root-marker.d.ts +33 -0
  552. package/dist/superdoc/src/core/editor-runtime/types.d.ts +405 -0
  553. package/dist/superdoc/src/core/editor-runtime/v2/v2-editor-runtime-adapter.d.ts +185 -0
  554. package/dist/superdoc/src/core/editor-runtime/v2/v2-session-shortcut-routes.d.ts +47 -0
  555. package/dist/superdoc/src/core/extensions/define.d.ts +56 -0
  556. package/dist/superdoc/src/core/extensions/index.d.ts +2 -0
  557. package/dist/superdoc/src/core/extensions/types.d.ts +519 -0
  558. package/dist/superdoc/src/core/helpers/export.d.ts +2 -0
  559. package/dist/superdoc/src/core/helpers/file.d.ts +43 -0
  560. package/dist/superdoc/src/core/helpers/normalize-track-changes-config.d.ts +60 -0
  561. package/dist/superdoc/src/core/helpers/normalize-user.d.ts +13 -0
  562. package/dist/superdoc/src/core/index.d.ts +1 -0
  563. package/dist/superdoc/src/core/pdf/helpers/constants.d.ts +2 -0
  564. package/dist/superdoc/src/core/pdf/helpers/floor.d.ts +1 -0
  565. package/dist/superdoc/src/core/pdf/helpers/range.d.ts +1 -0
  566. package/dist/superdoc/src/core/pdf/helpers/read-file.d.ts +1 -0
  567. package/dist/superdoc/src/core/pdf/pdf-adapter.d.ts +66 -0
  568. package/dist/superdoc/src/core/surface-manager.d.ts +90 -0
  569. package/dist/superdoc/src/core/theme/create-theme.d.ts +82 -0
  570. package/dist/superdoc/src/core/types/index.d.ts +3253 -0
  571. package/dist/superdoc/src/core/v2-integration/browser-peer-runtime.d.ts +3 -0
  572. package/dist/superdoc/src/core/v2-integration/cdn-engine-loader.d.ts +16 -0
  573. package/dist/superdoc/src/core/v2-integration/v2-integration.d.ts +97 -0
  574. package/dist/superdoc/src/core/whiteboard/Whiteboard.d.ts +247 -0
  575. package/dist/superdoc/src/core/whiteboard/WhiteboardPage.d.ts +251 -0
  576. package/dist/superdoc/src/core/whiteboard/WhiteboardRenderer.d.ts +2 -0
  577. package/dist/superdoc/src/core/whiteboard/helpers/createTextarea.d.ts +1 -0
  578. package/dist/superdoc/src/core/whiteboard/helpers/flattenPoints.d.ts +1 -0
  579. package/dist/superdoc/src/core/whiteboard/helpers/getRandomId.d.ts +1 -0
  580. package/dist/superdoc/src/helpers/collect-touched-tracked-change-ids.d.ts +11 -0
  581. package/dist/superdoc/src/helpers/comment-focus.d.ts +4 -0
  582. package/dist/superdoc/src/helpers/comment-small-screen.d.ts +14 -0
  583. package/dist/superdoc/src/helpers/deprecation.d.ts +26 -0
  584. package/dist/superdoc/src/helpers/floor.d.ts +1 -0
  585. package/dist/superdoc/src/helpers/group-changes.d.ts +1 -0
  586. package/dist/superdoc/src/helpers/interaction-trace.d.ts +26 -0
  587. package/dist/superdoc/src/helpers/selection-source.d.ts +1 -0
  588. package/dist/superdoc/src/helpers/transaction-touches-structural-change.d.ts +19 -0
  589. package/dist/superdoc/src/helpers/use-selection.d.ts +17 -0
  590. package/dist/superdoc/src/helpers/v2-author-required-rejection.d.ts +22 -0
  591. package/dist/superdoc/src/helpers/v2-remote-review-hydration.d.ts +12 -0
  592. package/dist/superdoc/src/helpers/v2-review-mutation-impact.d.ts +19 -0
  593. package/dist/superdoc/src/helpers/v2-review-mutation-reconciler.d.ts +19 -0
  594. package/dist/superdoc/src/helpers/v2-review-target.d.ts +7 -0
  595. package/dist/superdoc/src/helpers/v2-selection-sync.d.ts +12 -0
  596. package/dist/superdoc/src/helpers/v2-typing-mutation-event.d.ts +5 -0
  597. package/dist/superdoc/src/icons.d.ts +11 -0
  598. package/dist/superdoc/src/index.d.cts +13 -0
  599. package/dist/superdoc/src/index.d.ts +11 -0
  600. package/dist/superdoc/src/internal/toolbar/built-in/AIWriter.vue.d.ts +21 -0
  601. package/dist/superdoc/src/internal/toolbar/built-in/AlignmentButtons.vue.d.ts +6 -0
  602. package/dist/superdoc/src/internal/toolbar/built-in/ButtonGroup.vue.d.ts +10 -0
  603. package/dist/superdoc/src/internal/toolbar/built-in/DocumentMode.vue.d.ts +10 -0
  604. package/dist/superdoc/src/internal/toolbar/built-in/FontFamilyCombobox.vue.d.ts +10 -0
  605. package/dist/superdoc/src/internal/toolbar/built-in/FontSizeCombobox.vue.d.ts +10 -0
  606. package/dist/superdoc/src/internal/toolbar/built-in/IconGrid.vue.d.ts +14 -0
  607. package/dist/superdoc/src/internal/toolbar/built-in/IconGridRow.vue.d.ts +13 -0
  608. package/dist/superdoc/src/internal/toolbar/built-in/LinkInput.vue.d.ts +37 -0
  609. package/dist/superdoc/src/internal/toolbar/built-in/LinkedStyle.vue.d.ts +12 -0
  610. package/dist/superdoc/src/internal/toolbar/built-in/OverflowMenu.vue.d.ts +10 -0
  611. package/dist/superdoc/src/internal/toolbar/built-in/SdTooltip.vue.d.ts +34 -0
  612. package/dist/superdoc/src/internal/toolbar/built-in/StyleButtonsList.vue.d.ts +14 -0
  613. package/dist/superdoc/src/internal/toolbar/built-in/TableActions.vue.d.ts +8 -0
  614. package/dist/superdoc/src/internal/toolbar/built-in/TableGrid.vue.d.ts +6 -0
  615. package/dist/superdoc/src/internal/toolbar/built-in/Toolbar.vue.d.ts +4 -0
  616. package/dist/superdoc/src/internal/toolbar/built-in/ToolbarButton.vue.d.ts +24 -0
  617. package/dist/superdoc/src/internal/toolbar/built-in/ToolbarButtonIcon.vue.d.ts +11 -0
  618. package/dist/superdoc/src/internal/toolbar/built-in/ToolbarComboBox.vue.d.ts +18 -0
  619. package/dist/superdoc/src/internal/toolbar/built-in/ToolbarDropdown.vue.d.ts +38 -0
  620. package/dist/superdoc/src/internal/toolbar/built-in/ToolbarSeparator.vue.d.ts +8 -0
  621. package/dist/superdoc/src/internal/toolbar/built-in/color-dropdown-helpers.d.ts +24 -0
  622. package/dist/superdoc/src/internal/toolbar/built-in/constants.d.ts +101 -0
  623. package/dist/superdoc/src/internal/toolbar/built-in/default-items.d.ts +17 -0
  624. package/dist/superdoc/src/internal/toolbar/built-in/font-options.d.ts +1 -0
  625. package/dist/superdoc/src/internal/toolbar/built-in/font-typeahead.d.ts +11 -0
  626. package/dist/superdoc/src/internal/toolbar/built-in/format-negation.d.ts +5 -0
  627. package/dist/superdoc/src/internal/toolbar/built-in/general.d.ts +1 -0
  628. package/dist/superdoc/src/internal/toolbar/built-in/helpers.d.ts +5 -0
  629. package/dist/superdoc/src/internal/toolbar/built-in/list-style-buttons.d.ts +10 -0
  630. package/dist/superdoc/src/internal/toolbar/built-in/scroll-helpers.d.ts +4 -0
  631. package/dist/superdoc/src/internal/toolbar/built-in/toolbar-focus-helpers.d.ts +1 -0
  632. package/dist/superdoc/src/internal/toolbar/built-in/toolbarIcons.d.ts +76 -0
  633. package/dist/superdoc/src/internal/toolbar/built-in/toolbarTexts.d.ts +58 -0
  634. package/dist/superdoc/src/internal/toolbar/built-in/url-safety.d.ts +8 -0
  635. package/dist/superdoc/src/internal/toolbar/built-in/use-toolbar-item.d.ts +48 -0
  636. package/dist/superdoc/src/internal/toolbar/built-in-toolbar.d.ts +237 -0
  637. package/dist/superdoc/src/internal/toolbar/compatibility-catalog.d.ts +59 -0
  638. package/dist/superdoc/src/internal/toolbar/image-upload.d.ts +63 -0
  639. package/dist/superdoc/src/internal/toolbar/index.d.ts +10 -0
  640. package/dist/superdoc/src/main.d.ts +1 -0
  641. package/dist/superdoc/src/public/browser-document-api.d.ts +53 -0
  642. package/dist/superdoc/src/public/collaboration-upgrade-engine.d.cts +26 -0
  643. package/dist/superdoc/src/public/collaboration-upgrade-engine.d.ts +130 -0
  644. package/dist/superdoc/src/public/index.d.cts +365 -0
  645. package/dist/superdoc/src/public/index.d.ts +182 -0
  646. package/dist/superdoc/src/public/ui/commands.d.ts +249 -0
  647. package/dist/superdoc/src/public/ui/create-super-doc-ui.d.ts +18 -0
  648. package/dist/superdoc/src/public/ui/entity-at.d.ts +29 -0
  649. package/dist/superdoc/src/public/ui/equality.d.ts +10 -0
  650. package/dist/superdoc/src/public/ui/format-painter-helpers.d.ts +36 -0
  651. package/dist/superdoc/src/public/ui/react.d.ts +81 -0
  652. package/dist/superdoc/src/public/ui/reasons.d.ts +99 -0
  653. package/dist/superdoc/src/public/ui/types.d.ts +1425 -0
  654. package/dist/superdoc/src/public/ui-react.d.cts +20 -0
  655. package/dist/superdoc/src/public/ui-react.d.ts +20 -0
  656. package/dist/superdoc/src/public/ui.d.cts +194 -0
  657. package/dist/superdoc/src/public/ui.d.ts +29 -0
  658. package/dist/superdoc/src/stores/comments-store.d.ts +700 -0
  659. package/dist/superdoc/src/stores/helpers/floating-comment-instances.d.ts +14 -0
  660. package/dist/superdoc/src/stores/helpers/tracked-change-thread-index.d.ts +14 -0
  661. package/dist/superdoc/src/stores/hrbr-fields-store.d.ts +43 -0
  662. package/dist/superdoc/src/stores/superdoc-store.d.ts +2254 -0
  663. package/dist/superdoc.cjs +40494 -0
  664. package/dist/superdoc.es.js +40418 -0
  665. package/dist/word-layout/src/index.d.ts +64 -0
  666. package/dist/word-layout/src/list-marker.d.ts +68 -0
  667. package/dist/word-layout/src/marker-utils.d.ts +20 -0
  668. package/dist/word-layout/src/numbering-manager.d.ts +85 -0
  669. package/dist/word-layout/src/tab-layout.d.ts +193 -0
  670. package/dist/word-layout/src/types.d.ts +106 -0
  671. package/dist/word-layout/src/unit-conversions.d.ts +120 -0
  672. package/dist-cdn/style.layered.css +2 -0
  673. package/dist-cdn/superdoc.min.css +2 -0
  674. package/dist-cdn/superdoc.min.js +108 -0
  675. package/package.json +138 -24
  676. package/.npmignore +0 -4
  677. package/data.json +0 -17
  678. package/index.js +0 -2
  679. package/lib/Augmenter.js +0 -27
  680. package/lib/Runner.js +0 -80
  681. package/lib/Stopper.js +0 -71
  682. package/test/superdoc.js +0 -126
  683. package/utils/app.js +0 -18
  684. package/utils/server.js +0 -2
  685. package/web/index.js +0 -54
  686. package/web/public/style.css +0 -76
  687. package/web/views/index.ejs +0 -53
  688. package/web/views/layout.ejs +0 -13
  689. package/web/views/method.ejs +0 -59
@@ -0,0 +1,3253 @@
1
+ import { Doc as YDoc } from 'yjs';
2
+ import { HocuspocusProviderWebsocket } from '@hocuspocus/provider';
3
+ import { Ref, ComputedRef } from 'vue';
4
+ import { DocumentFontOption, FontAssetUrlResolver, FontFamilyOption, FontLoadSummary, FontResolutionRecord } from '../../../../shared/font-system/src/index.js';
5
+ import { SuperDoc as SuperDocClass } from '../SuperDoc.js';
6
+ import { SuperDocActiveEditorExtensions, SuperDocExtension } from '../extensions/index.js';
7
+ import { BrowserDocumentApi } from '../../public/browser-document-api.js';
8
+ import { CustomCommandContext } from '../../public/ui/types.js';
9
+ export type { DocumentFontOption, FontAssetUrlContext, FontAssetUrlResolver, FontFaceSlot, FontFamilyOption, FontLoadResult, FontLoadStatus, FontLoadSummary, FontResolutionReason, FontResolutionRecord, GlyphException, ResolvedFontEvidence, SubstitutePolicyAction, SubstituteVerdict, } from '../../../../shared/font-system/src/index.js';
10
+ export type SuperDoc = SuperDocClass;
11
+ export type { BrowserDocumentApi } from '../../public/browser-document-api.js';
12
+ /**
13
+ * A row in a custom dropdown's option list, and the value handed back to the
14
+ * `command` callback when one is chosen.
15
+ *
16
+ * `label` and `key` are what the toolbar reads: `handleSelect` uses `label` as
17
+ * the command argument (unless `dropdownValueKey` names another member) and
18
+ * `key` as the selection identity (`ButtonGroup.vue:167-169`).
19
+ *
20
+ * Both are optional here rather than required, because a `type: 'render'`
21
+ * entry is a custom-rendered row that the selection path explicitly skips
22
+ * (`ButtonGroup.vue:268`), so it carries neither. The index signature keeps
23
+ * the rest of the row open.
24
+ */
25
+ export interface ToolbarDropdownOption {
26
+ /** Row text, and the default command argument when the row is chosen. */
27
+ label?: string;
28
+ /** Stable row identity, used for selection state. */
29
+ key?: string;
30
+ /** Attributes spread onto the rendered row. */
31
+ props?: Record<string, unknown>;
32
+ [key: string]: unknown;
33
+ }
34
+ /**
35
+ * The context a custom toolbar button's `command` callback receives.
36
+ *
37
+ * The runtime registers the callback as a custom command and invokes it with
38
+ * the controller's {@link CustomCommandContext} plus three toolbar-specific
39
+ * members (`built-in-toolbar.js:#prepareCustomButton`), so a consumer writing
40
+ * `({ execute, option }) => ...` gets both halves typed.
41
+ *
42
+ * `item` is deliberately `unknown`. It is the live Vue reactive object
43
+ * `useToolbarItem` returns — a bag of `ref`s whose shape is an implementation
44
+ * detail. Typing it would publish that internal and freeze it; see #1098 for
45
+ * the public toolbar-item contract that would replace it.
46
+ */
47
+ export interface ToolbarCustomButtonContext extends CustomCommandContext {
48
+ /** The live toolbar item handle. Internal shape; see #1098. */
49
+ item: unknown;
50
+ /**
51
+ * The selected dropdown row, passed through verbatim, or `undefined` for a
52
+ * plain button that has no selection.
53
+ */
54
+ option?: ToolbarDropdownOption;
55
+ /** Argument threaded through the command payload. */
56
+ argument?: unknown;
57
+ }
58
+ /**
59
+ * A custom entry appended to the built-in toolbar's default item set.
60
+ *
61
+ * Intentionally loose. `name` and `command` are the two members the runtime
62
+ * contract already fixes, and the rest stays open because the public
63
+ * toolbar-item shape has not been decided yet (#1098).
64
+ *
65
+ * Tightening it further needs that contract first. `useToolbarItem` accepting
66
+ * a `type` only proves construction does not throw, not that the entry renders
67
+ * as a top-level toolbar item -- `options` has no render branch at all,
68
+ * `dropdown` needs rows and a trigger, and `overflow` draws only when the
69
+ * separately-built overflow list is non-empty, which `customButtons` cannot
70
+ * populate. Encoding those rules here would publish a contract on the strength
71
+ * of constructor behavior, and they need rendered-behavior tests rather than
72
+ * direct `useToolbarItem` construction to establish.
73
+ */
74
+ export interface ToolbarCustomButton {
75
+ /** Unique item name. Also derives the registered command id. */
76
+ name: string;
77
+ /**
78
+ * What the entry does when activated. A function is registered as a custom
79
+ * command and invoked with {@link ToolbarCustomButtonContext}; a string is
80
+ * read as a canonical V2 command id and routed through the shared controller
81
+ * (`built-in-toolbar.js:948`).
82
+ *
83
+ * Optional because a separator has nothing to do. An actionable entry that
84
+ * omits it silently no-ops on click -- a real defect, but one this type
85
+ * cannot flag without the variant split that #1098 owns.
86
+ */
87
+ command?: string | ((context: ToolbarCustomButtonContext) => unknown);
88
+ [key: string]: unknown;
89
+ }
90
+ export type V2AuthoringSelectionCollapse = 'start' | 'end' | null;
91
+ export type V2AuthoringResult = {
92
+ ok: true;
93
+ mode?: 'collapsed' | 'range';
94
+ [key: string]: unknown;
95
+ } | {
96
+ ok: false;
97
+ reason: string;
98
+ detail?: string;
99
+ };
100
+ /**
101
+ * Narrow v2 browser-authoring bridge for shell/proof setup code. This surface
102
+ * does not expose v1 ProseMirror `view` / `state` / `commands`; it resolves
103
+ * public Document API selection targets and asks the v2 host to apply them to
104
+ * the live editable selection.
105
+ */
106
+ export interface V2AuthoringFacade {
107
+ setSelectionByText(input: {
108
+ text: string;
109
+ occurrence?: number;
110
+ collapse?: V2AuthoringSelectionCollapse;
111
+ focus?: boolean;
112
+ }): Promise<V2AuthoringResult>;
113
+ setSelectionTarget(input: {
114
+ target: unknown;
115
+ collapse?: V2AuthoringSelectionCollapse;
116
+ focus?: boolean;
117
+ }): Promise<V2AuthoringResult>;
118
+ focusEditable(): unknown;
119
+ readBlocks?(input?: Record<string, unknown>): unknown;
120
+ replaceTextByText?(input: {
121
+ findText: string;
122
+ replacement: string;
123
+ occurrence?: number;
124
+ mode?: 'direct' | 'tracked';
125
+ }): Promise<V2AuthoringResult>;
126
+ replaceSelection?(input: {
127
+ target: unknown;
128
+ replacement?: string;
129
+ mode?: 'direct' | 'tracked';
130
+ }): Promise<V2AuthoringResult>;
131
+ serializeSelectionToClipboard?(input?: {
132
+ includeHtml?: boolean;
133
+ }): Promise<V2AuthoringResult>;
134
+ pasteClipboardPayload?(input: {
135
+ payload: unknown;
136
+ target?: unknown;
137
+ mode?: 'direct' | 'tracked';
138
+ fallback?: unknown;
139
+ }): Promise<V2AuthoringResult>;
140
+ pastePlainText?(input: {
141
+ text: string;
142
+ target?: unknown;
143
+ mode?: 'direct' | 'tracked';
144
+ }): Promise<V2AuthoringResult>;
145
+ }
146
+ /**
147
+ * The current user of this superdoc.
148
+ *
149
+ * Every field is optional on input. `SuperDoc.#init` normalizes a
150
+ * missing or partial `user` by spreading `DEFAULT_USER` over consumer
151
+ * input, so `name` and `email` always have a value at runtime even
152
+ * when the consumer omits them.
153
+ *
154
+ * `User` does NOT carry the collab-awareness `color` field; that is on
155
+ * the internal `AwarenessUser` (see below), assigned by SuperDoc's
156
+ * `#assignUserColor()` after `#init`.
157
+ */
158
+ export interface User {
159
+ id?: string | null;
160
+ name?: string | null;
161
+ email?: string | null;
162
+ image?: string | null;
163
+ [key: string]: unknown;
164
+ }
165
+ /** V2-neutral active editor facade exposed by legacy shell methods. */
166
+ export interface EditorCommands {
167
+ search?: (text: string | RegExp, options?: Record<string, unknown>) => SearchMatch[];
168
+ goToSearchResult?: (match: SearchMatch) => unknown;
169
+ [key: string]: unknown;
170
+ }
171
+ export interface Editor {
172
+ editorVersion?: 2;
173
+ options?: {
174
+ documentId?: string;
175
+ documentMode?: DocumentMode;
176
+ [key: string]: unknown;
177
+ };
178
+ /**
179
+ * The public, read-only-guarded browser Document API facade for the active
180
+ * editor (`superdoc.activeEditor.doc`). It exposes the supported browser
181
+ * Document API surface customers know (`doc.comments.*`,
182
+ * `doc.trackChanges.*`, `doc.history.*`, `doc.selection.current`,
183
+ * `doc.format.*`, `doc.query.*`, etc.), with read-only enforcement and
184
+ * mutation finalization owned by the v2 host facade. In browser mode this
185
+ * surface is async-capable and operations may return promises; SDK/headless
186
+ * document automation stays synchronous on its own surface.
187
+ */
188
+ doc?: BrowserDocumentApi | null;
189
+ authoring?: V2AuthoringFacade | null;
190
+ /**
191
+ * Command bag exposed by v1 editors (`null` on v2-shaped runtimes). Only the
192
+ * commands the shell dispatches directly are typed; everything else stays
193
+ * behind the index signature.
194
+ */
195
+ commands?: EditorCommands | null;
196
+ state?: unknown;
197
+ view?: unknown;
198
+ exportDocx?: (options?: Record<string, unknown>) => Promise<Blob | File | null | undefined>;
199
+ focus?: (options?: {
200
+ preventScroll?: boolean;
201
+ restoreSelection?: boolean;
202
+ }) => unknown;
203
+ setOptions?: (options: Record<string, unknown>) => unknown;
204
+ setDocumentMode?: (mode: DocumentMode) => unknown;
205
+ setHighContrastMode?: (isHighContrast: boolean) => unknown;
206
+ on?: (...args: unknown[]) => unknown;
207
+ off?: (...args: unknown[]) => unknown;
208
+ getHTML: (options?: Record<string, unknown>) => unknown;
209
+ getDocumentId?: () => string | null | undefined;
210
+ /**
211
+ * Narrow v2 extension facet for command execution and diagnostics, backed by
212
+ * the active document's extension manager. Present only when one or more
213
+ * `extensions` are registered on the active document; `null`/absent
214
+ * otherwise. Does not expose the raw private extension manager. See
215
+ * {@link SuperDocActiveEditorExtensions}.
216
+ */
217
+ extensions?: SuperDocActiveEditorExtensions | null;
218
+ [key: string]: unknown;
219
+ }
220
+ /**
221
+ * Presentation-editor capability bag retained for shell compatibility. The
222
+ * methods the shell dispatches to are typed; capabilities stay optional because
223
+ * JS composables assemble this bag incrementally.
224
+ */
225
+ export interface DocumentRendererRuntime {
226
+ getLastFontsChangedPayload?: () => FontsChangedPayload | null;
227
+ navigateTo?: (target: NavigableAddress) => unknown;
228
+ scrollToElement?: (elementId: string) => unknown;
229
+ setContextMenuDisabled?: (disabled: boolean) => unknown;
230
+ setShowBookmarks?: (show: boolean) => unknown;
231
+ setShowFormattingMarks?: (show: boolean) => unknown;
232
+ setDocumentMode?: (mode: DocumentMode) => unknown;
233
+ setTrackedChangesOverrides?: (preferences?: {
234
+ mode?: 'review' | 'original' | 'final' | 'off';
235
+ enabled?: boolean;
236
+ }) => unknown;
237
+ setViewingCommentOptions?: (options: Record<string, unknown>) => unknown;
238
+ [key: string]: unknown;
239
+ }
240
+ export type StoryLocator = string | Record<string, unknown>;
241
+ export type BookmarkAddress = string | Record<string, unknown>;
242
+ export type BlockNavigationAddress = string | Record<string, unknown>;
243
+ export type CommentAddress = string | Record<string, unknown>;
244
+ export type TrackedChangeAddress = string | Record<string, unknown>;
245
+ export type NavigableAddress = StoryLocator | BookmarkAddress | BlockNavigationAddress | CommentAddress | TrackedChangeAddress;
246
+ export interface CollaborationProvider {
247
+ awareness?: unknown;
248
+ document?: unknown;
249
+ synced?: boolean;
250
+ isSynced?: boolean;
251
+ on?: (...args: unknown[]) => unknown;
252
+ off?: (...args: unknown[]) => unknown;
253
+ disconnect?: () => unknown;
254
+ destroy?: () => unknown;
255
+ [key: string]: unknown;
256
+ }
257
+ /**
258
+ * Document-level v2 collaboration handoff.
259
+ *
260
+ * This is the public surface for SuperDoc v2's shipped real-time collaboration
261
+ * model. v2 collaboration is always single-doc: one `Y.Doc`, one provider
262
+ * session, and one awareness channel bound to one document/root identity. Set
263
+ * it on a `Document` entry to make that document collaborative under the v2
264
+ * runtime; SuperDoc forwards it into the v2 browser shell, which constructs the
265
+ * single-doc provider internally. One `documentId` maps to exactly one
266
+ * room/provider/root identity.
267
+ *
268
+ * SuperDoc v2 supports three first-class provider families through this field:
269
+ * y-websocket, Hocuspocus, and Liveblocks. The provider is selected with
270
+ * `providerType`; omitting it preserves the original y-websocket-only shape
271
+ * (`{ documentId, serverUrl, params? }`) for backward compatibility.
272
+ *
273
+ * This is intentionally distinct from the legacy provider-agnostic
274
+ * {@link CollaborationConfig} (`Config.modules.collaboration`): v2 owns its
275
+ * provider internally and does **not** accept an external Yjs `provider`/`ydoc`
276
+ * through this field. External `{ ydoc, provider }` remains a v1 /
277
+ * provider-compat concern only and is rejected as a v2 content driver.
278
+ */
279
+ export type V2CollaborationConfig = V2YWebsocketCollaborationConfig | V2HocuspocusCollaborationConfig | V2LiveblocksCollaborationConfig;
280
+ /**
281
+ * y-websocket single-doc provider config.
282
+ *
283
+ * `providerType` is optional: omitting it (the `{ documentId, serverUrl }`
284
+ * shape) is the backward-compatible default and resolves to y-websocket.
285
+ */
286
+ export interface V2YWebsocketCollaborationConfig {
287
+ /** Provider family selector. Optional; defaults to `'y-websocket'`. */
288
+ providerType?: 'y-websocket';
289
+ /**
290
+ * Stable shared document identity. Both actors that pass the same
291
+ * `documentId` join the same room and converge on the same root Y.Doc.
292
+ */
293
+ documentId: string;
294
+ /** WebSocket server URL for the single-doc y-websocket provider. */
295
+ serverUrl?: string;
296
+ /** Alias for {@link serverUrl}; `url` wins when both are present. */
297
+ url?: string;
298
+ /**
299
+ * Optional connection query params forwarded to the provider (for example
300
+ * an auth token). Values are strings.
301
+ */
302
+ params?: Record<string, string> | null;
303
+ /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
304
+ roomMode?: 'join' | 'create';
305
+ }
306
+ /** Hocuspocus single-doc provider config. */
307
+ export interface V2HocuspocusCollaborationConfig {
308
+ providerType: 'hocuspocus';
309
+ /** Stable shared document identity (used as the v2 root/room identity). */
310
+ documentId: string;
311
+ /** Hocuspocus backend websocket URL. */
312
+ serverUrl?: string;
313
+ /** Alias for {@link serverUrl}; `url` wins when both are present. */
314
+ url?: string;
315
+ /** Optional connection params forwarded to the backend. */
316
+ params?: Record<string, string> | null;
317
+ /** Auth-message token forwarded to the Hocuspocus backend. */
318
+ token?: string;
319
+ /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
320
+ roomMode?: 'join' | 'create';
321
+ }
322
+ /**
323
+ * Liveblocks single-doc provider config.
324
+ *
325
+ * Exactly one auth mode is supported: `publicApiKey` (anonymous) or
326
+ * `authEndpoint` (server-side token issuance).
327
+ */
328
+ export interface V2LiveblocksCollaborationConfig {
329
+ providerType: 'liveblocks';
330
+ /** Stable shared document/room identity. */
331
+ documentId?: string;
332
+ /** Alias for {@link documentId} (Liveblocks room naming). */
333
+ roomId?: string;
334
+ /** Liveblocks public API key (anonymous auth) — mutually exclusive with {@link authEndpoint}. */
335
+ publicApiKey?: string;
336
+ /**
337
+ * Liveblocks auth endpoint URL (server-side token) — mutually exclusive with
338
+ * {@link publicApiKey}. Browser-relative URLs resolve against the current
339
+ * page; non-browser SDK/CLI callers must use an absolute HTTP(S) URL.
340
+ */
341
+ authEndpoint?: string;
342
+ /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
343
+ roomMode?: 'join' | 'create';
344
+ }
345
+ export interface Comment {
346
+ id?: string;
347
+ commentId?: string;
348
+ text?: string;
349
+ resolved?: boolean;
350
+ [key: string]: unknown;
351
+ }
352
+ export interface FontFaceConfig {
353
+ source?: string;
354
+ url?: string;
355
+ weight?: string | number;
356
+ style?: string;
357
+ display?: string;
358
+ [key: string]: unknown;
359
+ }
360
+ export interface FontFamilyConfig {
361
+ family: string;
362
+ faces?: FontFaceConfig[];
363
+ [key: string]: unknown;
364
+ }
365
+ export type FontConfig = FontFamilyConfig;
366
+ /**
367
+ * One row in the toolbar's font-family dropdown.
368
+ *
369
+ * Distinct from {@link FontFamilyConfig}, which describes a family to load and
370
+ * measure. This describes a row to render.
371
+ *
372
+ * `label` and `key` are both required because the toolbar has no fallback for
373
+ * either. `label` is the value applied to the selection
374
+ * (`emitFontCommand(option.label)`) and what active-state matching compares
375
+ * against (`fontOptions.find((i) => i.label === fontFamily)`); `key` is the
376
+ * selection identity and the rendered list key. An entry missing either one
377
+ * produces a blank row or an undefined command value rather than a
378
+ * degraded-but-working option.
379
+ */
380
+ export interface ToolbarFontOption {
381
+ /**
382
+ * Logical family name. Rendered as the row's text, written to the selection
383
+ * when chosen, and compared against the current font for active state.
384
+ */
385
+ label: string;
386
+ /** Stable option identity, used for selection state and the list key. */
387
+ key: string;
388
+ /**
389
+ * Attributes spread onto the rendered row, which is the only channel that
390
+ * reaches it: both renderers bind `option.props` and nothing else
391
+ * (`ToolbarComboBox.vue:559`, `ToolbarDropdown.vue:420`).
392
+ *
393
+ * `props.style.fontFamily` is the preview stack the row is drawn in;
394
+ * `normalizeFontOption` falls back to `label` then `key` when it is absent,
395
+ * so a row always previews in something. Weight and any other per-row style
396
+ * go here too — `props: { style: { fontWeight: 700 } }` renders, a top-level
397
+ * `fontWeight` does not.
398
+ */
399
+ props?: {
400
+ style?: {
401
+ fontFamily?: string;
402
+ [key: string]: unknown;
403
+ };
404
+ [key: string]: unknown;
405
+ };
406
+ }
407
+ export interface FontsConfig {
408
+ bundled?: boolean | 'baseline' | 'full' | string[] | Record<string, unknown>;
409
+ families?: FontFamilyConfig[];
410
+ /**
411
+ * Base URL the bundled substitute pack (and curated faces) are fetched from, e.g. `'/fonts/'`.
412
+ * Canonical self-hosting field. When no pack is configured, SuperDoc fetches no bundled assets.
413
+ */
414
+ assetBaseUrl?: string;
415
+ /**
416
+ * Resolver for per-asset URLs (signed / versioned / CDN), called for each bundled face filename.
417
+ * Takes precedence over {@link assetBaseUrl} when present.
418
+ */
419
+ resolveAssetUrl?: FontAssetUrlResolver;
420
+ /** @deprecated Use {@link assetBaseUrl} (string) or {@link resolveAssetUrl} (function) instead. */
421
+ assetUrl?: string | FontAssetUrlResolver;
422
+ [key: string]: unknown;
423
+ }
424
+ export interface FontsResolvedPayload {
425
+ report?: FontResolutionRecord[];
426
+ missingFonts?: string[];
427
+ documentFonts?: string[];
428
+ documentFontOptions?: DocumentFontOption[];
429
+ [key: string]: unknown;
430
+ }
431
+ export interface FontsChangedPayload extends FontsResolvedPayload {
432
+ source?: string;
433
+ loadSummary?: FontLoadSummary | null;
434
+ }
435
+ export interface ListDefinitionsPayload {
436
+ [key: string]: unknown;
437
+ }
438
+ export type ProofingIssueKind = 'spelling' | 'grammar' | 'style';
439
+ export interface ProofingCapabilities {
440
+ issueKinds: ProofingIssueKind[];
441
+ supportsSuggestions?: boolean;
442
+ supportsMultipleLanguages?: boolean;
443
+ supportsBatching?: boolean;
444
+ requiresNetwork?: boolean;
445
+ }
446
+ export interface ProofingSegmentMetadata {
447
+ blockId?: string;
448
+ pageIndex?: number;
449
+ surface: 'body' | 'header' | 'footer' | 'table-cell' | 'other';
450
+ }
451
+ export interface ProofingSegment {
452
+ id: string;
453
+ text: string;
454
+ language?: string | null;
455
+ metadata: ProofingSegmentMetadata;
456
+ }
457
+ export interface ProofingCheckRequest {
458
+ documentId?: string | null;
459
+ defaultLanguage?: string | null;
460
+ maxSuggestions?: number;
461
+ segments: ProofingSegment[];
462
+ signal?: AbortSignal;
463
+ }
464
+ export interface ProofingIssue {
465
+ segmentId: string;
466
+ /** Zero-based start offset into the segment text (UTF-16 code units). */
467
+ start: number;
468
+ /** Zero-based end offset into the segment text (UTF-16 code units, exclusive). */
469
+ end: number;
470
+ kind: ProofingIssueKind;
471
+ message?: string;
472
+ replacements?: string[];
473
+ ruleId?: string;
474
+ providerMeta?: Record<string, unknown>;
475
+ }
476
+ export interface ProofingCheckResult {
477
+ issues: ProofingIssue[];
478
+ }
479
+ /**
480
+ * Provider-agnostic proofing engine. SuperDoc owns segment extraction,
481
+ * scheduling, and rendering; providers only inspect text and return ranges.
482
+ */
483
+ export interface ProofingProvider {
484
+ id: string;
485
+ getCapabilities?: () => Promise<ProofingCapabilities> | ProofingCapabilities;
486
+ check: (request: ProofingCheckRequest) => Promise<ProofingCheckResult>;
487
+ dispose?: () => Promise<void> | void;
488
+ }
489
+ export interface SelectionInfo {
490
+ [key: string]: unknown;
491
+ }
492
+ /**
493
+ * Font surface on a SuperDoc instance (`superdoc.fonts`). The substitution- and load-aware
494
+ * answer to "what fonts does this document use and did SuperDoc render them faithfully" -
495
+ * pulled on demand and streamed via the `fonts-changed` event - plus a per-document write
496
+ * surface: {@link map}/{@link unmap} override resolution, {@link add} registers custom faces,
497
+ * {@link preload} loads them. All reflect the ACTIVE editor: reads return empty arrays when no
498
+ * editor is active; writes throw. {@link getReport} and {@link getDocumentFonts} cover the
499
+ * document's DECLARED fonts (font table + theme + defaults), not only fonts visible on screen.
500
+ */
501
+ /** Public SuperDoc alias for the canonical font face config. */
502
+ export type SuperDocFontFace = FontFaceConfig;
503
+ /** Public SuperDoc alias for the canonical font family config. */
504
+ export type SuperDocFontFamily = FontFamilyConfig;
505
+ export interface SuperDocFontsApi {
506
+ /** Per-font report: requested logical family -> physical render family, reason, load status, export family, missing. */
507
+ getReport(): FontResolutionRecord[];
508
+ /** Declared families with no faithful render font loaded (the substitution-aware truth). */
509
+ getMissingFonts(): string[];
510
+ /** The document's declared logical font families, deduped. */
511
+ getDocumentFonts(): string[];
512
+ /**
513
+ * The document's own fonts as toolbar options: one per logical family the document renders, each with
514
+ * a preview family. Document fonts only - compose with the defaults.
515
+ */
516
+ getDocumentFontOptions(): DocumentFontOption[];
517
+ /**
518
+ * The complete font-family picker list for the active document: the bundled offerings gated on its
519
+ * font activation (baseline when no pack is configured, the curated rich set when it is, honoring
520
+ * include/exclude) unioned with the document's own fonts, sorted alphabetically. Drives the built-in
521
+ * toolbar font dropdown; ready to use, not just document fonts.
522
+ */
523
+ getFontFamilyOptions(): FontFamilyOption[];
524
+ /**
525
+ * Observe the font report: replays the current report immediately if one has already
526
+ * resolved, then invokes `callback` on every future change. Use this rather than
527
+ * `on('fonts-changed')` when you may subscribe after the report resolved. Note: right after
528
+ * a document swap, if the new active editor has not produced a report yet, nothing is
529
+ * delivered until it does (no stale prior-document report). Returns an unsubscribe function.
530
+ */
531
+ onReport(callback: (payload: FontsChangedPayload) => void): () => void;
532
+ /**
533
+ * Map logical families to physical render families for the ACTIVE document, overriding bundled
534
+ * defaults: `map({ Georgia: 'Gelasio', Arial: 'Liberation Sans' })`. Applies all entries, then
535
+ * re-measures and repaints once (a redundant map - a self-map, or a mapping identical to an
536
+ * already-stored override - does neither); observe via {@link onReport} / `fonts-changed` (`source:
537
+ * 'config-change'`). Mapping a family to its bundled clone (`map({ Calibri: 'Carlito' })`) is honored
538
+ * as an explicit PIN - stored so it outranks a registered real face for that family - not treated as
539
+ * a no-op. Each physical family must be loadable - a bundled substitute, or a face added via `add`.
540
+ * Per document: other editors on the page are unaffected. Render-only - export keeps the logical
541
+ * family name.
542
+ * @throws Error if no editor is active (a write needs a document; this fails loudly, not silently).
543
+ */
544
+ map(mappings: Record<string, string>): void;
545
+ /**
546
+ * Remove runtime mappings for the ACTIVE document; each family reverts to its bundled default
547
+ * (or its logical name). Accepts one family or several. Re-measures and repaints if anything
548
+ * changed.
549
+ * @throws Error if no editor is active.
550
+ */
551
+ unmap(families: string | string[]): void;
552
+ /**
553
+ * Register custom physical font faces (URL sources) for the ACTIVE document so they can be mapped
554
+ * to and loaded - e.g.
555
+ * `add({ family: 'Gelasio', faces: [{ source: '/fonts/Gelasio-Regular.woff2', weight: 400 }] })`.
556
+ * Registering does NOT map; pair with {@link map}. Re-adding the same source for a face is
557
+ * idempotent; a DIFFERENT source for the same family/weight/style throws. Reflows once if a
558
+ * registered face is one the document already uses.
559
+ * @throws Error if no editor is active, or if a conflicting source is registered.
560
+ */
561
+ add(families: SuperDocFontFamily | SuperDocFontFamily[]): void;
562
+ /**
563
+ * Proactively load the physical faces for the given LOGICAL families (resolved through the active
564
+ * document's mappings) so they are ready before use, avoiding a late-load reflow. Awaits the
565
+ * regular (400/normal) face via the registry.
566
+ * @throws Error if no editor is active.
567
+ */
568
+ preload(families: string[]): Promise<void>;
569
+ }
570
+ /**
571
+ * Internal post-`#init` shape of the active user. Extends the public
572
+ * `User` with the collab-awareness `color` field assigned by
573
+ * `SuperDoc.#assignUserColor()` and read by the presence system. Not
574
+ * part of the consumer-facing surface; consumers continue to pass
575
+ * `User` via `Config.user`, and SuperDoc widens to `AwarenessUser`
576
+ * internally once it has computed the color.
577
+ */
578
+ export interface AwarenessUser extends User {
579
+ /**
580
+ * Awareness color for collaborative cursors. Auto-assigned from the
581
+ * configured palette (or a default palette) by `#assignUserColor`,
582
+ * derived from a hash of the user's identity so the assignment is
583
+ * stable across reloads.
584
+ */
585
+ color?: string;
586
+ }
587
+ /**
588
+ * One entry in the `states` array delivered to
589
+ * {@link Config.onAwarenessUpdate}. SuperDoc emits an entry per remote
590
+ * client, derived from the underlying Yjs awareness states.
591
+ *
592
+ * The runtime helper `awarenessStatesToArray` spreads each remote user
593
+ * onto the top of the entry (`{ clientId, ...value.user, color }`), so
594
+ * `User` fields like `name`, `email`, `image` appear at the top level
595
+ * (not nested under a `user` property). Consumers should read `state.id`,
596
+ * `state.name`, and `state.email`, not `state.user.name`.
597
+ *
598
+ * Application-specific fields attached to the awareness state by the
599
+ * provider surface through the `[key: string]: unknown` index
600
+ * signature; consumers narrow before use.
601
+ */
602
+ export interface AwarenessState extends User {
603
+ /** Yjs client identifier for the remote peer. */
604
+ clientId?: number;
605
+ /**
606
+ * Color assigned by SuperDoc's presence system. Spread onto the
607
+ * awareness entry after the user fields, so it takes precedence
608
+ * over any color the awareness user carried in (see
609
+ * {@link AwarenessUser.color}). Used when the presence system
610
+ * computes a stable palette assignment for the remote peer.
611
+ */
612
+ color?: string;
613
+ /** Application-specific fields spread from the awareness provider. */
614
+ [key: string]: unknown;
615
+ }
616
+ export interface Document {
617
+ /** The ID of the document. */
618
+ id?: string;
619
+ /** The type of the document. */
620
+ type: string;
621
+ /** The initial data of the document (File, Blob, or null). */
622
+ data?: globalThis.File | globalThis.Blob | null;
623
+ /** The name of the document. */
624
+ name?: string;
625
+ /** The URL of the document. */
626
+ url?: string;
627
+ /** Whether the document is a new file. */
628
+ isNewFile?: boolean;
629
+ /** The Yjs document for collaboration. */
630
+ ydoc?: YDoc;
631
+ /**
632
+ * The provider for collaboration. Widened from `HocuspocusProvider` to
633
+ * `CollaborationProvider` to match the runtime, which stores whatever
634
+ * provider the consumer passed via `Config.modules.collaboration.provider`
635
+ * (HocuspocusProvider, LiveblocksYjsProvider, TiptapCollabProvider, etc.).
636
+ * Consumers needing Hocuspocus-specific members must narrow before use.
637
+ */
638
+ provider?: CollaborationProvider;
639
+ /**
640
+ * Document-level v2 collaboration handoff. When present, the v2 runtime
641
+ * makes this document collaborative through the shipped single-doc
642
+ * y-websocket provider (one room / Y.Doc / awareness channel per
643
+ * `documentId`). See {@link V2CollaborationConfig}. Ignored by the v1
644
+ * editor, which uses `Config.modules.collaboration` instead.
645
+ */
646
+ v2Collaboration?: V2CollaborationConfig | null;
647
+ }
648
+ /**
649
+ * Public snapshot shape returned by `SuperDoc#state`. Always reflects
650
+ * the most recent values from the Pinia store; consumers must re-read
651
+ * on change rather than caching.
652
+ *
653
+ * `documents` is typed as the public `Document[]` view. Internally the
654
+ * runtime tracks `RuntimeDocument`, which adds runtime-only fields
655
+ * (editor/renderer accessors, `restoreComments`, etc.) for
656
+ * SuperDoc's own lifecycle plumbing. Those fields are not part of the
657
+ * supported surface; consumers using `state.documents` should treat
658
+ * each entry as `Document` and not rely on the richer runtime shape.
659
+ */
660
+ export interface SuperDocState {
661
+ /** Documents tracked by the instance, in consumer-provided order. */
662
+ documents: Document[];
663
+ /** Shared users (drives presence + "@"-mention surfaces). */
664
+ users: User[];
665
+ }
666
+ /**
667
+ * External collaboration provider interface. Accepts any Yjs-compatible
668
+ * provider (HocuspocusProvider, LiveblocksYjsProvider, TiptapCollabProvider,
669
+ * etc.). The v2 branch exposes a structural provider type so public
670
+ * declarations do not depend on the v1 editor package.
671
+ */
672
+ /**
673
+ * Internal augmentation of `Document` for runtime-only fields that the
674
+ * SuperDoc instance attaches to each document during initialization. The
675
+ * public `Document` interface above is what consumers pass in via
676
+ * `Config.documents`; this type adds the fields SuperDoc itself sets and
677
+ * reads internally (per-document `role` propagation, the live editor and
678
+ * renderer accessors that the surface manager and
679
+ * mode-switch helpers walk).
680
+ *
681
+ * Internal use only: not part of any public typedef. Consumers cannot
682
+ * import this through `superdoc` and should not pass any of these fields
683
+ * into `Config.documents` from outside.
684
+ */
685
+ export interface RuntimeDocument extends Document {
686
+ /**
687
+ * Per-document role. `useDocument()` reads `params.role` from the input
688
+ * config and exposes it on the smart-doc object; once collaboration
689
+ * setup runs, SuperDoc unconditionally writes `doc.role = config.role`,
690
+ * silently replacing whatever was passed. SD-2872 removed this from
691
+ * the public `Document` interface so consumers stop trying to use it
692
+ * as a stable per-document override; it lives on `RuntimeDocument`
693
+ * only so internal SuperDoc callsites can type the assignment.
694
+ */
695
+ role?: 'editor' | 'viewer' | 'suggester';
696
+ /**
697
+ * Returns the body Editor for this document, when the runtime has
698
+ * created one. Set by the editor-create lifecycle.
699
+ *
700
+ * @deprecated Direct editor access will be removed in a future version.
701
+ * Use the Document API (`editor.doc`) instead. This typedef carries the
702
+ * deprecation marker forward from the source accessor in
703
+ * `packages/superdoc/src/composables/use-document.js`.
704
+ */
705
+ getEditor?: () => Editor | null | undefined;
706
+ /**
707
+ * Returns the DocumentRendererRuntime for this document, when the runtime
708
+ * has created one. Set by the editor-create lifecycle.
709
+ *
710
+ * @deprecated Direct editor access will be removed in a future version.
711
+ * Use the Document API (`editor.doc`) instead.
712
+ */
713
+ getDocumentRuntime?: () => DocumentRendererRuntime | null | undefined;
714
+ /**
715
+ * Runtime-only flag mirrored from `Config.rulers` per document by the
716
+ * Pinia store. SuperDoc writes this on each document during the
717
+ * setShowRulers flow; not part of consumer-supplied `Document`.
718
+ */
719
+ rulers?: boolean;
720
+ /**
721
+ * Runtime-only method attached by the comments composable on each
722
+ * document. Set after the comments store is ready; called during
723
+ * mode switches. Not part of consumer-supplied `Document`.
724
+ */
725
+ restoreComments?: () => void;
726
+ /**
727
+ * Runtime-only method attached by the comments composable on each
728
+ * document. Set after the comments store is ready; called during
729
+ * DOCX export when comments should be stripped. Not part of
730
+ * consumer-supplied `Document`.
731
+ */
732
+ removeComments?: () => void;
733
+ }
734
+ /** Collaboration module configuration. */
735
+ export interface CollaborationConfig {
736
+ /** External Yjs document (provider-agnostic mode). */
737
+ ydoc?: YDoc;
738
+ /** External collaboration provider (provider-agnostic mode). */
739
+ provider?: CollaborationProvider;
740
+ /** Internal provider type (deprecated). */
741
+ providerType?: 'hocuspocus' | 'superdoc';
742
+ /** WebSocket URL for internal provider (deprecated). */
743
+ url?: string;
744
+ /** Authentication token for internal provider (deprecated). */
745
+ token?: string;
746
+ /** Additional params for internal provider (deprecated). */
747
+ params?: object;
748
+ }
749
+ /**
750
+ * Options for `upgradeToCollaboration()`.
751
+ *
752
+ * v2 promotes a local single-DOCX editor into the shipped single-doc
753
+ * y-websocket room described by {@link V2CollaborationConfig}. Pass a
754
+ * `v2Collaboration` target to promote into a supported v2 room.
755
+ *
756
+ * The legacy `ydoc` / `provider` fields remain accepted for source
757
+ * compatibility with v1-shaped callers, but v2 does **not** drive document
758
+ * content from an arbitrary external `{ ydoc, provider }` pair: a v2 upgrade
759
+ * resolves to a supported v2 target through the shell's collaboration target
760
+ * resolver, or fails closed with a named, redacted diagnostic. The legacy
761
+ * fields are therefore optional and only honored when they resolve to a
762
+ * supported v2 room.
763
+ *
764
+ * @see {@link V2CollaborationConfig}
765
+ */
766
+ export interface UpgradeToCollaborationOptions {
767
+ /**
768
+ * Canonical supported v2 promotion target: the single-doc y-websocket room
769
+ * ({ documentId, serverUrl, params? }) to create from the current document.
770
+ * Promotion fails if the v2 room already exists.
771
+ */
772
+ v2Collaboration?: V2CollaborationConfig;
773
+ /**
774
+ * Legacy external Yjs document. Accepted for v1 source compatibility; not a
775
+ * supported v2 content source on its own.
776
+ */
777
+ ydoc?: YDoc;
778
+ /**
779
+ * Legacy external collaboration provider. Accepted for v1 source
780
+ * compatibility; not a supported v2 content source on its own.
781
+ */
782
+ provider?: CollaborationProvider;
783
+ }
784
+ /** Context passed to a link popover resolver when a link is clicked. */
785
+ export interface LinkPopoverContext {
786
+ /** The editor instance. */
787
+ editor: Editor;
788
+ /** The href attribute of the clicked link. */
789
+ href: string;
790
+ /** The target attribute of the clicked link. */
791
+ target: string | null;
792
+ /** The rel attribute of the clicked link. */
793
+ rel: string | null;
794
+ /** The title/tooltip attribute of the clicked link. */
795
+ tooltip: string | null;
796
+ /** The clicked anchor DOM element. */
797
+ element: HTMLAnchorElement;
798
+ /** X coordinate of the click. */
799
+ clientX: number;
800
+ /** Y coordinate of the click. */
801
+ clientY: number;
802
+ /** Whether this is an anchor link (href starts with #). */
803
+ isAnchorLink: boolean;
804
+ /** Current document mode ('editing', 'viewing', 'suggesting'). */
805
+ documentMode: DocumentMode;
806
+ /** Computed popover position relative to editor surface. */
807
+ position: {
808
+ left: string;
809
+ top: string;
810
+ };
811
+ /** Close the popover programmatically. */
812
+ closePopover: () => void;
813
+ }
814
+ /** Context passed to an external (framework-agnostic) popover renderer. */
815
+ export interface ExternalPopoverRenderContext {
816
+ /** Empty DOM container positioned where the popover should appear. */
817
+ container: HTMLElement;
818
+ /** Call to close the popover and clean up. */
819
+ closePopover: () => void;
820
+ /** The editor instance. */
821
+ editor: Editor;
822
+ /** The href of the clicked link. */
823
+ href: string;
824
+ }
825
+ /** Resolution returned by a link popover resolver. */
826
+ export type LinkPopoverResolution = {
827
+ type: 'default';
828
+ } | {
829
+ type: 'none';
830
+ } | {
831
+ type: 'custom';
832
+ component: unknown;
833
+ props?: Record<string, unknown>;
834
+ } | {
835
+ type: 'external';
836
+ render: (ctx: ExternalPopoverRenderContext) => {
837
+ destroy?: () => void;
838
+ } | void;
839
+ };
840
+ /**
841
+ * Resolver function for customizing the link click popover. Must be
842
+ * synchronous; do not return a Promise. Return null/undefined to use the
843
+ * default popover.
844
+ */
845
+ export type LinkPopoverResolver = (ctx: LinkPopoverContext) => LinkPopoverResolution | null | undefined;
846
+ /** Context object passed to context menu callbacks (showWhen, render, action, menuProvider). */
847
+ export interface ContextMenuContext {
848
+ /** The editor instance. */
849
+ editor: Editor;
850
+ /** Currently selected text (empty string if no selection). */
851
+ selectedText: string;
852
+ /** Whether there is an expanded selection. */
853
+ hasSelection: boolean;
854
+ /** ProseMirror start position of the selection. */
855
+ selectionStart: number;
856
+ /** ProseMirror end position of the selection. */
857
+ selectionEnd: number;
858
+ /** How the menu was opened. */
859
+ trigger: 'click' | 'slash';
860
+ /** Whether the cursor is inside a table. */
861
+ isInTable: boolean;
862
+ /** Whether the cursor is inside a list. */
863
+ isInList: boolean;
864
+ /** Whether the cursor is inside a document section. */
865
+ isInSectionNode: boolean;
866
+ /** Whether a table cell selection is active. */
867
+ isCellSelection: boolean;
868
+ /** Kind of table selection (row, column, etc.). */
869
+ tableSelectionKind: string | null;
870
+ /** ProseMirror node type name at the cursor. */
871
+ currentNodeType: string | null;
872
+ /** Names of marks active at the cursor. */
873
+ activeMarks: string[];
874
+ /** Whether the cursor is on a tracked change. */
875
+ isTrackedChange: boolean;
876
+ /** ID of the tracked change at the cursor. */
877
+ trackedChangeId: string | null;
878
+ /** Current document mode (editing, viewing, suggesting). */
879
+ documentMode: string;
880
+ /** Whether undo is available. */
881
+ canUndo: boolean;
882
+ /** Whether redo is available. */
883
+ canRedo: boolean;
884
+ /** Whether the editor is editable. */
885
+ isEditable: boolean;
886
+ /** Screen coordinates of the cursor. */
887
+ cursorPosition: {
888
+ x: number;
889
+ y: number;
890
+ } | null;
891
+ }
892
+ /** A single item inside a context menu section. */
893
+ export interface ContextMenuItem {
894
+ /** Unique identifier for the menu item. */
895
+ id: string;
896
+ /** Display text. */
897
+ label: string;
898
+ /** Icon identifier. */
899
+ icon?: string;
900
+ /** Custom Vue component to render this item. */
901
+ component?: unknown;
902
+ /**
903
+ * Callback invoked when the item is clicked.
904
+ *
905
+ * @deprecated replaceWith=`onSelect` removeIn=v3.0 — V1 only. SuperDoc 2
906
+ * cannot invoke this: its first argument is a ProseMirror `Editor` the v2
907
+ * runtime does not have, and `ContextMenuContext` carries fields v2 does not
908
+ * expose. Items using it render and then do nothing when clicked, and the
909
+ * runtime warns once naming the replacement.
910
+ */
911
+ action?: (editor: Editor, context: ContextMenuContext) => void;
912
+ /**
913
+ * Application-owned click handler. Runs after the menu dismisses.
914
+ *
915
+ * This is the supported way to attach a product action such as "copy the
916
+ * selection into our workflow"; the built-in `intent` union covers only what
917
+ * SuperDoc itself performs.
918
+ */
919
+ onSelect?: (payload: ContextMenuSelectPayload) => void | Promise<void>;
920
+ /** Predicate controlling visibility. */
921
+ showWhen?: (context: ContextMenuContext) => boolean;
922
+ /** Custom renderer returning an HTML element. */
923
+ render?: (context: ContextMenuContext) => HTMLElement;
924
+ /** Keyboard shortcut label displayed beside the item. */
925
+ shortcut?: string;
926
+ }
927
+ /** The menu context a `ContextMenuItem.onSelect` handler receives. */
928
+ export interface ContextMenuSelectContext {
929
+ /**
930
+ * Text selected when the menu opened. Empty when the caret was collapsed, and
931
+ * also empty when a worker-backed read had not settled by click time — await
932
+ * `selectedTextSettled` when accuracy matters more than the gesture.
933
+ */
934
+ selectedText: string;
935
+ /**
936
+ * The settled selection text.
937
+ *
938
+ * The handler is invoked synchronously so it keeps the click's user
939
+ * activation, which gesture-gated APIs such as `navigator.clipboard.write`,
940
+ * `window.open`, and `showOpenFilePicker` require. Awaiting this resolves the
941
+ * accurate text but spends that activation, so reach for it only when the
942
+ * handler does not need a gesture. Resolves to `selectedText` when the read
943
+ * had already settled or failed.
944
+ */
945
+ selectedTextSettled: Promise<string>;
946
+ hasSelection: boolean;
947
+ /** How the menu was opened. */
948
+ trigger: 'click' | 'slash';
949
+ isInTable: boolean;
950
+ isInList: boolean;
951
+ documentMode: 'editing' | 'suggesting' | 'viewing';
952
+ isEditable: boolean;
953
+ }
954
+ /** Repaint coordination handed alongside the Document API surface. */
955
+ export interface ContextMenuSelectReadiness {
956
+ /** Render epoch of the mounted surface, or null when not mounted. */
957
+ getRenderEpoch(): number | null;
958
+ /** Resolves once a mutation's scheduled repaint has settled. */
959
+ whenPainted(input?: {
960
+ txId?: string;
961
+ afterEpoch?: number | null;
962
+ }): Promise<{
963
+ renderEpoch: number | null;
964
+ }>;
965
+ }
966
+ /**
967
+ * What a `ContextMenuItem.onSelect` handler is given.
968
+ *
969
+ * `document` is the async Document API surface, and it is a result rather than
970
+ * a handle: it reports `available: false` with a reason before the document is
971
+ * ready, so a handler has to check before reaching for `doc`. It is not the
972
+ * ProseMirror `Editor` the deprecated `action` callback took, which the v2
973
+ * runtime does not have.
974
+ */
975
+ export interface ContextMenuSelectPayload {
976
+ document: {
977
+ available: true;
978
+ doc: BrowserDocumentApi;
979
+ readiness: ContextMenuSelectReadiness;
980
+ } | {
981
+ available: false;
982
+ reason: string;
983
+ };
984
+ /** The context captured when the menu opened, not the live document state. */
985
+ context: ContextMenuSelectContext | null;
986
+ }
987
+ /** A section (group) of items in the context menu. */
988
+ export interface ContextMenuSection {
989
+ /** Unique identifier for the section. */
990
+ id: string;
991
+ /** Menu items in this section. */
992
+ items: ContextMenuItem[];
993
+ }
994
+ /** Configuration for the context menu module. */
995
+ export interface ContextMenuConfig {
996
+ /** Custom menu sections appended (or merged by id) to the default menu. */
997
+ customItems?: ContextMenuSection[];
998
+ /**
999
+ * Advanced: transform the final section list before render. Return
1000
+ * null/undefined to keep the original sections.
1001
+ */
1002
+ menuProvider?: (context: ContextMenuContext, sections: ContextMenuSection[]) => ContextMenuSection[] | null | undefined;
1003
+ /** Whether to include default menu items (default: true). */
1004
+ includeDefaultItems?: boolean;
1005
+ }
1006
+ /** Surface presentation mode. */
1007
+ export type SurfaceMode = 'dialog' | 'floating';
1008
+ export type SurfaceFloatingPlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
1009
+ /** Per-request floating-mode overrides. */
1010
+ interface FloatingRequestOptions {
1011
+ /** Position preset (default: 'top-right'). Ignored when explicit insets are provided. */
1012
+ placement?: SurfaceFloatingPlacement;
1013
+ /** Exact top inset (overrides placement). */
1014
+ top?: string | number;
1015
+ /** Exact right inset (overrides placement). */
1016
+ right?: string | number;
1017
+ /** Exact bottom inset (overrides placement). */
1018
+ bottom?: string | number;
1019
+ /** Exact left inset (overrides placement). */
1020
+ left?: string | number;
1021
+ /** Surface width. */
1022
+ width?: string | number;
1023
+ /** Max width. */
1024
+ maxWidth?: string | number;
1025
+ /** Max height. */
1026
+ maxHeight?: string | number;
1027
+ /** Move focus into first focusable child on open (default: true). */
1028
+ autoFocus?: boolean;
1029
+ /** Close when pointer down outside the surface (default: false). */
1030
+ closeOnOutsidePointerDown?: boolean;
1031
+ }
1032
+ /** Intent-based surface request — resolved by the resolver or built-in registry. */
1033
+ export interface IntentSurfaceRequest {
1034
+ /** Optional surface id (auto-generated if omitted). */
1035
+ id?: string;
1036
+ /** Opaque intent identifier used by the resolver. */
1037
+ kind: string;
1038
+ /** Presentation mode. */
1039
+ mode: SurfaceMode;
1040
+ /** Optional title rendered in the surface chrome. */
1041
+ title?: string;
1042
+ /**
1043
+ * Accessible name for the surface when no visible title is provided. Used as
1044
+ * aria-label fallback when neither title nor ariaLabelledBy is set.
1045
+ */
1046
+ ariaLabel?: string;
1047
+ /**
1048
+ * ID of the element that labels the surface. Takes precedence over
1049
+ * ariaLabel. Use this when the content component renders its own heading
1050
+ * that should serve as the accessible name.
1051
+ */
1052
+ ariaLabelledBy?: string;
1053
+ /**
1054
+ * Whether Escape closes the surface (default: true). Set at the request top
1055
+ * level — the runtime does not read `floating.closeOnEscape` on a per-request
1056
+ * basis.
1057
+ */
1058
+ closeOnEscape?: boolean;
1059
+ /** Whether backdrop click closes a dialog (default: true). */
1060
+ closeOnBackdrop?: boolean;
1061
+ /** Dialog-specific overrides. */
1062
+ dialog?: {
1063
+ maxWidth?: string | number;
1064
+ };
1065
+ /** Floating-specific overrides. */
1066
+ floating?: FloatingRequestOptions;
1067
+ /** Arbitrary data for the resolver or content. */
1068
+ payload?: Record<string, unknown>;
1069
+ }
1070
+ /** Direct-render surface request — provides its own component or external renderer. */
1071
+ export interface DirectSurfaceRequest {
1072
+ /** Optional surface id (auto-generated if omitted). */
1073
+ id?: string;
1074
+ /** Presentation mode. */
1075
+ mode: SurfaceMode;
1076
+ /** Optional title rendered in the surface chrome. */
1077
+ title?: string;
1078
+ /**
1079
+ * Accessible name for the surface when no visible title is provided. Used as
1080
+ * aria-label fallback when neither title nor ariaLabelledBy is set.
1081
+ */
1082
+ ariaLabel?: string;
1083
+ /**
1084
+ * ID of the element that labels the surface. Takes precedence over
1085
+ * ariaLabel. Use this when the content component renders its own heading
1086
+ * that should serve as the accessible name.
1087
+ */
1088
+ ariaLabelledBy?: string;
1089
+ /**
1090
+ * Whether Escape closes the surface (default: true). Set at the request top
1091
+ * level — the runtime does not read `floating.closeOnEscape` on a per-request
1092
+ * basis.
1093
+ */
1094
+ closeOnEscape?: boolean;
1095
+ /** Whether backdrop click closes a dialog (default: true). */
1096
+ closeOnBackdrop?: boolean;
1097
+ /** Dialog-specific overrides. */
1098
+ dialog?: {
1099
+ maxWidth?: string | number;
1100
+ };
1101
+ /** Floating-specific overrides. */
1102
+ floating?: FloatingRequestOptions;
1103
+ /** Vue component to render as the surface content. */
1104
+ component?: unknown;
1105
+ /** Extra props passed to the Vue component. */
1106
+ props?: Record<string, unknown>;
1107
+ /** External (framework-agnostic) renderer function. */
1108
+ render?: (ctx: ExternalSurfaceRenderContext) => {
1109
+ destroy?: () => void;
1110
+ } | void;
1111
+ }
1112
+ /** Combined surface request type (intent-based or direct-render). */
1113
+ export type SurfaceRequest = IntentSurfaceRequest | DirectSurfaceRequest;
1114
+ /** Resolution returned by a surface resolver. */
1115
+ export type SurfaceResolution = {
1116
+ type: 'none';
1117
+ } | {
1118
+ type: 'custom';
1119
+ component: unknown;
1120
+ props?: Record<string, unknown>;
1121
+ } | {
1122
+ type: 'external';
1123
+ render: (ctx: ExternalSurfaceRenderContext) => {
1124
+ destroy?: () => void;
1125
+ } | void;
1126
+ };
1127
+ /**
1128
+ * Resolver function for customizing surface rendering. Must be synchronous;
1129
+ * do not return a Promise. Return null/undefined to fall through to built-in
1130
+ * handling. Return `{ type: 'none' }` to explicitly suppress the surface.
1131
+ */
1132
+ export type SurfaceResolver = (request: SurfaceRequest) => SurfaceResolution | null | undefined;
1133
+ /**
1134
+ * Outcome of a surface lifecycle. The handle.result promise always resolves
1135
+ * with one of these — it never rejects for normal lifecycle events.
1136
+ */
1137
+ export interface SurfaceOutcome<TResult = unknown> {
1138
+ status: 'submitted' | 'closed' | 'replaced' | 'destroyed';
1139
+ /** Present when status is 'submitted'. */
1140
+ data?: TResult;
1141
+ /** Present when status is 'closed'. */
1142
+ reason?: unknown;
1143
+ /** Present when status is 'replaced'. */
1144
+ replacedBy?: string;
1145
+ }
1146
+ /**
1147
+ * Handle returned by openSurface(). Callers use this to await the outcome or
1148
+ * close the surface programmatically.
1149
+ */
1150
+ export interface SurfaceHandle<TResult = unknown> {
1151
+ /** Resolved surface id. */
1152
+ id: string;
1153
+ /** Presentation mode. */
1154
+ mode: SurfaceMode;
1155
+ /** Close this surface programmatically. */
1156
+ close: (reason?: unknown) => void;
1157
+ /** Resolves when the surface settles. */
1158
+ result: Promise<SurfaceOutcome<TResult>>;
1159
+ }
1160
+ /**
1161
+ * Props passed to a custom Vue component rendered inside a surface shell.
1162
+ * Reserved props (surfaceId, mode, request, resolve, close) always win over
1163
+ * caller-provided props to prevent accidental lifecycle override.
1164
+ */
1165
+ export interface SurfaceComponentProps {
1166
+ /** The surface id. */
1167
+ surfaceId: string;
1168
+ /** Presentation mode. */
1169
+ mode: SurfaceMode;
1170
+ /** The original (normalized) request. */
1171
+ request: SurfaceRequest;
1172
+ /** Resolves the handle with `{ status: 'submitted', data }`. */
1173
+ resolve: (data?: unknown) => void;
1174
+ /** Resolves the handle with `{ status: 'closed', reason }`. */
1175
+ close: (reason?: unknown) => void;
1176
+ }
1177
+ /** Context passed to an external (framework-agnostic) surface renderer. */
1178
+ export interface ExternalSurfaceRenderContext {
1179
+ /** Empty DOM container to render into. */
1180
+ container: HTMLElement;
1181
+ /** The surface id. */
1182
+ surfaceId: string;
1183
+ /** Presentation mode. */
1184
+ mode: SurfaceMode;
1185
+ /** The original (normalized) request. */
1186
+ request: SurfaceRequest;
1187
+ /** Resolves the handle with `{ status: 'submitted', data }`. */
1188
+ resolve: (data?: unknown) => void;
1189
+ /** Resolves the handle with `{ status: 'closed', reason }`. */
1190
+ close: (reason?: unknown) => void;
1191
+ }
1192
+ /** Module-level configuration for the surface system. */
1193
+ export interface SurfacesModuleConfig {
1194
+ /**
1195
+ * Global surface resolver.
1196
+ *
1197
+ * `null` is the resolved "no resolver" value the normalizer produces after
1198
+ * rejecting a non-function; SurfaceManager guards with `typeof === 'function'`
1199
+ * either way.
1200
+ */
1201
+ resolver?: SurfaceResolver | null;
1202
+ /** Default dialog options. */
1203
+ dialog?: {
1204
+ /** Default escape behavior for dialogs (default: true). */
1205
+ closeOnEscape?: boolean;
1206
+ /** Default backdrop-click behavior for dialogs (default: true). */
1207
+ closeOnBackdrop?: boolean;
1208
+ /** Default dialog max-width. */
1209
+ maxWidth?: string | number;
1210
+ };
1211
+ /** Default floating options. */
1212
+ floating?: {
1213
+ /** Default placement preset (default: 'top-right'). */
1214
+ placement?: SurfaceFloatingPlacement;
1215
+ /** Default floating width. */
1216
+ width?: string | number;
1217
+ /** Default floating max-width. */
1218
+ maxWidth?: string | number;
1219
+ /** Default floating max-height. */
1220
+ maxHeight?: string | number;
1221
+ /** Default escape behavior for floating surfaces (default: true). */
1222
+ closeOnEscape?: boolean;
1223
+ /** Default outside-pointer behavior (default: false). */
1224
+ closeOnOutsidePointerDown?: boolean;
1225
+ /** Default auto-focus behavior (default: true). */
1226
+ autoFocus?: boolean;
1227
+ };
1228
+ /**
1229
+ * Built-in find/replace popover for editor-backed documents. Disabled by
1230
+ * default. Set to `true` to intercept Cmd+F / Ctrl+F inside SuperDoc and
1231
+ * open the built-in UI. When an object, allows text customization, custom
1232
+ * components, resolvers, and replace-disabling.
1233
+ */
1234
+ findReplace?: boolean | FindReplaceConfig;
1235
+ /**
1236
+ * Built-in password prompt dialog for encrypted DOCX files. Enabled by
1237
+ * default when omitted. Set to `false` to disable. When `true`, uses
1238
+ * default titles/labels. When an object, allows custom titles and labels.
1239
+ */
1240
+ passwordPrompt?: boolean | PasswordPromptConfig;
1241
+ }
1242
+ /** All customizable text strings for the password prompt, resolved with defaults. */
1243
+ export interface ResolvedPasswordPromptTexts {
1244
+ /** Dialog title for first attempt. */
1245
+ title: string;
1246
+ /** Dialog title after wrong password. */
1247
+ invalidTitle: string;
1248
+ /** Explanatory text shown below the title. */
1249
+ description: string;
1250
+ /** Input placeholder text. */
1251
+ placeholder: string;
1252
+ /** Accessible label for the password input. */
1253
+ inputAriaLabel: string;
1254
+ /** Submit button text. */
1255
+ submitLabel: string;
1256
+ /** Cancel button text. */
1257
+ cancelLabel: string;
1258
+ /** Submit button text while decrypting. */
1259
+ busyLabel: string;
1260
+ /** Error message for wrong password. */
1261
+ invalidMessage: string;
1262
+ /** Error message for decryption timeout. */
1263
+ timeoutMessage: string;
1264
+ /** Error message for other failures. */
1265
+ genericErrorMessage: string;
1266
+ }
1267
+ /** Result of a password attempt via the `attemptPassword` function. */
1268
+ export interface PasswordPromptAttemptResult {
1269
+ /** Whether the password was accepted. */
1270
+ success: boolean;
1271
+ /** Error code when success is false (e.g. 'DOCX_PASSWORD_INVALID', 'timeout'). */
1272
+ errorCode?: string;
1273
+ }
1274
+ /**
1275
+ * Handle object injected into custom password prompt UIs as the
1276
+ * `passwordPrompt` prop/context field. Provides document metadata, resolved
1277
+ * texts, and the retry function.
1278
+ */
1279
+ export interface PasswordPromptHandle {
1280
+ /** The document ID requiring a password. */
1281
+ documentId: string;
1282
+ /** The current error code (e.g. 'DOCX_PASSWORD_REQUIRED', 'DOCX_PASSWORD_INVALID'). */
1283
+ errorCode: string;
1284
+ /** All text strings resolved with defaults. */
1285
+ texts: ResolvedPasswordPromptTexts;
1286
+ /**
1287
+ * Submit a password attempt. Returns the outcome; do not mutate document
1288
+ * state directly.
1289
+ */
1290
+ attemptPassword: (password: string) => Promise<PasswordPromptAttemptResult>;
1291
+ }
1292
+ /**
1293
+ * Read-only context passed to a password prompt resolver to decide how to
1294
+ * render. Does NOT include `attemptPassword` — the resolver decides, it does
1295
+ * not act.
1296
+ */
1297
+ export interface PasswordPromptContext {
1298
+ /** The document ID requiring a password. */
1299
+ documentId: string;
1300
+ /** The current error code. */
1301
+ errorCode: string;
1302
+ /** Resolved text strings. */
1303
+ texts: ResolvedPasswordPromptTexts;
1304
+ }
1305
+ /** Context passed to an external (framework-agnostic) password prompt renderer. */
1306
+ export interface PasswordPromptRenderContext {
1307
+ /** Empty DOM container to render into. */
1308
+ container: HTMLElement;
1309
+ /** The password prompt handle. */
1310
+ passwordPrompt: PasswordPromptHandle;
1311
+ /** Resolves the surface with `{ status: 'submitted', data }`. */
1312
+ resolve: (data?: unknown) => void;
1313
+ /** Resolves the surface with `{ status: 'closed', reason }`. */
1314
+ close: (reason?: unknown) => void;
1315
+ /** The surface id. */
1316
+ surfaceId: string;
1317
+ /** Presentation mode. */
1318
+ mode: SurfaceMode;
1319
+ }
1320
+ /** Resolution returned by a password prompt resolver. */
1321
+ export type PasswordPromptResolution = {
1322
+ type: 'default';
1323
+ } | {
1324
+ type: 'none';
1325
+ } | {
1326
+ type: 'custom';
1327
+ component: unknown;
1328
+ props?: Record<string, unknown>;
1329
+ } | {
1330
+ type: 'external';
1331
+ render: (ctx: PasswordPromptRenderContext) => {
1332
+ destroy?: () => void;
1333
+ } | void;
1334
+ };
1335
+ /** Configuration for the password prompt surface. */
1336
+ export interface PasswordPromptConfig {
1337
+ /** Dialog title for first attempt (default: 'Password Required'). */
1338
+ title?: string;
1339
+ /** Dialog title after wrong password (default: 'Incorrect Password'). */
1340
+ invalidTitle?: string;
1341
+ /** Explanatory text (default: 'This document is password protected. Enter the password to open it.'). */
1342
+ description?: string;
1343
+ /** Input placeholder (default: 'Enter password'). */
1344
+ placeholder?: string;
1345
+ /** Accessible label for the input (default: 'Document password'). */
1346
+ inputAriaLabel?: string;
1347
+ /** Submit button text (default: 'Open'). */
1348
+ submitLabel?: string;
1349
+ /** Cancel button text (default: 'Cancel'). */
1350
+ cancelLabel?: string;
1351
+ /** Submit button text while decrypting (default: 'Decrypting…'). */
1352
+ busyLabel?: string;
1353
+ /** Error for wrong password (default: 'Incorrect password. Please try again.'). */
1354
+ invalidMessage?: string;
1355
+ /** Error for timeout (default: 'Timed out while decrypting. Please try again.'). */
1356
+ timeoutMessage?: string;
1357
+ /** Error for other failures (default: 'Unable to decrypt this document.'). */
1358
+ genericErrorMessage?: string;
1359
+ /** Vue component to render as custom password prompt content. Mutually exclusive with `render`. */
1360
+ component?: unknown;
1361
+ /** Extra props passed to the custom Vue component. Component-only; ignored for `render`. */
1362
+ props?: Record<string, unknown>;
1363
+ /** External (framework-agnostic) renderer. Mutually exclusive with `component`. */
1364
+ render?: (ctx: PasswordPromptRenderContext) => {
1365
+ destroy?: () => void;
1366
+ } | void;
1367
+ /** Conditional resolver for per-document customization. Can coexist with `component`/`render`. */
1368
+ resolver?: (ctx: PasswordPromptContext) => PasswordPromptResolution | null | undefined;
1369
+ }
1370
+ /** All customizable text strings for the find/replace surface, resolved with defaults. */
1371
+ export interface ResolvedFindReplaceTexts {
1372
+ /** Input placeholder for the find field. */
1373
+ findPlaceholder: string;
1374
+ /** Accessible label for the find input. */
1375
+ findAriaLabel: string;
1376
+ /** Input placeholder for the replace field. */
1377
+ replacePlaceholder: string;
1378
+ /** Accessible label for the replace input. */
1379
+ replaceAriaLabel: string;
1380
+ /** Text shown when there are no matches. */
1381
+ noResultsLabel: string;
1382
+ /** Button label / title for previous match. */
1383
+ previousMatchLabel: string;
1384
+ /** Accessible label for previous match button. */
1385
+ previousMatchAriaLabel: string;
1386
+ /** Button label / title for next match. */
1387
+ nextMatchLabel: string;
1388
+ /** Accessible label for next match button. */
1389
+ nextMatchAriaLabel: string;
1390
+ /** Button label / title for close. */
1391
+ closeLabel: string;
1392
+ /** Accessible label for close button. */
1393
+ closeAriaLabel: string;
1394
+ /** Replace button text. */
1395
+ replaceLabel: string;
1396
+ /** Replace-all button text. */
1397
+ replaceAllLabel: string;
1398
+ /** Toggle replace row label. */
1399
+ toggleReplaceLabel: string;
1400
+ /** Accessible label for toggle replace button. */
1401
+ toggleReplaceAriaLabel: string;
1402
+ /** Match case toggle text. */
1403
+ matchCaseLabel: string;
1404
+ /** Accessible label for match case toggle. */
1405
+ matchCaseAriaLabel: string;
1406
+ /** Ignore diacritics toggle text. */
1407
+ ignoreDiacriticsLabel: string;
1408
+ /** Accessible label for ignore diacritics toggle. */
1409
+ ignoreDiacriticsAriaLabel: string;
1410
+ /** Regex toggle text. */
1411
+ regexLabel: string;
1412
+ /** Accessible label for the regex toggle. */
1413
+ regexAriaLabel: string;
1414
+ /** Inline error shown when the regex pattern is invalid or unsafe. */
1415
+ invalidPatternLabel: string;
1416
+ }
1417
+ /**
1418
+ * A document position range, in ProseMirror coordinates.
1419
+ *
1420
+ * SD-2828: Surfaced on the public type contract so consumers can
1421
+ * destructure `SearchMatch.ranges` without falling back to `any`. Mirrors
1422
+ * the private `DocRange` typedef in the search extension; keep them in
1423
+ * sync. Pure data, no methods.
1424
+ */
1425
+ export interface DocRange {
1426
+ /** Start position in the document. */
1427
+ from: number;
1428
+ /** End position in the document. */
1429
+ to: number;
1430
+ }
1431
+ /**
1432
+ * One match returned by `SuperDoc.search()` (and consumed by
1433
+ * `SuperDoc.goToSearchResult()`).
1434
+ *
1435
+ * SD-2828: Promoted from the private search-extension typedef to a
1436
+ * public contract so consumers get real types instead of `any` on the
1437
+ * search return value, and so `goToSearchResult` can declare the input
1438
+ * shape it expects rather than accepting an opaque `Object`. Match
1439
+ * instances are produced by the runtime; consumers should treat them as
1440
+ * read-only and pass them back unchanged.
1441
+ */
1442
+ export interface SearchMatch {
1443
+ /** Combined match text across all ranges. */
1444
+ text: string;
1445
+ /** Start position of the first range. */
1446
+ from: number;
1447
+ /** End position of the last range. */
1448
+ to: number;
1449
+ /**
1450
+ * Stable match identifier. For single-range matches this is the
1451
+ * position-tracker id; for multi-range (cross-paragraph) matches it is
1452
+ * the first tracker id. Use as the dedupe / equality key when wiring a
1453
+ * custom navigator.
1454
+ */
1455
+ id: string;
1456
+ /**
1457
+ * Document ranges for the match. Present for multi-range matches
1458
+ * (cross-paragraph), and may also be populated for single-range
1459
+ * matches by the search runtime; consumers should not assume length 1.
1460
+ */
1461
+ ranges?: DocRange[];
1462
+ /** Position-tracker ids, one per range in `ranges`. */
1463
+ trackerIds?: string[];
1464
+ }
1465
+ /**
1466
+ * Handle object injected into find/replace UIs as the `findReplace`
1467
+ * prop/context field. Provides reactive search state and all action functions.
1468
+ */
1469
+ export interface FindReplaceHandle {
1470
+ /** Current search query. */
1471
+ findQuery: Ref<string>;
1472
+ /** Current replacement text. */
1473
+ replaceText: Ref<string>;
1474
+ /** Case-sensitive toggle. */
1475
+ caseSensitive: Ref<boolean>;
1476
+ /** Ignore diacritics toggle. */
1477
+ ignoreDiacritics: Ref<boolean>;
1478
+ /** Whether replace row is expanded. */
1479
+ showReplace: Ref<boolean>;
1480
+ /** Total match count (read-only by convention). */
1481
+ matchCount: Ref<number>;
1482
+ /** Active match index, -1 when none (read-only by convention). */
1483
+ activeMatchIndex: Ref<number>;
1484
+ /** Formatted match label e.g. "3 of 12" or "No results". */
1485
+ matchLabel: ComputedRef<string>;
1486
+ /** Whether there are any matches. */
1487
+ hasMatches: ComputedRef<boolean>;
1488
+ /**
1489
+ * Whether the replace controls should be enabled right now: there are
1490
+ * matches, no replace is in flight, and the active session permits mutation
1491
+ * (V2 read-only/viewing mode disables replace; V1 stays enabled).
1492
+ */
1493
+ canReplace: ComputedRef<boolean>;
1494
+ /** Whether a replace mutation is currently in flight (re-entrancy guard). */
1495
+ replacePending: Ref<boolean>;
1496
+ /**
1497
+ * Runtime mutability of the active session (false in viewing/read-only
1498
+ * mode). Surfaces hide replace controls on this; `canReplace` additionally
1499
+ * requires matches and gates the actions.
1500
+ */
1501
+ replaceCanMutate: Ref<boolean>;
1502
+ /**
1503
+ * Whether the active driver supports the ignore-diacritics toggle. V1
1504
+ * supports it; the V2 Document API query path does not, so the toggle is
1505
+ * hidden rather than shipped as a no-op.
1506
+ */
1507
+ ignoreDiacriticsSupported: Ref<boolean>;
1508
+ /**
1509
+ * Whether the active driver supports regex search. The V2 (`ui.search`)
1510
+ * driver supports it; V1 hides the toggle.
1511
+ */
1512
+ regexSupported: Ref<boolean>;
1513
+ /** Whether the current query is treated as a regular expression. */
1514
+ regex: Ref<boolean>;
1515
+ /** Inline error label when the regex pattern is invalid/unsafe, else null. */
1516
+ searchError: Ref<string | null>;
1517
+ /** Whether replace actions are available (false for find-only mode). */
1518
+ replaceEnabled: boolean;
1519
+ /** All text strings resolved with defaults. */
1520
+ texts: ResolvedFindReplaceTexts;
1521
+ /** Navigate to the next match. */
1522
+ goNext: () => void;
1523
+ /** Navigate to the previous match. */
1524
+ goPrev: () => void;
1525
+ /** Replace the active match. */
1526
+ replaceCurrent: () => void;
1527
+ /** Replace all matches. */
1528
+ replaceAll: () => void;
1529
+ /** Register a function the composable calls to refocus the find input. */
1530
+ registerFocusFn: (fn: () => void) => void;
1531
+ /** Close the find/replace surface. */
1532
+ close: (reason?: unknown) => void;
1533
+ }
1534
+ /**
1535
+ * Read-only context passed to a find/replace resolver to decide how to
1536
+ * render. Does NOT include action functions — the resolver decides, it does
1537
+ * not act.
1538
+ */
1539
+ export interface FindReplaceContext {
1540
+ /** Resolved text strings. */
1541
+ texts: ResolvedFindReplaceTexts;
1542
+ /** Whether replace is available. */
1543
+ replaceEnabled: boolean;
1544
+ }
1545
+ /**
1546
+ * Context passed to an external (framework-agnostic) find/replace renderer.
1547
+ * Vue refs are unwrapped as getter/setter properties for framework neutrality.
1548
+ */
1549
+ export interface FindReplaceRenderContext {
1550
+ /** Empty DOM container to render into. */
1551
+ container: HTMLElement;
1552
+ /** The find/replace handle with getters/setters instead of Vue refs. */
1553
+ findReplace: object;
1554
+ /** Resolves the surface with `{ status: 'submitted', data }`. */
1555
+ resolve: (data?: unknown) => void;
1556
+ /** Resolves the surface with `{ status: 'closed', reason }`. */
1557
+ close: (reason?: unknown) => void;
1558
+ /** The surface id. */
1559
+ surfaceId: string;
1560
+ /** Presentation mode. */
1561
+ mode: SurfaceMode;
1562
+ }
1563
+ /** Resolution returned by a find/replace resolver. */
1564
+ export type FindReplaceResolution = {
1565
+ type: 'default';
1566
+ } | {
1567
+ type: 'none';
1568
+ } | {
1569
+ type: 'custom';
1570
+ component: unknown;
1571
+ props?: Record<string, unknown>;
1572
+ } | {
1573
+ type: 'external';
1574
+ render: (ctx: FindReplaceRenderContext) => {
1575
+ destroy?: () => void;
1576
+ } | void;
1577
+ };
1578
+ /** Configuration for the find/replace surface. */
1579
+ export interface FindReplaceConfig {
1580
+ /** Override find placeholder text. */
1581
+ findPlaceholder?: string;
1582
+ /** Override find input aria-label. */
1583
+ findAriaLabel?: string;
1584
+ /** Override replace placeholder text. */
1585
+ replacePlaceholder?: string;
1586
+ /** Override replace input aria-label. */
1587
+ replaceAriaLabel?: string;
1588
+ /** Override "No results" text. */
1589
+ noResultsLabel?: string;
1590
+ /** Override previous match button title. */
1591
+ previousMatchLabel?: string;
1592
+ /** Override previous match aria-label. */
1593
+ previousMatchAriaLabel?: string;
1594
+ /** Override next match button title. */
1595
+ nextMatchLabel?: string;
1596
+ /** Override next match aria-label. */
1597
+ nextMatchAriaLabel?: string;
1598
+ /** Override close button title. */
1599
+ closeLabel?: string;
1600
+ /** Override close button aria-label. */
1601
+ closeAriaLabel?: string;
1602
+ /** Override replace button text. */
1603
+ replaceLabel?: string;
1604
+ /** Override replace-all button text. */
1605
+ replaceAllLabel?: string;
1606
+ /** Override toggle replace button title. */
1607
+ toggleReplaceLabel?: string;
1608
+ /** Override toggle replace aria-label. */
1609
+ toggleReplaceAriaLabel?: string;
1610
+ /** Override match case toggle text. */
1611
+ matchCaseLabel?: string;
1612
+ /** Override match case aria-label. */
1613
+ matchCaseAriaLabel?: string;
1614
+ /** Override ignore diacritics toggle text. */
1615
+ ignoreDiacriticsLabel?: string;
1616
+ /** Override ignore diacritics aria-label. */
1617
+ ignoreDiacriticsAriaLabel?: string;
1618
+ /** Override regex toggle text. */
1619
+ regexLabel?: string;
1620
+ /** Override regex toggle aria-label. */
1621
+ regexAriaLabel?: string;
1622
+ /** Override the inline invalid-pattern error text. */
1623
+ invalidPatternLabel?: string;
1624
+ /** Whether replace is available (default: true). */
1625
+ replaceEnabled?: boolean;
1626
+ /** When true, search includes text from pending tracked deletions. Defaults to false. */
1627
+ includeDeletedText?: boolean;
1628
+ /** Vue component to render as custom find/replace content. Mutually exclusive with `render`. */
1629
+ component?: unknown;
1630
+ /** Extra props passed to the custom Vue component. */
1631
+ props?: Record<string, unknown>;
1632
+ /** External (framework-agnostic) renderer. Mutually exclusive with `component`. */
1633
+ render?: (ctx: FindReplaceRenderContext) => {
1634
+ destroy?: () => void;
1635
+ } | void;
1636
+ /** Conditional resolver. Can coexist with `component`/`render`. */
1637
+ resolver?: (ctx: FindReplaceContext) => FindReplaceResolution | null | undefined;
1638
+ /**
1639
+ * Where the floating find/replace bar is pinned, so it can be moved clear of
1640
+ * the document. `placement` is a corner/edge preset; explicit insets
1641
+ * (`top`/`right`/`bottom`/`left`, a px number or CSS length) override it.
1642
+ * Defaults to `{ placement: 'top-right' }`.
1643
+ */
1644
+ floating?: {
1645
+ placement?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
1646
+ top?: number | string;
1647
+ right?: number | string;
1648
+ bottom?: number | string;
1649
+ left?: number | string;
1650
+ width?: number | string;
1651
+ maxWidth?: number | string;
1652
+ maxHeight?: number | string;
1653
+ };
1654
+ }
1655
+ /**
1656
+ * Payload passed to a permission resolver callback. SuperDoc invokes
1657
+ * the resolver when a consumer registers one via
1658
+ * `Config.permissionResolver` or `Modules.comments.permissionResolver`,
1659
+ * forwarding the in-flight check so the resolver can decide whether
1660
+ * to override the built-in policy.
1661
+ *
1662
+ * Returning `boolean` from the resolver overrides the default;
1663
+ * returning `undefined` (or any non-boolean) falls through to
1664
+ * `defaultDecision`, which the resolver receives so it can mirror or
1665
+ * branch off the built-in policy without re-deriving it.
1666
+ *
1667
+ * `comment` and `trackedChange` are typed as `object | null` because
1668
+ * consumer comment / tracked-change shapes vary; resolvers that read
1669
+ * fields on those payloads should narrow before use.
1670
+ *
1671
+ * Distinct from `CanPerformPermissionParams`, which is the input
1672
+ * shape consumers pass _to_ `SuperDoc#canPerformPermission`. That
1673
+ * input becomes part of this resolver payload after SuperDoc resolves
1674
+ * `currentUser`, `superdoc`, and `defaultDecision`.
1675
+ */
1676
+ export interface PermissionResolverParams {
1677
+ /** The permission key being checked (e.g. `'comment.create'`). */
1678
+ permission: string;
1679
+ /**
1680
+ * The effective role (consumer-supplied or falling back to
1681
+ * `Config.role`). The key is always present on the payload; the
1682
+ * value is `undefined` when `Config.role` was never set.
1683
+ */
1684
+ role: string | undefined;
1685
+ /**
1686
+ * The effective internal/external flag (consumer-supplied or
1687
+ * `Config.isInternal`). The key is always present; the value is
1688
+ * `undefined` when `Config.isInternal` was never set.
1689
+ */
1690
+ isInternal: boolean | undefined;
1691
+ /**
1692
+ * What the built-in policy would return if the resolver does not
1693
+ * override. Resolvers can return this value to defer to the
1694
+ * default, or branch off it.
1695
+ */
1696
+ defaultDecision: boolean;
1697
+ /** The comment object being acted on, if any. Shape is consumer-defined. */
1698
+ comment: object | null;
1699
+ /** The tracked-change payload (as emitted by the editor) being acted on, if any. */
1700
+ trackedChange: object | null;
1701
+ /** The active user performing the action; resolved from `Config.user`. */
1702
+ currentUser: User | null;
1703
+ /** The SuperDoc instance the check ran against. */
1704
+ superdoc: SuperDoc | null;
1705
+ }
1706
+ /**
1707
+ * Input shape for `SuperDoc#canPerformPermission`. All fields are
1708
+ * optional; an empty payload short-circuits to `false`. `role` and
1709
+ * `isInternal` fall back to `Config.role` / `Config.isInternal` when
1710
+ * omitted. `comment` and `trackedChange` carry open index signatures
1711
+ * because the runtime forwards the full payload to the resolver
1712
+ * context, and consumer comment / tracked-change shapes vary; the
1713
+ * named fields below are the ones the method itself reads. Distinct
1714
+ * from `PermissionResolverParams`, which is the exported resolver
1715
+ * callback payload SuperDoc passes to configured permission resolvers
1716
+ * (with resolved `currentUser`, `superdoc`, and `defaultDecision`
1717
+ * context attached).
1718
+ */
1719
+ export interface CanPerformPermissionParams {
1720
+ /** The permission key to check (e.g. `'comment.create'`). Required at runtime; omitting returns `false`. */
1721
+ permission?: string;
1722
+ /** Override `Config.role` for this check. */
1723
+ role?: string;
1724
+ /** Override `Config.isInternal` for this check. */
1725
+ isInternal?: boolean;
1726
+ /** The comment object being acted on, if any. */
1727
+ comment?: (object & Record<string, unknown>) | null;
1728
+ /** The tracked-change payload (as emitted by the editor) being acted on, if any. */
1729
+ trackedChange?: ({
1730
+ id?: string;
1731
+ commentId?: string;
1732
+ comment?: unknown;
1733
+ } & Record<string, unknown>) | null;
1734
+ }
1735
+ /** Modules registered with the SuperDoc instance. */
1736
+ export interface Modules {
1737
+ /** Content controls module configuration. */
1738
+ contentControls?: {
1739
+ /** Built-in SDT chrome rendering mode. */
1740
+ chrome?: 'default' | 'none';
1741
+ };
1742
+ /**
1743
+ * Comments module configuration (false to disable). The named fields below
1744
+ * are typed for IDE help; the runtime spreads the entire object through the
1745
+ * comments store and accepts additional keys (`useInternalExternalComments`,
1746
+ * `suppressInternalExternalComments`, etc.), so the type intersects with an
1747
+ * open index signature to keep pass-through configs compiling.
1748
+ */
1749
+ comments?: false | ({
1750
+ /** Custom permission resolver for comment actions. */
1751
+ permissionResolver?: (params: PermissionResolverParams) => boolean | undefined;
1752
+ /** Hide and reject every comment and tracked-change mutation affordance. */
1753
+ readOnly?: boolean;
1754
+ /** Show ordinary comment resolve/reopen actions when writable (default: true). */
1755
+ allowResolve?: boolean;
1756
+ /** Comment highlight colors (internal/external and active overrides). */
1757
+ highlightColors?: {
1758
+ /** Base highlight color for internal comments. */
1759
+ internal?: string;
1760
+ /** Base highlight color for external comments. */
1761
+ external?: string;
1762
+ /** Active highlight color override for internal comments. */
1763
+ activeInternal?: string;
1764
+ /** Active highlight color override for external comments. */
1765
+ activeExternal?: string;
1766
+ };
1767
+ /** Comment highlight opacity values (0-1). */
1768
+ highlightOpacity?: {
1769
+ /** Opacity for active comment highlight. */
1770
+ active?: number;
1771
+ /** Opacity for inactive comment highlight. */
1772
+ inactive?: number;
1773
+ };
1774
+ /** Hover highlight color for comment marks. */
1775
+ highlightHoverColor?: string;
1776
+ /** Track change highlight colors. */
1777
+ trackChangeHighlightColors?: {
1778
+ /** Border color for inserted text highlight. */
1779
+ insertBorder?: string;
1780
+ /** Background color for inserted text highlight. */
1781
+ insertBackground?: string;
1782
+ /** Border color for deleted text highlight. */
1783
+ deleteBorder?: string;
1784
+ /** Background color for deleted text highlight. */
1785
+ deleteBackground?: string;
1786
+ /** Border color for format change highlight. */
1787
+ formatBorder?: string;
1788
+ };
1789
+ /** Active track change highlight colors (defaults to trackChangeHighlightColors). */
1790
+ trackChangeActiveHighlightColors?: {
1791
+ /** Active border color for inserted text highlight. */
1792
+ insertBorder?: string;
1793
+ /** Active background color for inserted text highlight. */
1794
+ insertBackground?: string;
1795
+ /** Active border color for deleted text highlight. */
1796
+ deleteBorder?: string;
1797
+ /** Active background color for deleted text highlight. */
1798
+ deleteBackground?: string;
1799
+ /** Active border color for format change highlight. */
1800
+ formatBorder?: string;
1801
+ };
1802
+ /** Comments/track-changes UI display policy for responsive comment surfaces. */
1803
+ displayMode?: 'auto' | 'sidebar' | 'inline';
1804
+ /** CSS selector for an explicit width measurement target in auto mode. */
1805
+ compactMeasurementSelector?: string;
1806
+ /** Optional fixed compact-mode breakpoint override in pixels. */
1807
+ compactBreakpointPx?: number;
1808
+ } & Record<string, unknown>);
1809
+ /** AI module configuration. */
1810
+ ai?: {
1811
+ /** Harbour API key for AI features. */
1812
+ apiKey?: string;
1813
+ /** Custom endpoint URL for AI services. */
1814
+ endpoint?: string;
1815
+ } & Record<string, unknown>;
1816
+ /** PDF module configuration. */
1817
+ pdf?: {
1818
+ /** Preloaded pdf.js library instance. */
1819
+ pdfLib: object;
1820
+ /** PDF.js worker source URL (falls back to CDN when omitted). */
1821
+ workerSrc?: string;
1822
+ /** Whether to auto-configure pdf.js worker. */
1823
+ setWorker?: boolean;
1824
+ /** Enable text layer rendering (default: false). */
1825
+ textLayer?: boolean;
1826
+ /** Canvas render scale (quality). */
1827
+ outputScale?: number;
1828
+ } & Record<string, unknown>;
1829
+ /** Collaboration module configuration. */
1830
+ collaboration?: CollaborationConfig;
1831
+ /**
1832
+ * Toolbar module configuration. Pass `true` to configure the toolbar with
1833
+ * defaults (equivalent to an empty object).
1834
+ *
1835
+ * This field configures the toolbar's contents and behavior; it does not by
1836
+ * itself provide a place to render it. A toolbar is only rendered once a
1837
+ * mount target resolves, from either `selector` here or the top-level
1838
+ * `Config.toolbar`. Without one, SuperDoc still creates the
1839
+ * `superdoc.toolbar` handle (item lookup and command routing keep working)
1840
+ * but renders no toolbar UI.
1841
+ *
1842
+ * Fallbacks to the top-level aliases are per field: `selector` falls back to
1843
+ * `Config.toolbar`, `icons` to `Config.toolbarIcons`, and `texts` to
1844
+ * `Config.toolbarTexts`. `Config.toolbarGroups` supplies the group ordering,
1845
+ * not `groups`: the two are different settings. `groups` maps group ids to
1846
+ * item ids (composition) and has no top-level alias, so omitting it uses the
1847
+ * built-in composition. Supplying it also replaces the group ordering with
1848
+ * its own keys.
1849
+ */
1850
+ toolbar?: boolean | ({
1851
+ /**
1852
+ * Selector for the DOM element to render the toolbar into: an id
1853
+ * selector (`#toolbar`), a class selector (`.toolbar`), or a bare
1854
+ * element id (`toolbar`). Must be a string, not an `HTMLElement`
1855
+ * reference — pass an element through the top-level `Config.toolbar`.
1856
+ * Falls back to `Config.toolbar` if omitted.
1857
+ */
1858
+ selector?: string;
1859
+ /** Toolbar item ids to hide from the default set. */
1860
+ excludeItems?: string[];
1861
+ /**
1862
+ * Object map of group id to item ids
1863
+ * (`{ left: [...], center: [...], right: [...] }`) that overrides the
1864
+ * default group composition. Default group ids are
1865
+ * `'left' | 'center' | 'right'`. To pass an ordered group-id array
1866
+ * (`['left', 'center', 'right']`) use the top-level `Config.toolbarGroups`
1867
+ * instead — the array form is not accepted here.
1868
+ */
1869
+ groups?: Record<string, string[]>;
1870
+ /** Icon overrides keyed by toolbar item id. Falls back to `Config.toolbarIcons`. */
1871
+ icons?: Record<string, unknown>;
1872
+ /** Text/label overrides keyed by toolbar item id. Falls back to `Config.toolbarTexts`. */
1873
+ texts?: Record<string, string>;
1874
+ /**
1875
+ * Custom font list rendered in the font-family dropdown.
1876
+ *
1877
+ * AIDEV-NOTE: legacy-public - accepts {@link FontFamilyConfig} entries
1878
+ * alongside dropdown rows. This spelling was typed `FontConfig[]`,
1879
+ * whose index signature let `{ family, label, key }` compile and work,
1880
+ * so narrowing it to rows alone would break installs mid-2.x.
1881
+ * Replaced by `ui.toolbar.fonts`, which takes rows only.
1882
+ * Earliest removal: v3.0 (#853).
1883
+ *
1884
+ * The runtime uses the list verbatim and reads `label` and `key` off
1885
+ * each entry, so a `family`-only entry renders a blank row either way.
1886
+ */
1887
+ fonts?: Array<FontConfig | ToolbarFontOption>;
1888
+ /** Hide buttons that overflow the available width (default: true). */
1889
+ hideButtons?: boolean;
1890
+ /** Recompute the visible toolbar item set on container resize (default: false). */
1891
+ responsiveToContainer?: boolean;
1892
+ /**
1893
+ * Custom toolbar buttons appended to the default item set.
1894
+ *
1895
+ * AIDEV-NOTE: legacy-public - stays an open record. This spelling was
1896
+ * typed `Array<Record<string, unknown>>`, so narrowing it now would
1897
+ * reject entries that compile and work today. Replaced by
1898
+ * `ui.toolbar.customButtons`. Earliest removal: v3.0 (#853).
1899
+ */
1900
+ customButtons?: Array<Record<string, unknown>>;
1901
+ /**
1902
+ * Show the formatting marks (pilcrow) button in the toolbar. Off by
1903
+ * default. Distinct from `layoutEngineOptions.showFormattingMarks`, which
1904
+ * controls whether the marks render in the document.
1905
+ */
1906
+ showFormattingMarksButton?: boolean;
1907
+ /**
1908
+ * Show the table of contents insert button in the toolbar. Off by default.
1909
+ */
1910
+ showTableOfContentsButton?: boolean;
1911
+ } & Record<string, unknown>);
1912
+ /** Link click popover configuration. */
1913
+ links?: {
1914
+ /** Custom resolver for the link click popover. */
1915
+ popoverResolver?: LinkPopoverResolver;
1916
+ } & Record<string, unknown>;
1917
+ /** Context menu module configuration. */
1918
+ contextMenu?: ContextMenuConfig;
1919
+ /** Deprecated. Use `contextMenu` instead. */
1920
+ slashMenu?: object;
1921
+ /** Surface system configuration. */
1922
+ surfaces?: SurfacesModuleConfig;
1923
+ /** Track changes module configuration. */
1924
+ trackChanges?: TrackChangesModuleConfig;
1925
+ /**
1926
+ * Whiteboard module configuration. Pass `false` to disable the module
1927
+ * entirely; pass an object to opt in (with `enabled: true`) or to keep it
1928
+ * registered but inert (`enabled: false`, the default when no field is set).
1929
+ */
1930
+ whiteboard?: false | {
1931
+ enabled?: boolean;
1932
+ };
1933
+ }
1934
+ /**
1935
+ * Canonical configuration for the track-changes module. Supersedes the
1936
+ * top-level `config.trackChanges` and `config.layoutEngineOptions.trackedChanges`
1937
+ * keys, which remain supported as deprecated aliases.
1938
+ */
1939
+ /**
1940
+ * Identity of a tracked-change author, passed to a per-author color
1941
+ * {@link TrackChangesAuthorColorsConfig.resolve | resolver}. Mirrors the
1942
+ * author metadata SuperDoc carries on each tracked change.
1943
+ */
1944
+ export interface TrackChangeAuthor {
1945
+ /** Author display name (from the OOXML `w:author` attribute). */
1946
+ name?: string;
1947
+ /** Author email, when available. */
1948
+ email?: string;
1949
+ /** Author avatar image URL, when available. */
1950
+ image?: string;
1951
+ }
1952
+ /**
1953
+ * Per-author tracked-change color configuration. Lets hosts assign a color
1954
+ * per author without injecting CSS `!important` rules against
1955
+ * `[data-track-change-author]` or reaching into private editor internals.
1956
+ *
1957
+ * Resolution order per author: `overrides` by identity (email first, then
1958
+ * name; exact match) → `resolve(author)` → a deterministic fallback color
1959
+ * derived from the author identity. The fallback guarantees imported /
1960
+ * discovered authors the host did not configure ahead of time still receive
1961
+ * a stable, distinct color.
1962
+ */
1963
+ export interface TrackChangesAuthorColorsConfig {
1964
+ /** When `false`, per-author colors are not applied. Defaults to enabled. */
1965
+ enabled?: boolean;
1966
+ /**
1967
+ * Color overrides keyed by author identity. Both `email` and `name` keys
1968
+ * are supported (email is checked first); matching is exact.
1969
+ */
1970
+ overrides?: Record<string, string>;
1971
+ /**
1972
+ * Resolver consulted after `overrides`. Return a CSS color string, or
1973
+ * `undefined` to fall through to the deterministic fallback.
1974
+ */
1975
+ resolve?: (author: TrackChangeAuthor) => string | undefined;
1976
+ }
1977
+ /**
1978
+ * Semantic tracked-change color categories configurable through
1979
+ * {@link TrackChangesSemanticColorsConfig}. These color review roles: inserted
1980
+ * text, deleted text, moved-from/-to text, table cell insertion/deletion, cell
1981
+ * merge, and cell split, not authors. The same author can therefore receive
1982
+ * different colors for different review roles, which the author-identity path
1983
+ * cannot express.
1984
+ *
1985
+ * Whole-table, table-row, and table-split changes are NOT part of this config
1986
+ * surface: their paint colors are themed via the
1987
+ * `--sd-tracked-changes-table-*` CSS variables instead.
1988
+ *
1989
+ * Declared locally (mirroring the {@link TrackChangeAuthor} pattern) so the
1990
+ * published `superdoc` type graph never depends on the private
1991
+ * `@superdoc/contracts` specifier. Mirrors the
1992
+ * `TrackedChangeConfigurableSemanticColorKey` union in `@superdoc/contracts`.
1993
+ */
1994
+ export type TrackedChangeSemanticColorKey = 'insertion' | 'deletion' | 'move' | 'move-from' | 'move-to' | 'table-cell-insertion' | 'table-cell-deletion' | 'cell-merge' | 'cell-split';
1995
+ /**
1996
+ * Input passed to a semantic tracked-change color
1997
+ * {@link TrackChangesSemanticColorsConfig.resolve | resolver} for a single
1998
+ * review role. `key` is always present; the remaining fields describe the
1999
+ * change being colored when SuperDoc knows them.
2000
+ */
2001
+ export interface TrackedChangeSemanticColorResolverInput {
2002
+ /** Semantic category being colored. */
2003
+ key: TrackedChangeSemanticColorKey;
2004
+ /** Author identity, when known. Semantic colors are not author-derived. */
2005
+ author?: TrackChangeAuthor;
2006
+ /** Raw tracked-change type, when known. */
2007
+ type?: string;
2008
+ /** Logical subtype, when known. */
2009
+ subtype?: string;
2010
+ /** Target kind (e.g. text/cell/row/table), when known. */
2011
+ targetKind?: string;
2012
+ /** Scope of the semantic paint anchor, when known. */
2013
+ semanticAnchorScope?: string;
2014
+ }
2015
+ /**
2016
+ * Semantic tracked-change color configuration. The second
2017
+ * tracked-change color axis alongside {@link TrackChangesAuthorColorsConfig}:
2018
+ * `authorColors` colors by author identity, `semanticColors` colors review
2019
+ * roles (inserted text, deleted text, moved text, table cell
2020
+ * insertion/deletion, cell merge, cell split).
2021
+ *
2022
+ * Supported semantic colors are active by default. Word-like defaults apply with
2023
+ * no configuration: insertion blue, deletion red, and moved text green.
2024
+ * Resolution order per key: `overrides` by semantic key, `overrides.move` for
2025
+ * `move-from` / `move-to`, then `resolve(input)`, then the built-in default for
2026
+ * that key. Set `enabled: false` to suppress semantic colors and fall back to
2027
+ * existing author/broad defaults.
2028
+ *
2029
+ * Whole-table, table-row, and table-split paint colors are themed through the
2030
+ * `--sd-tracked-changes-table-*` CSS variables, not this config.
2031
+ *
2032
+ * This is separate from `modules.comments.trackChangeHighlightColors`, the
2033
+ * older broad insert/delete/format CSS-variable surface.
2034
+ */
2035
+ export interface TrackChangesSemanticColorsConfig {
2036
+ /** When `false`, semantic colors are not applied. Defaults to enabled. */
2037
+ enabled?: boolean;
2038
+ /**
2039
+ * Color overrides keyed by semantic category (`'insertion'`, `'deletion'`,
2040
+ * `'move'`, `'move-from'`, `'move-to'`, `'table-cell-insertion'`,
2041
+ * `'table-cell-deletion'`, `'cell-merge'`, `'cell-split'`). `move` applies
2042
+ * to both move sides unless a side-specific override exists.
2043
+ */
2044
+ overrides?: Partial<Record<TrackedChangeSemanticColorKey, string>>;
2045
+ /**
2046
+ * Resolver consulted after `overrides`. Return a CSS color string, or
2047
+ * `undefined` to fall through to the built-in default for the key.
2048
+ */
2049
+ resolve?: (input: TrackedChangeSemanticColorResolverInput) => string | undefined;
2050
+ }
2051
+ export interface TrackChangesModuleConfig {
2052
+ /** Whether tracked-change indicators are shown in viewing mode. */
2053
+ visible?: boolean;
2054
+ /**
2055
+ * Rendering mode for tracked changes (see `TrackedChangesMode` in
2056
+ * `@superdoc/contracts`).
2057
+ * - 'review': show insertions and deletions inline (default for editing/suggesting)
2058
+ * - 'original': show the document as it existed before tracked changes (default for viewing when `visible` is false)
2059
+ * - 'final': show the document with changes applied
2060
+ * - 'off': disable tracked-change rendering
2061
+ */
2062
+ mode?: 'review' | 'original' | 'final' | 'off';
2063
+ /** Whether the layout engine treats tracked changes as active. */
2064
+ enabled?: boolean;
2065
+ /**
2066
+ * How a tracked replacement (adjacent insertion + deletion created by typing
2067
+ * over selected text) surfaces in the UI and API.
2068
+ * - `'paired'` (default, Google Docs model): the two halves share one id
2069
+ * and resolve together with a single accept/reject click.
2070
+ * - `'independent'` (Microsoft Word / ECMA-376 §17.13.5 model): each
2071
+ * insertion and each deletion has its own id, is addressable on its own,
2072
+ * and resolves independently.
2073
+ */
2074
+ replacements?: 'paired' | 'independent';
2075
+ /**
2076
+ * Per-author tracked-change colors. When configured, insert/delete/format
2077
+ * tracked-change highlights are tinted per author through the
2078
+ * `--sd-tracked-changes-*` CSS variable surface, and
2079
+ * `ui.trackChanges.getSnapshot()` exposes the resolved author colors.
2080
+ */
2081
+ authorColors?: TrackChangesAuthorColorsConfig;
2082
+ /**
2083
+ * Semantic (structural) tracked-change colors. Colors structural change
2084
+ * subtypes: moved text, table cell insertion/deletion, cell merge, and cell
2085
+ * split, independently of {@link authorColors}. Supported keys are active by
2086
+ * default; set `enabled: false` to fall back to existing author/broad
2087
+ * defaults. Separate from `modules.comments.trackChangeHighlightColors`.
2088
+ */
2089
+ semanticColors?: TrackChangesSemanticColorsConfig;
2090
+ }
2091
+ export type DocumentMode = 'editing' | 'viewing' | 'suggesting';
2092
+ export type ExportType = 'docx' | 'pdf' | 'html';
2093
+ /**
2094
+ * - 'external': Include only external comments (default)
2095
+ * - 'clean': Export without any comments
2096
+ */
2097
+ export type CommentsType = 'external' | 'clean';
2098
+ /**
2099
+ * Document view layout values — mirrors OOXML ST_View (ECMA-376 §17.18.102).
2100
+ * - 'print': Print Layout View — displays document as it prints (default)
2101
+ * - 'web': Web Page View — content reflows to fit container (mobile/accessibility)
2102
+ */
2103
+ export type ViewLayout = 'print' | 'web';
2104
+ /**
2105
+ * Document view options for controlling how the document is displayed.
2106
+ * Mirrors OOXML document view settings.
2107
+ */
2108
+ export interface ViewOptions {
2109
+ /** Document view layout (OOXML ST_View compatible). */
2110
+ layout?: ViewLayout;
2111
+ }
2112
+ export interface ExportParams {
2113
+ /** File formats to export. */
2114
+ exportType?: ExportType[];
2115
+ /** How to handle comments. */
2116
+ commentsType?: CommentsType;
2117
+ /** Custom filename (without extension). */
2118
+ exportedName?: string;
2119
+ /** Extra files to include in the export zip. */
2120
+ additionalFiles?: globalThis.Blob[];
2121
+ /** Filenames for the additional files. */
2122
+ additionalFileNames?: string[];
2123
+ /** Whether this is a final document export. */
2124
+ isFinalDoc?: boolean;
2125
+ /** Auto-download or return blob. */
2126
+ triggerDownload?: boolean;
2127
+ /**
2128
+ * Color for field highlights. The runtime defaults to `null` when no
2129
+ * value is supplied (and forwards `null` through to the underlying
2130
+ * editor export, which accepts `string | null`); the typedef accepts
2131
+ * `null` explicitly so consumers can pass an explicit "no highlight"
2132
+ * value without a typecheck failure.
2133
+ */
2134
+ fieldsHighlightColor?: string | null;
2135
+ }
2136
+ /** Surface where the edit originated. */
2137
+ export type EditorSurface = 'body' | 'header' | 'footer';
2138
+ export interface EditorUpdateEvent {
2139
+ /**
2140
+ * The primary editor associated with the update. For header/footer
2141
+ * edits, this is the main body editor. Optional because the runtime
2142
+ * payload builder falls back to `sourceEditor` and emits `undefined`
2143
+ * when neither is present (defensive in test/stub paths); consumers
2144
+ * should narrow before use.
2145
+ */
2146
+ editor?: Editor;
2147
+ /** The editor instance that emitted the update. For body edits, this matches `editor`. */
2148
+ sourceEditor?: Editor;
2149
+ /** The surface where the edit originated. */
2150
+ surface: EditorSurface;
2151
+ /**
2152
+ * Relationship ID for header/footer edits. Always present (the
2153
+ * runtime payload builder defaults to `null`); may be `null` for
2154
+ * body edits.
2155
+ */
2156
+ headerId: string | null;
2157
+ /**
2158
+ * Header/footer variant (`default`, `first`, `even`, `odd`) when
2159
+ * available. Always present (defaults to `null`); may be `null`.
2160
+ */
2161
+ sectionType: string | null;
2162
+ }
2163
+ /**
2164
+ * Payload emitted with the `ready` event and passed to `Config.onReady`.
2165
+ * Carries the live SuperDoc instance.
2166
+ */
2167
+ export interface SuperDocReadyPayload {
2168
+ superdoc: SuperDoc;
2169
+ }
2170
+ /**
2171
+ * Payload emitted with the `editorCreate` / `editorBeforeCreate` /
2172
+ * `collaboration-ready` events and passed to the matching `Config.onX`
2173
+ * callbacks. The runtime always wraps the editor in this shape; bare
2174
+ * `Editor` references in earlier callback typings were incorrect.
2175
+ */
2176
+ export interface SuperDocEditorPayload {
2177
+ editor: Editor;
2178
+ }
2179
+ /**
2180
+ * Payload emitted with `document-replaced`.
2181
+ *
2182
+ * `editor` is the editor whose replacement completed, not necessarily the one
2183
+ * active when the event is received: a replace is asynchronous, so the active
2184
+ * editor can move while it is in flight. A consumer must compare this against
2185
+ * the editor it is bound to and ignore anything else.
2186
+ *
2187
+ * Typed `unknown` rather than `Editor`: the active editor can be a v2 facade
2188
+ * that does not satisfy `Editor` (`getHTML` is required there and absent on the
2189
+ * facade), so annotating it as `Editor` would promise methods that are not
2190
+ * present. It is an identity token to compare, not an object to call.
2191
+ */
2192
+ export interface SuperDocDocumentReplacedPayload {
2193
+ editor: unknown;
2194
+ /**
2195
+ * The host that rendered the replaced document.
2196
+ *
2197
+ * Carried because `editor` alone cannot be matched in the V2 browser path: a
2198
+ * successful replace emits its ready payload before `replaceFile()` resolves,
2199
+ * so the shell has already installed a NEW facade by the time this event
2200
+ * fires, and the captured facade is one the controller no longer holds. The
2201
+ * host survives that swap, so it is the identity that still lines up.
2202
+ */
2203
+ host: unknown;
2204
+ }
2205
+ /**
2206
+ * Payload emitted with the `locked` event and passed to
2207
+ * `Config.onLocked`. `lockedBy` is non-optional because the runtime
2208
+ * always includes the key (`lockSuperdoc` defaults `lockedBy` to
2209
+ * `null`); the value may be `User | null` because unlocking and
2210
+ * unattributed locks both pass `null`.
2211
+ */
2212
+ export interface SuperDocLockedPayload {
2213
+ isLocked: boolean;
2214
+ lockedBy: User | null;
2215
+ }
2216
+ /**
2217
+ * Payload emitted with the `awareness-update` event and passed to
2218
+ * `Config.onAwarenessUpdate`. Field set differs from older inline
2219
+ * declarations: the runtime emits `superdoc` (not `context`) and
2220
+ * includes `added` / `removed` client-id arrays alongside `states`.
2221
+ */
2222
+ export interface SuperDocAwarenessUpdatePayload {
2223
+ states: AwarenessState[];
2224
+ added: number[];
2225
+ removed: number[];
2226
+ superdoc: SuperDoc;
2227
+ }
2228
+ /**
2229
+ * Payload emitted with the `comments-update` event and passed to
2230
+ * `Config.onCommentsUpdate`. Field set differs from older inline
2231
+ * declarations: the runtime emits `comment?` and `changes?` (never a
2232
+ * `data` field).
2233
+ */
2234
+ export interface SuperDocCommentsUpdatePayload {
2235
+ /** Update kind (e.g. `'created'`, `'updated'`, `'deleted'`); set by the comments store. */
2236
+ type: string;
2237
+ /** The comment object the update refers to, when applicable. */
2238
+ comment?: Comment;
2239
+ /** Per-field change set when the update is a mutation. */
2240
+ changes?: Array<{
2241
+ key: string;
2242
+ commentId: string;
2243
+ fileId?: string | null;
2244
+ }>;
2245
+ /**
2246
+ * The Document API selection snapshot captured at the moment a
2247
+ * `'pending'` comment was started, before the pending mark is
2248
+ * inserted (which clears the live DOM selection). Present only on the
2249
+ * `'pending'` event. When it has a `target`, forward it straight to
2250
+ * `ui.comments.createFromCapture(pendingSelection, { text })` to build
2251
+ * the comment from a custom composer without tracking the selection
2252
+ * yourself ahead of the floating-bubble click.
2253
+ *
2254
+ * `null` means the pending comment did not start from an addressable
2255
+ * SuperDoc editor text selection, or the active editor/selection API was
2256
+ * unavailable. PDF and other non-SuperDoc editor selections emit `null`.
2257
+ * Empty SuperDoc editor selections can still yield a `SelectionInfo` with
2258
+ * `target: null`.
2259
+ */
2260
+ pendingSelection?: SelectionInfo | null;
2261
+ }
2262
+ export interface EditorTransactionLike {
2263
+ readonly docChanged?: boolean;
2264
+ readonly doc?: {
2265
+ readonly content?: {
2266
+ readonly size?: number;
2267
+ };
2268
+ nodesBetween?: (from: number, to: number, callback: (node: {
2269
+ readonly type?: {
2270
+ readonly name?: string;
2271
+ };
2272
+ readonly attrs?: Record<string, unknown>;
2273
+ readonly marks?: ReadonlyArray<{
2274
+ readonly type?: {
2275
+ readonly name?: string;
2276
+ };
2277
+ readonly attrs?: Record<string, unknown>;
2278
+ }>;
2279
+ }) => false | void | undefined) => void;
2280
+ };
2281
+ readonly mapping?: {
2282
+ readonly maps?: ReadonlyArray<{
2283
+ forEach(callback: (oldStart: number, oldEnd: number, newStart: number, newEnd: number) => void): void;
2284
+ }>;
2285
+ slice?(from: number): {
2286
+ map(position: number, assoc?: number): number;
2287
+ };
2288
+ };
2289
+ getMeta?(key: unknown): unknown;
2290
+ }
2291
+ export interface EditorTransactionEvent {
2292
+ /** The primary editor associated with the transaction. For header/footer edits, this is the main body editor. */
2293
+ editor: Editor;
2294
+ /** The editor instance that emitted the transaction. For body edits, this matches `editor`. */
2295
+ sourceEditor: Editor;
2296
+ /** The editor transaction emitted by the source editor. */
2297
+ transaction: EditorTransactionLike;
2298
+ /** Time spent applying the transaction, in milliseconds. */
2299
+ duration?: number;
2300
+ /** The surface where the transaction originated. */
2301
+ surface: EditorSurface;
2302
+ /** Relationship ID for header/footer edits. */
2303
+ headerId?: string | null;
2304
+ /** Header/footer variant (`default`, `first`, `even`, `odd`) when available. */
2305
+ sectionType?: string | null;
2306
+ }
2307
+ export interface SdtRef {
2308
+ id: string;
2309
+ tag?: string;
2310
+ alias?: string;
2311
+ controlType: string;
2312
+ scope: 'inline' | 'block';
2313
+ }
2314
+ export interface ContentControlActiveChangePayload {
2315
+ active: SdtRef | null;
2316
+ previous: SdtRef | null;
2317
+ /**
2318
+ * Active content-control stack for the new selection, innermost first
2319
+ * (matches `ui.contentControls` activeIds). `active` is `activePath[0]`.
2320
+ * Empty when the selection is not inside any control. Lets nested-aware
2321
+ * custom UI read the surrounding controls without combining with observe().
2322
+ */
2323
+ activePath: SdtRef[];
2324
+ source: 'keyboard' | 'pointer';
2325
+ }
2326
+ export interface ContentControlClickPayload {
2327
+ target: SdtRef;
2328
+ source: 'pointer';
2329
+ }
2330
+ export interface SuperDocLayoutEngineOptions {
2331
+ /**
2332
+ * Layout engine flow mode.
2333
+ * - 'paginated': standard page-first layout (default)
2334
+ * - 'semantic': continuous semantic flow without visible pagination boundaries
2335
+ */
2336
+ flowMode?: 'paginated' | 'semantic';
2337
+ /**
2338
+ * Deprecated. Use `modules.trackChanges` instead. Optional override for
2339
+ * paginated track-changes rendering (e.g., `{ mode: 'original' }` or
2340
+ * `{ enabled: false }`).
2341
+ */
2342
+ trackedChanges?: object;
2343
+ /**
2344
+ * Page virtualization options for paginated layout. Defaults to
2345
+ * `{ enabled: true, window: 5, overscan: 1 }` to render only the visible
2346
+ * window of pages plus a small overscan buffer.
2347
+ */
2348
+ virtualization?: {
2349
+ /** Whether virtualization is active (default: true). */
2350
+ enabled?: boolean;
2351
+ /** Number of pages kept rendered around the active page (default: 5). */
2352
+ window?: number;
2353
+ /** Extra pages rendered outside the active window for smoother scrolling (default: 1). */
2354
+ overscan?: number;
2355
+ };
2356
+ /**
2357
+ * Whether bookmark indicators are shown in the rendered layout. Toggleable
2358
+ * at runtime via `superdoc.setShowBookmarks()`.
2359
+ */
2360
+ showBookmarks?: boolean;
2361
+ /**
2362
+ * Whether nonprinting formatting marks are shown in the rendered layout.
2363
+ * Toggleable at runtime via `superdoc.setShowFormattingMarks()`.
2364
+ */
2365
+ showFormattingMarks?: boolean;
2366
+ /**
2367
+ * Whether the V2 mounted body paints progressively from an initial window.
2368
+ * Defaults to `true`.
2369
+ *
2370
+ * @experimental Diagnostic posture, not a supported product mode and not a
2371
+ * pipeline bypass: both settings route through the same canonical
2372
+ * render-pipeline engine. `true` (default) paints an initial window and
2373
+ * (the canonical initial-render and incremental engine
2374
+ * passes); `false` makes EVERY mounted repaint wait for complete source
2375
+ * coverage and materialize the full body before painting — not only the
2376
+ * first paint — via the exact-complete engine pass, which can be much
2377
+ * slower than progressive streaming on large documents. Failures fail
2378
+ * closed: the mount/repaint promise rejects with a named
2379
+ * `render.complete-before-first-paint-*` error and the host records a
2380
+ * render-readiness diagnostic. The render surface has no independent
2381
+ * first-paint timeout; callers and harnesses must provide their own.
2382
+ */
2383
+ /**
2384
+ * P6a: per-paint work-counter HUD (console table +
2385
+ * `data-v2-paint-hud-recent`) and the dark reuse-collapse tripwire for the
2386
+ * windowed paint owner (since P7, vertical-paginated flow's only paint
2387
+ * path — no flag needed).
2388
+ *
2389
+ * @experimental Dev/verification instrument.
2390
+ */
2391
+ paintHud?: boolean;
2392
+ }
2393
+ export interface ViewingVisibilityConfig {
2394
+ visible?: boolean;
2395
+ }
2396
+ export interface SuperDocTelemetryConfig {
2397
+ enabled: boolean;
2398
+ endpoint?: string;
2399
+ metadata?: Record<string, unknown>;
2400
+ licenseKey?: string;
2401
+ }
2402
+ /**
2403
+ * Exception payload raised by the SuperDoc store during document
2404
+ * initialization (empty entry, init failure, normalization error).
2405
+ * Always carries `stage: 'document-init'` and the offending document
2406
+ * config (`null`/`undefined` when the entry itself was empty).
2407
+ *
2408
+ * `error` is `unknown` because the catch path in `initializeDocuments`
2409
+ * forwards the raw caught value (`catch (e) { emitException({ error: e,
2410
+ * ... }) }`) and thrown values can be anything in JS. The other two
2411
+ * emit sites construct `new Error(...)`, but consumers must narrow
2412
+ * before reading `.message`.
2413
+ */
2414
+ export interface SuperDocExceptionStorePayload {
2415
+ error: unknown;
2416
+ stage: 'document-init';
2417
+ document: Document | null | undefined;
2418
+ }
2419
+ /**
2420
+ * Exception payload raised when restoring SuperDoc state from a
2421
+ * persisted source fails. Carries the document the runtime tried to
2422
+ * restore.
2423
+ */
2424
+ export interface SuperDocExceptionRestorePayload {
2425
+ error: unknown;
2426
+ document: Document;
2427
+ }
2428
+ /**
2429
+ * Exception payload raised by the underlying editor lifecycle (load,
2430
+ * encryption-prompt, command failures, etc.). `code` is set when the
2431
+ * editor maps the failure to a known kind (e.g. `'password-required'`).
2432
+ * `editor` is `Editor | null | undefined` because the password-prompt
2433
+ * re-emit path forwards `originalException?.editor ?? null`, so
2434
+ * consumers may receive `null` (not just `undefined`).
2435
+ */
2436
+ export interface SuperDocExceptionEditorPayload {
2437
+ error: unknown;
2438
+ editor?: Editor | null;
2439
+ code?: string;
2440
+ documentId?: string | null;
2441
+ }
2442
+ /**
2443
+ * Union of all `exception` event payloads SuperDoc emits at runtime.
2444
+ * Consumers can narrow with `'stage' in payload` (store init) or
2445
+ * `'code' in payload` (editor lifecycle).
2446
+ *
2447
+ * The union exists today because three independent emit sites
2448
+ * (`initializeDocuments`, the restore path, and the editor lifecycle)
2449
+ * pre-date a shared error contract. Normalizing them to a single
2450
+ * payload shape is a separate follow-up; consumers can narrow with
2451
+ * the `in` checks above in the meantime.
2452
+ */
2453
+ export type SuperDocExceptionPayload = SuperDocExceptionStorePayload | SuperDocExceptionRestorePayload | SuperDocExceptionEditorPayload;
2454
+ /**
2455
+ * Zoom mode. `manual` holds whatever value was last set; `fit-width`
2456
+ * continuously recomputes the zoom that fits the page width into the
2457
+ * available container width. Calling `setZoom()` switches to
2458
+ * `manual`; `setZoomMode('fit-width')` re-enters fitting.
2459
+ */
2460
+ export type SuperDocZoomMode = 'manual' | 'fit-width';
2461
+ /**
2462
+ * Measurement unit for rulers and measurement fields (Word's "measurement
2463
+ * units" preference). `in` = inches, `cm` = centimetres. Set the starting unit
2464
+ * with `Config.measurementUnit`; change it at runtime with `setMeasurementUnit()`.
2465
+ */
2466
+ export type SuperDocMeasurementUnit = 'in' | 'cm';
2467
+ /**
2468
+ * Payload emitted with the `measurement-unit-change` event. Fires when
2469
+ * `setMeasurementUnit()` changes the document-wide ruler/measurement unit.
2470
+ */
2471
+ export interface SuperDocMeasurementUnitChangePayload {
2472
+ /** The measurement unit now in effect. */
2473
+ unit: SuperDocMeasurementUnit;
2474
+ }
2475
+ /**
2476
+ * Payload emitted with the `zoomChange` event and passed to
2477
+ * `Config.onZoomChange`. Fires for every zoom source: `setZoom()`,
2478
+ * the toolbar zoom control, and fit-width adjustments.
2479
+ */
2480
+ export interface SuperDocZoomPayload {
2481
+ /** The zoom level as a percentage (e.g. 100, 150). */
2482
+ zoom: number;
2483
+ /** The zoom mode that produced this value. */
2484
+ mode: SuperDocZoomMode;
2485
+ }
2486
+ /**
2487
+ * Payload emitted with the `viewport-change` event and passed to
2488
+ * `Config.onViewportChange`. The event fires when the implied fit
2489
+ * changes: the rounded `fitZoom` or the rounded base page width.
2490
+ * Pixel-level `availableWidth` movement that cannot change any fit
2491
+ * decision does not emit; read `getViewportMetrics()` for the
2492
+ * always-latest measurements. These are pure measurements:
2493
+ * `zoom.fitWidth` policy options (`min`, `max`, `padding`) do not
2494
+ * affect them. For the common case, prefer `zoom.mode: 'fit-width'`,
2495
+ * which applies a clamped fit automatically.
2496
+ */
2497
+ export interface SuperDocViewportChangePayload {
2498
+ /**
2499
+ * Width available to the document in pixels: the measured container
2500
+ * width minus the comments sidebar when it is visible.
2501
+ */
2502
+ availableWidth: number;
2503
+ /** Widest document page width in pixels at 100% zoom. */
2504
+ documentWidth: number;
2505
+ /** Zoom percentage that fits the document in the available width (unclamped, padding-free). Clamp before applying. */
2506
+ fitZoom: number;
2507
+ }
2508
+ /**
2509
+ * Latest viewport measurements, readable at any time via
2510
+ * `superdoc.getViewportMetrics()`. Same shape as the
2511
+ * `viewport-change` payload and refreshed on every measurement
2512
+ * (including pixel-level changes the deduped event skips); `null`
2513
+ * until the first measurement (editors still mounting).
2514
+ */
2515
+ export type SuperDocViewportMetrics = SuperDocViewportChangePayload;
2516
+ /**
2517
+ * Options for the `fit-width` zoom mode. `min`/`max` clamp the
2518
+ * applied zoom percentage; `padding` reserves horizontal space
2519
+ * inside the available width before computing the applied fit.
2520
+ * These shape the applied policy only, never the reported metrics.
2521
+ */
2522
+ export interface SuperDocFitWidthOptions {
2523
+ /** Lower bound for the applied zoom percentage (default: 10). */
2524
+ min?: number;
2525
+ /**
2526
+ * Upper bound for the applied zoom percentage (default: 100, so
2527
+ * fitting never enlarges the document past its natural size; raise
2528
+ * it to let wide containers scale the page up).
2529
+ */
2530
+ max?: number;
2531
+ /** Horizontal padding in pixels reserved inside the available width before computing the fit (default: 0). */
2532
+ padding?: number;
2533
+ }
2534
+ /**
2535
+ * Snapshot of the current zoom state, readable via
2536
+ * `superdoc.getZoomState()`.
2537
+ */
2538
+ export interface SuperDocZoomState {
2539
+ /** Current zoom mode. */
2540
+ mode: SuperDocZoomMode;
2541
+ /** Current zoom value as a percentage. */
2542
+ value: number;
2543
+ /** Latest computed fit zoom (unclamped), or `null` before the first viewport measurement. */
2544
+ fitZoom: number | null;
2545
+ /** Effective lower bound the fit policy applies (config or default). */
2546
+ min: number;
2547
+ /** Effective upper bound the fit policy applies (config or default). */
2548
+ max: number;
2549
+ }
2550
+ /**
2551
+ * Options for `Config.zoom`: the initial zoom level, the starting
2552
+ * mode, and the fit-width policy bounds. Runtime control stays on
2553
+ * the instance: `setZoom()` (switches to manual), `setZoomMode()`,
2554
+ * `getZoomState()`, `getViewportMetrics()`, and the `zoomChange` /
2555
+ * `viewport-change` events.
2556
+ */
2557
+ export interface SuperDocZoomConfig {
2558
+ /**
2559
+ * Initial zoom level as a percentage (default: 100). Applied before
2560
+ * the first paint, so the document renders directly at this zoom
2561
+ * with no visible jump. In `fit-width` mode this is the paint zoom
2562
+ * until the first fit computes. Invalid values (non-finite or <= 0)
2563
+ * are ignored with a console warning.
2564
+ */
2565
+ initial?: number;
2566
+ /**
2567
+ * Starting zoom mode (default: `'manual'`). In `'fit-width'` the
2568
+ * document continuously re-fits to the available container width;
2569
+ * the fit is applied through the normal zoom pipeline, so
2570
+ * `zoomChange` fires for every adjustment.
2571
+ */
2572
+ mode?: SuperDocZoomMode;
2573
+ /** Bounds and padding for the `fit-width` policy. */
2574
+ fitWidth?: SuperDocFitWidthOptions;
2575
+ }
2576
+ /**
2577
+ * Per-surface built-in UI configuration. Every field is optional; an omitted
2578
+ * field keeps that surface's historical default rather than inheriting from
2579
+ * its siblings, so a partial config only changes what it names.
2580
+ *
2581
+ * `false` disables a surface, `true` enables it with defaults, and an options
2582
+ * object both enables and configures it.
2583
+ *
2584
+ * @see {@link Config.ui}
2585
+ */
2586
+ export interface UIConfig {
2587
+ /**
2588
+ * Built-in toolbar. Enabled by default, but a toolbar only appears once
2589
+ * `container` resolves to an element — enabling it without one creates the
2590
+ * `superdoc.toolbar` handle and renders nothing.
2591
+ */
2592
+ toolbar?: boolean | {
2593
+ /**
2594
+ * Where to render the toolbar: an element, an id selector
2595
+ * (`#toolbar`), a class selector (`.toolbar`), or a bare element id.
2596
+ * Other CSS selector syntax resolves to nothing.
2597
+ */
2598
+ container?: string | HTMLElement;
2599
+ /**
2600
+ * Which groups render, or what goes in them. The shape decides which
2601
+ * of the two it means, so both v1 spellings have somewhere to land.
2602
+ *
2603
+ * An array selects which groups render, e.g.
2604
+ * `['left', 'center', 'right']`. This is where `Config.toolbarGroups`
2605
+ * moves to. It is a membership list, not a sort order: the built-in
2606
+ * toolbar lays groups out left, center, right, and renders center
2607
+ * whether or not it is listed.
2608
+ *
2609
+ * An object is composition: a group id mapped to the item ids inside
2610
+ * it, e.g. `{ right: ['bold'] }`. This is where
2611
+ * `modules.toolbar.groups` moves to. Supplying both an ordering array
2612
+ * here and a legacy composition map keeps the composition and applies
2613
+ * the ordering as a filter.
2614
+ */
2615
+ groups?: string[] | Record<string, string[]>;
2616
+ /** Toolbar item ids to hide from the default set. */
2617
+ excludeItems?: string[];
2618
+ /** Icon overrides, merged over the built-in set. */
2619
+ icons?: Record<string, unknown>;
2620
+ /** Text overrides, merged over the built-in set. */
2621
+ texts?: Record<string, unknown>;
2622
+ /**
2623
+ * Hide buttons that overflow the available width (default: true).
2624
+ *
2625
+ * The runtime has always honored this through the toolbar options
2626
+ * pass-through; it was only missing from this type, so passing it here
2627
+ * failed excess-property checks while working at runtime.
2628
+ */
2629
+ hideButtons?: boolean;
2630
+ /** Size the toolbar to its container rather than the viewport. */
2631
+ responsiveToContainer?: boolean;
2632
+ /**
2633
+ * Custom font list rendered in the font-family dropdown. The runtime
2634
+ * uses this list verbatim, so entries are dropdown rows
2635
+ * ({@link ToolbarFontOption}), not families to load
2636
+ * ({@link FontFamilyConfig}). Register loadable families through
2637
+ * `fonts.families` instead.
2638
+ */
2639
+ fonts?: ToolbarFontOption[];
2640
+ /**
2641
+ * Custom toolbar buttons appended to the default item set.
2642
+ *
2643
+ * `name` and the `command` callback are typed; the rest of the
2644
+ * `ToolbarItem` shape stays open because it is not yet public (#1098).
2645
+ */
2646
+ customButtons?: ToolbarCustomButton[];
2647
+ /**
2648
+ * Show the formatting marks (pilcrow) button in the toolbar. Off by
2649
+ * default. Distinct from `layoutEngineOptions.showFormattingMarks`, which
2650
+ * controls whether the marks render in the document.
2651
+ */
2652
+ showFormattingMarksButton?: boolean;
2653
+ /** Show the table of contents insert button in the toolbar. Off by default. */
2654
+ showTableOfContentsButton?: boolean;
2655
+ };
2656
+ /** Built-in comments UI. Enabled by default. */
2657
+ comments?: boolean | Record<string, unknown>;
2658
+ /** Built-in right-click and slash context menu. Enabled by default. */
2659
+ contextMenu?: boolean | ContextMenuConfig;
2660
+ /**
2661
+ * Built-in find/replace surface. Disabled by default. Enabling it lets
2662
+ * SuperDoc intercept Cmd+F / Ctrl+F; `editor.ui.search` stays available to
2663
+ * custom UI either way.
2664
+ */
2665
+ search?: boolean | Record<string, unknown>;
2666
+ /** Built-in popover shown when a link is selected. Disabled by default. */
2667
+ linkPopover?: boolean | Record<string, unknown>;
2668
+ /** Built-in ruler. Disabled by default. */
2669
+ ruler?: boolean | {
2670
+ /** Element or selector to render the ruler into. */
2671
+ container?: string | HTMLElement;
2672
+ };
2673
+ /** Built-in chrome drawn around content controls. Enabled by default. */
2674
+ contentControls?: boolean | Record<string, unknown>;
2675
+ }
2676
+ /**
2677
+ * What the user is permitted to do, as distinct from what SuperDoc draws.
2678
+ *
2679
+ * Policy outlives presentation: `ui: false` removes the built-in comment
2680
+ * dialog, but an application rendering its own still needs `readOnly`
2681
+ * enforced. Keeping the two apart means a custom UI does not have to hold a
2682
+ * `modules.comments` object alive purely to carry policy.
2683
+ */
2684
+ export interface InteractionConfig {
2685
+ /** Comment and tracked-change interaction policy. */
2686
+ comments?: {
2687
+ /** Reject every comment and tracked-change mutation (default: false). */
2688
+ readOnly?: boolean;
2689
+ /** Offer resolve/reopen actions when writable (default: true). */
2690
+ allowResolve?: boolean;
2691
+ };
2692
+ }
2693
+ /**
2694
+ * Shared plumbing for dialogs and floating overlays, including surfaces the
2695
+ * application opens itself through `superdoc.openSurface()`.
2696
+ *
2697
+ * Unaffected by `ui: false`: turning off SuperDoc's own surfaces does not
2698
+ * disable the mechanism an application uses to render its own.
2699
+ */
2700
+ export interface SurfacesConfig {
2701
+ /**
2702
+ * Resolver for intent-based surface requests.
2703
+ *
2704
+ * `null` explicitly clears a resolver inherited from the legacy
2705
+ * `modules.surfaces.resolver`, which omitting the key does not do.
2706
+ */
2707
+ resolver?: SurfaceResolver | null;
2708
+ /** Defaults applied to dialog surfaces. */
2709
+ dialog?: {
2710
+ /** Close on Escape (default: true). */
2711
+ closeOnEscape?: boolean;
2712
+ /** Close on backdrop click (default: true). */
2713
+ closeOnBackdrop?: boolean;
2714
+ /** Default max width. */
2715
+ maxWidth?: string | number;
2716
+ };
2717
+ /** Defaults applied to floating surfaces. */
2718
+ floating?: {
2719
+ /** Placement preset (default: 'top-right'). */
2720
+ placement?: SurfaceFloatingPlacement;
2721
+ /** Default width. */
2722
+ width?: string | number;
2723
+ /** Default max width. */
2724
+ maxWidth?: string | number;
2725
+ /** Default max height. */
2726
+ maxHeight?: string | number;
2727
+ /** Close on Escape (default: true). */
2728
+ closeOnEscape?: boolean;
2729
+ /** Close on outside pointer down (default: false). */
2730
+ closeOnOutsidePointerDown?: boolean;
2731
+ /** Focus the surface on open (default: true). */
2732
+ autoFocus?: boolean;
2733
+ };
2734
+ }
2735
+ export interface Config {
2736
+ /** The ID of the SuperDoc. */
2737
+ superdocId?: string;
2738
+ /** The selector or element to mount the SuperDoc into. */
2739
+ selector: string | HTMLElement;
2740
+ /** The mode of the document (default: 'editing'). */
2741
+ documentMode?: DocumentMode;
2742
+ /**
2743
+ * When `documentMode` is `'viewing'`, allow the user to make text
2744
+ * selections even though editing is disabled. Defaults to `false`.
2745
+ * Forwarded to the underlying editor as `options.allowSelectionInViewMode`.
2746
+ */
2747
+ allowSelectionInViewMode?: boolean;
2748
+ /** The role of the user in this SuperDoc. */
2749
+ role?: 'editor' | 'viewer' | 'suggester';
2750
+ /**
2751
+ * The document to load. If a string, it will be treated as a URL. If a File
2752
+ * or Blob, it will be used directly. For a v2 collaboration room, pass a
2753
+ * structured document carrying `v2Collaboration`.
2754
+ *
2755
+ * Omitting this field and `documents` mounts a blank DOCX, so the Editor
2756
+ * opens a real document rather than an empty surface. The blank document is
2757
+ * a supported v2 source; it is seeded before mount and behaves like any
2758
+ * other opened DOCX, including export.
2759
+ *
2760
+ * Setting the v1 `modules.collaboration` field also suppresses that seeding,
2761
+ * but it is not a supported v2 path: the runtime fails closed with
2762
+ * `collaboration-v1-config-unsupported` and mounts only enough state to
2763
+ * report that error.
2764
+ */
2765
+ document?: object | string | globalThis.File | globalThis.Blob;
2766
+ /** Password for encrypted DOCX files. Forwarded during document load. */
2767
+ password?: string;
2768
+ /** The documents to load → soon to be deprecated. */
2769
+ documents?: Document[];
2770
+ /**
2771
+ * The current user of this SuperDoc. Typed as `AwarenessUser` (an
2772
+ * extension of `User` with the optional `color` field) so consumers
2773
+ * can pass an explicit awareness color and have the runtime honor it
2774
+ * as an override - `SuperDoc#assignUserColor()` skips its hash-based
2775
+ * assignment when `user.color` is already set.
2776
+ */
2777
+ user?: AwarenessUser;
2778
+ /** All users of this SuperDoc (can be used for "@"-mentions). */
2779
+ users?: User[];
2780
+ /** Colors to use for user awareness. */
2781
+ colors?: string[];
2782
+ /**
2783
+ * Which built-in interface SuperDoc renders.
2784
+ *
2785
+ * Omit it to keep SuperDoc's historical rendering: comments, the context
2786
+ * menu, and content-control chrome are on; search, the link popover, and
2787
+ * the ruler are opt-in; and the toolbar renders once it has somewhere to
2788
+ * mount. That profile is not symmetrical, and omitting this field
2789
+ * reproduces it exactly.
2790
+ *
2791
+ * Pass `false` when the application owns the interface. SuperDoc then
2792
+ * renders no controls, chrome, dialogs, or popovers, while the document,
2793
+ * the Document API, and `editor.ui` keep working — so a custom UI drives
2794
+ * the same commands the built-in one would have.
2795
+ *
2796
+ * Pass an object to choose per surface. An omitted key keeps that
2797
+ * surface's default rather than following its siblings, so
2798
+ * `{ comments: false }` disables comments and changes nothing else.
2799
+ *
2800
+ * @example
2801
+ * // Application owns the interface.
2802
+ * new SuperDoc({ selector: '#editor', document: file, ui: false });
2803
+ *
2804
+ * @example
2805
+ * // Built-in toolbar and search, no comments or context menu.
2806
+ * new SuperDoc({
2807
+ * selector: '#editor',
2808
+ * document: file,
2809
+ * ui: {
2810
+ * toolbar: { container: '#toolbar' },
2811
+ * search: true,
2812
+ * comments: false,
2813
+ * contextMenu: false,
2814
+ * },
2815
+ * });
2816
+ */
2817
+ ui?: false | UIConfig;
2818
+ /**
2819
+ * What the user is permitted to do. Independent of {@link Config.ui}: a
2820
+ * `readOnly` policy still applies when the application renders its own
2821
+ * comment UI.
2822
+ */
2823
+ interaction?: InteractionConfig;
2824
+ /**
2825
+ * Shared configuration for dialogs and floating overlays, including ones
2826
+ * opened through `superdoc.openSurface()`. Stays active under `ui: false`.
2827
+ */
2828
+ surfaces?: SurfacesConfig;
2829
+ /** Modules to load. */
2830
+ modules?: Modules;
2831
+ /** Top-level override for permission checks. */
2832
+ permissionResolver?: (params: PermissionResolverParams) => boolean | undefined;
2833
+ /**
2834
+ * Where to render the built-in toolbar. Either an `HTMLElement`, or a
2835
+ * selector string in one of the supported forms: an id selector (`#toolbar`),
2836
+ * a class selector (`.toolbar`), or a bare element id (`toolbar`). Other CSS
2837
+ * selector syntax is not supported — an attribute or descendant selector such
2838
+ * as `[data-toolbar]` resolves to nothing and leaves the toolbar unrendered.
2839
+ *
2840
+ * SuperDoc renders into the resolved element but does not manage its
2841
+ * placement, and never includes it in the `contained` layout calculation.
2842
+ * Where the application puts it therefore decides the space it needs: a
2843
+ * sibling of a 400px `contained` Editor adds its own height alongside it,
2844
+ * while a toolbar placed inside that host consumes part of the 400px and can
2845
+ * overflow it.
2846
+ *
2847
+ * Omitting this field (and `modules.toolbar.selector`) renders no toolbar.
2848
+ * `modules.toolbar: true` on its own does not render one either — it creates
2849
+ * the `superdoc.toolbar` handle without a mount target. See
2850
+ * {@link Modules.toolbar}.
2851
+ */
2852
+ toolbar?: string | HTMLElement;
2853
+ /** Toolbar groups to show. */
2854
+ toolbarGroups?: string[];
2855
+ /** Icons to show in the toolbar. */
2856
+ toolbarIcons?: object;
2857
+ /** Texts to override in the toolbar. */
2858
+ toolbarTexts?: object;
2859
+ /**
2860
+ * The font-family to use for all SuperDoc UI surfaces (toolbar, comments
2861
+ * UI, dropdowns, tooltips, etc.). This ensures consistent typography across
2862
+ * the entire application and helps match your application's design system.
2863
+ * The value should be a valid CSS font-family string.
2864
+ *
2865
+ * Example (system fonts):
2866
+ * uiDisplayFallbackFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
2867
+ *
2868
+ * Example (custom font):
2869
+ * uiDisplayFallbackFont: '"Inter", Arial, sans-serif'
2870
+ */
2871
+ uiDisplayFallbackFont?: string;
2872
+ /** Whether the SuperDoc is in development mode. */
2873
+ isDev?: boolean;
2874
+ /**
2875
+ * Disable Pinia/Vue devtools plugin setup for this SuperDoc instance
2876
+ * (useful in non-Vue hosts).
2877
+ */
2878
+ disablePiniaDevtools?: boolean;
2879
+ /**
2880
+ * Layout engine overrides passed through to DocumentRendererRuntime (page size,
2881
+ * margins, virtualization, zoom, debug label, etc.).
2882
+ */
2883
+ layoutEngineOptions?: SuperDocLayoutEngineOptions;
2884
+ /**
2885
+ * Advanced DocumentRendererRuntime feature toggles. `unifiedHistory` is enabled
2886
+ * by default; set it to `false` to force legacy active-surface undo
2887
+ * routing. `v2Host` enables the experimental mode-aware v2 DOCX shell path.
2888
+ */
2889
+ experimental?: {
2890
+ unifiedHistory?: boolean;
2891
+ v2Host?: boolean;
2892
+ /**
2893
+ * Derived-invalidation deferral for direct single-paragraph edits (v2
2894
+ * engine only). Field display text settles off the keystroke path under
2895
+ * the engine's settlement contract. DEFAULT TRUE — this is the engine's
2896
+ * standard behavior; set `false` only as an emergency kill switch.
2897
+ */
2898
+ deferDerivedInvalidations?: boolean;
2899
+ };
2900
+ /** Callback before an editor is created. Receives a wrapper carrying the editor. */
2901
+ onEditorBeforeCreate?: (params: SuperDocEditorPayload) => void;
2902
+ /** Callback after an editor is created. Receives a wrapper carrying the editor. */
2903
+ onEditorCreate?: (params: SuperDocEditorPayload) => void;
2904
+ /** Callback when the v2 document source reaches source-complete posture and diff.capture is safe to call. */
2905
+ onSourceComplete?: () => void;
2906
+ /** Callback when v2 source signals finish building (fires after onSourceComplete; diff.capture is synchronously safe). */
2907
+ onSourceSignalsComplete?: () => void;
2908
+ /** Callback when a transaction is made. */
2909
+ onTransaction?: (params: EditorTransactionEvent) => void;
2910
+ /** Callback after an editor is destroyed. */
2911
+ onEditorDestroy?: () => void;
2912
+ /**
2913
+ * Callback when an editor reports a content error (parse failure, doc
2914
+ * import error, etc.). `error` is widened to `unknown` because the
2915
+ * document editor side mostly normalizes to `Error` but some emitters
2916
+ * (e.g. `insertContentAt`) forward the original caught value. `file`
2917
+ * matches `Document.data` (`File | Blob | null | undefined`) since
2918
+ * the document can be loaded from any of those shapes. `documentId`
2919
+ * is guaranteed at runtime by `#initDocuments`.
2920
+ */
2921
+ onContentError?: (params: {
2922
+ error: unknown;
2923
+ editor: Editor;
2924
+ documentId: string;
2925
+ file: globalThis.File | globalThis.Blob | null | undefined;
2926
+ }) => void;
2927
+ /** Callback when the SuperDoc is ready. Receives a wrapper carrying the live SuperDoc instance. */
2928
+ onReady?: (params: SuperDocReadyPayload) => void;
2929
+ /** Callback when comments are updated. */
2930
+ onCommentsUpdate?: (params: SuperDocCommentsUpdatePayload) => void;
2931
+ /** Callback when active content control changes. */
2932
+ onContentControlActiveChange?: (params: ContentControlActiveChangePayload) => void;
2933
+ /** Callback when user clicks inside a content control. */
2934
+ onContentControlClick?: (params: ContentControlClickPayload) => void;
2935
+ /** Callback when awareness is updated. */
2936
+ onAwarenessUpdate?: (params: SuperDocAwarenessUpdatePayload) => void;
2937
+ /** Callback when the SuperDoc is locked or unlocked. */
2938
+ onLocked?: (params: SuperDocLockedPayload) => void;
2939
+ /** Callback when the PDF document is ready. */
2940
+ onPdfDocumentReady?: () => void;
2941
+ /** Callback when the sidebar is toggled. */
2942
+ onSidebarToggle?: (isOpened: boolean) => void;
2943
+ /** Callback when collaboration is ready. Receives a wrapper carrying the editor. */
2944
+ onCollaborationReady?: (params: SuperDocEditorPayload) => void;
2945
+ /** Callback when document is updated. */
2946
+ onEditorUpdate?: (params: EditorUpdateEvent) => void;
2947
+ /**
2948
+ * Callback when SuperDoc emits an `exception` event. The payload is a
2949
+ * union of three runtime shapes (store init, restore failure, editor
2950
+ * lifecycle). Narrow with `'stage' in params` (store init) or `'code'
2951
+ * in params` (editor) before reading shape-specific fields.
2952
+ */
2953
+ onException?: (params: SuperDocExceptionPayload) => void;
2954
+ /** Callback when the comments list is rendered. */
2955
+ onCommentsListChange?: (params: {
2956
+ isRendered: boolean;
2957
+ }) => void;
2958
+ /**
2959
+ * Callback when pagination layout updates (fires after each layout pass
2960
+ * with the current page count).
2961
+ */
2962
+ onPaginationUpdate?: (params: {
2963
+ totalPages: number;
2964
+ superdoc: SuperDoc;
2965
+ }) => void;
2966
+ /** Callback when the list definitions change. */
2967
+ onListDefinitionsChange?: (params: ListDefinitionsPayload) => void;
2968
+ /**
2969
+ * Callback when the zoom level changes. Fires for every zoom source:
2970
+ * `setZoom()`, the toolbar zoom control, and fit-width
2971
+ * adjustments.
2972
+ */
2973
+ onZoomChange?: (params: SuperDocZoomPayload) => void;
2974
+ /**
2975
+ * Callback when the implied fit changes (rounded fit zoom or base
2976
+ * page width); pixel-level width jitter does not fire it, and
2977
+ * `getViewportMetrics()` always reads latest. Registered before the
2978
+ * first emit.
2979
+ */
2980
+ onViewportChange?: (params: SuperDocViewportChangePayload) => void;
2981
+ /** The format of the document (docx, pdf, html). */
2982
+ format?: string;
2983
+ /**
2984
+ * Legacy v1 ProseMirror extensions. `editorExtensions` is a v1/ProseMirror
2985
+ * concept and is IGNORED by `superdoc@2`: these objects are never loaded into
2986
+ * the v2 runtime. Passing `editorExtensions` records a clear console
2987
+ * diagnostic at construction. For v2, use {@link Config.extensions} with
2988
+ * `defineSuperDocExtension`; the two are not interchangeable.
2989
+ */
2990
+ editorExtensions?: object[];
2991
+ /**
2992
+ * v2 SuperDoc extensions, created with `defineSuperDocExtension`. `superdoc@2`
2993
+ * IS the v2 editor, so these activate unconditionally — there is no
2994
+ * `editorVersion` / `editorIntegration` selector. Each extension owns
2995
+ * isolated storage, named events, commands, anchors, and render-only
2996
+ * decorations, and mutates the document exclusively through the guarded
2997
+ * Document API (`ctx.doc.*`). This is the v2 replacement for the
2998
+ * v1/ProseMirror `editorExtensions` path; the two are not interchangeable.
2999
+ * Extension arrays are mount-time config: changing the array reference
3000
+ * requires a remount to take effect.
3001
+ */
3002
+ extensions?: SuperDocExtension[];
3003
+ /** Whether the SuperDoc is internal. */
3004
+ isInternal?: boolean;
3005
+ /** The title of the SuperDoc. */
3006
+ title?: string;
3007
+ /** The conversations to load. */
3008
+ conversations?: object[];
3009
+ /** Toggle comment visibility when `documentMode` is `viewing` (default: false). */
3010
+ comments?: ViewingVisibilityConfig;
3011
+ /**
3012
+ * Deprecated. Use `modules.trackChanges.visible` instead. Toggle
3013
+ * tracked-change visibility when `documentMode` is `viewing` (default:
3014
+ * false).
3015
+ */
3016
+ trackChanges?: ViewingVisibilityConfig;
3017
+ /** Whether the SuperDoc is locked. */
3018
+ isLocked?: boolean;
3019
+ /** The function to handle image uploads. */
3020
+ handleImageUpload?: (file: globalThis.File) => Promise<string>;
3021
+ /** The user who locked the SuperDoc. */
3022
+ lockedBy?: User;
3023
+ /** Whether to show the ruler in the editor. */
3024
+ rulers?: boolean;
3025
+ /**
3026
+ * Element or selector the ruler mounts into. Omit to render it inline above
3027
+ * the editor.
3028
+ *
3029
+ * @deprecated replaceWith=`ui.ruler.container` removeIn=v3.0 — the runtime
3030
+ * still honors it, and the canonical value wins when both are set.
3031
+ */
3032
+ rulerContainer?: string | HTMLElement;
3033
+ /** Whether to suppress default styles in docx mode. */
3034
+ suppressDefaultDocxStyles?: boolean;
3035
+ /** Provided JSON to override content with. */
3036
+ jsonOverride?: object;
3037
+ /** Whether to disable slash / right-click custom context menu. */
3038
+ disableContextMenu?: boolean;
3039
+ /** HTML content to initialize the editor with. */
3040
+ html?: string;
3041
+ /** Markdown content to initialize the editor with. */
3042
+ markdown?: string;
3043
+ /**
3044
+ * Callback invoked with unsupported HTML elements dropped during import.
3045
+ * When provided, console.warn is NOT emitted.
3046
+ */
3047
+ onUnsupportedContent?: ((items: Array<{
3048
+ tagName: string;
3049
+ outerHTML: string;
3050
+ count: number;
3051
+ }>) => void) | null;
3052
+ /**
3053
+ * When true and no onUnsupportedContent callback is provided, emits a
3054
+ * console.warn with unsupported items.
3055
+ */
3056
+ warnOnUnsupportedContent?: boolean;
3057
+ /** Whether to enable debug mode. */
3058
+ isDebug?: boolean;
3059
+ /** Document view options (OOXML ST_View compatible). */
3060
+ viewOptions?: ViewOptions;
3061
+ /**
3062
+ * Enable contained mode for fixed-height container embedding.
3063
+ *
3064
+ * SuperDoc supports two layout modes, and the host element's height
3065
+ * requirement differs between them:
3066
+ *
3067
+ * - Natural (default, `false`): the Editor grows to the document's full
3068
+ * height and the page scrolls. The host needs no height. Setting one does
3069
+ * not constrain the document or enable internal scrolling, because
3070
+ * SuperDoc leaves overflow visible in this mode, though application CSS
3071
+ * on the host can still clip what is drawn.
3072
+ * - Contained (`true`): SuperDoc propagates `height: 100%` through its DOM
3073
+ * tree and scrolls the document internally, so multi-page documents stay
3074
+ * inside the host. This mode requires the host to have a definite height
3075
+ * (for example `height: 400px`); without one there is nothing for the
3076
+ * percentage heights to resolve against.
3077
+ *
3078
+ * A toolbar mounted through `Config.toolbar` or `modules.toolbar.selector` is
3079
+ * never part of this calculation. Placed as a sibling of the host, its height
3080
+ * adds to the host's: a 400px host with a 40px toolbar occupies 440px in
3081
+ * total. Placed inside the host, it consumes part of the 400px instead.
3082
+ */
3083
+ contained?: boolean;
3084
+ /** Content Security Policy nonce for dynamically injected styles. */
3085
+ cspNonce?: string;
3086
+ /** License key for organization identification. */
3087
+ licenseKey?: string;
3088
+ /** Telemetry configuration. */
3089
+ telemetry?: SuperDocTelemetryConfig;
3090
+ /** Proofing / spellcheck configuration. */
3091
+ proofing?: ProofingConfig;
3092
+ /**
3093
+ * Font system configuration. The reviewed fallback pack ships in the optional
3094
+ * `@superdoc-dev/fonts` package: pass `superdocFonts` (bundler) or the `SuperDocFonts`
3095
+ * global from its `superdoc-fonts.min.js` browser build (CDN). To self-host, set
3096
+ * `fonts.assetBaseUrl` (e.g. `/fonts/` or a CDN URL) or `fonts.resolveAssetUrl` for
3097
+ * signed/versioned hosting. SuperDoc core ships no fonts; with none configured the
3098
+ * toolbar shows the baseline and documents render with system fonts.
3099
+ */
3100
+ fonts?: FontsConfig;
3101
+ /**
3102
+ * Opt-in toggle for the layout engine. Auto-disabled when web layout is
3103
+ * requested without `layoutEngineOptions.flowMode === 'semantic'`; the
3104
+ * loader logs a warning and falls back to the legacy ProseMirror render
3105
+ * path in that case.
3106
+ */
3107
+ useLayoutEngine?: boolean;
3108
+ /**
3109
+ * Zoom behavior: the initial zoom level and optional fit-width
3110
+ * policy. See `SuperDocZoomConfig`.
3111
+ */
3112
+ zoom?: SuperDocZoomConfig;
3113
+ /**
3114
+ * Starting measurement unit for rulers and measurement fields (Word's
3115
+ * "measurement units" preference). Defaults to `'in'` (Word's en-US default).
3116
+ * Change it at runtime with `setMeasurementUnit()`. See `SuperDocMeasurementUnit`.
3117
+ */
3118
+ measurementUnit?: SuperDocMeasurementUnit;
3119
+ /**
3120
+ * Callback fired after the editor reports `fonts-resolved`. The payload
3121
+ * contains `documentFonts` and `unsupportedFonts` arrays so hosts can fall
3122
+ * back, warn, or block printing on unsupported faces.
3123
+ *
3124
+ * LEGACY/EARLY: this fires once before fonts load and is not substitution-aware
3125
+ * (`unsupportedFonts` over-reports families that render via a bundled substitute).
3126
+ * For the authoritative, load-settled picture use {@link onFontsChanged}.
3127
+ */
3128
+ onFontsResolved?: (payload: FontsResolvedPayload) => void;
3129
+ /**
3130
+ * Painter plan P7 §1 (@experimental): fires when the paginated page count
3131
+ * changes, at layout-end — before resolve or paint, so page counters and
3132
+ * minimaps can trust the number as soon as it is knowable. The payload's
3133
+ * `generation` identifies the announcing layout pass (informational; the
3134
+ * event is keyed on page-count changes, not generations). v2 vertical
3135
+ * pagination only; semantic "web layout" surfaces never fire it.
3136
+ */
3137
+ onPageCountKnown?: (payload: {
3138
+ pageCount: number;
3139
+ generation: number;
3140
+ }) => void;
3141
+ /**
3142
+ * Callback fired with the authoritative substitution + load-aware font report: once
3143
+ * after the load-before-measure gate settles (`source: 'initial'`), again when a face
3144
+ * arrives after a timed-out first paint (`'late-load'`). Each payload carries the full
3145
+ * per-font `resolutions`, the genuinely `missingFonts`, and a `loadSummary`. Also
3146
+ * available to pull on demand via `superdoc.fonts.getReport()`.
3147
+ */
3148
+ onFontsChanged?: (payload: FontsChangedPayload) => void;
3149
+ }
3150
+ /**
3151
+ * Internal augmentation of `Config` for runtime-only fields and tightened
3152
+ * invariants that must not appear on the published consumer surface. The
3153
+ * `Config` interface above is the public contract; this type adds the
3154
+ * fields SuperDoc sets/reads internally so the implementation can be
3155
+ * type-checked without leaking the fields into customer IDE autocomplete.
3156
+ *
3157
+ * The four overrides below mark fields that `Config` exposes as optional
3158
+ * but `SuperDoc.#init` always normalizes to a populated shape. Internal
3159
+ * call sites cast `this.config` to this type so they can access these
3160
+ * invariants without per-site null guards.
3161
+ *
3162
+ * Use this from internal SuperDoc callsites that need the augmented
3163
+ * shape, e.g. `(this.config as InternalConfig).socket = ...`.
3164
+ */
3165
+ export interface InternalConfig extends Config {
3166
+ /**
3167
+ * Internal v2 boot gate set when a consumer supplies the removed v1
3168
+ * `modules.collaboration` API. The shell surfaces this without ever
3169
+ * attaching the supplied Y.Doc/provider.
3170
+ */
3171
+ v2CollaborationPreflightFailure?: {
3172
+ readonly code: 'collaboration-v1-config-unsupported';
3173
+ readonly message: string;
3174
+ };
3175
+ /**
3176
+ * The shared websocket instance created by SuperDoc when
3177
+ * `modules.collaboration.providerType === 'hocuspocus'`. Set automatically;
3178
+ * not part of the public Config surface.
3179
+ */
3180
+ socket?: HocuspocusProviderWebsocket;
3181
+ /**
3182
+ * Normalized to `[]` by `#init` if the consumer passes nothing or
3183
+ * `undefined`. Narrowed to `RuntimeDocument[]` because once `#init`
3184
+ * runs, each entry has been augmented with the runtime-only fields
3185
+ * (`role`, editor/renderer accessors, etc.). Consumers
3186
+ * still pass `Document[]` via the public `Config` interface; this
3187
+ * override only describes the post-init shape internal callsites see.
3188
+ */
3189
+ documents: RuntimeDocument[];
3190
+ /** Normalized to `{}` by `#init` if the consumer passes nothing or `undefined`. */
3191
+ modules: Modules;
3192
+ /**
3193
+ * Spread of `DEFAULT_USER` over consumer input by `#init`; `name`
3194
+ * always present. Widened to `AwarenessUser` because `#assignUserColor`
3195
+ * runs synchronously during init and writes `color` into this object.
3196
+ */
3197
+ user: AwarenessUser;
3198
+ /** Normalized to `{}` by `#init` if the consumer passes nothing or `undefined`. */
3199
+ layoutEngineOptions: SuperDocLayoutEngineOptions;
3200
+ }
3201
+ /**
3202
+ * Internal augmentation of `SuperDocLayoutEngineOptions` for unstable tuning
3203
+ * fields. The public `SuperDocLayoutEngineOptions` interface above is the
3204
+ * customer-facing contract; this type adds fields the implementation may
3205
+ * read but that are intentionally not part of the v1 stable API.
3206
+ */
3207
+ export interface InternalSuperDocLayoutEngineOptions extends SuperDocLayoutEngineOptions {
3208
+ /**
3209
+ * Internal-only semantic mode tuning options. Shape may change without
3210
+ * notice; not part of the public surface.
3211
+ */
3212
+ semanticOptions?: object;
3213
+ }
3214
+ export type ProofingStatus = 'idle' | 'checking' | 'disabled' | 'degraded';
3215
+ export interface ProofingError {
3216
+ kind: 'provider-error' | 'validation-error' | 'timeout';
3217
+ message: string;
3218
+ segmentIds?: string[];
3219
+ /**
3220
+ * Underlying error (genuinely opaque: whatever the proofing provider
3221
+ * threw). Use `unknown` per Error-cause convention; consumers narrow
3222
+ * with `instanceof` or shape checks before reading fields.
3223
+ */
3224
+ cause?: unknown;
3225
+ }
3226
+ export interface ProofingConfig {
3227
+ /** Enable or disable proofing (default: false). */
3228
+ enabled?: boolean;
3229
+ /** Provider instance. */
3230
+ provider?: ProofingProvider | null;
3231
+ /** Fallback language for segments without a resolved language. */
3232
+ defaultLanguage?: string | null;
3233
+ /** Debounce delay after edits before rechecking (default: 500). */
3234
+ debounceMs?: number;
3235
+ /** Maximum replacement suggestions per issue. */
3236
+ maxSuggestions?: number;
3237
+ /** Prioritize checking visible pages first (default: true). */
3238
+ visibleFirst?: boolean;
3239
+ /** Show "Ignore" in context menu (default: true). */
3240
+ allowIgnoreWord?: boolean;
3241
+ /** Words to suppress from proofing results. */
3242
+ ignoredWords?: string[];
3243
+ /** Provider call timeout in milliseconds (default: 10000). */
3244
+ timeoutMs?: number;
3245
+ /** Max concurrent provider requests (default: 2). */
3246
+ maxConcurrentRequests?: number;
3247
+ /** Max segments per provider call (default: 20). */
3248
+ maxSegmentsPerBatch?: number;
3249
+ /** Error callback for provider failures. */
3250
+ onProofingError?: (error: ProofingError) => void;
3251
+ /** Status change callback. */
3252
+ onStatusChange?: (status: ProofingStatus) => void;
3253
+ }