@harbour-enterprises/superdoc 0.20.0-next.9 → 0.20.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 (175) hide show
  1. package/dist/chunks/{PdfViewer-BqGjx7hC.cjs → PdfViewer-BLwxuMWh.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BZlsmhsJ.es.js → PdfViewer-t_JS3Mbo.es.js} +1 -1
  3. package/dist/chunks/{index-DPzgGSfg.cjs → index-CBTSdULo.cjs} +2 -2
  4. package/dist/chunks/{index-4GToG3C3.es.js → index-Vp2WxlNm.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-BkxUKZfn.cjs → super-editor.es-Cten5oWF.cjs} +2494 -3327
  6. package/dist/chunks/{super-editor.es-DqX3Ipsk.es.js → super-editor.es-DGV2_J23.es.js} +2494 -3327
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/style.css +0 -38
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-C6YOTAXG.js → converter-Dq0PLazx.js} +1092 -1625
  11. package/dist/super-editor/chunks/{docx-zipper-CSiwWpmr.js → docx-zipper-jT0gaoep.js} +2 -2
  12. package/dist/super-editor/chunks/{editor-chVid4VD.js → editor-BEtv1kuN.js} +1046 -1335
  13. package/dist/super-editor/chunks/{toolbar-ancqgN0p.js → toolbar-CJfSHfLU.js} +2 -2
  14. package/dist/super-editor/converter.es.js +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/file-zipper.es.js +1 -1
  18. package/dist/super-editor/src/core/helpers/index.d.ts +0 -1
  19. package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -7
  20. package/dist/super-editor/src/core/super-converter/helpers.d.ts +0 -2
  21. package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +1 -1
  22. package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +22 -0
  23. package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +0 -2
  24. package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +3 -10
  25. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +1 -1
  26. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
  27. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +1 -11
  28. package/dist/super-editor/src/extensions/block-node/block-node.d.ts +5 -30
  29. package/dist/super-editor/src/extensions/bold/bold.d.ts +0 -20
  30. package/dist/super-editor/src/extensions/bullet-list/bullet-list.d.ts +0 -12
  31. package/dist/super-editor/src/extensions/color/color.d.ts +0 -26
  32. package/dist/super-editor/src/extensions/content-block/content-block.d.ts +0 -30
  33. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +0 -16
  34. package/dist/super-editor/src/extensions/document/document.d.ts +0 -26
  35. package/dist/super-editor/src/extensions/dropcursor/dropcursor.d.ts +0 -26
  36. package/dist/super-editor/src/extensions/font-family/font-family.d.ts +0 -29
  37. package/dist/super-editor/src/extensions/font-size/font-size.d.ts +0 -21
  38. package/dist/super-editor/src/extensions/format-commands/format-commands.d.ts +0 -9
  39. package/dist/super-editor/src/extensions/gapcursor/gapcursor.d.ts +0 -9
  40. package/dist/super-editor/src/extensions/heading/heading.d.ts +6 -12
  41. package/dist/super-editor/src/extensions/highlight/highlight.d.ts +0 -20
  42. package/dist/super-editor/src/extensions/history/history.d.ts +15 -7
  43. package/dist/super-editor/src/extensions/image/image.d.ts +0 -78
  44. package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +5 -0
  45. package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -3
  46. package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
  47. package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +23 -18
  48. package/dist/super-editor/src/extensions/italic/italic.d.ts +0 -10
  49. package/dist/super-editor/src/extensions/line-break/line-break.d.ts +0 -43
  50. package/dist/super-editor/src/extensions/line-height/line-height.d.ts +0 -22
  51. package/dist/super-editor/src/extensions/link/link.d.ts +25 -53
  52. package/dist/super-editor/src/extensions/linked-styles/linked-styles.d.ts +0 -9
  53. package/dist/super-editor/src/extensions/list-item/list-item.d.ts +0 -48
  54. package/dist/super-editor/src/extensions/mention/mention.d.ts +0 -26
  55. package/dist/super-editor/src/extensions/noderesizer/noderesizer.d.ts +0 -14
  56. package/dist/super-editor/src/extensions/ordered-list/ordered-list.d.ts +0 -35
  57. package/dist/super-editor/src/extensions/page-number/page-number.d.ts +0 -52
  58. package/dist/super-editor/src/extensions/paragraph/paragraph.d.ts +0 -49
  59. package/dist/super-editor/src/extensions/placeholder/placeholder.d.ts +0 -15
  60. package/dist/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts +0 -9
  61. package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -24
  62. package/dist/super-editor/src/extensions/search/search.d.ts +2 -11
  63. package/dist/super-editor/src/extensions/shape-container/shape-container.d.ts +0 -29
  64. package/dist/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts +0 -26
  65. package/dist/super-editor/src/extensions/slash-menu/slash-menu.d.ts +0 -9
  66. package/dist/super-editor/src/extensions/strike/strike.d.ts +0 -10
  67. package/dist/super-editor/src/extensions/structured-content/document-section.d.ts +27 -46
  68. package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +1 -29
  69. package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +1 -29
  70. package/dist/super-editor/src/extensions/tab/tab.d.ts +0 -25
  71. package/dist/super-editor/src/extensions/table/table.d.ts +55 -376
  72. package/dist/super-editor/src/extensions/table-cell/table-cell.d.ts +0 -41
  73. package/dist/super-editor/src/extensions/table-header/table-header.d.ts +0 -22
  74. package/dist/super-editor/src/extensions/table-row/table-row.d.ts +0 -28
  75. package/dist/super-editor/src/extensions/text/text.d.ts +0 -14
  76. package/dist/super-editor/src/extensions/text-align/text-align.d.ts +0 -22
  77. package/dist/super-editor/src/extensions/text-indent/text-indent.d.ts +10 -19
  78. package/dist/super-editor/src/extensions/text-style/text-style.d.ts +0 -20
  79. package/dist/super-editor/src/extensions/text-transform/text-transform.d.ts +0 -20
  80. package/dist/super-editor/src/extensions/underline/underline.d.ts +0 -25
  81. package/dist/super-editor/style.css +0 -38
  82. package/dist/super-editor/super-editor.es.js +55 -65
  83. package/dist/super-editor/toolbar.es.js +2 -2
  84. package/dist/super-editor.cjs +1 -1
  85. package/dist/super-editor.es.js +1 -1
  86. package/dist/superdoc.cjs +2 -2
  87. package/dist/superdoc.es.js +2 -2
  88. package/dist/superdoc.umd.js +3122 -3955
  89. package/dist/superdoc.umd.js.map +1 -1
  90. package/package.json +1 -1
  91. package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +0 -1
  92. package/dist/super-editor/src/core/super-converter/export-helpers/pre-process-vertical-merge-cells.d.ts +0 -6
  93. package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
  94. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +0 -6
  95. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +0 -1
  96. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +0 -6
  97. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +0 -2
  98. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +0 -6
  99. package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +0 -6
  100. package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +0 -1
  101. package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +0 -6
  102. package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +0 -2
  103. package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +0 -6
  104. package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +0 -6
  105. package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +0 -1
  106. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +0 -1
  107. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +0 -6
  108. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +0 -1
  109. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +0 -6
  110. package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +0 -2
  111. package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +0 -6
  112. package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +0 -6
  113. package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +0 -2
  114. package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +0 -6
  115. package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +0 -6
  116. package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +0 -1
  117. package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +0 -6
  118. package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +0 -2
  119. package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +0 -6
  120. package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +0 -6
  121. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +0 -1
  122. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +0 -28
  123. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +0 -1
  124. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +0 -6
  125. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +0 -1
  126. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +0 -6
  127. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +0 -1
  128. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +0 -2
  129. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +0 -1
  130. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +0 -6
  131. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +0 -1
  132. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +0 -5
  133. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +0 -5
  134. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +0 -1
  135. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +0 -6
  136. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +0 -1
  137. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +0 -6
  138. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +0 -1
  139. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +0 -6
  140. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +0 -1
  141. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +0 -6
  142. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +0 -1
  143. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +0 -5
  144. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +0 -1
  145. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +0 -6
  146. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +0 -1
  147. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +0 -6
  148. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +0 -1
  149. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +0 -6
  150. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +0 -1
  151. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +0 -6
  152. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +0 -1
  153. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +0 -6
  154. package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +0 -2
  155. package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +0 -6
  156. package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +0 -6
  157. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +0 -6
  158. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +0 -6
  159. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +0 -6
  160. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +0 -1
  161. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +0 -18
  162. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +0 -6
  163. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +0 -6
  164. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +0 -6
  165. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +0 -1
  166. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +0 -6
  167. package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +0 -3
  168. package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +0 -1
  169. package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +0 -2
  170. package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +0 -11
  171. package/dist/super-editor/src/extensions/image/imageHelpers/rotation.d.ts +0 -4
  172. package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +0 -9
  173. package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +0 -9
  174. package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +0 -24
  175. package/dist/super-editor/src/tests/helpers/editor-test-utils.d.ts +0 -14
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __typeError = (msg) => {
3
3
  throw TypeError(msg);
4
4
  };
5
- var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
6
- var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
8
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as SelectionRange, ap as Transform, aq as isInTable$1, ar as generateDocxRandomId, as as insertNewRelationship, at as updateDOMAttributes, au as htmlHandler } from "./converter-C6YOTAXG.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as htmlHandler } from "./converter-Dq0PLazx.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-CSiwWpmr.js";
17
+ import { D as DocxZipper } from "./docx-zipper-jT0gaoep.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -662,11 +662,11 @@ function hasBlockDesc(dom) {
662
662
  const selectionCollapsed = function(domSel) {
663
663
  return domSel.focusNode && isEquivalentPosition(domSel.focusNode, domSel.focusOffset, domSel.anchorNode, domSel.anchorOffset);
664
664
  };
665
- function keyEvent(keyCode, key2) {
665
+ function keyEvent(keyCode, key) {
666
666
  let event = document.createEvent("Event");
667
667
  event.initEvent("keydown", true, true);
668
668
  event.keyCode = keyCode;
669
- event.key = event.code = key2;
669
+ event.key = event.code = key;
670
670
  return event;
671
671
  }
672
672
  function deepActiveElement(doc2) {
@@ -1872,18 +1872,17 @@ class NodeViewDesc extends ViewDesc {
1872
1872
  }
1873
1873
  // Mark this node as being the selected node.
1874
1874
  selectNode() {
1875
- if (this.nodeDOM.nodeType == 1) {
1875
+ if (this.nodeDOM.nodeType == 1)
1876
1876
  this.nodeDOM.classList.add("ProseMirror-selectednode");
1877
- if (this.contentDOM || !this.node.type.spec.draggable)
1878
- this.nodeDOM.draggable = true;
1879
- }
1877
+ if (this.contentDOM || !this.node.type.spec.draggable)
1878
+ this.dom.draggable = true;
1880
1879
  }
1881
1880
  // Remove selected node marking from this node.
1882
1881
  deselectNode() {
1883
1882
  if (this.nodeDOM.nodeType == 1) {
1884
1883
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
1885
1884
  if (this.contentDOM || !this.node.type.spec.draggable)
1886
- this.nodeDOM.removeAttribute("draggable");
1885
+ this.dom.removeAttribute("draggable");
1887
1886
  }
1888
1887
  }
1889
1888
  get domAtom() {
@@ -3543,7 +3542,7 @@ class MouseDown {
3543
3542
  }
3544
3543
  const target = flushed ? null : event.target;
3545
3544
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
3546
- this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
3545
+ this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
3547
3546
  let { selection } = view.state;
3548
3547
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
3549
3548
  this.mightDrag = {
@@ -5914,9 +5913,9 @@ const writeAny = (encoder, data) => {
5914
5913
  const keys2 = Object.keys(data);
5915
5914
  writeVarUint(encoder, keys2.length);
5916
5915
  for (let i = 0; i < keys2.length; i++) {
5917
- const key2 = keys2[i];
5918
- writeVarString(encoder, key2);
5919
- writeAny(encoder, data[key2]);
5916
+ const key = keys2[i];
5917
+ writeVarString(encoder, key);
5918
+ writeAny(encoder, data[key]);
5920
5919
  }
5921
5920
  }
5922
5921
  break;
@@ -5935,17 +5934,17 @@ const unexpectedCase = () => {
5935
5934
  throw create$1("Unexpected case");
5936
5935
  };
5937
5936
  const create = () => /* @__PURE__ */ new Map();
5938
- const setIfUndefined = (map2, key2, createT) => {
5939
- let set = map2.get(key2);
5937
+ const setIfUndefined = (map2, key, createT) => {
5938
+ let set = map2.get(key);
5940
5939
  if (set === void 0) {
5941
- map2.set(key2, set = createT());
5940
+ map2.set(key, set = createT());
5942
5941
  }
5943
5942
  return set;
5944
5943
  };
5945
5944
  const keys = Object.keys;
5946
5945
  const every = (obj, f) => {
5947
- for (const key2 in obj) {
5948
- if (!f(obj[key2], key2)) {
5946
+ for (const key in obj) {
5947
+ if (!f(obj[key], key)) {
5949
5948
  return false;
5950
5949
  }
5951
5950
  }
@@ -6001,14 +6000,14 @@ class VarStoragePolyfill {
6001
6000
  * @param {string} key
6002
6001
  * @param {any} newValue
6003
6002
  */
6004
- setItem(key2, newValue) {
6005
- this.map.set(key2, newValue);
6003
+ setItem(key, newValue) {
6004
+ this.map.set(key, newValue);
6006
6005
  }
6007
6006
  /**
6008
6007
  * @param {string} key
6009
6008
  */
6010
- getItem(key2) {
6011
- return this.map.get(key2);
6009
+ getItem(key) {
6010
+ return this.map.get(key);
6012
6011
  }
6013
6012
  }
6014
6013
  let _localStorage = new VarStoragePolyfill();
@@ -6051,9 +6050,9 @@ const computeParams = () => {
6051
6050
  params = create();
6052
6051
  (location.search || "?").slice(1).split("&").forEach((kv) => {
6053
6052
  if (kv.length !== 0) {
6054
- const [key2, value] = kv.split("=");
6055
- params.set(`--${fromCamelCase(key2, "-")}`, value);
6056
- params.set(`-${fromCamelCase(key2, "-")}`, value);
6053
+ const [key, value] = kv.split("=");
6054
+ params.set(`--${fromCamelCase(key, "-")}`, value);
6055
+ params.set(`-${fromCamelCase(key, "-")}`, value);
6057
6056
  }
6058
6057
  });
6059
6058
  } else {
@@ -6336,8 +6335,8 @@ const ySyncPlugin = (yXmlFragment, {
6336
6335
  const change = tr.getMeta(ySyncPluginKey);
6337
6336
  if (change !== void 0) {
6338
6337
  pluginState = Object.assign({}, pluginState);
6339
- for (const key2 in change) {
6340
- pluginState[key2] = change[key2];
6338
+ for (const key in change) {
6339
+ pluginState[key] = change[key];
6341
6340
  }
6342
6341
  }
6343
6342
  pluginState.addToHistory = tr.getMeta("addToHistory") !== false;
@@ -6609,7 +6608,7 @@ class ProsemirrorBinding {
6609
6608
  snapshot = Y.snapshot(historyDoc);
6610
6609
  if (historyType._item === null) {
6611
6610
  const rootKey = Array.from(this.doc.share.keys()).find(
6612
- (key2) => this.doc.share.get(key2) === this.type
6611
+ (key) => this.doc.share.get(key) === this.type
6613
6612
  );
6614
6613
  historyType = historyDoc.getXmlFragment(rootKey);
6615
6614
  } else {
@@ -6898,10 +6897,10 @@ const createTypeFromTextNodes = (nodes, meta) => {
6898
6897
  };
6899
6898
  const createTypeFromElementNode = (node, meta) => {
6900
6899
  const type = new Y.XmlElement(node.type.name);
6901
- for (const key2 in node.attrs) {
6902
- const val = node.attrs[key2];
6903
- if (val !== null && key2 !== "ychange") {
6904
- type.setAttribute(key2, val);
6900
+ for (const key in node.attrs) {
6901
+ const val = node.attrs[key];
6902
+ if (val !== null && key !== "ychange") {
6903
+ type.setAttribute(key, val);
6905
6904
  }
6906
6905
  }
6907
6906
  type.insert(
@@ -6916,13 +6915,13 @@ const createTypeFromElementNode = (node, meta) => {
6916
6915
  const createTypeFromTextOrElementNode = (node, meta) => node instanceof Array ? createTypeFromTextNodes(node, meta) : createTypeFromElementNode(node, meta);
6917
6916
  const isObject = (val) => typeof val === "object" && val !== null;
6918
6917
  const equalAttrs = (pattrs, yattrs) => {
6919
- const keys2 = Object.keys(pattrs).filter((key2) => pattrs[key2] !== null);
6920
- let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((key2) => yattrs[key2] !== null).length);
6918
+ const keys2 = Object.keys(pattrs).filter((key) => pattrs[key] !== null);
6919
+ let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((key) => yattrs[key] !== null).length);
6921
6920
  for (let i = 0; i < keys2.length && eq; i++) {
6922
- const key2 = keys2[i];
6923
- const l = pattrs[key2];
6924
- const r2 = yattrs[key2];
6925
- eq = key2 === "ychange" || l === r2 || isObject(l) && isObject(r2) && equalAttrs(l, r2);
6921
+ const key = keys2[i];
6922
+ const l = pattrs[key];
6923
+ const r2 = yattrs[key];
6924
+ eq = key === "ychange" || l === r2 || isObject(l) && isObject(r2) && equalAttrs(l, r2);
6926
6925
  }
6927
6926
  return eq;
6928
6927
  };
@@ -7069,18 +7068,18 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
7069
7068
  if (yDomFragment instanceof Y.XmlElement) {
7070
7069
  const yDomAttrs = yDomFragment.getAttributes();
7071
7070
  const pAttrs = pNode.attrs;
7072
- for (const key2 in pAttrs) {
7073
- if (pAttrs[key2] !== null) {
7074
- if (yDomAttrs[key2] !== pAttrs[key2] && key2 !== "ychange") {
7075
- yDomFragment.setAttribute(key2, pAttrs[key2]);
7071
+ for (const key in pAttrs) {
7072
+ if (pAttrs[key] !== null) {
7073
+ if (yDomAttrs[key] !== pAttrs[key] && key !== "ychange") {
7074
+ yDomFragment.setAttribute(key, pAttrs[key]);
7076
7075
  }
7077
7076
  } else {
7078
- yDomFragment.removeAttribute(key2);
7077
+ yDomFragment.removeAttribute(key);
7079
7078
  }
7080
7079
  }
7081
- for (const key2 in yDomAttrs) {
7082
- if (pAttrs[key2] === void 0) {
7083
- yDomFragment.removeAttribute(key2);
7080
+ for (const key in yDomAttrs) {
7081
+ if (pAttrs[key] === void 0) {
7082
+ yDomFragment.removeAttribute(key);
7084
7083
  }
7085
7084
  }
7086
7085
  }
@@ -7211,19 +7210,19 @@ const updateMetas = () => {
7211
7210
  const tr = view.state.tr;
7212
7211
  const syncState = ySyncPluginKey.getState(view.state);
7213
7212
  if (syncState && syncState.binding && !syncState.binding.isDestroyed) {
7214
- metas.forEach((val, key2) => {
7215
- tr.setMeta(key2, val);
7213
+ metas.forEach((val, key) => {
7214
+ tr.setMeta(key, val);
7216
7215
  });
7217
7216
  view.dispatch(tr);
7218
7217
  }
7219
7218
  });
7220
7219
  };
7221
- const setMeta$1 = (view, key2, value) => {
7220
+ const setMeta$1 = (view, key, value) => {
7222
7221
  if (!viewsToUpdate) {
7223
7222
  viewsToUpdate = /* @__PURE__ */ new Map();
7224
7223
  timeout(0, updateMetas);
7225
7224
  }
7226
- setIfUndefined(viewsToUpdate, view, create).set(key2, value);
7225
+ setIfUndefined(viewsToUpdate, view, create).set(key, value);
7227
7226
  };
7228
7227
  const absolutePositionToRelativePosition = (pos, type, mapping) => {
7229
7228
  if (pos === 0) {
@@ -7683,6 +7682,12 @@ const History = Extension.create({
7683
7682
  name: "history",
7684
7683
  addOptions() {
7685
7684
  return {
7685
+ /**
7686
+ * @typedef {Object} HistoryOptions
7687
+ * @category Options
7688
+ * @property {number} [depth=100] - Maximum undo/redo steps to remember
7689
+ * @property {number} [newGroupDelay=500] - Milliseconds to wait before starting a new history group
7690
+ */
7686
7691
  depth: 100,
7687
7692
  newGroupDelay: 500
7688
7693
  };
@@ -7701,8 +7706,9 @@ const History = Extension.create({
7701
7706
  /**
7702
7707
  * Undo the last action
7703
7708
  * @category Command
7709
+ * @returns {Function} Command function
7704
7710
  * @example
7705
- * editor.commands.undo()
7711
+ * undo()
7706
7712
  * @note Groups changes within the newGroupDelay window
7707
7713
  */
7708
7714
  undo: () => ({ state, dispatch, tr }) => {
@@ -7716,8 +7722,9 @@ const History = Extension.create({
7716
7722
  /**
7717
7723
  * Redo the last undone action
7718
7724
  * @category Command
7725
+ * @returns {Function} Command function
7719
7726
  * @example
7720
- * editor.commands.redo()
7727
+ * redo()
7721
7728
  * @note Only available after an undo action
7722
7729
  */
7723
7730
  redo: () => ({ state, dispatch, tr }) => {
@@ -7915,21 +7922,21 @@ class Attribute {
7915
7922
  let attrs = {};
7916
7923
  for (const item of items) {
7917
7924
  const mergedAttributes = { ...attrs };
7918
- for (const [key2, value] of Object.entries(item)) {
7919
- const exists = mergedAttributes[key2];
7925
+ for (const [key, value] of Object.entries(item)) {
7926
+ const exists = mergedAttributes[key];
7920
7927
  if (!exists) {
7921
- mergedAttributes[key2] = value;
7928
+ mergedAttributes[key] = value;
7922
7929
  continue;
7923
7930
  }
7924
- if (key2 === "class") {
7931
+ if (key === "class") {
7925
7932
  const valueClasses = value ? value.split(" ") : [];
7926
- const existingClasses = mergedAttributes[key2] ? mergedAttributes[key2].split(" ") : [];
7933
+ const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(" ") : [];
7927
7934
  const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
7928
- mergedAttributes[key2] = [...existingClasses, ...insertClasses].join(" ");
7929
- } else if (key2 === "style") {
7930
- mergedAttributes[key2] = [mergedAttributes[key2], value].join("; ");
7935
+ mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
7936
+ } else if (key === "style") {
7937
+ mergedAttributes[key] = [mergedAttributes[key], value].join("; ");
7931
7938
  } else {
7932
- mergedAttributes[key2] = value;
7939
+ mergedAttributes[key] = value;
7933
7940
  }
7934
7941
  }
7935
7942
  attrs = mergedAttributes;
@@ -8239,8 +8246,8 @@ const insertTabNode = () => ({ tr, state, dispatch }) => {
8239
8246
  if (dispatch) dispatch(tr);
8240
8247
  return true;
8241
8248
  };
8242
- const setMeta = (key2, value) => ({ tr }) => {
8243
- tr.setMeta(key2, value);
8249
+ const setMeta = (key, value) => ({ tr }) => {
8250
+ tr.setMeta(key, value);
8244
8251
  return true;
8245
8252
  };
8246
8253
  const ensureMarks = (state, splittableMarks) => {
@@ -11368,14 +11375,14 @@ const updateYdocDocxData = async (editor, ydoc) => {
11368
11375
  const metaMap = ydoc.getMap("meta");
11369
11376
  const docx = [...metaMap.get("docx")];
11370
11377
  const newXml = await editor.exportDocx({ getUpdatedDocs: true });
11371
- Object.keys(newXml).forEach((key2) => {
11372
- const fileIndex = docx.findIndex((item) => item.name === key2);
11378
+ Object.keys(newXml).forEach((key) => {
11379
+ const fileIndex = docx.findIndex((item) => item.name === key);
11373
11380
  if (fileIndex > -1) {
11374
11381
  docx.splice(fileIndex, 1);
11375
11382
  }
11376
11383
  docx.push({
11377
- name: key2,
11378
- content: newXml[key2]
11384
+ name: key,
11385
+ content: newXml[key]
11379
11386
  });
11380
11387
  });
11381
11388
  ydoc.transact(
@@ -11391,8 +11398,8 @@ const initPaginationData = async (editor) => {
11391
11398
  const sectionData = { headers: {}, footers: {} };
11392
11399
  const headerIds = editor.converter.headerIds.ids;
11393
11400
  const footerIds = editor.converter.footerIds.ids;
11394
- for (let key2 in headerIds) {
11395
- const sectionId = headerIds[key2];
11401
+ for (let key in headerIds) {
11402
+ const sectionId = headerIds[key];
11396
11403
  if (!sectionId) continue;
11397
11404
  const dataForThisSection = editor.converter.headers[sectionId];
11398
11405
  if (!sectionData.headers[sectionId]) sectionData.headers[sectionId] = {};
@@ -11402,8 +11409,8 @@ const initPaginationData = async (editor) => {
11402
11409
  sectionData.headers[sectionId].sectionEditor = sectionEditor;
11403
11410
  sectionData.headers[sectionId].sectionContainer = sectionContainer;
11404
11411
  }
11405
- for (let key2 in footerIds) {
11406
- const sectionId = footerIds[key2];
11412
+ for (let key in footerIds) {
11413
+ const sectionId = footerIds[key];
11407
11414
  if (!sectionId) continue;
11408
11415
  const dataForThisSection = editor.converter.footers[sectionId];
11409
11416
  if (!sectionData.headers[sectionId]) sectionData.footers[sectionId] = {};
@@ -12472,16 +12479,16 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state }) =>
12472
12479
  if (rowsToGenerate <= 1) return;
12473
12480
  const validateAttributes = (attrs) => {
12474
12481
  const cleaned = {};
12475
- for (const [key2, value] of Object.entries(attrs)) {
12482
+ for (const [key, value] of Object.entries(attrs)) {
12476
12483
  if (value !== void 0 && value !== null) {
12477
- if (key2 === "displayLabel") {
12478
- cleaned[key2] = String(value);
12479
- } else if (key2 === "rawHtml" || key2 === "linkUrl" || key2 === "imageSrc") {
12480
- cleaned[key2] = String(value);
12484
+ if (key === "displayLabel") {
12485
+ cleaned[key] = String(value);
12486
+ } else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
12487
+ cleaned[key] = String(value);
12481
12488
  } else if (typeof value === "string" && value.length > 0) {
12482
- cleaned[key2] = value;
12489
+ cleaned[key] = value;
12483
12490
  } else if (typeof value !== "string") {
12484
- cleaned[key2] = value;
12491
+ cleaned[key] = value;
12485
12492
  }
12486
12493
  }
12487
12494
  }
@@ -12759,10 +12766,10 @@ const Collaboration = Extension.create({
12759
12766
  this.options.fragment = fragment;
12760
12767
  const metaMap = this.options.ydoc.getMap("media");
12761
12768
  metaMap.observe((event) => {
12762
- event.changes.keys.forEach((_, key2) => {
12763
- if (!(key2 in this.editor.storage.image.media)) {
12764
- const fileData = metaMap.get(key2);
12765
- this.editor.storage.image.media[key2] = fileData;
12769
+ event.changes.keys.forEach((_, key) => {
12770
+ if (!(key in this.editor.storage.image.media)) {
12771
+ const fileData = metaMap.get(key);
12772
+ this.editor.storage.image.media[key] = fileData;
12766
12773
  }
12767
12774
  });
12768
12775
  });
@@ -12782,8 +12789,8 @@ const initializeMetaMap = (ydoc, editor) => {
12782
12789
  metaMap.set("docx", editor.options.content);
12783
12790
  metaMap.set("fonts", editor.options.fonts);
12784
12791
  const mediaMap = ydoc.getMap("media");
12785
- Object.entries(editor.options.mediaFiles).forEach(([key2, value]) => {
12786
- mediaMap.set(key2, value);
12792
+ Object.entries(editor.options.mediaFiles).forEach(([key, value]) => {
12793
+ mediaMap.set(key, value);
12787
12794
  });
12788
12795
  };
12789
12796
  const checkDocxChanged = (transaction) => {
@@ -13545,8 +13552,8 @@ function processRelationships(root, convertedXml, results) {
13545
13552
  };
13546
13553
  const seenIds = /* @__PURE__ */ new Set();
13547
13554
  const filtered = [];
13548
- function extractStringAttr(attrs, key2) {
13549
- return typeof attrs[key2] === "string" ? attrs[key2].trim() : "";
13555
+ function extractStringAttr(attrs, key) {
13556
+ return typeof attrs[key] === "string" ? attrs[key].trim() : "";
13550
13557
  }
13551
13558
  for (const rel of root.elements) {
13552
13559
  rel.attributes = rel.attributes || {};
@@ -13768,10 +13775,10 @@ class SuperValidator {
13768
13775
  this.logger.debug("Document analysis:", documentAnalysis);
13769
13776
  let hasModifiedDocument = false;
13770
13777
  const validationResults = [];
13771
- Object.entries(__privateGet(this, _stateValidators)).forEach(([key2, validator]) => {
13772
- this.logger.debug(`🕵 Validating with ${key2}...`);
13778
+ Object.entries(__privateGet(this, _stateValidators)).forEach(([key, validator]) => {
13779
+ this.logger.debug(`🕵 Validating with ${key}...`);
13773
13780
  const { results, modified } = validator(tr, documentAnalysis);
13774
- validationResults.push({ key: key2, results });
13781
+ validationResults.push({ key, results });
13775
13782
  hasModifiedDocument = hasModifiedDocument || modified;
13776
13783
  });
13777
13784
  if (!this.dryRun) dispatch(tr);
@@ -13788,10 +13795,10 @@ class SuperValidator {
13788
13795
  const { dispatch } = __privateGet(this, _editor).view;
13789
13796
  let hasModifiedDocument = false;
13790
13797
  const validationResults = [];
13791
- Object.entries(__privateGet(this, _xmlValidators)).forEach(([key2, validator]) => {
13792
- this.logger.debug(`🕵 Validating export with ${key2}...`);
13798
+ Object.entries(__privateGet(this, _xmlValidators)).forEach(([key, validator]) => {
13799
+ this.logger.debug(`🕵 Validating export with ${key}...`);
13793
13800
  const { results, modified } = validator();
13794
- validationResults.push({ key: key2, results });
13801
+ validationResults.push({ key, results });
13795
13802
  hasModifiedDocument = hasModifiedDocument || modified;
13796
13803
  });
13797
13804
  if (!this.dryRun && hasModifiedDocument) dispatch(tr);
@@ -13815,11 +13822,11 @@ initializeValidators_fn = function() {
13815
13822
  const requiredMarks = /* @__PURE__ */ new Set();
13816
13823
  const initializeValidatorSet = (validatorFactories) => {
13817
13824
  return Object.fromEntries(
13818
- Object.entries(validatorFactories).map(([key2, factory]) => {
13819
- const validatorLogger = this.logger.withPrefix(key2);
13825
+ Object.entries(validatorFactories).map(([key, factory]) => {
13826
+ const validatorLogger = this.logger.withPrefix(key);
13820
13827
  const validator = factory({ editor: __privateGet(this, _editor), logger: validatorLogger });
13821
13828
  __privateMethod(this, _SuperValidator_instances, collectValidatorRequirements_fn).call(this, validator, requiredNodes, requiredMarks);
13822
- return [key2, validator];
13829
+ return [key, validator];
13823
13830
  })
13824
13831
  );
13825
13832
  };
@@ -14697,7 +14704,6 @@ const _Editor = class _Editor extends EventEmitter {
14697
14704
  return result;
14698
14705
  } catch (error) {
14699
14706
  this.emit("exception", { error, editor: this });
14700
- console.error(error);
14701
14707
  }
14702
14708
  }
14703
14709
  /**
@@ -14721,7 +14727,6 @@ const _Editor = class _Editor extends EventEmitter {
14721
14727
  this.converter.footerEditors.length = 0;
14722
14728
  } catch (error) {
14723
14729
  this.emit("exception", { error, editor: this });
14724
- console.error(error);
14725
14730
  }
14726
14731
  }
14727
14732
  /**
@@ -15143,8 +15148,8 @@ initMedia_fn = function() {
15143
15148
  if (!this.options.ydoc) return this.storage.image.media = this.options.mediaFiles;
15144
15149
  const mediaMap = this.options.ydoc.getMap("media");
15145
15150
  if (this.options.isNewFile) {
15146
- Object.entries(this.options.mediaFiles).forEach(([key2, value]) => {
15147
- mediaMap.set(key2, value);
15151
+ Object.entries(this.options.mediaFiles).forEach(([key, value]) => {
15152
+ mediaMap.set(key, value);
15148
15153
  });
15149
15154
  this.storage.image.media = this.options.mediaFiles;
15150
15155
  } else {
@@ -15419,7 +15424,6 @@ endCollaboration_fn = function() {
15419
15424
  if (this.options.ydoc) this.options.ydoc.destroy();
15420
15425
  } catch (error) {
15421
15426
  this.emit("exception", { error, editor: this });
15422
- console.error(error);
15423
15427
  }
15424
15428
  };
15425
15429
  /**
@@ -15454,6 +15458,11 @@ const Color = Extension.create({
15454
15458
  name: "color",
15455
15459
  addOptions() {
15456
15460
  return {
15461
+ /**
15462
+ * @typedef {Object} ColorOptions
15463
+ * @category Options
15464
+ * @property {string[]} [types=['textStyle']] - Mark types to add color support to
15465
+ */
15457
15466
  types: ["textStyle"]
15458
15467
  };
15459
15468
  },
@@ -15462,6 +15471,10 @@ const Color = Extension.create({
15462
15471
  {
15463
15472
  types: this.options.types,
15464
15473
  attributes: {
15474
+ /**
15475
+ * @category Attribute
15476
+ * @param {ColorValue} [color] - Text color value
15477
+ */
15465
15478
  color: {
15466
15479
  default: null,
15467
15480
  parseDOM: (el) => el.style.color?.replace(/['"]+/g, ""),
@@ -15480,17 +15493,16 @@ const Color = Extension.create({
15480
15493
  * Set text color
15481
15494
  * @category Command
15482
15495
  * @param {ColorValue} color - Color value to apply
15496
+ * @returns {Function} Command function
15483
15497
  * @example
15484
15498
  * // Set to red using hex
15485
- * editor.commands.setColor('#ff0000')
15499
+ * setColor('#ff0000')
15486
15500
  *
15487
- * @example
15488
15501
  * // Set using rgb
15489
- * editor.commands.setColor('rgb(255, 0, 0)')
15502
+ * setColor('rgb(255, 0, 0)')
15490
15503
  *
15491
- * @example
15492
15504
  * // Set using named color
15493
- * editor.commands.setColor('blue')
15505
+ * setColor('blue')
15494
15506
  * @note Preserves other text styling attributes
15495
15507
  */
15496
15508
  setColor: (color) => ({ chain }) => {
@@ -15499,8 +15511,9 @@ const Color = Extension.create({
15499
15511
  /**
15500
15512
  * Remove text color
15501
15513
  * @category Command
15514
+ * @returns {Function} Command function
15502
15515
  * @example
15503
- * editor.commands.unsetColor()
15516
+ * unsetColor()
15504
15517
  * @note Removes color while preserving other text styles
15505
15518
  */
15506
15519
  unsetColor: () => ({ chain }) => {
@@ -15513,6 +15526,11 @@ const FontFamily = Extension.create({
15513
15526
  name: "fontFamily",
15514
15527
  addOptions() {
15515
15528
  return {
15529
+ /**
15530
+ * @typedef {Object} FontFamilyOptions
15531
+ * @category Options
15532
+ * @property {string[]} [types=['textStyle']] - Mark types to add font family support to
15533
+ */
15516
15534
  types: ["textStyle"]
15517
15535
  };
15518
15536
  },
@@ -15521,6 +15539,10 @@ const FontFamily = Extension.create({
15521
15539
  {
15522
15540
  types: this.options.types,
15523
15541
  attributes: {
15542
+ /**
15543
+ * @category Attribute
15544
+ * @param {FontFamilyValue} [fontFamily] - Font family for text
15545
+ */
15524
15546
  fontFamily: {
15525
15547
  default: null,
15526
15548
  parseDOM: (el) => el.style.fontFamily?.replace(/['"]+/g, ""),
@@ -15539,13 +15561,13 @@ const FontFamily = Extension.create({
15539
15561
  * Set font family
15540
15562
  * @category Command
15541
15563
  * @param {FontFamilyValue} fontFamily - Font family to apply
15564
+ * @returns {Function} Command function
15542
15565
  * @example
15543
15566
  * // Set to Arial
15544
- * editor.commands.setFontFamily('Arial')
15567
+ * setFontFamily('Arial')
15545
15568
  *
15546
- * @example
15547
15569
  * // Set to serif font
15548
- * editor.commands.setFontFamily('Georgia, serif')
15570
+ * setFontFamily('Georgia, serif')
15549
15571
  * @note Preserves other text styling attributes
15550
15572
  */
15551
15573
  setFontFamily: (fontFamily) => ({ chain }) => {
@@ -15554,8 +15576,9 @@ const FontFamily = Extension.create({
15554
15576
  /**
15555
15577
  * Remove font family
15556
15578
  * @category Command
15579
+ * @returns {Function} Command function
15557
15580
  * @example
15558
- * editor.commands.unsetFontFamily()
15581
+ * unsetFontFamily()
15559
15582
  * @note Reverts to default document font
15560
15583
  */
15561
15584
  unsetFontFamily: () => ({ chain }) => {
@@ -15568,6 +15591,12 @@ const FontSize = Extension.create({
15568
15591
  name: "fontSize",
15569
15592
  addOptions() {
15570
15593
  return {
15594
+ /**
15595
+ * @typedef {Object} FontSizeOptions
15596
+ * @category Options
15597
+ * @property {string[]} [types=['textStyle', 'tableCell']] - Node/mark types to add font size support to
15598
+ * @property {FontSizeDefaults} [defaults] - Default size configuration
15599
+ */
15571
15600
  types: ["textStyle", "tableCell"],
15572
15601
  defaults: {
15573
15602
  value: 12,
@@ -15582,6 +15611,10 @@ const FontSize = Extension.create({
15582
15611
  {
15583
15612
  types: this.options.types,
15584
15613
  attributes: {
15614
+ /**
15615
+ * @category Attribute
15616
+ * @param {FontSizeValue} [fontSize] - Font size with unit
15617
+ */
15585
15618
  fontSize: {
15586
15619
  default: null,
15587
15620
  parseDOM: (el) => el.style.fontSize,
@@ -15603,10 +15636,16 @@ const FontSize = Extension.create({
15603
15636
  * Set font size
15604
15637
  * @category Command
15605
15638
  * @param {FontSizeValue} fontSize - Size to apply (with optional unit)
15639
+ * @returns {Function} Command function
15606
15640
  * @example
15607
- * editor.commands.setFontSize('14pt')
15608
- * editor.commands.setFontSize('18px')
15609
- * editor.commands.setFontSize(16)
15641
+ * // Set to 14pt
15642
+ * setFontSize('14pt')
15643
+ *
15644
+ * // Set to 18px
15645
+ * setFontSize('18px')
15646
+ *
15647
+ * // Set without unit (uses default)
15648
+ * setFontSize(16)
15610
15649
  * @note Automatically clamps to min/max values
15611
15650
  */
15612
15651
  setFontSize: (fontSize) => ({ chain }) => {
@@ -15628,8 +15667,9 @@ const FontSize = Extension.create({
15628
15667
  /**
15629
15668
  * Remove font size
15630
15669
  * @category Command
15670
+ * @returns {Function} Command function
15631
15671
  * @example
15632
- * editor.commands.unsetFontSize()
15672
+ * unsetFontSize()
15633
15673
  * @note Reverts to default document size
15634
15674
  */
15635
15675
  unsetFontSize: () => ({ chain }) => {
@@ -15679,9 +15719,13 @@ const TextAlign = Extension.create({
15679
15719
  * Set text alignment
15680
15720
  * @category Command
15681
15721
  * @param {string} alignment - Alignment value (left, center, right, justify)
15722
+ * @returns {Function} Command function
15682
15723
  * @example
15683
- * editor.commands.setTextAlign('center')
15684
- * editor.commands.setTextAlign('justify')
15724
+ * // Set to center
15725
+ * setTextAlign('center')
15726
+ *
15727
+ * // Set to justify
15728
+ * setTextAlign('justify')
15685
15729
  * @note Applies to all configured node types (heading, paragraph by default)
15686
15730
  */
15687
15731
  setTextAlign: (alignment) => ({ commands: commands2 }) => {
@@ -15692,8 +15736,9 @@ const TextAlign = Extension.create({
15692
15736
  /**
15693
15737
  * Remove text alignment (reset to default)
15694
15738
  * @category Command
15739
+ * @returns {Function} Command function
15695
15740
  * @example
15696
- * editor.commands.unsetTextAlign()
15741
+ * unsetTextAlign()
15697
15742
  * @note Resets alignment to the default value
15698
15743
  */
15699
15744
  unsetTextAlign: () => ({ commands: commands2 }) => {
@@ -15834,6 +15879,13 @@ const LineHeight = Extension.create({
15834
15879
  name: "lineHeight",
15835
15880
  addOptions() {
15836
15881
  return {
15882
+ /**
15883
+ * @typedef {Object} LineHeightOptions
15884
+ * @category Options
15885
+ * @property {string[]} [types=['heading', 'paragraph']] - Block types to add line height support to
15886
+ * @property {Object} [defaults] - Default configuration
15887
+ * @property {string} [defaults.unit=''] - Default unit for line height values
15888
+ */
15837
15889
  types: ["heading", "paragraph"],
15838
15890
  defaults: {
15839
15891
  unit: ""
@@ -15845,6 +15897,10 @@ const LineHeight = Extension.create({
15845
15897
  {
15846
15898
  types: this.options.types,
15847
15899
  attributes: {
15900
+ /**
15901
+ * @category Attribute
15902
+ * @param {LineHeightValue} [lineHeight] - Line height value
15903
+ */
15848
15904
  lineHeight: {
15849
15905
  default: null,
15850
15906
  parseDOM: (el) => el.style.lineHeight,
@@ -15870,10 +15926,16 @@ const LineHeight = Extension.create({
15870
15926
  * Set line height for blocks
15871
15927
  * @category Command
15872
15928
  * @param {LineHeightValue} lineHeight - Line height to apply
15929
+ * @returns {Function} Command function
15873
15930
  * @example
15874
- * editor.commands.setLineHeight(1.5)
15875
- * editor.commands.setLineHeight('24px')
15876
- * editor.commands.setLineHeight(2)
15931
+ * // Set to 1.5x spacing
15932
+ * setLineHeight(1.5)
15933
+ *
15934
+ * // Set to 24px spacing
15935
+ * setLineHeight('24px')
15936
+ *
15937
+ * // Set to double spacing
15938
+ * setLineHeight(2)
15877
15939
  * @note Applies to paragraphs and headings
15878
15940
  */
15879
15941
  setLineHeight: (lineHeight) => ({ commands: commands2 }) => {
@@ -15883,8 +15945,9 @@ const LineHeight = Extension.create({
15883
15945
  /**
15884
15946
  * Remove line height
15885
15947
  * @category Command
15948
+ * @returns {Function} Command function
15886
15949
  * @example
15887
- * editor.commands.unsetLineHeight()
15950
+ * unsetLineHeight()
15888
15951
  * @note Reverts to default line spacing
15889
15952
  */
15890
15953
  unsetLineHeight: () => ({ commands: commands2 }) => {
@@ -15912,8 +15975,9 @@ const FormatCommands = Extension.create({
15912
15975
  /**
15913
15976
  * Clear all formatting (nodes and marks)
15914
15977
  * @category Command
15978
+ * @returns {Function} Command function
15915
15979
  * @example
15916
- * editor.commands.clearFormat()
15980
+ * clearFormat()
15917
15981
  * @note Removes all marks and resets nodes to default paragraph
15918
15982
  */
15919
15983
  clearFormat: () => ({ chain }) => {
@@ -15922,8 +15986,9 @@ const FormatCommands = Extension.create({
15922
15986
  /**
15923
15987
  * Clear only mark formatting
15924
15988
  * @category Command
15989
+ * @returns {Function} Command function
15925
15990
  * @example
15926
- * editor.commands.clearMarksFormat()
15991
+ * clearMarksFormat()
15927
15992
  * @note Removes bold, italic, underline, colors, etc. but preserves block structure
15928
15993
  */
15929
15994
  clearMarksFormat: () => ({ chain }) => {
@@ -15932,8 +15997,9 @@ const FormatCommands = Extension.create({
15932
15997
  /**
15933
15998
  * Clear only node formatting
15934
15999
  * @category Command
16000
+ * @returns {Function} Command function
15935
16001
  * @example
15936
- * editor.commands.clearNodesFormat()
16002
+ * clearNodesFormat()
15937
16003
  * @note Converts headings, lists, etc. to paragraphs but preserves text marks
15938
16004
  */
15939
16005
  clearNodesFormat: () => ({ chain }) => {
@@ -15942,8 +16008,13 @@ const FormatCommands = Extension.create({
15942
16008
  /**
15943
16009
  * Copy format from selection or apply copied format
15944
16010
  * @category Command
16011
+ * @returns {Function} Command function
15945
16012
  * @example
15946
- * editor.commands.copyFormat()
16013
+ * // First call: copy format from selection
16014
+ * copyFormat()
16015
+ *
16016
+ * // Second call: apply copied format to new selection
16017
+ * copyFormat()
15947
16018
  * @note Works like format painter - first click copies, second click applies
15948
16019
  */
15949
16020
  copyFormat: () => ({ chain }) => {
@@ -15962,11 +16033,11 @@ const FormatCommands = Extension.create({
15962
16033
  const { type, attrs } = mark;
15963
16034
  const { name } = type;
15964
16035
  if (name === "textStyle") {
15965
- Object.keys(attrs).forEach((key2) => {
15966
- if (!attrs[key2]) return;
16036
+ Object.keys(attrs).forEach((key) => {
16037
+ if (!attrs[key]) return;
15967
16038
  const attributes = {};
15968
- attributes[key2] = attrs[key2];
15969
- processedMarks.push({ name: key2, attrs: attributes });
16039
+ attributes[key] = attrs[key];
16040
+ processedMarks.push({ name: key, attrs: attributes });
15970
16041
  });
15971
16042
  } else {
15972
16043
  processedMarks.push({ name, attrs });
@@ -15981,13 +16052,13 @@ const FormatCommands = Extension.create({
15981
16052
  fontFamily: ["setFontFamily", "unsetFontFamily"]
15982
16053
  };
15983
16054
  let result = chain();
15984
- Object.keys(marksToCommands).forEach((key2) => {
15985
- const [setCommand, unsetCommand, defaultParam] = marksToCommands[key2];
15986
- const markToApply = processedMarks.find((mark) => mark.name === key2);
15987
- const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key2];
16055
+ Object.keys(marksToCommands).forEach((key) => {
16056
+ const [setCommand, unsetCommand, defaultParam] = marksToCommands[key];
16057
+ const markToApply = processedMarks.find((mark) => mark.name === key);
16058
+ const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key];
15988
16059
  let cmd = {};
15989
16060
  if (!markToApply && !hasEmptyAttrs) cmd = { command: unsetCommand, argument: defaultParam };
15990
- else cmd = { command: setCommand, argument: markToApply.attrs[key2] || defaultParam };
16061
+ else cmd = { command: setCommand, argument: markToApply.attrs[key] || defaultParam };
15991
16062
  result = result[cmd.command](cmd.argument);
15992
16063
  });
15993
16064
  this.storage.storedStyle = null;
@@ -16356,9 +16427,6 @@ function drawGapCursor(state) {
16356
16427
  }
16357
16428
  const Gapcursor = Extension.create({
16358
16429
  name: "gapCursor",
16359
- addOptions() {
16360
- return {};
16361
- },
16362
16430
  addPmPlugins() {
16363
16431
  return [gapCursor()];
16364
16432
  },
@@ -16699,9 +16767,6 @@ function getCursorPositionRelativeToContainer(view, eventLocation) {
16699
16767
  const SlashMenuPluginKey = new PluginKey("slashMenu");
16700
16768
  const SlashMenu = Extension.create({
16701
16769
  name: "slashMenu",
16702
- addOptions() {
16703
- return {};
16704
- },
16705
16770
  addPmPlugins() {
16706
16771
  if (this.editor.options?.disableContextMenu) {
16707
16772
  return [];
@@ -16839,6 +16904,11 @@ const Document = Node$1.create({
16839
16904
  },
16840
16905
  addAttributes() {
16841
16906
  return {
16907
+ /**
16908
+ * @private
16909
+ * @category Attribute
16910
+ * @param {Object} [attributes] - Internal document attributes
16911
+ */
16842
16912
  attributes: {
16843
16913
  rendered: false,
16844
16914
  "aria-label": "Document node"
@@ -16850,10 +16920,10 @@ const Document = Node$1.create({
16850
16920
  /**
16851
16921
  * Get document statistics
16852
16922
  * @category Command
16923
+ * @returns {Function} Command function
16853
16924
  * @example
16854
16925
  * // Get word and character count
16855
- * const stats = editor.commands.getDocumentStats()
16856
- * console.log(`${stats.words} words, ${stats.characters} characters`)
16926
+ * getDocumentStats()
16857
16927
  * @note Returns word count, character count, and paragraph count
16858
16928
  */
16859
16929
  getDocumentStats: () => ({ editor }) => {
@@ -16870,8 +16940,9 @@ const Document = Node$1.create({
16870
16940
  /**
16871
16941
  * Clear entire document
16872
16942
  * @category Command
16943
+ * @returns {Function} Command function
16873
16944
  * @example
16874
- * editor.commands.clearDocument()
16945
+ * clearDocument()
16875
16946
  * @note Replaces all content with an empty paragraph
16876
16947
  */
16877
16948
  clearDocument: () => ({ commands: commands2 }) => {
@@ -16883,19 +16954,13 @@ const Document = Node$1.create({
16883
16954
  const Text = Node$1.create({
16884
16955
  name: "text",
16885
16956
  group: "inline",
16886
- inline: true,
16887
- addOptions() {
16888
- return {};
16889
- }
16957
+ inline: true
16890
16958
  });
16891
16959
  const RunItem = Node$1.create({
16892
16960
  name: "run",
16893
16961
  group: "inline",
16894
16962
  content: "text*",
16895
16963
  inline: true,
16896
- addOptions() {
16897
- return {};
16898
- },
16899
16964
  parseDOM() {
16900
16965
  return [{ tag: "run" }];
16901
16966
  },
@@ -16921,6 +16986,14 @@ const BulletList = Node$1.create({
16921
16986
  },
16922
16987
  addOptions() {
16923
16988
  return {
16989
+ /**
16990
+ * @typedef {Object} BulletListOptions
16991
+ * @category Options
16992
+ * @property {string} [itemTypeName='listItem'] - Name of the list item node type
16993
+ * @property {Object} [htmlAttributes] - HTML attributes for the ul element
16994
+ * @property {boolean} [keepMarks=true] - Whether to preserve marks when splitting
16995
+ * @property {boolean} [keepAttributes=false] - Whether to preserve attributes when splitting
16996
+ */
16924
16997
  itemTypeName: "listItem",
16925
16998
  htmlAttributes: {
16926
16999
  "aria-label": "Bullet list node"
@@ -16938,13 +17011,27 @@ const BulletList = Node$1.create({
16938
17011
  },
16939
17012
  addAttributes() {
16940
17013
  return {
17014
+ /**
17015
+ * @category Attribute
17016
+ * @param {string} [list-style-type='bullet'] - List style type for this list
17017
+ */
16941
17018
  "list-style-type": {
16942
17019
  default: "bullet",
16943
17020
  rendered: false
16944
17021
  },
17022
+ /**
17023
+ * @private
17024
+ * @category Attribute
17025
+ * @param {string} [listId] - Internal list identifier for numbering
17026
+ */
16945
17027
  listId: {
16946
17028
  rendered: false
16947
17029
  },
17030
+ /**
17031
+ * @private
17032
+ * @category Attribute
17033
+ * @param {string} [sdBlockId] - Internal block tracking ID
17034
+ */
16948
17035
  sdBlockId: {
16949
17036
  default: null,
16950
17037
  keepOnSplit: false,
@@ -16953,6 +17040,11 @@ const BulletList = Node$1.create({
16953
17040
  return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
16954
17041
  }
16955
17042
  },
17043
+ /**
17044
+ * @private
17045
+ * @category Attribute
17046
+ * @param {Object} [attributes] - Additional attributes for the list
17047
+ */
16956
17048
  attributes: {
16957
17049
  rendered: false,
16958
17050
  keepOnSplit: true
@@ -16964,9 +17056,10 @@ const BulletList = Node$1.create({
16964
17056
  /**
16965
17057
  * Toggle a bullet list at the current selection
16966
17058
  * @category Command
17059
+ * @returns {Function} Command function
16967
17060
  * @example
16968
17061
  * // Toggle bullet list on selected text
16969
- * editor.commands.toggleBulletList()
17062
+ * toggleBulletList()
16970
17063
  * @note Converts selected paragraphs to list items or removes list formatting
16971
17064
  */
16972
17065
  toggleBulletList: () => (params2) => {
@@ -17085,25 +17178,9 @@ const OrderedList = Node$1.create({
17085
17178
  },
17086
17179
  addCommands() {
17087
17180
  return {
17088
- /**
17089
- * Toggle ordered list formatting
17090
- * @category Command
17091
- * @example
17092
- * editor.commands.toggleOrderedList()
17093
- * @note Converts selection to ordered list or back to paragraphs
17094
- */
17095
17181
  toggleOrderedList: () => (params2) => {
17096
17182
  return toggleList(this.type)(params2);
17097
17183
  },
17098
- /**
17099
- * Restart list node numbering
17100
- * @category Command
17101
- * @param {Array} followingNodes - Nodes to restart
17102
- * @param {number} pos - Starting position
17103
- * @example
17104
- * editor.commands.restartListNodes(nodes, position)
17105
- * @note Resets list numbering for specified nodes
17106
- */
17107
17184
  restartListNodes: (followingNodes, pos) => ({ tr }) => {
17108
17185
  let currentNodePos = pos;
17109
17186
  const nodes = followingNodes.map((node) => {
@@ -17122,11 +17199,8 @@ const OrderedList = Node$1.create({
17122
17199
  return true;
17123
17200
  },
17124
17201
  /**
17125
- * Update ordered list style type based on nesting level
17126
- * @category Command
17127
- * @example
17128
- * editor.commands.updateOrderedListStyleType()
17129
- * @note Cycles through decimal -> lowerAlpha -> lowerRoman based on depth
17202
+ * Updates ordered list style type when sink or lift `listItem`.
17203
+ * @example 1,2,3 -> a,b,c -> i,ii,iii -> 1,2,3 -> etc
17130
17204
  */
17131
17205
  updateOrderedListStyleType: () => ({ dispatch, tr }) => {
17132
17206
  let list = findParentNode((node) => node.type.name === this.name)(tr.selection);
@@ -17403,7 +17477,7 @@ const CustomSelection = Extension.create({
17403
17477
  * @returns {Function} Command function
17404
17478
  * @example
17405
17479
  * // Restore selection after toolbar interaction
17406
- * editor.commands.restorePreservedSelection()
17480
+ * restorePreservedSelection()
17407
17481
  * @note Used internally to maintain selection when interacting with toolbar
17408
17482
  */
17409
17483
  restorePreservedSelection: () => ({ tr, state }) => {
@@ -17488,7 +17562,7 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
17488
17562
  resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
17489
17563
  }
17490
17564
  Object.entries(resultStyles).forEach(([k, value]) => {
17491
- const key2 = kebabCase(k);
17565
+ const key = kebabCase(k);
17492
17566
  const flattenedMarks = [];
17493
17567
  node?.marks?.forEach((n) => {
17494
17568
  if (n.type.name === "textStyle") {
@@ -17499,46 +17573,46 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
17499
17573
  });
17500
17574
  return;
17501
17575
  }
17502
- flattenedMarks.push({ key: n.type.name, value: n.attrs[key2] });
17576
+ flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
17503
17577
  });
17504
- const mark = flattenedMarks.find((n) => n.key === key2);
17578
+ const mark = flattenedMarks.find((n) => n.key === key);
17505
17579
  const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
17506
17580
  const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
17507
17581
  const listTypes = ["orderedList", "listItem"];
17508
17582
  if (!mark) {
17509
- if (key2 === "spacing" && includeSpacing && !hasParentSpacing) {
17583
+ if (key === "spacing" && includeSpacing && !hasParentSpacing) {
17510
17584
  const space = getSpacingStyle(value);
17511
17585
  Object.entries(space).forEach(([k2, v]) => {
17512
17586
  markValue[k2] = v;
17513
17587
  });
17514
- } else if (key2 === "indent" && includeSpacing && !hasParentIndent) {
17588
+ } else if (key === "indent" && includeSpacing && !hasParentIndent) {
17515
17589
  const { leftIndent, rightIndent, firstLine } = value;
17516
17590
  if (leftIndent) markValue["margin-left"] = leftIndent + "px";
17517
17591
  if (rightIndent) markValue["margin-right"] = rightIndent + "px";
17518
17592
  if (firstLine) markValue["text-indent"] = firstLine + "px";
17519
- } else if (key2 === "bold" && node) {
17593
+ } else if (key === "bold" && node) {
17520
17594
  const val = value?.value;
17521
17595
  if (!listTypes.includes(node.type.name) && val !== "0") {
17522
17596
  markValue["font-weight"] = "bold";
17523
17597
  }
17524
- } else if (key2 === "text-transform" && node) {
17598
+ } else if (key === "text-transform" && node) {
17525
17599
  if (!listTypes.includes(node.type.name)) {
17526
- markValue[key2] = value;
17600
+ markValue[key] = value;
17527
17601
  }
17528
- } else if (key2 === "font-size" && node) {
17602
+ } else if (key === "font-size" && node) {
17529
17603
  if (!listTypes.includes(node.type.name)) {
17530
- markValue[key2] = value;
17604
+ markValue[key] = value;
17531
17605
  }
17532
- } else if (key2 === "color" && node) {
17606
+ } else if (key === "color" && node) {
17533
17607
  if (!listTypes.includes(node.type.name)) {
17534
- markValue[key2] = value;
17608
+ markValue[key] = value;
17535
17609
  }
17536
17610
  } else if (typeof value === "string") {
17537
- markValue[key2] = value;
17611
+ markValue[key] = value;
17538
17612
  }
17539
17613
  }
17540
17614
  });
17541
- const final = Object.entries(markValue).map(([key2, value]) => `${key2}: ${value}`).join(";");
17615
+ const final = Object.entries(markValue).map(([key, value]) => `${key}: ${value}`).join(";");
17542
17616
  return final;
17543
17617
  };
17544
17618
  const applyLinkedStyleToTransaction = (tr, editor, style) => {
@@ -17692,9 +17766,6 @@ const LinkedStyles = Extension.create({
17692
17766
  name: "linkedStyles",
17693
17767
  priority: 1,
17694
17768
  // We need this plugin to run before the list plugins
17695
- addOptions() {
17696
- return {};
17697
- },
17698
17769
  addPmPlugins() {
17699
17770
  return [createLinkedStylesPlugin(this.editor)];
17700
17771
  },
@@ -17703,10 +17774,11 @@ const LinkedStyles = Extension.create({
17703
17774
  /**
17704
17775
  * Apply a linked style to the selected paragraphs
17705
17776
  * @category Command
17706
- * @param {LinkedStyle} style - The style object to apply
17777
+ * @param {Object} style - The style object to apply
17778
+ * @returns {Function} Command function
17707
17779
  * @example
17708
17780
  * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
17709
- * editor.commands.setLinkedStyle(style);
17781
+ * setLinkedStyle(style);
17710
17782
  * @note Clears existing formatting when applying a style
17711
17783
  * @note Works with custom selection preservation
17712
17784
  */
@@ -17717,12 +17789,16 @@ const LinkedStyles = Extension.create({
17717
17789
  /**
17718
17790
  * Toggle a linked style on the current selection
17719
17791
  * @category Command
17720
- * @param {LinkedStyle} style - The linked style to apply (with id property)
17792
+ * @param {Object} style - The linked style to apply (with id property)
17721
17793
  * @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
17794
+ * @returns {Function} Command function
17722
17795
  * @example
17796
+ * // Toggle a heading style
17723
17797
  * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
17724
- * editor.commands.toggleLinkedStyle(style)
17725
- * editor.commands.toggleLinkedStyle(style, 'paragraph')
17798
+ * toggleLinkedStyle(style)
17799
+ *
17800
+ * // Toggle only on paragraph nodes
17801
+ * toggleLinkedStyle(style, 'paragraph')
17726
17802
  * @note If selection is empty, returns false
17727
17803
  * @note Removes style if already applied, applies it if not
17728
17804
  */
@@ -17750,9 +17826,13 @@ const LinkedStyles = Extension.create({
17750
17826
  * Apply a linked style by its ID
17751
17827
  * @category Command
17752
17828
  * @param {string} styleId - The style ID to apply (e.g., 'Heading1')
17829
+ * @returns {Function} Command function
17753
17830
  * @example
17754
- * editor.commands.setStyleById('Heading1')
17755
- * editor.commands.setStyleById('Normal')
17831
+ * // Apply a heading style
17832
+ * setStyleById('Heading1')
17833
+ *
17834
+ * // Apply a normal style
17835
+ * setStyleById('Normal')
17756
17836
  * @note Looks up the style from loaded Word styles
17757
17837
  */
17758
17838
  setStyleById: (styleId) => (params2) => {
@@ -18227,7 +18307,7 @@ function orderedListSync(editor) {
18227
18307
  listNumberingType,
18228
18308
  customFormat
18229
18309
  };
18230
- const keysChanged = Object.keys(updatedAttrs).some((key2) => node.attrs[key2] !== updatedAttrs[key2]);
18310
+ const keysChanged = Object.keys(updatedAttrs).some((key) => node.attrs[key] !== updatedAttrs[key]);
18231
18311
  if (keysChanged) {
18232
18312
  tr.setNodeMarkup(pos, void 0, updatedAttrs);
18233
18313
  }
@@ -18460,6 +18540,12 @@ const Paragraph = OxmlNode.create({
18460
18540
  inline: false,
18461
18541
  addOptions() {
18462
18542
  return {
18543
+ /**
18544
+ * @typedef {Object} HeadingOptions
18545
+ * @category Options
18546
+ * @property {number[]} [headingLevels=[1,2,3,4,5,6]] - Supported heading levels
18547
+ * @property {Object} [htmlAttributes] - HTML attributes for paragraph elements
18548
+ */
18463
18549
  headingLevels: [1, 2, 3, 4, 5, 6],
18464
18550
  htmlAttributes: {}
18465
18551
  };
@@ -18691,6 +18777,11 @@ const Heading = Extension.create({
18691
18777
  name: "heading",
18692
18778
  addOptions() {
18693
18779
  return {
18780
+ /**
18781
+ * @typedef {Object} HeadingOptions
18782
+ * @category Options
18783
+ * @property {number[]} [levels=[1,2,3,4,5,6]] - Supported heading levels
18784
+ */
18694
18785
  levels: [1, 2, 3, 4, 5, 6]
18695
18786
  };
18696
18787
  },
@@ -18700,8 +18791,10 @@ const Heading = Extension.create({
18700
18791
  * Set a heading with specified level
18701
18792
  * @category Command
18702
18793
  * @param {HeadingAttributes} attributes - Heading attributes including level
18794
+ * @returns {Function} Command function
18703
18795
  * @example
18704
- * editor.commands.setHeading({ level: 2 })
18796
+ * // Set heading level 2
18797
+ * setHeading({ level: 2 })
18705
18798
  * @note Converts current block to heading
18706
18799
  */
18707
18800
  setHeading: (attributes) => ({ commands: commands2 }) => {
@@ -18713,9 +18806,13 @@ const Heading = Extension.create({
18713
18806
  * Toggle between heading and paragraph
18714
18807
  * @category Command
18715
18808
  * @param {HeadingAttributes} attributes - Heading attributes including level
18809
+ * @returns {Function} Command function
18716
18810
  * @example
18717
- * editor.commands.toggleHeading({ level: 1 })
18718
- * editor.commands.toggleHeading({ level: 3 })
18811
+ * // Toggle heading level 1
18812
+ * toggleHeading({ level: 1 })
18813
+ *
18814
+ * // Toggle heading level 3
18815
+ * toggleHeading({ level: 3 })
18719
18816
  * @note Switches between heading and paragraph for the same level
18720
18817
  */
18721
18818
  toggleHeading: (attributes) => ({ commands: commands2 }) => {
@@ -19120,9 +19217,6 @@ const LineBreak = Node$1.create({
19120
19217
  selectable: false,
19121
19218
  content: "",
19122
19219
  atom: true,
19123
- addOptions() {
19124
- return {};
19125
- },
19126
19220
  parseDOM() {
19127
19221
  return [{ tag: "br" }];
19128
19222
  },
@@ -19131,7 +19225,17 @@ const LineBreak = Node$1.create({
19131
19225
  },
19132
19226
  addAttributes() {
19133
19227
  return {
19228
+ /**
19229
+ * @private
19230
+ * @category Attribute
19231
+ * @param {string} [lineBreakType] - Type of line break - passthrough in this node
19232
+ */
19134
19233
  lineBreakType: { rendered: false },
19234
+ /**
19235
+ * @private
19236
+ * @category Attribute
19237
+ * @param {string} [clear] - Clear attribute - passthrough in this node
19238
+ */
19135
19239
  clear: { rendered: false }
19136
19240
  };
19137
19241
  },
@@ -19140,8 +19244,9 @@ const LineBreak = Node$1.create({
19140
19244
  /**
19141
19245
  * Insert a line break
19142
19246
  * @category Command
19247
+ * @returns {Function} Command function
19143
19248
  * @example
19144
- * editor.commands.insertLineBreak()
19249
+ * insertLineBreak()
19145
19250
  * @note Creates a soft break within the same paragraph
19146
19251
  */
19147
19252
  insertLineBreak: () => ({ commands: commands2 }) => {
@@ -19158,6 +19263,11 @@ const HardBreak = Node$1.create({
19158
19263
  atom: true,
19159
19264
  addOptions() {
19160
19265
  return {
19266
+ /**
19267
+ * @typedef {Object} HardBreakOptions
19268
+ * @category Options
19269
+ * @property {Object} [htmlAttributes] - HTML attributes for the break element
19270
+ */
19161
19271
  htmlAttributes: {
19162
19272
  contentEditable: "false",
19163
19273
  lineBreakType: "page",
@@ -19168,15 +19278,35 @@ const HardBreak = Node$1.create({
19168
19278
  },
19169
19279
  addAttributes() {
19170
19280
  return {
19281
+ /**
19282
+ * @private
19283
+ * @category Attribute
19284
+ * @param {string} [pageBreakSource] - Source of the page break
19285
+ */
19171
19286
  pageBreakSource: {
19172
19287
  rendered: false,
19173
19288
  default: null
19174
19289
  },
19290
+ /**
19291
+ * @private
19292
+ * @category Attribute
19293
+ * @param {string} [pageBreakType] - Type of page break
19294
+ */
19175
19295
  pageBreakType: {
19176
19296
  default: null,
19177
19297
  rendered: false
19178
19298
  },
19299
+ /**
19300
+ * @private
19301
+ * @category Attribute
19302
+ * @param {string} [lineBreakType] - Type of line break - passthrough in this node
19303
+ */
19179
19304
  lineBreakType: { rendered: false },
19305
+ /**
19306
+ * @private
19307
+ * @category Attribute
19308
+ * @param {string} [clear] - Clear attribute - passthrough in this node
19309
+ */
19180
19310
  clear: { rendered: false }
19181
19311
  };
19182
19312
  },
@@ -19202,8 +19332,9 @@ const HardBreak = Node$1.create({
19202
19332
  /**
19203
19333
  * Insert a page break
19204
19334
  * @category Command
19335
+ * @returns {Function} Command function
19205
19336
  * @example
19206
- * editor.commands.insertPageBreak()
19337
+ * insertPageBreak()
19207
19338
  * @note Forces content to start on a new page when printed
19208
19339
  */
19209
19340
  insertPageBreak: () => ({ commands: commands2 }) => {
@@ -19215,12 +19346,6 @@ const HardBreak = Node$1.create({
19215
19346
  };
19216
19347
  }
19217
19348
  });
19218
- const getColStyleDeclaration = (minWidth, width) => {
19219
- if (width) {
19220
- return ["width", `${Math.max(width, minWidth)}px`];
19221
- }
19222
- return ["min-width", `${minWidth}px`];
19223
- };
19224
19349
  const createTableView = ({ editor }) => {
19225
19350
  return class TableView {
19226
19351
  constructor(node, cellMinWidth) {
@@ -19309,11 +19434,11 @@ function updateTable(editor, node, table) {
19309
19434
  const allExtensionsAttrs = editor.extensionService.attributes;
19310
19435
  const tableExtensionAttrs = allExtensionsAttrs.filter((e) => e.type === "table");
19311
19436
  const htmlAttributes = Attribute.getAttributesToRender(node, tableExtensionAttrs);
19312
- Object.entries(htmlAttributes).forEach(([key2, value]) => {
19313
- if (key2 === "style") {
19437
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
19438
+ if (key === "style") {
19314
19439
  table.style.cssText = value;
19315
19440
  } else {
19316
- table.setAttribute(key2, value);
19441
+ table.setAttribute(key, value);
19317
19442
  }
19318
19443
  });
19319
19444
  }
@@ -19381,55 +19506,26 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
19381
19506
  const tableBorders = createTableBorders();
19382
19507
  return types.table.createChecked({ borders: tableBorders }, rows);
19383
19508
  };
19384
- const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
19385
- let totalWidth = 0;
19386
- let fixedWidth = true;
19387
- const cols = [];
19388
- const colsValues = [];
19389
- const row = node.firstChild;
19390
- if (!row) return {};
19391
- for (let i = 0, col = 0; i < row.childCount; i++) {
19392
- const { colspan, colwidth } = row.child(i).attrs;
19393
- for (let j = 0; j < colspan; j++, col++) {
19394
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
19395
- totalWidth += hasWidth || cellMinWidth;
19396
- if (!hasWidth) fixedWidth = false;
19397
- const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
19398
- cols.push(["col", { style: `${prop}: ${value}` }]);
19399
- colsValues.push(parseInt(value, 10));
19400
- }
19401
- }
19402
- const tableWidth = fixedWidth ? `${totalWidth}px` : "";
19403
- const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
19404
- const colgroup = ["colgroup", {}, ...cols];
19405
- const colgroupValues = [...colsValues];
19406
- return {
19407
- colgroup,
19408
- tableWidth,
19409
- tableMinWidth,
19410
- colgroupValues
19411
- };
19412
- };
19413
19509
  var readFromCache;
19414
19510
  var addToCache;
19415
19511
  if (typeof WeakMap != "undefined") {
19416
19512
  let cache = /* @__PURE__ */ new WeakMap();
19417
- readFromCache = (key2) => cache.get(key2);
19418
- addToCache = (key2, value) => {
19419
- cache.set(key2, value);
19513
+ readFromCache = (key) => cache.get(key);
19514
+ addToCache = (key, value) => {
19515
+ cache.set(key, value);
19420
19516
  return value;
19421
19517
  };
19422
19518
  } else {
19423
19519
  const cache = [];
19424
19520
  const cacheSize = 10;
19425
19521
  let cachePos = 0;
19426
- readFromCache = (key2) => {
19522
+ readFromCache = (key) => {
19427
19523
  for (let i = 0; i < cache.length; i += 2)
19428
- if (cache[i] == key2) return cache[i + 1];
19524
+ if (cache[i] == key) return cache[i + 1];
19429
19525
  };
19430
- addToCache = (key2, value) => {
19526
+ addToCache = (key, value) => {
19431
19527
  if (cachePos == cacheSize) cachePos = 0;
19432
- cache[cachePos++] = key2;
19528
+ cache[cachePos++] = key;
19433
19529
  return cache[cachePos++] = value;
19434
19530
  };
19435
19531
  }
@@ -21593,6 +21689,17 @@ const Table = Node$1.create({
21593
21689
  group: "block",
21594
21690
  isolating: true,
21595
21691
  tableRole: "table",
21692
+ /**
21693
+ * Table extension options
21694
+ * @category Options
21695
+ * @typedef {Object} TableOptions
21696
+ * @property {Object} [htmlAttributes={'aria-label': 'Table node'}] - Default HTML attributes for all tables
21697
+ * @property {boolean} [resizable=true] - Enable column resizing functionality
21698
+ * @property {number} [handleWidth=5] - Width of resize handles in pixels
21699
+ * @property {number} [cellMinWidth=10] - Minimum cell width constraint in pixels
21700
+ * @property {boolean} [lastColumnResizable=true] - Allow resizing of the last column
21701
+ * @property {boolean} [allowTableNodeSelection=false] - Enable selecting the entire table node
21702
+ */
21596
21703
  addOptions() {
21597
21704
  return {
21598
21705
  htmlAttributes: {
@@ -21652,8 +21759,8 @@ const Table = Node$1.create({
21652
21759
  default: {},
21653
21760
  renderDOM({ borders }) {
21654
21761
  if (!borders) return {};
21655
- const style = Object.entries(borders).reduce((acc, [key2, { size, color }]) => {
21656
- return `${acc}border-${key2}: ${Math.ceil(size)}px solid ${color || "black"};`;
21762
+ const style = Object.entries(borders).reduce((acc, [key, { size, color }]) => {
21763
+ return `${acc}border-${key}: ${Math.ceil(size)}px solid ${color || "black"};`;
21657
21764
  }, "");
21658
21765
  return {
21659
21766
  style
@@ -21712,24 +21819,6 @@ const Table = Node$1.create({
21712
21819
  tableCellSpacing: {
21713
21820
  default: null,
21714
21821
  rendered: false
21715
- },
21716
- /**
21717
- * @category Attribute
21718
- * @param {TableProperties} [tableProperties] - Properties for the table.
21719
- * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
21720
- */
21721
- tableProperties: {
21722
- default: null,
21723
- rendered: false
21724
- },
21725
- /**
21726
- * @category Attribute
21727
- * @param {TableGrid} [grid] - Grid definition for the table
21728
- * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 432
21729
- */
21730
- grid: {
21731
- default: null,
21732
- rendered: false
21733
21822
  }
21734
21823
  };
21735
21824
  },
@@ -21750,9 +21839,14 @@ const Table = Node$1.create({
21750
21839
  * Insert a new table into the document
21751
21840
  * @category Command
21752
21841
  * @param {TableConfig} [config] - Table configuration options
21842
+ * @returns {Function} Command
21753
21843
  * @example
21754
- * editor.commands.insertTable()
21755
- * editor.commands.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
21844
+ * // Using default values
21845
+ * insertTable() // Creates 3x3 table without header
21846
+ *
21847
+ * // Using custom values
21848
+ * insertTable({ rows: 3, cols: 3, withHeaderRow: true })
21849
+ *
21756
21850
  */
21757
21851
  insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
21758
21852
  const node = createTable(editor.schema, rows, cols, withHeaderRow);
@@ -21765,8 +21859,9 @@ const Table = Node$1.create({
21765
21859
  /**
21766
21860
  * Delete the entire table containing the cursor
21767
21861
  * @category Command
21862
+ * @returns {Function} Command
21768
21863
  * @example
21769
- * editor.commands.deleteTable()
21864
+ * deleteTable()
21770
21865
  */
21771
21866
  deleteTable: () => ({ state, dispatch }) => {
21772
21867
  return deleteTable(state, dispatch);
@@ -21774,8 +21869,9 @@ const Table = Node$1.create({
21774
21869
  /**
21775
21870
  * Add a column before the current column
21776
21871
  * @category Command
21872
+ * @returns {Function} Command
21777
21873
  * @example
21778
- * editor.commands.addColumnBefore()
21874
+ * addColumnBefore()
21779
21875
  * @note Preserves cell attributes from current column
21780
21876
  */
21781
21877
  addColumnBefore: () => ({ state, dispatch, chain }) => {
@@ -22152,9 +22248,10 @@ const Table = Node$1.create({
22152
22248
  * Set background color for selected cells
22153
22249
  * @category Command
22154
22250
  * @param {string} value - Color value (hex with or without #)
22251
+ * @returns {Function} Command
22155
22252
  * @example
22156
- * editor.commands.setCellBackground('#ff0000')
22157
- * editor.commands.setCellBackground('ff0000')
22253
+ * setCellBackground('#ff0000')
22254
+ * setCellBackground('ff0000')
22158
22255
  */
22159
22256
  setCellBackground: (value) => ({ editor, commands: commands2, dispatch }) => {
22160
22257
  const { selection } = editor.state;
@@ -22280,12 +22377,24 @@ const TableHeader = Node$1.create({
22280
22377
  },
22281
22378
  addAttributes() {
22282
22379
  return {
22380
+ /**
22381
+ * @category Attribute
22382
+ * @param {number} [colspan=1] - Number of columns this header spans
22383
+ */
22283
22384
  colspan: {
22284
22385
  default: 1
22285
22386
  },
22387
+ /**
22388
+ * @category Attribute
22389
+ * @param {number} [rowspan=1] - Number of rows this header spans
22390
+ */
22286
22391
  rowspan: {
22287
22392
  default: 1
22288
22393
  },
22394
+ /**
22395
+ * @category Attribute
22396
+ * @param {number[]} [colwidth] - Column widths array in pixels
22397
+ */
22289
22398
  colwidth: {
22290
22399
  default: null,
22291
22400
  parseDOM: (element) => {
@@ -22322,6 +22431,10 @@ const TableRow = Node$1.create({
22322
22431
  },
22323
22432
  addAttributes() {
22324
22433
  return {
22434
+ /**
22435
+ * @category Attribute
22436
+ * @param {number} [rowHeight] - Fixed row height in pixels
22437
+ */
22325
22438
  rowHeight: {
22326
22439
  renderDOM({ rowHeight }) {
22327
22440
  if (!rowHeight) return {};
@@ -22329,6 +22442,11 @@ const TableRow = Node$1.create({
22329
22442
  return { style };
22330
22443
  }
22331
22444
  },
22445
+ /**
22446
+ * Indicates that this row should not be split across pages when paginating/exporting.
22447
+ * @category Attribute
22448
+ * @param {boolean} [cantSplit]
22449
+ */
22332
22450
  cantSplit: {
22333
22451
  default: false,
22334
22452
  parseDOM() {
@@ -22340,30 +22458,44 @@ const TableRow = Node$1.create({
22340
22458
  }
22341
22459
  },
22342
22460
  /**
22461
+ * @category Attribute
22462
+ * @param {TableRowProperties} [tableRowProperties] - Properties for the table row.
22343
22463
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 377-482
22344
22464
  */
22345
22465
  tableRowProperties: { rendered: false },
22346
22466
  /**
22467
+ * @category Attribute
22468
+ * @param {string} [rsidDel] - Unique identifier used to track the editing session when the row was deleted from the main document.
22347
22469
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 472
22348
22470
  */
22349
22471
  rsidDel: { rendered: false },
22350
22472
  /**
22473
+ * @category Attribute
22474
+ * @param {string} [rsidR] - Unique identifier used to track the editing session when the table row was added to the main document.
22351
22475
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 472
22352
22476
  */
22353
22477
  rsidR: { rendered: false },
22354
22478
  /**
22479
+ * @category Attribute
22480
+ * @param {string} [rsidRPr] - Unique identifier used to track the editing session when the glyph character representing the table row mark was last modified in the main document.
22355
22481
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 473
22356
22482
  */
22357
22483
  rsidRPr: { rendered: false },
22358
22484
  /**
22485
+ * @category Attribute
22486
+ * @param {string} [rsidTr] - Unique identifier used to track the editing session when the table row's properties were last modified in this document.
22359
22487
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 473
22360
22488
  */
22361
22489
  rsidTr: { rendered: false },
22362
22490
  /**
22491
+ * @category Attribute
22492
+ * @param {string} [paraId] - A randomly generated unique identifier for the table row.
22363
22493
  * @see {@link https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/a0e7d2e2-2246-44c6-96e8-1cf009823615}
22364
22494
  */
22365
22495
  paraId: { rendered: false },
22366
22496
  /**
22497
+ * @category Attribute
22498
+ * @param {string} [textId] - A randomly generated unique identifier for the text of the table row.
22367
22499
  * @see {@link https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/b7eeddec-7c50-47fb-88b6-1feec3ed832c}
22368
22500
  */
22369
22501
  textId: { rendered: false }
@@ -22390,12 +22522,24 @@ const TableCell = Node$1.create({
22390
22522
  },
22391
22523
  addAttributes() {
22392
22524
  return {
22525
+ /**
22526
+ * @category Attribute
22527
+ * @param {number} [colspan=1] - Number of columns this cell spans
22528
+ */
22393
22529
  colspan: {
22394
22530
  default: 1
22395
22531
  },
22532
+ /**
22533
+ * @category Attribute
22534
+ * @param {number} [rowspan=1] - Number of rows this cell spans
22535
+ */
22396
22536
  rowspan: {
22397
22537
  default: 1
22398
22538
  },
22539
+ /**
22540
+ * @category Attribute
22541
+ * @param {number[]} [colwidth=[100]] - Column widths array in pixels
22542
+ */
22399
22543
  colwidth: {
22400
22544
  default: [100],
22401
22545
  parseDOM: (elem) => {
@@ -22410,6 +22554,10 @@ const TableCell = Node$1.create({
22410
22554
  };
22411
22555
  }
22412
22556
  },
22557
+ /**
22558
+ * @category Attribute
22559
+ * @param {CellBackground} [background] - Cell background color configuration
22560
+ */
22413
22561
  background: {
22414
22562
  renderDOM({ background }) {
22415
22563
  if (!background) return {};
@@ -22418,6 +22566,10 @@ const TableCell = Node$1.create({
22418
22566
  return { style };
22419
22567
  }
22420
22568
  },
22569
+ /**
22570
+ * @category Attribute
22571
+ * @param {string} [verticalAlign] - Vertical content alignment (top, middle, bottom)
22572
+ */
22421
22573
  verticalAlign: {
22422
22574
  renderDOM({ verticalAlign }) {
22423
22575
  if (!verticalAlign) return {};
@@ -22425,6 +22577,10 @@ const TableCell = Node$1.create({
22425
22577
  return { style };
22426
22578
  }
22427
22579
  },
22580
+ /**
22581
+ * @category Attribute
22582
+ * @param {CellMargins} [cellMargins] - Internal cell padding
22583
+ */
22428
22584
  cellMargins: {
22429
22585
  renderDOM({ cellMargins }) {
22430
22586
  if (!cellMargins) return {};
@@ -22437,6 +22593,10 @@ const TableCell = Node$1.create({
22437
22593
  return { style };
22438
22594
  }
22439
22595
  },
22596
+ /**
22597
+ * @category Attribute
22598
+ * @param {CellBorders} [borders] - Cell border configuration
22599
+ */
22440
22600
  borders: {
22441
22601
  default: () => createCellBorders(),
22442
22602
  renderDOM({ borders }) {
@@ -22451,10 +22611,20 @@ const TableCell = Node$1.create({
22451
22611
  return { style };
22452
22612
  }
22453
22613
  },
22614
+ /**
22615
+ * @private
22616
+ * @category Attribute
22617
+ * @param {string} [widthType='auto'] - Internal width type
22618
+ */
22454
22619
  widthType: {
22455
22620
  default: "auto",
22456
22621
  rendered: false
22457
22622
  },
22623
+ /**
22624
+ * @private
22625
+ * @category Attribute
22626
+ * @param {string} [widthUnit='px'] - Internal width unit
22627
+ */
22458
22628
  widthUnit: {
22459
22629
  default: "px",
22460
22630
  rendered: false
@@ -22705,11 +22875,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
22705
22875
  let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
22706
22876
  style: omitHighlight ? "" : annotationStyle
22707
22877
  });
22708
- for (let [key2, value] of Object.entries(mergedAttrs)) {
22709
- if (key2 === "style") {
22878
+ for (let [key, value] of Object.entries(mergedAttrs)) {
22879
+ if (key === "style") {
22710
22880
  annotation.style.cssText = value;
22711
22881
  } else {
22712
- annotation.setAttribute(key2, value);
22882
+ annotation.setAttribute(key, value);
22713
22883
  }
22714
22884
  }
22715
22885
  return {
@@ -22883,13 +23053,13 @@ function hash$2(str) {
22883
23053
  }
22884
23054
  const colorToInt = (x) => parseInt(x.replace(/_/g, ""), 36);
22885
23055
  const compressedColorMap = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((acc, next) => {
22886
- const key2 = colorToInt(next.substring(0, 3));
23056
+ const key = colorToInt(next.substring(0, 3));
22887
23057
  const hex = colorToInt(next.substring(3)).toString(16);
22888
23058
  let prefix = "";
22889
23059
  for (let i = 0; i < 6 - hex.length; i++) {
22890
23060
  prefix += "0";
22891
23061
  }
22892
- acc[key2] = `${prefix}${hex}`;
23062
+ acc[key] = `${prefix}${hex}`;
22893
23063
  return acc;
22894
23064
  }, {});
22895
23065
  function nameToHex(color) {
@@ -24005,552 +24175,41 @@ function getFormatAttrsFromMarks(marks) {
24005
24175
  }
24006
24176
  return formatAttrs;
24007
24177
  }
24008
- const simpleHash = (str) => {
24009
- let hash2 = 0;
24010
- for (let i = 0; i < str.length; i++) {
24011
- const char = str.charCodeAt(i);
24012
- hash2 = (hash2 << 5) - hash2 + char;
24013
- hash2 = hash2 & hash2;
24014
- }
24015
- return Math.abs(hash2).toString();
24016
- };
24017
- const base64ToFile = (base64String) => {
24018
- const arr = base64String.split(",");
24019
- const mimeMatch = arr[0].match(/:(.*?);/);
24020
- const mimeType = mimeMatch ? mimeMatch[1] : "";
24021
- const data = arr[1];
24022
- const binaryString = atob(data);
24023
- const hash2 = simpleHash(binaryString);
24024
- const extension = mimeType.split("/")[1] || "bin";
24025
- const filename = `image-${hash2}.${extension}`;
24026
- const bytes = new Uint8Array(binaryString.length);
24027
- for (let i = 0; i < binaryString.length; i++) {
24028
- bytes[i] = binaryString.charCodeAt(i);
24029
- }
24030
- const blob = new Blob([bytes], { type: mimeType });
24031
- return new File([blob], filename, { type: mimeType });
24032
- };
24033
- const urlToFile = async (url, filename, mimeType) => {
24034
- try {
24035
- const response = await fetch(url, {
24036
- mode: "cors",
24037
- credentials: "omit",
24038
- headers: {
24039
- // Add common headers that might help with CORS
24040
- Accept: "image/*,*/*;q=0.8"
24041
- }
24042
- });
24043
- if (!response.ok) {
24044
- console.warn(`Failed to fetch image from ${url}: ${response.status} ${response.statusText}`);
24045
- return null;
24046
- }
24047
- const blob = await response.blob();
24048
- const finalFilename = filename || extractFilenameFromUrl(url);
24049
- const finalMimeType = mimeType || response.headers.get("content-type") || blob.type || "image/jpeg";
24050
- return new File([blob], finalFilename, { type: finalMimeType });
24051
- } catch (error) {
24052
- if (isCorsError(error)) {
24053
- console.warn(`CORS policy prevents accessing image from ${url}:`, error.message);
24054
- return null;
24055
- }
24056
- console.error(`Error fetching image from ${url}:`, error);
24057
- return null;
24058
- }
24059
- };
24060
- const isCorsError = (error) => {
24061
- const errorMessage = error.message.toLowerCase();
24062
- const errorName = error.name.toLowerCase();
24063
- return errorName.includes("cors") || errorMessage.includes("cors") || errorMessage.includes("cross-origin") || errorMessage.includes("access-control") || errorMessage.includes("network error") || // Often indicates CORS in browsers
24064
- errorMessage.includes("failed to fetch");
24065
- };
24066
- const extractFilenameFromUrl = (url) => {
24067
- try {
24068
- const urlObj = new URL(url);
24069
- const pathname = urlObj.pathname;
24070
- const filename = pathname.split("/").pop();
24071
- if (filename && !filename.includes(".")) {
24072
- return `${filename}.jpg`;
24073
- }
24074
- return filename || "image.jpg";
24075
- } catch {
24076
- return "image.jpg";
24077
- }
24078
- };
24079
- const validateUrlAccessibility = async (url) => {
24080
- try {
24081
- const response = await fetch(url, {
24082
- method: "HEAD",
24083
- mode: "cors",
24084
- credentials: "omit"
24085
- });
24086
- return response.ok;
24087
- } catch {
24088
- return false;
24089
- }
24090
- };
24091
- const handleImageUpload = (file) => {
24092
- return new Promise((resolve, reject) => {
24093
- let reader = new FileReader();
24094
- reader.onload = (event) => {
24095
- resolve(event.target.result);
24096
- };
24097
- reader.onerror = reject;
24098
- setTimeout(() => reader.readAsDataURL(file), 250);
24099
- });
24100
- };
24101
- const processUploadedImage = (fileData, getMaxContentSize) => {
24102
- return new Promise((resolve, reject) => {
24103
- const img = new window.Image();
24104
- img.onload = () => {
24105
- const canvas = document.createElement("canvas");
24106
- const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(
24107
- img.width,
24108
- img.height,
24109
- getMaxContentSize
24110
- );
24111
- canvas.width = img.width;
24112
- canvas.height = img.height;
24113
- const ctx = canvas.getContext("2d");
24114
- if (ctx) {
24115
- ctx.imageSmoothingEnabled = true;
24116
- try {
24117
- ctx.imageSmoothingQuality = "high";
24118
- } catch {
24119
- }
24120
- }
24121
- ctx.drawImage(img, 0, 0, img.width, img.height);
24122
- const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
24123
- const targetPixelWidth = Math.round(logicalWidth * dpr);
24124
- const targetPixelHeight = Math.round(logicalHeight * dpr);
24125
- const finalTargetWidth = Math.min(targetPixelWidth, img.width);
24126
- const finalTargetHeight = Math.min(targetPixelHeight, img.height);
24127
- const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
24128
- if (resizeNeeded) {
24129
- multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
24130
- }
24131
- if (typeof fileData === "string") {
24132
- const resizedBase64 = canvas.toDataURL();
24133
- resolve(resizedBase64);
24134
- } else {
24135
- canvas.toBlob((blob) => {
24136
- const updatedFile = new File([blob], fileData.name, {
24137
- type: fileData.type,
24138
- lastModified: Date.now()
24139
- });
24140
- resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
24141
- });
24142
- }
24143
- };
24144
- img.onerror = (error) => reject(error);
24145
- img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
24146
- });
24147
- };
24148
- const getAllowedImageDimensions = (width, height, getMaxContentSize) => {
24149
- const { width: maxWidth, height: maxHeight } = getMaxContentSize();
24150
- if (!maxWidth || !maxHeight) return { width, height };
24151
- let adjustedWidth = width;
24152
- let adjustedHeight = height;
24153
- const aspectRatio = width / height;
24154
- if (height > maxHeight) {
24155
- adjustedHeight = maxHeight;
24156
- adjustedWidth = Math.round(maxHeight * aspectRatio);
24157
- }
24158
- if (adjustedWidth > maxWidth) {
24159
- adjustedWidth = maxWidth;
24160
- adjustedHeight = Math.round(maxWidth / aspectRatio);
24161
- }
24162
- return { width: adjustedWidth, height: adjustedHeight };
24163
- };
24164
- function resample_high_quality(canvas, width, height, resize_canvas) {
24165
- var width_source = canvas.width;
24166
- var height_source = canvas.height;
24167
- width = Math.round(width);
24168
- height = Math.round(height);
24169
- var ratio_w = width_source / width;
24170
- var ratio_h = height_source / height;
24171
- var ratio_w_half = Math.ceil(ratio_w / 2);
24172
- var ratio_h_half = Math.ceil(ratio_h / 2);
24173
- var ctx = canvas.getContext("2d");
24174
- var img = ctx.getImageData(0, 0, width_source, height_source);
24175
- var img2 = ctx.createImageData(width, height);
24176
- var data = img.data;
24177
- var data2 = img2.data;
24178
- for (var j = 0; j < height; j++) {
24179
- for (var i = 0; i < width; i++) {
24180
- var x2 = (i + j * width) * 4;
24181
- var weight = 0;
24182
- var weights = 0;
24183
- var weights_alpha = 0;
24184
- var gx_r = 0;
24185
- var gx_g = 0;
24186
- var gx_b = 0;
24187
- var gx_a = 0;
24188
- var center_y = (j + 0.5) * ratio_h;
24189
- var yy_start = Math.floor(j * ratio_h);
24190
- var yy_stop = Math.ceil((j + 1) * ratio_h);
24191
- for (var yy = yy_start; yy < yy_stop; yy++) {
24192
- var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
24193
- var center_x = (i + 0.5) * ratio_w;
24194
- var w0 = dy * dy;
24195
- var xx_start = Math.floor(i * ratio_w);
24196
- var xx_stop = Math.ceil((i + 1) * ratio_w);
24197
- for (var xx = xx_start; xx < xx_stop; xx++) {
24198
- var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
24199
- var w = Math.sqrt(w0 + dx * dx);
24200
- if (w >= 1) {
24201
- continue;
24202
- }
24203
- weight = 2 * w * w * w - 3 * w * w + 1;
24204
- var pos_x = 4 * (xx + yy * width_source);
24205
- gx_a += weight * data[pos_x + 3];
24206
- weights_alpha += weight;
24207
- if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
24208
- gx_r += weight * data[pos_x];
24209
- gx_g += weight * data[pos_x + 1];
24210
- gx_b += weight * data[pos_x + 2];
24211
- weights += weight;
24212
- }
24213
- }
24214
- data2[x2] = gx_r / weights;
24215
- data2[x2 + 1] = gx_g / weights;
24216
- data2[x2 + 2] = gx_b / weights;
24217
- data2[x2 + 3] = gx_a / weights_alpha;
24218
- }
24219
- }
24220
- {
24221
- canvas.width = width;
24222
- canvas.height = height;
24223
- }
24224
- ctx.putImageData(img2, 0, 0);
24225
- }
24226
- function multiStepResize(canvas, width, height) {
24227
- let oc = document.createElement("canvas");
24228
- let octx = oc.getContext("2d");
24229
- let ctx = canvas.getContext("2d");
24230
- let steps = Math.ceil(Math.log(canvas.width / width) / Math.log(2));
24231
- steps = Math.max(steps, 1);
24232
- let stepWidth = width * Math.pow(2, steps - 1);
24233
- let stepHeight = height * Math.pow(2, steps - 1);
24234
- let currentWidth = canvas.width;
24235
- let currentHeight = canvas.height;
24236
- oc.width = currentWidth;
24237
- oc.height = currentHeight;
24238
- octx.drawImage(canvas, 0, 0);
24239
- while (steps > 0) {
24240
- stepWidth = Math.max(stepWidth, width);
24241
- stepHeight = Math.max(stepHeight, height);
24242
- canvas.width = stepWidth;
24243
- canvas.height = stepHeight;
24244
- ctx.drawImage(oc, 0, 0, currentWidth, currentHeight, 0, 0, stepWidth, stepHeight);
24245
- currentWidth = stepWidth;
24246
- currentHeight = stepHeight;
24247
- oc.width = currentWidth;
24248
- oc.height = currentHeight;
24249
- octx.drawImage(canvas, 0, 0);
24250
- stepWidth = Math.round(stepWidth / 2);
24251
- stepHeight = Math.round(stepHeight / 2);
24252
- steps--;
24253
- }
24254
- resample_high_quality(canvas, width, height);
24255
- }
24256
- const FALLBACK_NAME = "image";
24257
- const stripDiacritics = (value) => value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
24258
- const sanitizeSegment = (segment, { allowDots = false } = {}) => {
24259
- if (!segment) return "";
24260
- const normalized = stripDiacritics(segment).replace(/[\s\u2000-\u206f]+/g, "_").replace(/[\\/]+/g, "_");
24261
- const allowedPattern = allowDots ? /[^0-9A-Za-z._-]+/g : /[^0-9A-Za-z_-]+/g;
24262
- let sanitized = normalized.replace(allowedPattern, "_");
24263
- sanitized = sanitized.replace(/_+/g, "_");
24264
- sanitized = sanitized.replace(/^[_.-]+/, "");
24265
- sanitized = sanitized.replace(/[_-]+$/, "");
24266
- return sanitized;
24267
- };
24268
- const splitFileName = (name) => {
24269
- const trimmed = name?.trim?.() ?? "";
24270
- const lastDot = trimmed.lastIndexOf(".");
24271
- if (lastDot <= 0 || lastDot === trimmed.length - 1) {
24272
- return { base: trimmed, ext: "" };
24273
- }
24274
- return {
24275
- base: trimmed.slice(0, lastDot),
24276
- ext: trimmed.slice(lastDot + 1)
24277
- };
24278
- };
24279
- const sanitizeImageFileName = (inputName) => {
24280
- const { base: base2, ext } = splitFileName(inputName || "");
24281
- const sanitizedBase = sanitizeSegment(base2, { allowDots: true }) || FALLBACK_NAME;
24282
- const sanitizedExt = sanitizeSegment(ext, { allowDots: false }).toLowerCase();
24283
- if (!sanitizedExt) return sanitizedBase;
24284
- return `${sanitizedBase}.${sanitizedExt}`;
24285
- };
24286
- const ensureUniqueFileName = (preferredName, existingNames = /* @__PURE__ */ new Set()) => {
24287
- const sanitized = sanitizeImageFileName(preferredName);
24288
- if (!existingNames || typeof existingNames.has !== "function") {
24289
- return sanitized;
24290
- }
24291
- const existingSet = /* @__PURE__ */ new Set();
24292
- existingNames.forEach((name) => existingSet.add(sanitizeImageFileName(name)));
24293
- if (!existingSet.has(sanitized)) {
24294
- return sanitized;
24295
- }
24296
- const { base: base2, ext } = splitFileName(sanitized);
24297
- let counter = 1;
24298
- let candidate = sanitized;
24299
- const suffix = () => `${base2}-${counter}${ext ? `.${ext}` : ""}`;
24300
- while (existingSet.has(candidate)) {
24301
- candidate = suffix();
24302
- counter += 1;
24303
- }
24304
- return candidate;
24305
- };
24306
- const buildMediaPath = (fileName) => `word/media/${fileName}`;
24307
- const fileTooLarge = (file) => {
24308
- let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
24309
- if (fileSizeMb > 5) {
24310
- window.alert("Image size must be less than 5MB");
24311
- return true;
24312
- }
24313
- return false;
24314
- };
24315
- const checkAndProcessImage = async ({ getMaxContentSize, file }) => {
24316
- if (fileTooLarge(file)) {
24317
- return { file: null, size: { width: 0, height: 0 } };
24318
- }
24319
- try {
24320
- const processedImageResult = await processUploadedImage(file, getMaxContentSize);
24321
- const process = processedImageResult;
24322
- return { file: process.file, size: { width: process.width, height: process.height } };
24323
- } catch (err) {
24324
- console.warn("Error processing image:", err);
24325
- return { file: null, size: { width: 0, height: 0 } };
24326
- }
24327
- };
24328
- function replaceSelectionWithImagePlaceholder({ editorOptions, view, id }) {
24329
- let { tr } = view.state;
24330
- let { selection } = tr;
24331
- if (editorOptions.isHeaderOrFooter) {
24332
- selection = editorOptions.lastSelection;
24333
- }
24334
- if (!selection.empty && !editorOptions.isHeaderOrFooter) {
24335
- tr.deleteSelection();
24336
- }
24337
- tr = addImagePlaceholder(view.state, tr, id, selection.from);
24338
- view.dispatch(tr);
24339
- }
24340
- const generateUniqueDocPrId = (editor) => {
24341
- const existingIds = /* @__PURE__ */ new Set();
24342
- editor?.state?.doc?.descendants((node) => {
24343
- if (node.type.name === "image" && node.attrs.id !== void 0 && node.attrs.id !== null) {
24344
- existingIds.add(String(node.attrs.id));
24345
- }
24346
- });
24347
- let candidate;
24348
- do {
24349
- const hex = generateDocxRandomId();
24350
- candidate = String(parseInt(hex, 16));
24351
- } while (!candidate || existingIds.has(candidate));
24352
- return candidate;
24353
- };
24354
- async function uploadAndInsertImage({ editor, view, file, size, id }) {
24355
- const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
24356
- const placeholderId = id;
24357
- try {
24358
- const existingFileNames = new Set(Object.keys(editor.storage.image.media ?? {}).map((key2) => key2.split("/").pop()));
24359
- const uniqueFileName = ensureUniqueFileName(file.name, existingFileNames);
24360
- const normalizedFile = uniqueFileName === file.name ? file : new File([file], uniqueFileName, {
24361
- type: file.type,
24362
- lastModified: file.lastModified ?? Date.now()
24363
- });
24364
- let url = await imageUploadHandler(normalizedFile);
24365
- let placeholderPos = findPlaceholder(view.state, placeholderId);
24366
- if (placeholderPos == null) {
24367
- return;
24368
- }
24369
- const mediaPath = buildMediaPath(uniqueFileName);
24370
- const docPrId = generateUniqueDocPrId(editor);
24371
- let rId = null;
24372
- if (editor.options.mode === "docx") {
24373
- const [, path] = mediaPath.split("word/");
24374
- const id2 = addImageRelationship({ editor, path });
24375
- if (id2) rId = id2;
24376
- }
24377
- let imageNode = view.state.schema.nodes.image.create({
24378
- src: mediaPath,
24379
- size,
24380
- id: docPrId,
24381
- rId
24382
- });
24383
- editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
24384
- if (editor.options.ydoc && typeof editor.commands.addImageToCollaboration === "function") {
24385
- editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
24386
- }
24387
- let tr = view.state.tr;
24388
- tr.replaceWith(placeholderPos, placeholderPos, imageNode);
24389
- tr = removeImagePlaceholder(view.state, tr, placeholderId);
24390
- view.dispatch(tr);
24391
- } catch {
24392
- const tr = removeImagePlaceholder(view.state, view.state.tr, placeholderId);
24393
- view.dispatch(tr);
24394
- }
24395
- }
24396
- function addImageRelationship({ editor, path }) {
24397
- const target = path;
24398
- const type = "image";
24399
- try {
24400
- const id = insertNewRelationship(target, type, editor);
24401
- return id;
24402
- } catch {
24403
- return null;
24404
- }
24405
- }
24406
- const key = new PluginKey("ImageRegistration");
24407
- const ImageRegistrationPlugin = ({ editor }) => {
24408
- const { view } = editor;
24409
- return new Plugin({
24410
- key,
24411
- state: {
24412
- init() {
24413
- return { set: DecorationSet.empty };
24414
- },
24415
- apply(tr, { set }) {
24416
- const meta = tr.getMeta(key);
24417
- if (meta) {
24418
- set = meta.set;
24419
- return { set };
24420
- }
24421
- set = set.map(tr.mapping, tr.doc);
24422
- return { set };
24423
- }
24424
- },
24425
- appendTransaction: (trs, _oldState, state) => {
24426
- let foundImages = [];
24427
- trs.forEach((tr2) => {
24428
- if (tr2.docChanged) {
24429
- tr2.steps.forEach((step, index2) => {
24430
- const stepMap = step.getMap();
24431
- foundImages = foundImages.map(({ node, pos, id }) => {
24432
- const mappedPos = stepMap.map(pos, -1);
24433
- return { node, pos: mappedPos, id };
24434
- });
24435
- if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
24436
- (tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
24437
- stepMap.map(step.from, -1),
24438
- stepMap.map(step.to, 1),
24439
- (node, pos) => {
24440
- if (node.type.name === "image" && !node.attrs.src.startsWith("word/media")) {
24441
- const id = {};
24442
- foundImages.push({ node, pos, id });
24443
- } else {
24444
- return true;
24445
- }
24446
- }
24447
- );
24448
- }
24449
- });
24450
- }
24451
- });
24452
- if (!foundImages || foundImages.length === 0) {
24453
- return null;
24454
- }
24455
- registerImages(foundImages, editor, view);
24456
- const tr = state.tr;
24457
- let { set } = key.getState(state);
24458
- foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
24459
- let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
24460
- side: -1,
24461
- id
24462
- });
24463
- set = set.add(tr.doc, [deco]);
24464
- });
24465
- foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
24466
- tr.delete(pos, pos + node.nodeSize);
24467
- });
24468
- set = set.map(tr.mapping, tr.doc);
24469
- tr.setMeta(key, { set });
24470
- return tr;
24471
- },
24472
- props: {
24473
- decorations(state) {
24474
- let { set } = key.getState(state);
24475
- return set;
24178
+ const ImagePlaceholderPluginKey = new PluginKey("ImagePlaceholder");
24179
+ const ImagePlaceholderPlugin = () => {
24180
+ return new Plugin({
24181
+ key: ImagePlaceholderPluginKey,
24182
+ state: {
24183
+ init() {
24184
+ return DecorationSet.empty;
24185
+ },
24186
+ apply(tr, set) {
24187
+ set = set.map(tr.mapping, tr.doc);
24188
+ let action = tr.getMeta(ImagePlaceholderPluginKey);
24189
+ if (action?.type === "add") {
24190
+ let widget = document.createElement("placeholder");
24191
+ let deco = Decoration.widget(action.pos, widget, {
24192
+ id: action.id
24193
+ });
24194
+ set = set.add(tr.doc, [deco]);
24195
+ } else if (action?.type === "remove") {
24196
+ set = set.remove(set.find(null, null, (spec) => spec.id == action.id));
24197
+ }
24198
+ return set;
24199
+ }
24200
+ },
24201
+ props: {
24202
+ decorations(state) {
24203
+ return this.getState(state);
24476
24204
  }
24477
24205
  }
24478
24206
  });
24479
24207
  };
24480
24208
  const findPlaceholder = (state, id) => {
24481
- let { set } = key.getState(state);
24482
- let found = set?.find(null, null, (spec) => spec.id === id);
24209
+ let decos = ImagePlaceholderPluginKey.getState(state);
24210
+ let found = decos?.find(null, null, (spec) => spec.id === id);
24483
24211
  return found?.length ? found[0].from : null;
24484
24212
  };
24485
- const removeImagePlaceholder = (state, tr, id) => {
24486
- let { set } = key.getState(state);
24487
- set = set.map(tr.mapping, tr.doc);
24488
- set = set.remove(set.find(null, null, (spec) => spec.id == id));
24489
- return tr.setMeta(key, { set, type: "remove" });
24490
- };
24491
- const addImagePlaceholder = (state, tr, id, pos) => {
24492
- let { set } = key.getState(state);
24493
- set = set.map(tr.mapping, tr.doc);
24494
- let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
24495
- id
24496
- });
24497
- set = set.add(tr.doc, [deco]);
24498
- return tr.setMeta(key, { set, type: "add" });
24499
- };
24500
- const getImageRegistrationMetaType = (tr) => {
24501
- const meta = tr.getMeta(key);
24502
- if (meta && meta.type) {
24503
- return meta.type;
24504
- }
24505
- return null;
24506
- };
24507
- const registerImages = async (foundImages, editor, view) => {
24508
- foundImages.forEach(async (image) => {
24509
- const src = image.node.attrs.src;
24510
- const id = image.id;
24511
- let file = null;
24512
- if (src.startsWith("http")) {
24513
- const isAccessible = await validateUrlAccessibility(src);
24514
- if (isAccessible) {
24515
- file = await urlToFile(src);
24516
- } else {
24517
- console.warn(`Image URL ${src} is not accessible due to CORS or other restrictions. Using original URL.`);
24518
- const tr = view.state.tr;
24519
- removeImagePlaceholder(view.state, tr, id);
24520
- view.dispatch(tr);
24521
- return;
24522
- }
24523
- } else if (src.startsWith("data:")) {
24524
- file = base64ToFile(src);
24525
- } else {
24526
- console.error(`Unsupported image source: ${src}`);
24527
- }
24528
- if (!file) {
24529
- const tr = view.state.tr;
24530
- removeImagePlaceholder(view.state, tr, id);
24531
- view.dispatch(tr);
24532
- return;
24533
- }
24534
- try {
24535
- const process = await checkAndProcessImage({
24536
- getMaxContentSize: () => editor.getMaxContentSize(),
24537
- file
24538
- });
24539
- if (!process.file) {
24540
- const tr = view.state.tr;
24541
- removeImagePlaceholder(view.state, tr, id);
24542
- view.dispatch(tr);
24543
- return;
24544
- }
24545
- await uploadAndInsertImage({ editor, view, file: process.file, size: process.size, id });
24546
- } catch (error) {
24547
- console.error(`Error processing image from ${src}:`, error);
24548
- const tr = view.state.tr;
24549
- removeImagePlaceholder(view.state, tr, id);
24550
- view.dispatch(tr);
24551
- }
24552
- });
24553
- };
24554
24213
  const ImagePositionPluginKey = new PluginKey("ImagePosition");
24555
24214
  const ImagePositionPlugin = ({ editor }) => {
24556
24215
  const { view } = editor;
@@ -24657,19 +24316,6 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
24657
24316
  }
24658
24317
  return null;
24659
24318
  };
24660
- const getRotationMargins = (w, h, angleDegrees) => {
24661
- const rad = angleDegrees * (Math.PI / 180);
24662
- const cos = Math.abs(Math.cos(rad));
24663
- const sin = Math.abs(Math.sin(rad));
24664
- const boundingWidth = w * cos + h * sin;
24665
- const boundingHeight = w * sin + h * cos;
24666
- const marginLeftRight = Math.round(Math.max(0, (boundingWidth - w) / 2));
24667
- const marginTopBottom = Math.round(Math.max(0, (boundingHeight - h) / 2));
24668
- return {
24669
- horizontal: marginLeftRight,
24670
- vertical: marginTopBottom
24671
- };
24672
- };
24673
24319
  const Image = Node$1.create({
24674
24320
  name: "image",
24675
24321
  group: "inline",
@@ -24691,6 +24337,10 @@ const Image = Node$1.create({
24691
24337
  },
24692
24338
  addAttributes() {
24693
24339
  return {
24340
+ /**
24341
+ * @category Attribute
24342
+ * @param {string} [src] - Image source URL or path
24343
+ */
24694
24344
  src: {
24695
24345
  default: null,
24696
24346
  renderDOM: ({ src }) => {
@@ -24699,75 +24349,95 @@ const Image = Node$1.create({
24699
24349
  };
24700
24350
  }
24701
24351
  },
24352
+ /**
24353
+ * @category Attribute
24354
+ * @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
24355
+ */
24702
24356
  alt: {
24703
24357
  default: "Uploaded picture"
24704
24358
  },
24359
+ /**
24360
+ * @category Attribute
24361
+ * @param {string} [id] - Image element ID
24362
+ * @private
24363
+ */
24705
24364
  id: { rendered: false },
24365
+ /**
24366
+ * @category Attribute
24367
+ * @param {string} [title] - Image title/tooltip text
24368
+ */
24706
24369
  title: {
24707
24370
  default: null
24708
24371
  },
24372
+ /**
24373
+ * @category Attribute
24374
+ * @param {string} [rId] - Relationship ID for Word export
24375
+ * @private
24376
+ */
24709
24377
  rId: {
24710
24378
  default: null,
24711
24379
  rendered: false
24712
24380
  },
24381
+ /**
24382
+ * @category Attribute
24383
+ * @param {Object} [originalPadding] - Original padding values from Word import
24384
+ * @private
24385
+ */
24713
24386
  originalPadding: {
24714
24387
  default: null,
24715
24388
  rendered: false
24716
24389
  },
24390
+ /**
24391
+ * @category Attribute
24392
+ * @param {Object} [originalAttributes] - Original attributes from Word import
24393
+ * @private
24394
+ */
24717
24395
  originalAttributes: { rendered: false },
24396
+ /**
24397
+ * @category Attribute
24398
+ * @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
24399
+ * @private
24400
+ */
24718
24401
  wrapTopAndBottom: { rendered: false },
24402
+ /**
24403
+ * @category Attribute
24404
+ * @param {Object} [anchorData] - Anchor positioning data for Word
24405
+ * @private
24406
+ */
24719
24407
  anchorData: {
24720
24408
  default: null,
24721
24409
  rendered: false
24722
24410
  },
24723
- isAnchor: { rendered: false },
24724
24411
  /**
24725
24412
  * @category Attribute
24726
- * @param {Object} [transformData] - Transform data for image (turn and flip)
24727
- * @param {number} [transformData.rotation] - Turn angle in degrees
24728
- * @param {boolean} [transformData.verticalFlip] - Whether to flip vertically
24729
- * @param {boolean} [transformData.horizontalFlip] - Whether to flip horizontally
24730
- * @param {Object} [transformData.sizeExtension] - Size extension for image due to transformation
24731
- * @param {number} [transformData.sizeExtension.left] - Left size extension for image
24732
- * @param {number} [transformData.sizeExtension.top] - Top size extension for image
24733
- * @param {number} [transformData.sizeExtension.right] - Right size extension for image
24734
- * @param {number} [transformData.sizeExtension.bottom] - Bottom size extension for image
24735
- *
24413
+ * @param {boolean} [isAnchor] - Whether image is anchored
24736
24414
  * @private
24737
24415
  */
24738
- transformData: {
24739
- default: {},
24740
- renderDOM: ({ transformData }) => {
24741
- let style = "";
24742
- if (transformData?.rotation) {
24743
- style += `rotate(${Math.round(transformData.rotation)}deg) `;
24744
- }
24745
- if (transformData?.verticalFlip) {
24746
- style += "scaleY(-1) ";
24747
- }
24748
- if (transformData?.horizontalFlip) {
24749
- style += "scaleX(-1) ";
24750
- }
24751
- style = style.trim();
24752
- if (style.length > 0) {
24753
- return { style: `transform: ${style};` };
24754
- }
24755
- return;
24756
- }
24757
- },
24416
+ isAnchor: { rendered: false },
24758
24417
  /**
24759
24418
  * @category Attribute
24760
24419
  * @param {boolean} [simplePos] - Simple positioning flag
24761
24420
  * @private
24762
24421
  */
24763
24422
  simplePos: { rendered: false },
24423
+ /**
24424
+ * @category Attribute
24425
+ * @param {string} [wrapText] - Text wrapping style
24426
+ * @private
24427
+ */
24764
24428
  wrapText: { rendered: false },
24765
24429
  extension: { rendered: false },
24430
+ /**
24431
+ * @category Attribute
24432
+ * @param {Object} [size] - Image dimensions
24433
+ * @param {number} [size.width] - Width in pixels
24434
+ * @param {number} [size.height] - Height in pixels
24435
+ */
24766
24436
  size: {
24767
24437
  default: {},
24768
24438
  renderDOM: ({ size, extension }) => {
24769
24439
  let style = "";
24770
- let { width, height } = size ?? {};
24440
+ const { width, height } = size ?? {};
24771
24441
  if (width) style += `width: ${width}px;`;
24772
24442
  if (height && ["emf", "wmf"].includes(extension))
24773
24443
  style += `height: ${height}px; border: 1px solid black; position: absolute;`;
@@ -24775,58 +24445,51 @@ const Image = Node$1.create({
24775
24445
  return { style };
24776
24446
  }
24777
24447
  },
24448
+ /**
24449
+ * @category Attribute
24450
+ * @param {Object} [padding] - Image padding/margins
24451
+ * @param {number} [padding.left] - Left padding in pixels
24452
+ * @param {number} [padding.top] - Top padding in pixels
24453
+ * @param {number} [padding.bottom] - Bottom padding in pixels
24454
+ * @param {number} [padding.right] - Right padding in pixels
24455
+ */
24778
24456
  padding: {
24779
24457
  default: {},
24780
- renderDOM: ({ size = {}, padding, marginOffset, transformData }) => {
24781
- let { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
24782
- const { rotation } = transformData ?? {};
24783
- const { height, width } = size ?? {};
24784
- if (rotation && height && width) {
24785
- const { horizontal, vertical } = getRotationMargins(width, height, rotation);
24786
- left2 += horizontal;
24787
- right2 += horizontal;
24788
- top2 += vertical;
24789
- bottom2 += vertical;
24790
- }
24458
+ renderDOM: ({ padding, marginOffset }) => {
24459
+ const { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
24791
24460
  let style = "";
24792
- if (left2 && marginOffset?.left == null) style += `margin-left: ${left2}px;`;
24793
- if (top2 && marginOffset?.top == null) style += `margin-top: ${top2}px;`;
24461
+ if (left2 && !marginOffset?.left) style += `margin-left: ${left2}px;`;
24462
+ if (top2 && !marginOffset?.top) style += `margin-top: ${top2}px;`;
24794
24463
  if (bottom2) style += `margin-bottom: ${bottom2}px;`;
24795
24464
  if (right2) style += `margin-right: ${right2}px;`;
24796
24465
  return { style };
24797
24466
  }
24798
24467
  },
24468
+ /**
24469
+ * @category Attribute
24470
+ * @param {Object} [marginOffset] - Margin offset for anchored images
24471
+ * @param {number} [marginOffset.left] - Left margin offset
24472
+ * @param {number} [marginOffset.top] - Top margin offset
24473
+ */
24799
24474
  marginOffset: {
24800
24475
  default: {},
24801
- renderDOM: ({ marginOffset, anchorData, transformData, size }) => {
24802
- const hasAnchorData = Boolean(anchorData);
24803
- const hasMarginOffsets = marginOffset?.left != null || marginOffset?.top != null;
24804
- if (!hasAnchorData && !hasMarginOffsets) return {};
24476
+ renderDOM: ({ marginOffset, anchorData }) => {
24805
24477
  const relativeFromPageV = anchorData?.vRelativeFrom === "page";
24806
24478
  const maxMarginV = 500;
24807
- const baseLeft = marginOffset?.left ?? 0;
24808
- const baseTop = marginOffset?.top ?? 0;
24809
- let rotationLeft = 0;
24810
- let rotationTop = 0;
24811
- const { rotation } = transformData ?? {};
24812
- const { height, width } = size ?? {};
24813
- if (rotation && height && width) {
24814
- const { horizontal, vertical } = getRotationMargins(width, height, rotation);
24815
- rotationLeft = horizontal;
24816
- rotationTop = vertical;
24817
- }
24818
- const left2 = baseLeft + rotationLeft;
24819
- const top2 = baseTop + rotationTop;
24479
+ const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
24820
24480
  let style = "";
24821
24481
  if (left2) style += `margin-left: ${left2}px;`;
24822
24482
  if (top2) {
24823
24483
  if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
24824
24484
  else style += `margin-top: ${top2}px;`;
24825
24485
  }
24826
- if (!style) return {};
24827
24486
  return { style };
24828
24487
  }
24829
24488
  },
24489
+ /**
24490
+ * @category Attribute
24491
+ * @param {string} [style] - Custom inline CSS styles
24492
+ */
24830
24493
  style: {
24831
24494
  default: null,
24832
24495
  rendered: true,
@@ -24852,10 +24515,18 @@ const Image = Node$1.create({
24852
24515
  /**
24853
24516
  * Insert an image at the current position
24854
24517
  * @category Command
24855
- * @param {ImageInsertOptions} options - Image insertion options
24518
+ * @param {Object} options - Image attributes
24519
+ * @param {string} options.src - Image source URL or data URI
24520
+ * @param {string} [options.alt] - Alternative text
24521
+ * @param {string} [options.title] - Image title
24522
+ * @param {Object} [options.size] - Image dimensions
24523
+ * @returns {Function} Command function
24856
24524
  * @example
24857
- * editor.commands.setImage({ src: 'https://example.com/image.jpg' })
24858
- * editor.commands.setImage({
24525
+ * // Insert an image from a URL
24526
+ * setImage({ src: 'https://example.com/image.jpg' })
24527
+ *
24528
+ * // Insert a base64 encoded image
24529
+ * setImage({
24859
24530
  * src: 'data:image/png;base64,...',
24860
24531
  * alt: 'Company logo',
24861
24532
  * size: { width: 200 }
@@ -24871,31 +24542,272 @@ const Image = Node$1.create({
24871
24542
  };
24872
24543
  },
24873
24544
  addPmPlugins() {
24874
- return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
24545
+ return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
24546
+ }
24547
+ });
24548
+ const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
24549
+ const getFileOpener = () => {
24550
+ let fileInput = document.createElement("input");
24551
+ fileInput.type = "file";
24552
+ let acceptTypes = ACCEPT_IMAGE_TYPES;
24553
+ fileInput.accept = acceptTypes.join(",");
24554
+ const openFile = () => {
24555
+ return new Promise((resolve, reject) => {
24556
+ fileInput.onchange = async () => {
24557
+ const files = fileInput.files;
24558
+ if (!files) return resolve(null);
24559
+ const file = files.item(0);
24560
+ if (!file) return resolve(null);
24561
+ return resolve({ file });
24562
+ };
24563
+ fileInput.oncancel = () => resolve(null);
24564
+ fileInput.onerror = reject;
24565
+ fileInput.click();
24566
+ });
24567
+ };
24568
+ return openFile;
24569
+ };
24570
+ const handleImageUpload = (file) => {
24571
+ return new Promise((resolve, reject) => {
24572
+ let reader = new FileReader();
24573
+ reader.onload = (event) => {
24574
+ resolve(event.target.result);
24575
+ };
24576
+ reader.onerror = reject;
24577
+ setTimeout(() => reader.readAsDataURL(file), 250);
24578
+ });
24579
+ };
24580
+ const processUploadedImage = (fileData, editor) => {
24581
+ return new Promise((resolve, reject) => {
24582
+ const img = new window.Image();
24583
+ img.onload = () => {
24584
+ const canvas = document.createElement("canvas");
24585
+ const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(img.width, img.height, editor);
24586
+ canvas.width = img.width;
24587
+ canvas.height = img.height;
24588
+ const ctx = canvas.getContext("2d");
24589
+ if (ctx) {
24590
+ ctx.imageSmoothingEnabled = true;
24591
+ try {
24592
+ ctx.imageSmoothingQuality = "high";
24593
+ } catch {
24594
+ }
24595
+ }
24596
+ ctx.drawImage(img, 0, 0, img.width, img.height);
24597
+ const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
24598
+ const targetPixelWidth = Math.round(logicalWidth * dpr);
24599
+ const targetPixelHeight = Math.round(logicalHeight * dpr);
24600
+ const finalTargetWidth = Math.min(targetPixelWidth, img.width);
24601
+ const finalTargetHeight = Math.min(targetPixelHeight, img.height);
24602
+ const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
24603
+ if (resizeNeeded) {
24604
+ multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
24605
+ }
24606
+ if (typeof fileData === "string") {
24607
+ const resizedBase64 = canvas.toDataURL();
24608
+ resolve(resizedBase64);
24609
+ } else {
24610
+ canvas.toBlob((blob) => {
24611
+ const updatedFile = new File([blob], fileData.name, {
24612
+ type: fileData.type,
24613
+ lastModified: Date.now()
24614
+ });
24615
+ resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
24616
+ });
24617
+ }
24618
+ };
24619
+ img.onerror = (error) => reject(error);
24620
+ img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
24621
+ });
24622
+ };
24623
+ const getAllowedImageDimensions = (width, height, editor) => {
24624
+ const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
24625
+ if (!maxWidth || !maxHeight) return { width, height };
24626
+ let adjustedWidth = width;
24627
+ let adjustedHeight = height;
24628
+ const aspectRatio = width / height;
24629
+ if (height > maxHeight) {
24630
+ adjustedHeight = maxHeight;
24631
+ adjustedWidth = Math.round(maxHeight * aspectRatio);
24632
+ }
24633
+ if (adjustedWidth > maxWidth) {
24634
+ adjustedWidth = maxWidth;
24635
+ adjustedHeight = Math.round(maxWidth / aspectRatio);
24636
+ }
24637
+ return { width: adjustedWidth, height: adjustedHeight };
24638
+ };
24639
+ function resample_high_quality(canvas, width, height, resize_canvas) {
24640
+ var width_source = canvas.width;
24641
+ var height_source = canvas.height;
24642
+ width = Math.round(width);
24643
+ height = Math.round(height);
24644
+ var ratio_w = width_source / width;
24645
+ var ratio_h = height_source / height;
24646
+ var ratio_w_half = Math.ceil(ratio_w / 2);
24647
+ var ratio_h_half = Math.ceil(ratio_h / 2);
24648
+ var ctx = canvas.getContext("2d");
24649
+ var img = ctx.getImageData(0, 0, width_source, height_source);
24650
+ var img2 = ctx.createImageData(width, height);
24651
+ var data = img.data;
24652
+ var data2 = img2.data;
24653
+ for (var j = 0; j < height; j++) {
24654
+ for (var i = 0; i < width; i++) {
24655
+ var x2 = (i + j * width) * 4;
24656
+ var weight = 0;
24657
+ var weights = 0;
24658
+ var weights_alpha = 0;
24659
+ var gx_r = 0;
24660
+ var gx_g = 0;
24661
+ var gx_b = 0;
24662
+ var gx_a = 0;
24663
+ var center_y = (j + 0.5) * ratio_h;
24664
+ var yy_start = Math.floor(j * ratio_h);
24665
+ var yy_stop = Math.ceil((j + 1) * ratio_h);
24666
+ for (var yy = yy_start; yy < yy_stop; yy++) {
24667
+ var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
24668
+ var center_x = (i + 0.5) * ratio_w;
24669
+ var w0 = dy * dy;
24670
+ var xx_start = Math.floor(i * ratio_w);
24671
+ var xx_stop = Math.ceil((i + 1) * ratio_w);
24672
+ for (var xx = xx_start; xx < xx_stop; xx++) {
24673
+ var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
24674
+ var w = Math.sqrt(w0 + dx * dx);
24675
+ if (w >= 1) {
24676
+ continue;
24677
+ }
24678
+ weight = 2 * w * w * w - 3 * w * w + 1;
24679
+ var pos_x = 4 * (xx + yy * width_source);
24680
+ gx_a += weight * data[pos_x + 3];
24681
+ weights_alpha += weight;
24682
+ if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
24683
+ gx_r += weight * data[pos_x];
24684
+ gx_g += weight * data[pos_x + 1];
24685
+ gx_b += weight * data[pos_x + 2];
24686
+ weights += weight;
24687
+ }
24688
+ }
24689
+ data2[x2] = gx_r / weights;
24690
+ data2[x2 + 1] = gx_g / weights;
24691
+ data2[x2 + 2] = gx_b / weights;
24692
+ data2[x2 + 3] = gx_a / weights_alpha;
24693
+ }
24694
+ }
24695
+ {
24696
+ canvas.width = width;
24697
+ canvas.height = height;
24698
+ }
24699
+ ctx.putImageData(img2, 0, 0);
24700
+ }
24701
+ function multiStepResize(canvas, targetWidth, targetHeight) {
24702
+ const originalWidth = canvas.width;
24703
+ const originalHeight = canvas.height;
24704
+ const scaleX = targetWidth / originalWidth;
24705
+ const scaleY = targetHeight / originalHeight;
24706
+ const scaleFactor = Math.min(scaleX, scaleY);
24707
+ if (scaleFactor < 0.5) {
24708
+ let currentWidth = originalWidth;
24709
+ let currentHeight = originalHeight;
24710
+ while (currentWidth > targetWidth * 2 || currentHeight > targetHeight * 2) {
24711
+ const nextWidth = Math.round(currentWidth / 2);
24712
+ const nextHeight = Math.round(currentHeight / 2);
24713
+ resample_high_quality(canvas, nextWidth, nextHeight);
24714
+ currentWidth = nextWidth;
24715
+ currentHeight = nextHeight;
24716
+ }
24717
+ if (currentWidth !== targetWidth || currentHeight !== targetHeight) {
24718
+ resample_high_quality(canvas, targetWidth, targetHeight);
24719
+ }
24720
+ } else {
24721
+ resample_high_quality(canvas, targetWidth, targetHeight);
24722
+ }
24723
+ }
24724
+ const startImageUpload = async ({ editor, view, file }) => {
24725
+ const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
24726
+ let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
24727
+ if (fileSizeMb > 5) {
24728
+ window.alert("Image size must be less than 5MB");
24729
+ return;
24875
24730
  }
24876
- });
24877
- const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
24878
- const getFileOpener = () => {
24879
- let fileInput = document.createElement("input");
24880
- fileInput.type = "file";
24881
- let acceptTypes = ACCEPT_IMAGE_TYPES;
24882
- fileInput.accept = acceptTypes.join(",");
24883
- const openFile = () => {
24884
- return new Promise((resolve, reject) => {
24885
- fileInput.onchange = async () => {
24886
- const files = fileInput.files;
24887
- if (!files) return resolve(null);
24888
- const file = files.item(0);
24889
- if (!file) return resolve(null);
24890
- return resolve({ file });
24891
- };
24892
- fileInput.oncancel = () => resolve(null);
24893
- fileInput.onerror = reject;
24894
- fileInput.click();
24895
- });
24896
- };
24897
- return openFile;
24731
+ let width;
24732
+ let height;
24733
+ try {
24734
+ const processedImageResult = await processUploadedImage(file, editor);
24735
+ width = processedImageResult.width;
24736
+ height = processedImageResult.height;
24737
+ file = processedImageResult.file;
24738
+ } catch (err) {
24739
+ console.warn("Error processing image:", err);
24740
+ editor.emit("exception", { error: err, editor });
24741
+ return;
24742
+ }
24743
+ await uploadImage({
24744
+ editor,
24745
+ view,
24746
+ file,
24747
+ size: { width, height },
24748
+ uploadHandler: imageUploadHandler
24749
+ });
24898
24750
  };
24751
+ async function uploadImage({ editor, view, file, size, uploadHandler }) {
24752
+ let id = {};
24753
+ let { tr, schema } = view.state;
24754
+ let { selection } = tr;
24755
+ if (editor.options.isHeaderOrFooter) {
24756
+ selection = editor.options.lastSelection;
24757
+ }
24758
+ if (!selection.empty && !editor.options.isHeaderOrFooter) {
24759
+ tr.deleteSelection();
24760
+ }
24761
+ let imageMeta = {
24762
+ type: "add",
24763
+ pos: selection.from,
24764
+ id
24765
+ };
24766
+ tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
24767
+ view.dispatch(tr);
24768
+ try {
24769
+ let url = await uploadHandler(file);
24770
+ let fileName = file.name.replace(" ", "_");
24771
+ let placeholderPos = findPlaceholder(view.state, id);
24772
+ if (placeholderPos == null) {
24773
+ return;
24774
+ }
24775
+ let removeMeta = { type: "remove", id };
24776
+ let mediaPath = `word/media/${fileName}`;
24777
+ let rId = null;
24778
+ if (editor.options.mode === "docx") {
24779
+ const [, path] = mediaPath.split("word/");
24780
+ const imageid = addImageRelationship({ editor, path });
24781
+ if (imageid) rId = imageid;
24782
+ }
24783
+ let imageNode = schema.nodes.image.create({
24784
+ src: mediaPath,
24785
+ size,
24786
+ rId
24787
+ });
24788
+ editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
24789
+ if (editor.options.ydoc) {
24790
+ editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
24791
+ }
24792
+ view.dispatch(
24793
+ view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
24794
+ );
24795
+ } catch (error) {
24796
+ let removeMeta = { type: "remove", id };
24797
+ view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
24798
+ editor.emit("exception", { error, editor });
24799
+ }
24800
+ }
24801
+ function addImageRelationship({ editor, path }) {
24802
+ const target = path;
24803
+ const type = "image";
24804
+ try {
24805
+ const relationshipId = insertNewRelationship(target, type, editor);
24806
+ return relationshipId;
24807
+ } catch {
24808
+ return null;
24809
+ }
24810
+ }
24899
24811
  const BookmarkStart = Node$1.create({
24900
24812
  name: "bookmarkStart",
24901
24813
  group: "inline",
@@ -25072,14 +24984,6 @@ const PageNumber = Node$1.create({
25072
24984
  },
25073
24985
  addCommands() {
25074
24986
  return {
25075
- /**
25076
- * Insert an automatic page number
25077
- * @category Command
25078
- * @returns {Function} Command function
25079
- * @example
25080
- * editor.commands.addAutoPageNumber()
25081
- * @note Only works in header/footer contexts
25082
- */
25083
24987
  addAutoPageNumber: () => ({ tr, dispatch, state, editor }) => {
25084
24988
  const { options } = editor;
25085
24989
  if (!options.isHeaderOrFooter) return false;
@@ -25142,14 +25046,6 @@ const TotalPageCount = Node$1.create({
25142
25046
  },
25143
25047
  addCommands() {
25144
25048
  return {
25145
- /**
25146
- * Insert total page count
25147
- * @category Command
25148
- * @returns {Function} Command function
25149
- * @example
25150
- * editor.commands.addTotalPageCount()
25151
- * @note Only works in header/footer contexts
25152
- */
25153
25049
  addTotalPageCount: () => ({ tr, dispatch, state, editor }) => {
25154
25050
  const { options } = editor;
25155
25051
  if (!options.isHeaderOrFooter) return false;
@@ -25226,8 +25122,8 @@ renderDom_fn = function(node, htmlAttributes) {
25226
25122
  __privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
25227
25123
  Object.assign(nodeContent.style, styles);
25228
25124
  nodeContent.appendChild(content);
25229
- Object.entries(htmlAttributes).forEach(([key2, value]) => {
25230
- if (value) nodeContent.setAttribute(key2, value);
25125
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
25126
+ if (value) nodeContent.setAttribute(key, value);
25231
25127
  });
25232
25128
  return nodeContent;
25233
25129
  };
@@ -25293,8 +25189,8 @@ const processMarks = (marks) => {
25293
25189
  break;
25294
25190
  default:
25295
25191
  if (attrs?.style) {
25296
- Object.entries(attrs.style).forEach(([key2, value]) => {
25297
- styles[key2] = value;
25192
+ Object.entries(attrs.style).forEach(([key, value]) => {
25193
+ styles[key] = value;
25298
25194
  });
25299
25195
  }
25300
25196
  break;
@@ -25416,6 +25312,11 @@ const ContentBlock = Node$1.create({
25416
25312
  inline: true,
25417
25313
  addOptions() {
25418
25314
  return {
25315
+ /**
25316
+ * @typedef {Object} ContentBlockOptions
25317
+ * @category Options
25318
+ * @property {Object} [htmlAttributes] - HTML attributes for the block element
25319
+ */
25419
25320
  htmlAttributes: {
25420
25321
  contenteditable: false
25421
25322
  }
@@ -25423,6 +25324,10 @@ const ContentBlock = Node$1.create({
25423
25324
  },
25424
25325
  addAttributes() {
25425
25326
  return {
25327
+ /**
25328
+ * @category Attribute
25329
+ * @param {boolean} [horizontalRule=false] - Whether this block is a horizontal rule
25330
+ */
25426
25331
  horizontalRule: {
25427
25332
  default: false,
25428
25333
  renderDOM: ({ horizontalRule }) => {
@@ -25430,6 +25335,10 @@ const ContentBlock = Node$1.create({
25430
25335
  return { "data-horizontal-rule": "true" };
25431
25336
  }
25432
25337
  },
25338
+ /**
25339
+ * @category Attribute
25340
+ * @param {ContentBlockSize} [size] - Size and position of the content block
25341
+ */
25433
25342
  size: {
25434
25343
  default: null,
25435
25344
  renderDOM: ({ size }) => {
@@ -25443,6 +25352,10 @@ const ContentBlock = Node$1.create({
25443
25352
  return { style };
25444
25353
  }
25445
25354
  },
25355
+ /**
25356
+ * @category Attribute
25357
+ * @param {string} [background] - Background color for the block
25358
+ */
25446
25359
  background: {
25447
25360
  default: null,
25448
25361
  renderDOM: (attrs) => {
@@ -25452,9 +25365,19 @@ const ContentBlock = Node$1.create({
25452
25365
  };
25453
25366
  }
25454
25367
  },
25368
+ /**
25369
+ * @private
25370
+ * @category Attribute
25371
+ * @param {Object} [drawingContent] - Internal drawing data
25372
+ */
25455
25373
  drawingContent: {
25456
25374
  rendered: false
25457
25375
  },
25376
+ /**
25377
+ * @private
25378
+ * @category Attribute
25379
+ * @param {Object} [attributes] - Additional internal attributes
25380
+ */
25458
25381
  attributes: {
25459
25382
  rendered: false
25460
25383
  }
@@ -25475,8 +25398,9 @@ const ContentBlock = Node$1.create({
25475
25398
  /**
25476
25399
  * Insert a horizontal rule
25477
25400
  * @category Command
25401
+ * @returns {Function} Command function
25478
25402
  * @example
25479
- * editor.commands.insertHorizontalRule()
25403
+ * insertHorizontalRule()
25480
25404
  * @note Creates a visual separator between content sections
25481
25405
  */
25482
25406
  insertHorizontalRule: () => ({ commands: commands2 }) => {
@@ -25493,13 +25417,13 @@ const ContentBlock = Node$1.create({
25493
25417
  * Insert a content block
25494
25418
  * @category Command
25495
25419
  * @param {ContentBlockConfig} config - Block configuration
25420
+ * @returns {Function} Command function
25496
25421
  * @example
25497
25422
  * // Insert a spacer block
25498
- * editor.commands.insertContentBlock({ size: { height: 20 } })
25423
+ * insertContentBlock({ size: { height: 20 } })
25499
25424
  *
25500
- * @example
25501
25425
  * // Insert a colored divider
25502
- * editor.commands.insertContentBlock({
25426
+ * insertContentBlock({
25503
25427
  * size: { width: '50%', height: 3 },
25504
25428
  * background: '#3b82f6'
25505
25429
  * })
@@ -25514,353 +25438,69 @@ const ContentBlock = Node$1.create({
25514
25438
  };
25515
25439
  }
25516
25440
  });
25517
- class StructuredContentViewBase {
25518
- constructor(props) {
25519
- __publicField(this, "node");
25520
- __publicField(this, "view");
25521
- __publicField(this, "getPos");
25522
- __publicField(this, "decorations");
25523
- __publicField(this, "innerDecorations");
25524
- __publicField(this, "editor");
25525
- __publicField(this, "extension");
25526
- __publicField(this, "htmlAttributes");
25527
- __publicField(this, "root");
25528
- __publicField(this, "isDragging", false);
25529
- this.node = props.node;
25530
- this.view = props.editor.view;
25531
- this.getPos = props.getPos;
25532
- this.decorations = props.decorations;
25533
- this.innerDecorations = props.innerDecorations;
25534
- this.editor = props.editor;
25535
- this.extension = props.extension;
25536
- this.htmlAttributes = props.htmlAttributes;
25537
- this.mount(props);
25538
- }
25539
- mount() {
25540
- return;
25541
- }
25542
- get dom() {
25543
- return this.root;
25544
- }
25545
- get contentDOM() {
25546
- return null;
25547
- }
25548
- update(node, decorations, innerDecorations) {
25549
- if (node.type !== this.node.type) {
25550
- return false;
25551
- }
25552
- this.node = node;
25553
- this.decorations = decorations;
25554
- this.innerDecorations = innerDecorations;
25555
- this.updateHTMLAttributes();
25556
- return true;
25557
- }
25558
- stopEvent(event) {
25559
- if (!this.dom) return false;
25560
- const target = event.target;
25561
- const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target);
25562
- if (!isInElement) return false;
25563
- const isDragEvent = event.type.startsWith("drag");
25564
- const isDropEvent = event.type === "drop";
25565
- const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
25566
- if (isInput && !isDropEvent && !isDragEvent) return true;
25567
- const { isEditable } = this.editor;
25568
- const { isDragging } = this;
25569
- const isDraggable = !!this.node.type.spec.draggable;
25570
- const isSelectable = NodeSelection.isSelectable(this.node);
25571
- const isCopyEvent = event.type === "copy";
25572
- const isPasteEvent = event.type === "paste";
25573
- const isCutEvent = event.type === "cut";
25574
- const isClickEvent = event.type === "mousedown";
25575
- if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {
25576
- event.preventDefault();
25577
- }
25578
- if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {
25579
- event.preventDefault();
25580
- return false;
25581
- }
25582
- if (isDraggable && isEditable && !isDragging && isClickEvent) {
25583
- const dragHandle = target.closest("[data-drag-handle]");
25584
- const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
25585
- if (isValidDragHandle) {
25586
- this.isDragging = true;
25587
- document.addEventListener(
25588
- "dragend",
25589
- () => {
25590
- this.isDragging = false;
25591
- },
25592
- { once: true }
25593
- );
25594
- document.addEventListener(
25595
- "drop",
25596
- () => {
25597
- this.isDragging = false;
25598
- },
25599
- { once: true }
25600
- );
25601
- document.addEventListener(
25602
- "mouseup",
25603
- () => {
25604
- this.isDragging = false;
25605
- },
25606
- { once: true }
25607
- );
25608
- }
25609
- }
25610
- if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
25611
- return false;
25612
- }
25613
- return true;
25614
- }
25615
- ignoreMutation(mutation) {
25616
- if (!this.dom || !this.contentDOM) return true;
25617
- if (this.node.isLeaf || this.node.isAtom) return true;
25618
- if (mutation.type === "selection") return false;
25619
- if (this.contentDOM === mutation.target && mutation.type === "attributes") return true;
25620
- if (this.contentDOM.contains(mutation.target)) return false;
25621
- return true;
25622
- }
25623
- destroy() {
25624
- this.dom.remove();
25625
- this.contentDOM?.remove();
25626
- }
25627
- updateAttributes(attrs) {
25628
- const pos = this.getPos();
25629
- if (typeof pos !== "number") {
25630
- return;
25631
- }
25632
- return this.view.dispatch(
25633
- this.view.state.tr.setNodeMarkup(pos, void 0, {
25634
- ...this.node.attrs,
25635
- ...attrs
25636
- })
25637
- );
25638
- }
25639
- updateHTMLAttributes() {
25640
- const { extensionService } = this.editor;
25641
- const { attributes } = extensionService;
25642
- const extensionAttrs = attributes.filter((i) => i.type === this.node.type.name);
25643
- this.htmlAttributes = Attribute.getAttributesToRender(this.node, extensionAttrs);
25644
- }
25645
- createDragHandle() {
25646
- const dragHandle = document.createElement("span");
25647
- dragHandle.classList.add("sd-structured-content-draggable");
25648
- dragHandle.draggable = true;
25649
- dragHandle.contentEditable = "false";
25650
- dragHandle.dataset.dragHandle = "";
25651
- const textElement = document.createElement("span");
25652
- textElement.textContent = "Structured content";
25653
- dragHandle.append(textElement);
25654
- return dragHandle;
25655
- }
25656
- onDragStart(event) {
25657
- const { view } = this.editor;
25658
- const target = event.target;
25659
- const dragHandle = target.nodeType === 3 ? target.parentElement?.closest("[data-drag-handle]") : target.closest("[data-drag-handle]");
25660
- if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {
25661
- return;
25662
- }
25663
- let x = 0;
25664
- let y = 0;
25665
- if (this.dom !== dragHandle) {
25666
- const domBox = this.dom.getBoundingClientRect();
25667
- const handleBox = dragHandle.getBoundingClientRect();
25668
- const offsetX = event.offsetX ?? event.nativeEvent?.offsetX;
25669
- const offsetY = event.offsetY ?? event.nativeEvent?.offsetY;
25670
- x = handleBox.x - domBox.x + offsetX;
25671
- y = handleBox.y - domBox.y + offsetY;
25672
- }
25673
- event.dataTransfer?.setDragImage(this.dom, x, y);
25674
- const pos = this.getPos();
25675
- if (typeof pos !== "number") {
25676
- return;
25677
- }
25678
- const selection = NodeSelection.create(view.state.doc, pos);
25679
- const transaction = view.state.tr.setSelection(selection);
25680
- view.dispatch(transaction);
25681
- }
25682
- }
25683
- class StructuredContentInlineView extends StructuredContentViewBase {
25684
- constructor(props) {
25685
- super(props);
25686
- }
25687
- mount() {
25688
- this.buildView();
25689
- }
25690
- get contentDOM() {
25691
- const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass$1}`);
25692
- return contentElement || null;
25693
- }
25694
- createElement() {
25695
- const element = document.createElement("span");
25696
- element.classList.add(structuredContentClass$1);
25697
- element.setAttribute("data-structured-content", "");
25698
- const contentElement = document.createElement("span");
25699
- contentElement.classList.add(structuredContentInnerClass$1);
25700
- element.append(contentElement);
25701
- const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
25702
- updateDOMAttributes(element, { ...domAttrs });
25703
- return { element, contentElement };
25704
- }
25705
- buildView() {
25706
- const { element } = this.createElement();
25707
- const dragHandle = this.createDragHandle();
25708
- element.prepend(dragHandle);
25709
- element.addEventListener("dragstart", (e) => this.onDragStart(e));
25710
- this.root = element;
25711
- }
25712
- updateView() {
25713
- const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
25714
- updateDOMAttributes(this.dom, { ...domAttrs });
25715
- }
25716
- update(node, decorations, innerDecorations) {
25717
- const result = super.update(node, decorations, innerDecorations);
25718
- if (!result) return false;
25719
- this.updateView();
25720
- return true;
25721
- }
25722
- }
25723
- const structuredContentClass$1 = "sd-structured-content";
25724
- const structuredContentInnerClass$1 = "sd-structured-content__content";
25725
25441
  const StructuredContent = Node$1.create({
25726
25442
  name: "structuredContent",
25727
- group: "inline structuredContent",
25443
+ group: "inline",
25728
25444
  inline: true,
25729
25445
  content: "inline*",
25730
- isolating: true,
25731
- atom: false,
25732
- // false - has editable content.
25733
- draggable: true,
25734
25446
  addOptions() {
25735
25447
  return {
25448
+ structuredContentClass: "sd-structured-content-tag",
25736
25449
  htmlAttributes: {
25737
- class: structuredContentClass$1,
25738
25450
  "aria-label": "Structured content node"
25739
25451
  }
25740
25452
  };
25741
25453
  },
25742
25454
  addAttributes() {
25743
25455
  return {
25744
- id: {
25745
- default: null,
25746
- parseDOM: (elem) => elem.getAttribute("data-id"),
25747
- renderDOM: (attrs) => {
25748
- if (!attrs.id) return {};
25749
- return { "data-id": attrs.id };
25750
- }
25751
- },
25752
25456
  sdtPr: {
25753
25457
  rendered: false
25754
25458
  }
25755
25459
  };
25756
25460
  },
25757
25461
  parseDOM() {
25758
- return [{ tag: "span[data-structured-content]" }];
25462
+ return [{ tag: `span.${this.options.structuredContentClass}` }];
25759
25463
  },
25760
25464
  renderDOM({ htmlAttributes }) {
25761
25465
  return [
25762
25466
  "span",
25763
25467
  Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
25764
- "data-structured-content": ""
25468
+ class: this.options.structuredContentClass
25765
25469
  }),
25766
25470
  0
25767
25471
  ];
25768
- },
25769
- addNodeView() {
25770
- return (props) => {
25771
- return new StructuredContentInlineView({ ...props });
25772
- };
25773
25472
  }
25774
25473
  });
25775
- class StructuredContentBlockView extends StructuredContentViewBase {
25776
- constructor(props) {
25777
- super(props);
25778
- }
25779
- mount() {
25780
- this.buildView();
25781
- }
25782
- get contentDOM() {
25783
- const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass}`);
25784
- return contentElement || null;
25785
- }
25786
- createElement() {
25787
- const element = document.createElement("div");
25788
- element.classList.add(structuredContentClass);
25789
- element.setAttribute("data-structured-content-block", "");
25790
- const contentElement = document.createElement("div");
25791
- contentElement.classList.add(structuredContentInnerClass);
25792
- element.append(contentElement);
25793
- const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
25794
- updateDOMAttributes(element, { ...domAttrs });
25795
- return { element, contentElement };
25796
- }
25797
- buildView() {
25798
- const { element } = this.createElement();
25799
- const dragHandle = this.createDragHandle();
25800
- element.prepend(dragHandle);
25801
- element.addEventListener("dragstart", (e) => this.onDragStart(e));
25802
- this.root = element;
25803
- }
25804
- updateView() {
25805
- const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
25806
- updateDOMAttributes(this.dom, { ...domAttrs });
25807
- }
25808
- update(node, decorations, innerDecorations) {
25809
- const result = super.update(node, decorations, innerDecorations);
25810
- if (!result) return false;
25811
- this.updateView();
25812
- return true;
25813
- }
25814
- }
25815
- const structuredContentClass = "sd-structured-content-block";
25816
- const structuredContentInnerClass = "sd-structured-content-block__content";
25817
25474
  const StructuredContentBlock = Node$1.create({
25818
25475
  name: "structuredContentBlock",
25819
- group: "block structuredContent",
25476
+ group: "block",
25820
25477
  content: "block*",
25821
- isolating: true,
25822
- atom: false,
25823
- // false - has editable content.
25824
- draggable: true,
25825
25478
  addOptions() {
25826
25479
  return {
25480
+ structuredContentClass: "sd-structured-content-block-tag",
25827
25481
  htmlAttributes: {
25828
- class: structuredContentClass,
25829
25482
  "aria-label": "Structured content block node"
25830
25483
  }
25831
25484
  };
25832
25485
  },
25833
25486
  addAttributes() {
25834
25487
  return {
25835
- id: {
25836
- default: null,
25837
- parseDOM: (elem) => elem.getAttribute("data-id"),
25838
- renderDOM: (attrs) => {
25839
- if (!attrs.id) return {};
25840
- return { "data-id": attrs.id };
25841
- }
25842
- },
25843
25488
  sdtPr: {
25844
25489
  rendered: false
25845
25490
  }
25846
25491
  };
25847
25492
  },
25848
25493
  parseDOM() {
25849
- return [{ tag: "div[data-structured-content-block]" }];
25494
+ return [{ tag: `div.${this.options.structuredContentClass}` }];
25850
25495
  },
25851
25496
  renderDOM({ htmlAttributes }) {
25852
25497
  return [
25853
25498
  "div",
25854
25499
  Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
25855
- "data-structured-content-block": ""
25500
+ class: this.options.structuredContentClass
25856
25501
  }),
25857
25502
  0
25858
25503
  ];
25859
- },
25860
- addNodeView() {
25861
- return (props) => {
25862
- return new StructuredContentBlockView({ ...props });
25863
- };
25864
25504
  }
25865
25505
  });
25866
25506
  class DocumentSectionView {
@@ -26027,7 +25667,16 @@ const DocumentSection = Node$1.create({
26027
25667
  },
26028
25668
  addAttributes() {
26029
25669
  return {
25670
+ /**
25671
+ * @category Attribute
25672
+ * @param {number} [id] - Unique section identifier
25673
+ */
26030
25674
  id: {},
25675
+ /**
25676
+ * @private
25677
+ * @category Attribute
25678
+ * @param {string} [sdBlockId] - Internal block tracking
25679
+ */
26031
25680
  sdBlockId: {
26032
25681
  default: null,
26033
25682
  keepOnSplit: false,
@@ -26036,9 +25685,25 @@ const DocumentSection = Node$1.create({
26036
25685
  return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
26037
25686
  }
26038
25687
  },
25688
+ /**
25689
+ * @category Attribute
25690
+ * @param {string} [title] - Section display label
25691
+ */
26039
25692
  title: {},
25693
+ /**
25694
+ * @category Attribute
25695
+ * @param {string} [description] - Section metadata
25696
+ */
26040
25697
  description: {},
25698
+ /**
25699
+ * @category Attribute
25700
+ * @param {string} [sectionType] - Business classification (e.g., 'legal', 'pricing')
25701
+ */
26041
25702
  sectionType: {},
25703
+ /**
25704
+ * @category Attribute
25705
+ * @param {boolean} [isLocked=false] - Lock state preventing edits
25706
+ */
26042
25707
  isLocked: { default: false }
26043
25708
  };
26044
25709
  },
@@ -26053,9 +25718,10 @@ const DocumentSection = Node$1.create({
26053
25718
  * Create a lockable content section
26054
25719
  * @category Command
26055
25720
  * @param {SectionCreate} [options={}] - Section configuration
25721
+ * @returns {Function} Command - true if created, false if position invalid
26056
25722
  * @example
26057
- * editor.commands.createDocumentSection({
26058
- * id: 1,
25723
+ * createDocumentSection({
25724
+ * id: 'legal-1',
26059
25725
  * title: 'Terms & Conditions',
26060
25726
  * isLocked: true,
26061
25727
  * html: '<p>Legal content...</p>'
@@ -26136,8 +25802,9 @@ const DocumentSection = Node$1.create({
26136
25802
  /**
26137
25803
  * Remove section wrapper at cursor, preserving its content
26138
25804
  * @category Command
25805
+ * @returns {Function} Command - true if removed, false if no section at position
26139
25806
  * @example
26140
- * editor.commands.removeSectionAtSelection()
25807
+ * removeSectionAtSelection()
26141
25808
  * @note Content stays in document, only section wrapper is removed
26142
25809
  */
26143
25810
  removeSectionAtSelection: () => ({ tr, dispatch }) => {
@@ -26163,8 +25830,9 @@ const DocumentSection = Node$1.create({
26163
25830
  * Delete section and all its content
26164
25831
  * @category Command
26165
25832
  * @param {number} id - Section to delete
25833
+ * @returns {Function} Command - true if deleted, false if ID doesn't exist
26166
25834
  * @example
26167
- * editor.commands.removeSectionById(123)
25835
+ * removeSectionById(123)
26168
25836
  */
26169
25837
  removeSectionById: (id) => ({ tr, dispatch }) => {
26170
25838
  const sections = SectionHelpers.getAllSections(this.editor);
@@ -26184,8 +25852,9 @@ const DocumentSection = Node$1.create({
26184
25852
  * Lock section against edits
26185
25853
  * @category Command
26186
25854
  * @param {number} id - Section to lock
25855
+ * @returns {Function} Command - true if locked, false if ID doesn't exist
26187
25856
  * @example
26188
- * editor.commands.lockSectionById(123)
25857
+ * lockSectionById(123)
26189
25858
  */
26190
25859
  lockSectionById: (id) => ({ tr, dispatch }) => {
26191
25860
  const sections = SectionHelpers.getAllSections(this.editor);
@@ -26202,10 +25871,16 @@ const DocumentSection = Node$1.create({
26202
25871
  * Modify section attributes or content
26203
25872
  * @category Command
26204
25873
  * @param {SectionUpdate} options - Changes to apply
25874
+ * @returns {Function} Command - true if updated, false if ID doesn't exist
26205
25875
  * @example
26206
- * editor.commands.updateSectionById({ id: 123, attrs: { isLocked: false } })
26207
- * editor.commands.updateSectionById({ id: 123, html: '<p>New content</p>' })
26208
- * editor.commands.updateSectionById({
25876
+ * // Toggle lock
25877
+ * updateSectionById({ id: 123, attrs: { isLocked: false } })
25878
+ *
25879
+ * // Replace content
25880
+ * updateSectionById({ id: 123, html: '<p>New content</p>' })
25881
+ *
25882
+ * // Both
25883
+ * updateSectionById({
26209
25884
  * id: 123,
26210
25885
  * html: '<p>Updated</p>',
26211
25886
  * attrs: { title: 'New Title' }
@@ -26255,10 +25930,11 @@ const BlockNode = Extension.create({
26255
25930
  * Replace a block node by its ID with new content
26256
25931
  * @category Command
26257
25932
  * @param {string} id - The sdBlockId of the node to replace
26258
- * @param {ProseMirrorNode} contentNode - The replacement ProseMirror node
25933
+ * @param {Object} contentNode - The replacement ProseMirror node
25934
+ * @returns {Function} Command function
26259
25935
  * @example
26260
25936
  * const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
26261
- * editor.commands.replaceBlockNodeById('block-123', newParagraph)
25937
+ * replaceBlockNodeById('block-123', newParagraph)
26262
25938
  * @note The replacement node should have the same type as the original
26263
25939
  */
26264
25940
  replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
@@ -26281,8 +25957,9 @@ const BlockNode = Extension.create({
26281
25957
  * Delete a block node by its ID
26282
25958
  * @category Command
26283
25959
  * @param {string} id - The sdBlockId of the node to delete
25960
+ * @returns {Function} Command function
26284
25961
  * @example
26285
- * editor.commands.deleteBlockNodeById('block-123')
25962
+ * deleteBlockNodeById('block-123')
26286
25963
  * @note Completely removes the node from the document
26287
25964
  */
26288
25965
  deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
@@ -26306,10 +25983,11 @@ const BlockNode = Extension.create({
26306
25983
  * @category Command
26307
25984
  * @param {string} id - The sdBlockId of the node to update
26308
25985
  * @param {Object} attrs - Attributes to update
25986
+ * @returns {Function} Command function
26309
25987
  * @example
26310
- * editor.commands.updateBlockNodeAttributes('block-123', { textAlign: 'center' })
25988
+ * updateBlockNodeAttributes('block-123', { textAlign: 'center' })
26311
25989
  * @example
26312
- * editor.commands.updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
25990
+ * updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
26313
25991
  * @note Merges new attributes with existing ones
26314
25992
  */
26315
25993
  updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
@@ -26403,7 +26081,7 @@ const BlockNode = Extension.create({
26403
26081
  key: BlockNodePluginKey,
26404
26082
  appendTransaction: (transactions, _oldState, newState) => {
26405
26083
  if (hasInitialized && !transactions.some((tr2) => tr2.docChanged)) return null;
26406
- if (hasInitialized && !checkForNewBlockNodesInTrs([...transactions])) return null;
26084
+ if (hasInitialized && !checkForNewBlockNodesInTrs(transactions)) return null;
26407
26085
  const { tr } = newState;
26408
26086
  let changed = false;
26409
26087
  newState.doc.descendants((node, pos) => {
@@ -26482,8 +26160,9 @@ const TextStyle = Mark.create({
26482
26160
  /**
26483
26161
  * Remove empty text style marks
26484
26162
  * @category Command
26163
+ * @returns {Function} Command function - Removes mark if no attributes present
26485
26164
  * @example
26486
- * editor.commands.removeEmptyTextStyle()
26165
+ * removeEmptyTextStyle()
26487
26166
  * @note Cleanup utility to prevent empty span elements
26488
26167
  * @note Automatically checks if any style attributes exist before removal
26489
26168
  */
@@ -26505,6 +26184,10 @@ const Bold = Mark.create({
26505
26184
  },
26506
26185
  addAttributes() {
26507
26186
  return {
26187
+ /**
26188
+ * @category Attribute
26189
+ * @param {string} [value] - Bold weight value ('0' renders as normal)
26190
+ */
26508
26191
  value: {
26509
26192
  default: null,
26510
26193
  renderDOM: (attrs) => {
@@ -26533,23 +26216,26 @@ const Bold = Mark.create({
26533
26216
  /**
26534
26217
  * Apply bold formatting
26535
26218
  * @category Command
26219
+ * @returns {Function} Command
26536
26220
  * @example
26537
- * editor.commands.setBold()
26221
+ * setBold()
26538
26222
  * @note '0' renders as normal weight
26539
26223
  */
26540
26224
  setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
26541
26225
  /**
26542
26226
  * Remove bold formatting
26543
26227
  * @category Command
26228
+ * @returns {Function} Command
26544
26229
  * @example
26545
- * editor.commands.unsetBold()
26230
+ * unsetBold()
26546
26231
  */
26547
26232
  unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
26548
26233
  /**
26549
26234
  * Toggle bold formatting
26550
26235
  * @category Command
26236
+ * @returns {Function} Command
26551
26237
  * @example
26552
- * editor.commands.toggleBold()
26238
+ * toggleBold()
26553
26239
  */
26554
26240
  toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
26555
26241
  };
@@ -26584,22 +26270,25 @@ const Italic = Mark.create({
26584
26270
  /**
26585
26271
  * Apply italic formatting
26586
26272
  * @category Command
26273
+ * @returns {Function} Command
26587
26274
  * @example
26588
- * editor.commands.setItalic()
26275
+ * setItalic()
26589
26276
  */
26590
26277
  setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
26591
26278
  /**
26592
26279
  * Remove italic formatting
26593
26280
  * @category Command
26281
+ * @returns {Function} Command
26594
26282
  * @example
26595
- * editor.commands.unsetItalic()
26283
+ * unsetItalic()
26596
26284
  */
26597
26285
  unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
26598
26286
  /**
26599
26287
  * Toggle italic formatting
26600
26288
  * @category Command
26289
+ * @returns {Function} Command
26601
26290
  * @example
26602
- * editor.commands.toggleItalic()
26291
+ * toggleItalic()
26603
26292
  */
26604
26293
  toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
26605
26294
  };
@@ -26683,6 +26372,10 @@ const Highlight = Mark.create({
26683
26372
  },
26684
26373
  addAttributes() {
26685
26374
  return {
26375
+ /**
26376
+ * @category Attribute
26377
+ * @param {string} [color] - Background color (CSS color value)
26378
+ */
26686
26379
  color: {
26687
26380
  default: null,
26688
26381
  parseDOM: (element) => element.getAttribute("data-color") || element.style.backgroundColor,
@@ -26710,23 +26403,26 @@ const Highlight = Mark.create({
26710
26403
  * Apply highlight with specified color
26711
26404
  * @category Command
26712
26405
  * @param {string} color - CSS color value
26406
+ * @returns {Function} Command
26713
26407
  * @example
26714
- * editor.commands.setHighlight('#FFEB3B')
26715
- * editor.commands.setHighlight('rgba(255, 235, 59, 0.5)')
26408
+ * setHighlight('#FFEB3B')
26409
+ * setHighlight('rgba(255, 235, 59, 0.5)')
26716
26410
  */
26717
26411
  setHighlight: (color) => ({ commands: commands2 }) => commands2.setMark(this.name, { color }),
26718
26412
  /**
26719
26413
  * Remove highlight formatting
26720
26414
  * @category Command
26415
+ * @returns {Function} Command
26721
26416
  * @example
26722
- * editor.commands.unsetHighlight()
26417
+ * unsetHighlight()
26723
26418
  */
26724
26419
  unsetHighlight: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
26725
26420
  /**
26726
26421
  * Toggle highlight formatting
26727
26422
  * @category Command
26423
+ * @returns {Function} Command
26728
26424
  * @example
26729
- * editor.commands.toggleHighlight()
26425
+ * toggleHighlight()
26730
26426
  */
26731
26427
  toggleHighlight: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
26732
26428
  };
@@ -26759,8 +26455,9 @@ const Strike = Mark.create({
26759
26455
  /**
26760
26456
  * Apply strikethrough formatting
26761
26457
  * @category Command
26458
+ * @returns {Function} Command
26762
26459
  * @example
26763
- * editor.commands.setStrike()
26460
+ * setStrike()
26764
26461
  */
26765
26462
  setStrike: () => ({ commands: commands2 }) => {
26766
26463
  return commands2.setMark(this.name);
@@ -26768,8 +26465,9 @@ const Strike = Mark.create({
26768
26465
  /**
26769
26466
  * Remove strikethrough formatting
26770
26467
  * @category Command
26468
+ * @returns {Function} Command
26771
26469
  * @example
26772
- * editor.commands.unsetStrike()
26470
+ * unsetStrike()
26773
26471
  */
26774
26472
  unsetStrike: () => ({ commands: commands2 }) => {
26775
26473
  return commands2.unsetMark(this.name);
@@ -26777,8 +26475,9 @@ const Strike = Mark.create({
26777
26475
  /**
26778
26476
  * Toggle strikethrough formatting
26779
26477
  * @category Command
26478
+ * @returns {Function} Command
26780
26479
  * @example
26781
- * editor.commands.toggleStrike()
26480
+ * toggleStrike()
26782
26481
  */
26783
26482
  toggleStrike: () => ({ commands: commands2 }) => {
26784
26483
  return commands2.toggleMark(this.name);
@@ -26798,6 +26497,11 @@ const Link = Mark.create({
26798
26497
  inclusive: false,
26799
26498
  addOptions() {
26800
26499
  return {
26500
+ /**
26501
+ * Allowed URL protocols
26502
+ * @type {string[]}
26503
+ * @default ['http', 'https']
26504
+ */
26801
26505
  protocols: ["http", "https"],
26802
26506
  htmlAttributes: {
26803
26507
  target: null,
@@ -26896,10 +26600,16 @@ const Link = Mark.create({
26896
26600
  /**
26897
26601
  * Create or update a link
26898
26602
  * @category Command
26899
- * @param {SetLinkOptions} [options] - Link configuration
26603
+ * @param {Object} options - Link configuration
26604
+ * @param {string} [options.href] - URL for the link
26605
+ * @param {string} [options.text] - Display text (uses selection if omitted)
26606
+ * @returns {Function} Command - Creates link with underline
26900
26607
  * @example
26901
- * editor.commands.setLink({ href: 'https://example.com' })
26902
- * editor.commands.setLink({
26608
+ * // Link selected text
26609
+ * setLink({ href: 'https://example.com' })
26610
+ *
26611
+ * // Link with custom text
26612
+ * setLink({
26903
26613
  * href: 'https://example.com',
26904
26614
  * text: 'Visit Example'
26905
26615
  * })
@@ -26951,8 +26661,9 @@ const Link = Mark.create({
26951
26661
  /**
26952
26662
  * Remove link and associated formatting
26953
26663
  * @category Command
26664
+ * @returns {Function} Command - Removes link, underline, and color
26954
26665
  * @example
26955
- * editor.commands.unsetLink()
26666
+ * unsetLink()
26956
26667
  * @note Also removes underline and text color
26957
26668
  */
26958
26669
  unsetLink: () => ({ chain }) => {
@@ -26961,10 +26672,16 @@ const Link = Mark.create({
26961
26672
  /**
26962
26673
  * Toggle link on selection
26963
26674
  * @category Command
26964
- * @param {SetLinkOptions} [options] - Link configuration
26675
+ * @param {Object} [options] - Link configuration
26676
+ * @param {string} [options.href] - URL for the link
26677
+ * @param {string} [options.text] - Display text
26678
+ * @returns {Function} Command - Creates link if href provided, removes otherwise
26965
26679
  * @example
26966
- * editor.commands.toggleLink({ href: 'https://example.com' })
26967
- * editor.commands.toggleLink()
26680
+ * // Add link
26681
+ * toggleLink({ href: 'https://example.com' })
26682
+ *
26683
+ * // Remove link
26684
+ * toggleLink()
26968
26685
  */
26969
26686
  toggleLink: ({ href, text } = {}) => ({ commands: commands2 }) => {
26970
26687
  if (!href) return commands2.unsetLink();
@@ -27851,8 +27568,8 @@ function mergePaddingObject(paddingObject) {
27851
27568
  return Object.assign({}, getFreshSideObject(), paddingObject);
27852
27569
  }
27853
27570
  function expandToHashMap(value, keys2) {
27854
- return keys2.reduce(function(hashMap, key2) {
27855
- hashMap[key2] = value;
27571
+ return keys2.reduce(function(hashMap, key) {
27572
+ hashMap[key] = value;
27856
27573
  return hashMap;
27857
27574
  }, {});
27858
27575
  }
@@ -28308,10 +28025,10 @@ function detectOverflow$1(state, options) {
28308
28025
  var offsetData = state.modifiersData.offset;
28309
28026
  if (elementContext === popper && offsetData) {
28310
28027
  var offset2 = offsetData[placement];
28311
- Object.keys(overflowOffsets).forEach(function(key2) {
28312
- var multiply = [right, bottom].indexOf(key2) >= 0 ? 1 : -1;
28313
- var axis = [top, bottom].indexOf(key2) >= 0 ? "y" : "x";
28314
- overflowOffsets[key2] += offset2[axis] * multiply;
28028
+ Object.keys(overflowOffsets).forEach(function(key) {
28029
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
28030
+ var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
28031
+ overflowOffsets[key] += offset2[axis] * multiply;
28315
28032
  });
28316
28033
  }
28317
28034
  return overflowOffsets;
@@ -28758,8 +28475,8 @@ function mergeByName(modifiers2) {
28758
28475
  }) : current;
28759
28476
  return merged2;
28760
28477
  }, {});
28761
- return Object.keys(merged).map(function(key2) {
28762
- return merged[key2];
28478
+ return Object.keys(merged).map(function(key) {
28479
+ return merged[key];
28763
28480
  });
28764
28481
  }
28765
28482
  var DEFAULT_OPTIONS = {
@@ -28916,8 +28633,8 @@ var TOUCH_OPTIONS = {
28916
28633
  var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
28917
28634
  return document.body;
28918
28635
  };
28919
- function hasOwnProperty(obj, key2) {
28920
- return {}.hasOwnProperty.call(obj, key2);
28636
+ function hasOwnProperty(obj, key) {
28637
+ return {}.hasOwnProperty.call(obj, key);
28921
28638
  }
28922
28639
  function getValueAtIndexOrReturn(value, index2, defaultValue) {
28923
28640
  if (Array.isArray(value)) {
@@ -28947,8 +28664,8 @@ function debounce(fn2, ms) {
28947
28664
  }
28948
28665
  function removeProperties(obj, keys2) {
28949
28666
  var clone = Object.assign({}, obj);
28950
- keys2.forEach(function(key2) {
28951
- delete clone[key2];
28667
+ keys2.forEach(function(key) {
28668
+ delete clone[key];
28952
28669
  });
28953
28670
  return clone;
28954
28671
  }
@@ -28975,9 +28692,9 @@ function arrayFrom(value) {
28975
28692
  return [].slice.call(value);
28976
28693
  }
28977
28694
  function removeUndefinedProps(obj) {
28978
- return Object.keys(obj).reduce(function(acc, key2) {
28979
- if (obj[key2] !== void 0) {
28980
- acc[key2] = obj[key2];
28695
+ return Object.keys(obj).reduce(function(acc, key) {
28696
+ if (obj[key] !== void 0) {
28697
+ acc[key] = obj[key];
28981
28698
  }
28982
28699
  return acc;
28983
28700
  }, {});
@@ -29229,8 +28946,8 @@ var setDefaultProps = function setDefaultProps2(partialProps) {
29229
28946
  validateProps(partialProps, []);
29230
28947
  }
29231
28948
  var keys2 = Object.keys(partialProps);
29232
- keys2.forEach(function(key2) {
29233
- defaultProps[key2] = partialProps[key2];
28949
+ keys2.forEach(function(key) {
28950
+ defaultProps[key] = partialProps[key];
29234
28951
  });
29235
28952
  };
29236
28953
  function getExtendedPassedProps(passedProps) {
@@ -29249,18 +28966,18 @@ function getDataAttributeProps(reference2, plugins) {
29249
28966
  var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
29250
28967
  plugins
29251
28968
  }))) : defaultKeys;
29252
- var props = propKeys.reduce(function(acc, key2) {
29253
- var valueAsString = (reference2.getAttribute("data-tippy-" + key2) || "").trim();
28969
+ var props = propKeys.reduce(function(acc, key) {
28970
+ var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim();
29254
28971
  if (!valueAsString) {
29255
28972
  return acc;
29256
28973
  }
29257
- if (key2 === "content") {
29258
- acc[key2] = valueAsString;
28974
+ if (key === "content") {
28975
+ acc[key] = valueAsString;
29259
28976
  } else {
29260
28977
  try {
29261
- acc[key2] = JSON.parse(valueAsString);
28978
+ acc[key] = JSON.parse(valueAsString);
29262
28979
  } catch (e) {
29263
- acc[key2] = valueAsString;
28980
+ acc[key] = valueAsString;
29264
28981
  }
29265
28982
  }
29266
28983
  return acc;
@@ -30184,8 +29901,8 @@ tippy.setDefaultProps({
30184
29901
  });
30185
29902
  const _export_sfc = (sfc, props) => {
30186
29903
  const target = sfc.__vccOpts || sfc;
30187
- for (const [key2, val] of props) {
30188
- target[key2] = val;
29904
+ for (const [key, val] of props) {
29905
+ target[key] = val;
30189
29906
  }
30190
29907
  return target;
30191
29908
  };
@@ -30281,9 +29998,6 @@ const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b
30281
29998
  const popoverPluginKey = new PluginKey("popoverPlugin");
30282
29999
  const PopoverPlugin = Extension.create({
30283
30000
  name: "popoverPlugin",
30284
- addOptions() {
30285
- return {};
30286
- },
30287
30001
  addPmPlugins() {
30288
30002
  const popover = new Plugin({
30289
30003
  key: popoverPluginKey,
@@ -31580,9 +31294,9 @@ const Pagination = Extension.create({
31580
31294
  if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
31581
31295
  return { ...oldState };
31582
31296
  }
31583
- const imageRegistrationMetaType = getImageRegistrationMetaType(tr);
31584
- if (imageRegistrationMetaType) {
31585
- if (imageRegistrationMetaType === "remove") {
31297
+ const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
31298
+ if (imagePluginTransaction) {
31299
+ if (imagePluginTransaction.type === "remove") {
31586
31300
  onImageLoad(editor);
31587
31301
  }
31588
31302
  return { ...oldState };
@@ -32511,11 +32225,12 @@ const Search = Extension.create({
32511
32225
  addCommands() {
32512
32226
  return {
32513
32227
  /**
32514
- * Navigate to the first search match
32228
+ * Navigates to the first search match
32515
32229
  * @category Command
32230
+ * @returns {Function} - Command function
32516
32231
  * @example
32517
- * editor.commands.goToFirstMatch()
32518
- * @note Scrolls editor to the first match from previous search
32232
+ * goToFirstMatch()
32233
+ * @note Scrolls Editor to the first match of called search().
32519
32234
  */
32520
32235
  goToFirstMatch: () => (
32521
32236
  /** @returns {boolean} */
@@ -32531,13 +32246,13 @@ const Search = Extension.create({
32531
32246
  }
32532
32247
  ),
32533
32248
  /**
32534
- * Search for string matches in editor content
32249
+ * Searches for the string match in Editor content
32535
32250
  * @category Command
32536
32251
  * @param {String|RegExp} patternInput - Search string or pattern
32252
+ * @returns {Function} - Command function that returns matches
32537
32253
  * @example
32538
- * const matches = editor.commands.search('test string')
32539
- * const regexMatches = editor.commands.search(/test/i)
32540
- * @note Returns array of SearchMatch objects with positions and IDs
32254
+ * search('test string')
32255
+ * @note Searches for the test string in the Editor content and returns an array of matches
32541
32256
  */
32542
32257
  search: (patternInput) => (
32543
32258
  /** @returns {SearchMatch[]} */
@@ -32580,13 +32295,14 @@ const Search = Extension.create({
32580
32295
  }
32581
32296
  ),
32582
32297
  /**
32583
- * Navigate to a specific search match
32298
+ * Navigates to the selected match
32584
32299
  * @category Command
32585
- * @param {SearchMatch} match - Match object to navigate to
32300
+ * @param {SearchMatch} match Match at specific index
32301
+ * @returns {Function} - Command function
32586
32302
  * @example
32587
- * const searchResults = editor.commands.search('test string')
32588
- * editor.commands.goToSearchResult(searchResults[3])
32589
- * @note Scrolls to match and selects it
32303
+ * const searchResult = search('test string')
32304
+ * goToSearchResult(searchResult[3])
32305
+ * @note Scrolls Editor to the fourth match of called search() and sets selection on it.
32590
32306
  */
32591
32307
  goToSearchResult: (match) => (
32592
32308
  /** @returns {boolean} */
@@ -32848,9 +32564,6 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
32848
32564
  };
32849
32565
  const NodeResizer = Extension.create({
32850
32566
  name: "nodeResizer",
32851
- addOptions() {
32852
- return {};
32853
- },
32854
32567
  addPmPlugins() {
32855
32568
  const isHeadless = this.editor.options.isHeadless;
32856
32569
  const hasDocument = typeof document !== "undefined";
@@ -32984,20 +32697,18 @@ export {
32984
32697
  getQuickFormatList as a,
32985
32698
  generateLinkedStyleString as b,
32986
32699
  getFileOpener as c,
32987
- checkAndProcessImage as d,
32988
- uploadAndInsertImage as e,
32989
- undoDepth as f,
32700
+ undoDepth as d,
32701
+ getStarterExtensions as e,
32702
+ getRichTextExtensions as f,
32990
32703
  global as g,
32991
- redoDepth as h,
32992
- getStarterExtensions as i,
32993
- getRichTextExtensions as j,
32994
- Extension as k,
32995
- index$1 as l,
32996
- index as m,
32997
- AnnotatorHelpers as n,
32998
- SectionHelpers as o,
32999
- getAllowedImageDimensions as p,
33000
- replaceSelectionWithImagePlaceholder as r,
32704
+ Extension as h,
32705
+ index$1 as i,
32706
+ index as j,
32707
+ AnnotatorHelpers as k,
32708
+ SectionHelpers as l,
32709
+ getAllowedImageDimensions as m,
32710
+ redoDepth as r,
32711
+ startImageUpload as s,
33001
32712
  useHighContrastMode as u,
33002
32713
  yUndoPluginKey as y
33003
32714
  };