superdoc 1.0.0-beta.2 → 1.0.0-beta.20

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 (44) hide show
  1. package/dist/chunks/{PdfViewer-saAhozRR.es.js → PdfViewer-CPnD95lv.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-CeuX3gOe.cjs → PdfViewer-DbSf6FKU.cjs} +2 -2
  3. package/dist/chunks/{eventemitter3-BZXKb7j7.es.js → eventemitter3-CcXAdeql.es.js} +1 -1
  4. package/dist/chunks/{eventemitter3-CFCpOk3d.cjs → eventemitter3-DQmQUge-.cjs} +1 -1
  5. package/dist/chunks/{index-C0OeGje6.es.js → index-BSHAWPko.es.js} +11 -7
  6. package/dist/chunks/{index-Sn-JVHIg-BCItIT88.es.js → index-DHhKY9FZ-CyEU4GWR.es.js} +1 -1
  7. package/dist/chunks/{index-Sn-JVHIg-BxOp3gSx.cjs → index-DHhKY9FZ-DORT-UR6.cjs} +1 -1
  8. package/dist/chunks/{index-Dh5oVJua.cjs → index-DLco7m-w.cjs} +11 -7
  9. package/dist/chunks/{jszip-Duxs2YMV.es.js → jszip-5vvIqAEE.es.js} +1 -1
  10. package/dist/chunks/{jszip-B99MTu59.cjs → jszip-BdEez1WM.cjs} +1 -1
  11. package/dist/chunks/{super-editor.es-BKljkYUU.cjs → super-editor.es-B6lsvAAY.cjs} +11449 -2706
  12. package/dist/chunks/{super-editor.es-Dcz39nKY.es.js → super-editor.es-C0tdU_gq.es.js} +11449 -2706
  13. package/dist/chunks/{vue-B5QAf5pA.es.js → vue-Dysv_7z5.es.js} +118 -29
  14. package/dist/chunks/{vue-ARQSyfaw.cjs → vue-jWLMl8Ts.cjs} +89 -0
  15. package/dist/chunks/xml-js-ClO_jHnq.es.js +2 -0
  16. package/dist/chunks/xml-js-Dz51sEbr.cjs +3 -0
  17. package/dist/packages/superdoc/src/components/CommentsLayer/use-comment.d.ts.map +1 -1
  18. package/dist/packages/superdoc/src/core/SuperDoc.d.ts +37 -4
  19. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  20. package/dist/packages/superdoc/src/core/types/index.d.ts +2 -2
  21. package/dist/packages/superdoc/src/stores/comments-store.d.ts.map +1 -1
  22. package/dist/style.css +66 -27
  23. package/dist/super-editor/ai-writer.es.js +2 -2
  24. package/dist/super-editor/chunks/{converter-BFGB7hqj.js → converter-m2x13P8G.js} +1217 -387
  25. package/dist/super-editor/chunks/{docx-zipper-OPbzIk16.js → docx-zipper-CRSKJF-o.js} +1 -1
  26. package/dist/super-editor/chunks/{editor-CtI4XnMw.js → editor-C9r_Jbbg.js} +9373 -2162
  27. package/dist/super-editor/chunks/{index-Sn-JVHIg.js → index-DHhKY9FZ.js} +1 -1
  28. package/dist/super-editor/chunks/{toolbar-BydALv4o.js → toolbar-fnptYAcU.js} +39 -24
  29. package/dist/super-editor/converter.es.js +1 -1
  30. package/dist/super-editor/docx-zipper.es.js +2 -2
  31. package/dist/super-editor/editor.es.js +3 -3
  32. package/dist/super-editor/file-zipper.es.js +2 -2
  33. package/dist/super-editor/style.css +66 -27
  34. package/dist/super-editor/super-editor.es.js +1085 -250
  35. package/dist/super-editor/toolbar.es.js +2 -2
  36. package/dist/super-editor.cjs +4 -4
  37. package/dist/super-editor.es.js +2 -2
  38. package/dist/superdoc.cjs +2 -2
  39. package/dist/superdoc.es.js +2 -2
  40. package/dist/superdoc.umd.js +11521 -2698
  41. package/dist/superdoc.umd.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunks/xml-js-CVyfrKaV.es.js +0 -2
  44. package/dist/chunks/xml-js-DQa4Ye5C.cjs +0 -3
@@ -8,15 +8,15 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
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);
10
10
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
11
- var _SuperToolbar_instances, initToolbarGroups_fn, _interceptedCommands, makeToolbarItems_fn, initDefaultFonts_fn, updateHighlightColors_fn, deactivateAll_fn, updateToolbarHistory_fn, enrichTrackedChanges_fn, runCommandWithArgumentOnly_fn;
12
- import { aJ as getDefaultExportFromCjs, a0 as v4, T as TextSelection$1, v as getMarkRange, aM as vClickOutside, aN as getActiveFormatting, aC as isInTable, U as findParentNode, aq as calculateResolvedParagraphProperties, a7 as twipsToLines, V as isList, a8 as pixelsToTwips, aO as getFileObject, aP as translator, aQ as translator$1, aR as translator$2, aS as translator$3, aT as translator$4, aU as translator$5, aV as translator$6, aW as translator$7, aX as translator$8, aY as translator$9, aZ as translator$a, a_ as translator$b, a$ as translator$c, b0 as translator$d, b1 as translator$e, b2 as commentRangeEndTranslator, b3 as commentRangeStartTranslator, b4 as translator$f, b5 as translator$g, b6 as translator$h, b7 as translator$i, b8 as translator$j, b9 as translator$k, ba as translator$l, bb as translator$m, bc as translator$n, bd as translator$o, be as translator$p, bf as translator$q, bg as translator$r, bh as translator$s, bi as translator$t, bj as translator$u, bk as translator$v, bl as translator$w, bm as translator$x, bn as translator$y, bo as translator$z, bp as translator$A, bq as translator$B, br as translator$C, bs as translator$D, bt as translator$E, bu as translator$F, bv as translator$G, bw as translator$H, bx as translator$I, by as translator$J, bz as translator$K, bA as translator$L, bB as translator$M, bC as translator$N, bD as translator$O, bE as translator$P, bF as translator$Q, bG as translator$R, bH as translator$S, bI as translator$T, bJ as translator$U, bK as translator$V, bL as translator$W, bM as translator$X, bN as translator$Y, bO as translator$Z, bP as translator$_, bQ as translator$$, bR as translator$10, bS as translator$11, bT as translator$12, bU as translator$13, bV as translator$14, bW as translator$15, bX as translator$16, bY as translator$17, bZ as translator$18, b_ as translator$19, b$ as translator$1a, c0 as translator$1b, c1 as translator$1c, c2 as translator$1d, c3 as translator$1e, c4 as translator$1f, c5 as translator$1g, c6 as translator$1h, c7 as translator$1i, c8 as translator$1j, P as PluginKey, a as Plugin } from "./chunks/converter-BFGB7hqj.js";
13
- import { ac, i, a9 } from "./chunks/converter-BFGB7hqj.js";
14
- import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, d as checkAndProcessImage, r as replaceSelectionWithImagePlaceholder, e as uploadAndInsertImage, f as collectTrackedChanges, i as isTrackedChangeActionAllowed, y as yUndoPluginKey, h as undoDepth, j as redoDepth, k as getEditorSurfaceElement, l as collectTrackedChangesForContext, s as shouldBypassContextMenu, S as SlashMenuPluginKey, m as measureCache, n as isHeadless, E as Editor, o as getStarterExtensions, P as PresentationEditor, p as Placeholder, q as getRichTextExtensions, D as DecorationSet, t as Decoration, M as Mark, v as Extension, A as Attribute, N as Node } from "./chunks/editor-CtI4XnMw.js";
15
- import { z, F, B, T, w, C, x } from "./chunks/editor-CtI4XnMw.js";
16
- import { ref, onMounted, createElementBlock, openBlock, normalizeClass, unref, Fragment, renderList, createElementVNode, withModifiers, toDisplayString, createCommentVNode, normalizeStyle, computed, watch, withDirectives, withKeys, vModelText, createTextVNode, createVNode, h, createApp, markRaw, nextTick, onBeforeUnmount, defineComponent, reactive, onUnmounted, renderSlot, shallowRef, createBlock, withCtx, resolveDynamicComponent, normalizeProps, guardReactiveProps } from "vue";
17
- import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, p as plusIconSvg, a as trashIconSvg, b as borderNoneIconSvg, c as arrowsToDotIconSvg, d as arrowsLeftRightIconSvg, w as wrenchIconSvg, m as magicWandIcon, e as checkIconSvg$1, x as xMarkIconSvg, l as linkIconSvg, f as tableIconSvg, g as scissorsIconSvg, h as copyIconSvg, i as pasteIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-BydALv4o.js";
11
+ var _MARK_TOGGLE_NAMES, _SuperToolbar_instances, initToolbarGroups_fn, _interceptedCommands, makeToolbarItems_fn, initDefaultFonts_fn, updateHighlightColors_fn, deactivateAll_fn, updateToolbarHistory_fn, enrichTrackedChanges_fn, runCommandWithArgumentOnly_fn, syncStickyMarksFromState_fn, restoreStickyMarksIfNeeded_fn, ensureStoredMarksForMarkToggle_fn;
12
+ import { aK as getDefaultExportFromCjs, a0 as v4, T as TextSelection$1, v as getMarkRange, aN as vClickOutside, aO as getActiveFormatting, aD as isInTable, U as findParentNode, ar as calculateResolvedParagraphProperties, a7 as twipsToLines, V as isList, al as parseSizeUnit, a8 as pixelsToTwips, aP as getFileObject, P as PluginKey, a as Plugin } from "./chunks/converter-m2x13P8G.js";
13
+ import { ac, i, a9, aQ } from "./chunks/converter-m2x13P8G.js";
14
+ import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, d as checkAndProcessImage, r as replaceSelectionWithImagePlaceholder, e as uploadAndInsertImage, f as collectTrackedChanges, i as isTrackedChangeActionAllowed, y as yUndoPluginKey, h as undoDepth, j as redoDepth, k as getEditorSurfaceElement, l as collectTrackedChangesForContext, s as shouldBypassContextMenu, S as SlashMenuPluginKey, m as measureCache, n as isHeadless, E as Editor, o as getStarterExtensions, P as PresentationEditor, p as Placeholder, q as getRichTextExtensions, D as DecorationSet, t as Decoration, M as Mark, v as Extension, A as Attribute, N as Node } from "./chunks/editor-C9r_Jbbg.js";
15
+ import { z, F, B, T, w, C, x } from "./chunks/editor-C9r_Jbbg.js";
16
+ import { ref, onMounted, createElementBlock, openBlock, normalizeClass, unref, Fragment, renderList, createElementVNode, withModifiers, toDisplayString, createCommentVNode, normalizeStyle, computed, watch, withDirectives, withKeys, vModelText, createTextVNode, createVNode, h, createApp, markRaw, nextTick, onBeforeUnmount, defineComponent, reactive, onUnmounted, renderSlot, useCssVars, shallowRef, createBlock, withCtx, resolveDynamicComponent, normalizeProps, guardReactiveProps } from "vue";
17
+ import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, p as plusIconSvg, a as trashIconSvg, b as borderNoneIconSvg, c as arrowsToDotIconSvg, d as arrowsLeftRightIconSvg, w as wrenchIconSvg, m as magicWandIcon, e as checkIconSvg$1, x as xMarkIconSvg, l as linkIconSvg, f as tableIconSvg, g as scissorsIconSvg, h as copyIconSvg, i as pasteIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-fnptYAcU.js";
18
18
  import AIWriter from "./ai-writer.es.js";
19
- import { D } from "./chunks/docx-zipper-OPbzIk16.js";
19
+ import { D } from "./chunks/docx-zipper-CRSKJF-o.js";
20
20
  import { createZip } from "./file-zipper.es.js";
21
21
  var eventemitter3 = { exports: {} };
22
22
  var hasRequiredEventemitter3;
@@ -236,7 +236,7 @@ const useToolbarItem = (options) => {
236
236
  if (!Array.isArray(options.options)) throw new Error("Invalid toolbar item options - " + options.options);
237
237
  nestedOptions.value?.push(...options.options);
238
238
  }
239
- const activate = (attrs, ...args) => {
239
+ const activate = (attrs = {}, ...args) => {
240
240
  onActivate(attrs, ...args);
241
241
  if (suppressActiveHighlight.value) return;
242
242
  active.value = true;
@@ -311,8 +311,8 @@ const useToolbarItem = (options) => {
311
311
  onDeactivate
312
312
  };
313
313
  };
314
- const _hoisted_1$e = ["onClick", "innerHTML", "aria-label", "onKeydown"];
315
- const _sfc_main$f = {
314
+ const _hoisted_1$f = ["onClick", "innerHTML", "aria-label", "onKeydown"];
315
+ const _sfc_main$h = {
316
316
  __name: "AlignmentButtons",
317
317
  emits: ["select"],
318
318
  setup(__props, { emit: __emit }) {
@@ -397,20 +397,20 @@ const _sfc_main$f = {
397
397
  ref_key: "alignmentButtonsRefs",
398
398
  ref: alignmentButtonsRefs,
399
399
  onKeydown: withModifiers((event) => handleKeyDown(event, index), ["prevent"])
400
- }, null, 40, _hoisted_1$e);
400
+ }, null, 40, _hoisted_1$f);
401
401
  }), 64))
402
402
  ], 2);
403
403
  };
404
404
  }
405
405
  };
406
- const AlignmentButtons = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-d84f57b6"]]);
407
- const _hoisted_1$d = ["onClick", "onKeydown"];
406
+ const AlignmentButtons = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-d84f57b6"]]);
407
+ const _hoisted_1$e = ["onClick", "onKeydown"];
408
408
  const _hoisted_2$9 = { class: "document-mode-column icon-column" };
409
409
  const _hoisted_3$7 = ["innerHTML"];
410
410
  const _hoisted_4$3 = { class: "document-mode-column text-column" };
411
411
  const _hoisted_5$2 = { class: "document-mode-type" };
412
412
  const _hoisted_6$1 = { class: "document-mode-description" };
413
- const _sfc_main$e = {
413
+ const _sfc_main$g = {
414
414
  __name: "DocumentMode",
415
415
  props: {
416
416
  options: {
@@ -484,19 +484,20 @@ const _sfc_main$e = {
484
484
  createElementVNode("div", _hoisted_5$2, toDisplayString(option.label), 1),
485
485
  createElementVNode("div", _hoisted_6$1, toDisplayString(option.description), 1)
486
486
  ])
487
- ], 42, _hoisted_1$d);
487
+ ], 42, _hoisted_1$e);
488
488
  }), 256))
489
489
  ], 2);
490
490
  };
491
491
  }
492
492
  };
493
- const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-8730b752"]]);
494
- const _hoisted_1$c = {
493
+ const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-8730b752"]]);
494
+ const _hoisted_1$d = {
495
495
  key: 0,
496
- class: "linked-style-buttons"
496
+ class: "linked-style-buttons",
497
+ "data-editor-ui-surface": ""
497
498
  };
498
499
  const _hoisted_2$8 = ["onClick", "onKeydown", "aria-label"];
499
- const _sfc_main$d = {
500
+ const _sfc_main$f = {
500
501
  __name: "LinkedStyle",
501
502
  props: {
502
503
  editor: {
@@ -550,7 +551,7 @@ const _sfc_main$d = {
550
551
  styleRefs.value[0].focus();
551
552
  });
552
553
  return (_ctx, _cache) => {
553
- return props.editor ? (openBlock(), createElementBlock("div", _hoisted_1$c, [
554
+ return props.editor ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
554
555
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getQuickFormatList)(__props.editor), (style, index) => {
555
556
  return openBlock(), createElementBlock("div", {
556
557
  class: normalizeClass(["style-item", { selected: __props.selectedOption === style.id }]),
@@ -572,8 +573,8 @@ const _sfc_main$d = {
572
573
  };
573
574
  }
574
575
  };
575
- const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-b53508a8"]]);
576
- const _hoisted_1$b = {
576
+ const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-ecb78965"]]);
577
+ const _hoisted_1$c = {
577
578
  key: 0,
578
579
  class: "link-title"
579
580
  };
@@ -601,7 +602,7 @@ const _hoisted_13 = {
601
602
  key: 4,
602
603
  class: "input-row go-to-anchor clickable"
603
604
  };
604
- const _sfc_main$c = {
605
+ const _sfc_main$e = {
605
606
  __name: "LinkInput",
606
607
  props: {
607
608
  showInput: {
@@ -740,7 +741,7 @@ const _sfc_main$c = {
740
741
  return openBlock(), createElementBlock("div", {
741
742
  class: normalizeClass(["link-input-ctn", { "high-contrast": unref(isHighContrastMode) }])
742
743
  }, [
743
- isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_1$b, "Page anchor")) : isEditing.value ? (openBlock(), createElementBlock("div", _hoisted_2$7, "Edit link")) : (openBlock(), createElementBlock("div", _hoisted_3$6, "Add link")),
744
+ isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_1$c, "Page anchor")) : isEditing.value ? (openBlock(), createElementBlock("div", _hoisted_2$7, "Edit link")) : (openBlock(), createElementBlock("div", _hoisted_3$6, "Add link")),
744
745
  __props.showInput && !isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
745
746
  createElementVNode("div", _hoisted_5$1, [
746
747
  _cache[4] || (_cache[4] = createElementVNode("div", { class: "input-icon text-input-icon" }, "T", -1)),
@@ -807,12 +808,12 @@ const _sfc_main$c = {
807
808
  };
808
809
  }
809
810
  };
810
- const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-ba50627b"]]);
811
- const _hoisted_1$a = ["aria-label", "onClick", "onKeydown"];
811
+ const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-ba50627b"]]);
812
+ const _hoisted_1$b = ["aria-label", "onClick", "onKeydown"];
812
813
  const _hoisted_2$6 = ["innerHTML"];
813
814
  const _hoisted_3$5 = ["innerHTML"];
814
815
  const ROW_SIZE$1 = 7;
815
- const _sfc_main$b = {
816
+ const _sfc_main$d = {
816
817
  __name: "IconGridRow",
817
818
  props: {
818
819
  icons: {
@@ -938,19 +939,19 @@ const _sfc_main$b = {
938
939
  innerHTML: unref(toolbarIcons).colorOptionCheck,
939
940
  style: normalizeStyle(getCheckStyle(option.value, optionIndex))
940
941
  }, null, 12, _hoisted_3$5)) : createCommentVNode("", true)
941
- ], 40, _hoisted_1$a);
942
+ ], 40, _hoisted_1$b);
942
943
  }), 128))
943
944
  ]);
944
945
  }), 128);
945
946
  };
946
947
  }
947
948
  };
948
- const IconGridRow = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-0f479b6c"]]);
949
+ const IconGridRow = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-0f479b6c"]]);
949
950
  const DropIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>\n';
950
- const _hoisted_1$9 = { class: "options-grid-wrap" };
951
+ const _hoisted_1$a = { class: "options-grid-wrap" };
951
952
  const _hoisted_2$5 = ["innerHTML"];
952
953
  const _hoisted_3$4 = { class: "option-grid-ctn" };
953
- const _sfc_main$a = {
954
+ const _sfc_main$c = {
954
955
  __name: "IconGrid",
955
956
  props: {
956
957
  icons: {
@@ -977,7 +978,7 @@ const _sfc_main$a = {
977
978
  emit("select", option);
978
979
  };
979
980
  return (_ctx, _cache) => {
980
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
981
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
981
982
  __props.hasNoneIcon ? (openBlock(), createElementBlock("div", {
982
983
  key: 0,
983
984
  class: "none-option",
@@ -1010,7 +1011,7 @@ const _sfc_main$a = {
1010
1011
  };
1011
1012
  }
1012
1013
  };
1013
- const IconGrid = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-3d19fedf"]]);
1014
+ const IconGrid = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-3d19fedf"]]);
1014
1015
  const closeDropdown$1 = (dropdown) => {
1015
1016
  dropdown.expand.value = false;
1016
1017
  };
@@ -1119,10 +1120,10 @@ const icons = [
1119
1120
  const getAvailableColorOptions = () => {
1120
1121
  return icons.flat().map((item) => item.value);
1121
1122
  };
1122
- const _hoisted_1$8 = ["data-cols", "data-rows", "onKeydown", "onClick"];
1123
+ const _hoisted_1$9 = ["data-cols", "data-rows", "onKeydown", "onClick"];
1123
1124
  const _hoisted_2$4 = ["aria-valuetext"];
1124
1125
  const ROW_SIZE = 5;
1125
- const _sfc_main$9 = {
1126
+ const _sfc_main$b = {
1126
1127
  __name: "TableGrid",
1127
1128
  emits: ["select", "clickoutside"],
1128
1129
  setup(__props, { emit: __emit }) {
@@ -1238,7 +1239,7 @@ const _sfc_main$9 = {
1238
1239
  ref: tableGridItems,
1239
1240
  onKeydown: withModifiers((event) => handleKeyDown(event, n, i2), ["prevent"]),
1240
1241
  onClick: withModifiers(($event) => handleClick({ cols: n, rows: i2 }), ["stop", "prevent"])
1241
- }, null, 40, _hoisted_1$8);
1242
+ }, null, 40, _hoisted_1$9);
1242
1243
  }), 64))
1243
1244
  ], 64);
1244
1245
  }), 64))
@@ -1251,13 +1252,13 @@ const _sfc_main$9 = {
1251
1252
  };
1252
1253
  }
1253
1254
  };
1254
- const TableGrid = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-92e8d5fb"]]);
1255
- const _hoisted_1$7 = { class: "toolbar-table-actions" };
1255
+ const TableGrid = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-92e8d5fb"]]);
1256
+ const _hoisted_1$8 = { class: "toolbar-table-actions" };
1256
1257
  const _hoisted_2$3 = ["onClick", "data-item", "ariaLabel"];
1257
1258
  const _hoisted_3$3 = { class: "toolbar-table-actions__icon" };
1258
1259
  const _hoisted_4$1 = ["innerHTML"];
1259
1260
  const _hoisted_5 = { class: "toolbar-table-actions__label" };
1260
- const _sfc_main$8 = {
1261
+ const _sfc_main$a = {
1261
1262
  __name: "TableActions",
1262
1263
  props: {
1263
1264
  options: {
@@ -1271,7 +1272,7 @@ const _sfc_main$8 = {
1271
1272
  emit("select", { command: item.command });
1272
1273
  };
1273
1274
  return (_ctx, _cache) => {
1274
- return openBlock(), createElementBlock("div", _hoisted_1$7, [
1275
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
1275
1276
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option) => {
1276
1277
  return openBlock(), createElementBlock("div", {
1277
1278
  class: normalizeClass(["toolbar-table-actions__item", { "toolbar-table-actions__item--border": option.bottomBorder }]),
@@ -1293,7 +1294,7 @@ const _sfc_main$8 = {
1293
1294
  };
1294
1295
  }
1295
1296
  };
1296
- const TableActions = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-990b9a25"]]);
1297
+ const TableActions = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-990b9a25"]]);
1297
1298
  function getScrollableParent(element) {
1298
1299
  let currentElement = element;
1299
1300
  while (currentElement) {
@@ -1317,10 +1318,10 @@ function scrollToElement(targetElement, options = { behavior: "smooth", block: "
1317
1318
  });
1318
1319
  }
1319
1320
  const checkIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>\n';
1320
- const _hoisted_1$6 = { class: "search-input-ctn" };
1321
+ const _hoisted_1$7 = { class: "search-input-ctn" };
1321
1322
  const _hoisted_2$2 = { class: "row" };
1322
1323
  const _hoisted_3$2 = ["onKeydown"];
1323
- const _sfc_main$7 = {
1324
+ const _sfc_main$9 = {
1324
1325
  __name: "SearchInput",
1325
1326
  props: {
1326
1327
  searchRef: {
@@ -1335,7 +1336,7 @@ const _sfc_main$7 = {
1335
1336
  emit("submit", { value: searchValue.value });
1336
1337
  };
1337
1338
  return (_ctx, _cache) => {
1338
- return openBlock(), createElementBlock("div", _hoisted_1$6, [
1339
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
1339
1340
  createElementVNode("div", _hoisted_2$2, [
1340
1341
  withDirectives(createElementVNode("input", {
1341
1342
  ref: __props.searchRef,
@@ -1359,7 +1360,7 @@ const _sfc_main$7 = {
1359
1360
  };
1360
1361
  }
1361
1362
  };
1362
- const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-957cbcf2"]]);
1363
+ const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-957cbcf2"]]);
1363
1364
  const TOOLBAR_FONTS = [
1364
1365
  {
1365
1366
  label: "Georgia",
@@ -2508,7 +2509,7 @@ const isNegatedMark = (name, attrs = {}) => {
2508
2509
  if (typeof checker !== "function") return false;
2509
2510
  return Boolean(checker(attrs));
2510
2511
  };
2511
- class SuperToolbar extends EventEmitter {
2512
+ const _SuperToolbar = class _SuperToolbar extends EventEmitter {
2512
2513
  /**
2513
2514
  * Creates a new SuperToolbar instance
2514
2515
  * @param {ToolbarConfig} config - The configuration for the toolbar
@@ -2561,11 +2562,11 @@ class SuperToolbar extends EventEmitter {
2561
2562
  const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
2562
2563
  if (isMobileDevice && isSmallScreen) {
2563
2564
  layers.style.transformOrigin = "0 0";
2564
- layers.style.transform = `scale(${parseInt(argument) / 100})`;
2565
+ layers.style.transform = `scale(${parseInt(argument, 10) / 100})`;
2565
2566
  } else {
2566
- layers.style.zoom = parseInt(argument) / 100;
2567
+ layers.style.zoom = parseInt(argument, 10) / 100;
2567
2568
  }
2568
- this.superdoc.superdocStore.activeZoom = parseInt(argument);
2569
+ this.superdoc.superdocStore.activeZoom = parseInt(argument, 10);
2569
2570
  },
2570
2571
  /**
2571
2572
  * Sets the document mode
@@ -2647,31 +2648,37 @@ class SuperToolbar extends EventEmitter {
2647
2648
  * @returns {Promise<void>}
2648
2649
  */
2649
2650
  startImageUpload: async () => {
2650
- let open = getFileOpener();
2651
- let result = await open();
2652
- if (!result?.file) {
2653
- return;
2654
- }
2655
- const { size, file } = await checkAndProcessImage({
2656
- file: result.file,
2657
- getMaxContentSize: () => this.activeEditor.getMaxContentSize()
2658
- });
2659
- if (!file) {
2660
- return;
2651
+ try {
2652
+ let open = getFileOpener();
2653
+ let result = await open();
2654
+ if (!result?.file) {
2655
+ return;
2656
+ }
2657
+ const { size, file } = await checkAndProcessImage({
2658
+ file: result.file,
2659
+ getMaxContentSize: () => this.activeEditor.getMaxContentSize()
2660
+ });
2661
+ if (!file) {
2662
+ return;
2663
+ }
2664
+ const id = {};
2665
+ replaceSelectionWithImagePlaceholder({
2666
+ view: this.activeEditor.view,
2667
+ editorOptions: this.activeEditor.options,
2668
+ id
2669
+ });
2670
+ await uploadAndInsertImage({
2671
+ editor: this.activeEditor,
2672
+ view: this.activeEditor.view,
2673
+ file,
2674
+ size,
2675
+ id
2676
+ });
2677
+ } catch (error) {
2678
+ const err = new Error("[super-toolbar 🎨] Image upload failed");
2679
+ this.emit("exception", { error: err, editor: this.activeEditor, originalError: error });
2680
+ console.error(err, error);
2661
2681
  }
2662
- const id = {};
2663
- replaceSelectionWithImagePlaceholder({
2664
- view: this.activeEditor.view,
2665
- editorOptions: this.activeEditor.options,
2666
- id
2667
- });
2668
- await uploadAndInsertImage({
2669
- editor: this.activeEditor,
2670
- view: this.activeEditor.view,
2671
- file,
2672
- size,
2673
- id
2674
- });
2675
2682
  },
2676
2683
  /**
2677
2684
  * Increases text indentation or list level
@@ -2844,6 +2851,13 @@ class SuperToolbar extends EventEmitter {
2844
2851
  };
2845
2852
  this.config.hideButtons = config.hideButtons ?? true;
2846
2853
  this.config.responsiveToContainer = config.responsiveToContainer ?? false;
2854
+ this.pendingMarkCommands = [];
2855
+ this.stickyStoredMarks = null;
2856
+ this._boundEditorHandlers = {
2857
+ transaction: null,
2858
+ selectionUpdate: null,
2859
+ focus: null
2860
+ };
2847
2861
  if (!this.config.selector && this.config.element) {
2848
2862
  this.config.selector = this.config.element;
2849
2863
  }
@@ -2903,12 +2917,28 @@ class SuperToolbar extends EventEmitter {
2903
2917
  }
2904
2918
  /**
2905
2919
  * The toolbar expects an active Super Editor instance.
2906
- * @param {Object} editor - The editor instance to attach to the toolbar
2920
+ * Removes listeners from the previous editor (if any) before attaching to the new one.
2921
+ * @param {Object|null} editor - The editor instance to attach to the toolbar, or null to detach
2907
2922
  * @returns {void}
2908
2923
  */
2909
2924
  setActiveEditor(editor) {
2925
+ if (this.activeEditor && this._boundEditorHandlers.transaction) {
2926
+ this.activeEditor.off("transaction", this._boundEditorHandlers.transaction);
2927
+ this.activeEditor.off("selectionUpdate", this._boundEditorHandlers.selectionUpdate);
2928
+ this.activeEditor.off("focus", this._boundEditorHandlers.focus);
2929
+ this._boundEditorHandlers.transaction = null;
2930
+ this._boundEditorHandlers.selectionUpdate = null;
2931
+ this._boundEditorHandlers.focus = null;
2932
+ }
2910
2933
  this.activeEditor = editor;
2911
- this.activeEditor.on("transaction", this.onEditorTransaction.bind(this));
2934
+ if (editor) {
2935
+ this._boundEditorHandlers.transaction = this.onEditorTransaction.bind(this);
2936
+ this._boundEditorHandlers.selectionUpdate = this.onEditorSelectionUpdate.bind(this);
2937
+ this._boundEditorHandlers.focus = this.onEditorFocus.bind(this);
2938
+ this.activeEditor.on("transaction", this._boundEditorHandlers.transaction);
2939
+ this.activeEditor.on("selectionUpdate", this._boundEditorHandlers.selectionUpdate);
2940
+ this.activeEditor.on("focus", this._boundEditorHandlers.focus);
2941
+ }
2912
2942
  }
2913
2943
  /**
2914
2944
  * Get toolbar items by group name
@@ -3056,15 +3086,28 @@ class SuperToolbar extends EventEmitter {
3056
3086
  * @returns {*} The result of the executed command, undefined if no result is returned
3057
3087
  */
3058
3088
  emitCommand({ item, argument, option }) {
3089
+ const hasFocusFn = this.activeEditor?.view?.hasFocus;
3090
+ const wasFocused = Boolean(typeof hasFocusFn === "function" && hasFocusFn.call(this.activeEditor.view));
3091
+ const { command } = item;
3092
+ const isMarkToggle = this.isMarkToggle(item);
3093
+ if (!wasFocused && isMarkToggle) {
3094
+ this.pendingMarkCommands.push({ command, argument, item });
3095
+ item?.activate?.();
3096
+ if (this.activeEditor && !this.activeEditor.options.isHeaderOrFooter) {
3097
+ this.activeEditor.focus();
3098
+ }
3099
+ return;
3100
+ }
3059
3101
  if (this.activeEditor && !this.activeEditor.options.isHeaderOrFooter) {
3060
3102
  this.activeEditor.focus();
3061
3103
  }
3062
- const { command } = item;
3063
3104
  if (!command) {
3064
3105
  return;
3065
3106
  }
3066
3107
  if (command in __privateGet(this, _interceptedCommands)) {
3067
- return __privateGet(this, _interceptedCommands)[command]({ item, argument });
3108
+ const result = __privateGet(this, _interceptedCommands)[command]({ item, argument });
3109
+ if (isMarkToggle) __privateMethod(this, _SuperToolbar_instances, syncStickyMarksFromState_fn).call(this);
3110
+ return result;
3068
3111
  }
3069
3112
  if (this.activeEditor && this.activeEditor.commands && command in this.activeEditor.commands) {
3070
3113
  this.activeEditor.commands[command](argument);
@@ -3075,9 +3118,67 @@ class SuperToolbar extends EventEmitter {
3075
3118
  this.emit("exception", { error, editor: this.activeEditor });
3076
3119
  throw error;
3077
3120
  }
3121
+ if (isMarkToggle) __privateMethod(this, _SuperToolbar_instances, syncStickyMarksFromState_fn).call(this);
3078
3122
  this.updateToolbarState();
3079
3123
  }
3080
- }
3124
+ /**
3125
+ * Processes and executes pending mark commands when editor selection updates.
3126
+ * This is triggered by the editor's 'selectionUpdate' event after focus is restored.
3127
+ * Clears the pending queue after execution.
3128
+ * @returns {void}
3129
+ */
3130
+ onEditorSelectionUpdate() {
3131
+ if (!this.activeEditor) return;
3132
+ if (this.pendingMarkCommands.length) {
3133
+ const pending = this.pendingMarkCommands;
3134
+ this.pendingMarkCommands = [];
3135
+ pending.forEach(({ command, argument, item }) => {
3136
+ if (!command) return;
3137
+ try {
3138
+ if (command in __privateGet(this, _interceptedCommands)) {
3139
+ __privateGet(this, _interceptedCommands)[command]({ item, argument });
3140
+ } else if (this.activeEditor.commands && command in this.activeEditor.commands) {
3141
+ this.activeEditor.commands[command](argument);
3142
+ }
3143
+ __privateMethod(this, _SuperToolbar_instances, ensureStoredMarksForMarkToggle_fn).call(this, { command, argument });
3144
+ } catch (error) {
3145
+ const err = new Error(`[super-toolbar 🎨] Failed to execute pending command: ${command}`);
3146
+ this.emit("exception", { error: err, editor: this.activeEditor, originalError: error });
3147
+ console.error(err, error);
3148
+ }
3149
+ });
3150
+ __privateMethod(this, _SuperToolbar_instances, syncStickyMarksFromState_fn).call(this);
3151
+ this.updateToolbarState();
3152
+ return;
3153
+ }
3154
+ const restored = __privateMethod(this, _SuperToolbar_instances, restoreStickyMarksIfNeeded_fn).call(this);
3155
+ if (restored) this.updateToolbarState();
3156
+ }
3157
+ /**
3158
+ * Handles editor focus events by flushing any pending mark commands.
3159
+ * This is triggered by the editor's 'focus' event.
3160
+ * @returns {void}
3161
+ */
3162
+ onEditorFocus() {
3163
+ if (this.pendingMarkCommands.length) {
3164
+ this.onEditorSelectionUpdate();
3165
+ return;
3166
+ }
3167
+ const restored = __privateMethod(this, _SuperToolbar_instances, restoreStickyMarksIfNeeded_fn).call(this);
3168
+ if (restored) this.updateToolbarState();
3169
+ }
3170
+ /**
3171
+ * Determines if a toolbar item represents a mark toggle command.
3172
+ * Mark toggles include text formatting commands like bold, italic, underline, etc.
3173
+ * @param {ToolbarItem} item - The toolbar item to check
3174
+ * @returns {boolean} True if the item is a mark toggle, false otherwise
3175
+ */
3176
+ isMarkToggle(item) {
3177
+ const name = item?.name?.value;
3178
+ return __privateGet(_SuperToolbar, _MARK_TOGGLE_NAMES).has(name);
3179
+ }
3180
+ };
3181
+ _MARK_TOGGLE_NAMES = new WeakMap();
3081
3182
  _SuperToolbar_instances = new WeakSet();
3082
3183
  /**
3083
3184
  * Initiate toolbar groups
@@ -3186,14 +3287,19 @@ deactivateAll_fn = function() {
3186
3287
  * @returns {void}
3187
3288
  */
3188
3289
  updateToolbarHistory_fn = function() {
3189
- if (!this.activeEditor) return;
3190
- if (this.activeEditor.options.ydoc) {
3191
- const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
3192
- this.undoDepth = undoManager?.undoStack.length || 0;
3193
- this.redoDepth = undoManager?.redoStack.length || 0;
3194
- } else {
3195
- this.undoDepth = undoDepth(this.activeEditor.state);
3196
- this.redoDepth = redoDepth(this.activeEditor.state);
3290
+ if (!this.activeEditor?.state) return;
3291
+ try {
3292
+ if (this.activeEditor.options.ydoc) {
3293
+ const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
3294
+ this.undoDepth = undoManager?.undoStack.length || 0;
3295
+ this.redoDepth = undoManager?.redoStack.length || 0;
3296
+ } else {
3297
+ this.undoDepth = undoDepth(this.activeEditor.state);
3298
+ this.redoDepth = redoDepth(this.activeEditor.state);
3299
+ }
3300
+ } catch {
3301
+ this.undoDepth = 0;
3302
+ this.redoDepth = 0;
3197
3303
  }
3198
3304
  };
3199
3305
  enrichTrackedChanges_fn = function(trackedChanges = []) {
@@ -3235,6 +3341,82 @@ runCommandWithArgumentOnly_fn = function({ item, argument, noArgumentCallback =
3235
3341
  this.updateToolbarState();
3236
3342
  }
3237
3343
  };
3344
+ /**
3345
+ * Capture stored marks when a mark toggle is used on an empty selection
3346
+ * so they can be re-applied after focus/selection changes.
3347
+ * @private
3348
+ * @returns {void}
3349
+ */
3350
+ syncStickyMarksFromState_fn = function() {
3351
+ if (!this.activeEditor) return;
3352
+ const { selection, storedMarks } = this.activeEditor.state || {};
3353
+ if (!selection?.empty) return;
3354
+ this.stickyStoredMarks = storedMarks?.length ? [...storedMarks] : null;
3355
+ };
3356
+ /**
3357
+ * Re-apply stored marks captured from toolbar toggles when the current
3358
+ * selection is empty and unformatted.
3359
+ * @private
3360
+ * @returns {boolean} True if marks were restored
3361
+ */
3362
+ restoreStickyMarksIfNeeded_fn = function() {
3363
+ if (!this.activeEditor) return false;
3364
+ if (!this.stickyStoredMarks?.length) return false;
3365
+ const { state, view } = this.activeEditor;
3366
+ const { selection, storedMarks } = state || {};
3367
+ if (!selection?.empty) return false;
3368
+ if (storedMarks?.length) return false;
3369
+ if (!view?.dispatch || !state?.tr) return false;
3370
+ const hasActiveMarkToggle = getActiveFormatting(this.activeEditor).some(
3371
+ (mark) => __privateGet(_SuperToolbar, _MARK_TOGGLE_NAMES).has(mark.name)
3372
+ );
3373
+ if (hasActiveMarkToggle) return false;
3374
+ const tr = state.tr.setStoredMarks(this.stickyStoredMarks);
3375
+ view.dispatch(tr);
3376
+ return true;
3377
+ };
3378
+ /**
3379
+ * Fallback to ensure stored marks exist for mark toggles when executed off-focus.
3380
+ * Helps cases where a command doesn't set storedMarks (e.g., font size from toolbar before focus).
3381
+ * @private
3382
+ * @param {Object} params
3383
+ * @param {string} params.command
3384
+ * @param {*} params.argument
3385
+ * @returns {void}
3386
+ */
3387
+ ensureStoredMarksForMarkToggle_fn = function({ command, argument }) {
3388
+ if (!this.activeEditor) return;
3389
+ if (!this.activeEditor.state?.selection?.empty) return;
3390
+ if (this.activeEditor.state?.storedMarks?.length) return;
3391
+ if (command !== "setFontSize") return;
3392
+ const { state, view } = this.activeEditor;
3393
+ const textStyleMark = state.schema?.marks?.textStyle;
3394
+ if (!textStyleMark || !view?.dispatch || !state?.tr) return;
3395
+ const [value, unit] = parseSizeUnit(argument ?? "");
3396
+ if (Number.isNaN(value)) return;
3397
+ const clamped = Math.min(96, Math.max(8, Number(value)));
3398
+ const resolvedUnit = unit || "pt";
3399
+ const mark = textStyleMark.create({ fontSize: `${clamped}${resolvedUnit}` });
3400
+ const tr = state.tr.setStoredMarks([mark]);
3401
+ view.dispatch(tr);
3402
+ };
3403
+ /**
3404
+ * Mark toggle names used to identify mark commands that need special handling
3405
+ * when the editor is not focused.
3406
+ * @type {Set<string>}
3407
+ * @private
3408
+ */
3409
+ __privateAdd(_SuperToolbar, _MARK_TOGGLE_NAMES, /* @__PURE__ */ new Set([
3410
+ "bold",
3411
+ "italic",
3412
+ "underline",
3413
+ "strike",
3414
+ "highlight",
3415
+ "color",
3416
+ "fontSize",
3417
+ "fontFamily"
3418
+ ]));
3419
+ let SuperToolbar = _SuperToolbar;
3238
3420
  const onMarginClickCursorChange = (event, editor) => {
3239
3421
  const y = event.clientY;
3240
3422
  const x2 = event.clientX;
@@ -4030,7 +4212,7 @@ function getItems(context, customItems = [], includeDefaultItems = true) {
4030
4212
  }).filter((section) => section.items.length > 0);
4031
4213
  return filteredSections;
4032
4214
  }
4033
- const _hoisted_1$5 = { class: "slash-menu-items" };
4215
+ const _hoisted_1$6 = { class: "slash-menu-items" };
4034
4216
  const _hoisted_2$1 = {
4035
4217
  key: 0,
4036
4218
  class: "slash-menu-divider",
@@ -4038,7 +4220,7 @@ const _hoisted_2$1 = {
4038
4220
  };
4039
4221
  const _hoisted_3$1 = ["onClick"];
4040
4222
  const _hoisted_4 = ["innerHTML"];
4041
- const _sfc_main$6 = {
4223
+ const _sfc_main$8 = {
4042
4224
  __name: "SlashMenu",
4043
4225
  props: {
4044
4226
  editor: {
@@ -4166,7 +4348,7 @@ const _sfc_main$6 = {
4166
4348
  customItemRefs.clear();
4167
4349
  };
4168
4350
  const handleGlobalKeyDown = (event) => {
4169
- if (event.key === "Escape") {
4351
+ if (event.key === "Escape" && isOpen.value) {
4170
4352
  event.preventDefault();
4171
4353
  event.stopPropagation();
4172
4354
  closeMenu();
@@ -4354,7 +4536,7 @@ const _sfc_main$6 = {
4354
4536
  }, null, 544), [
4355
4537
  [vModelText, searchQuery.value]
4356
4538
  ]),
4357
- createElementVNode("div", _hoisted_1$5, [
4539
+ createElementVNode("div", _hoisted_1$6, [
4358
4540
  (openBlock(true), createElementBlock(Fragment, null, renderList(filteredSections.value, (section, sectionIndex) => {
4359
4541
  return openBlock(), createElementBlock(Fragment, {
4360
4542
  key: section.id
@@ -4389,8 +4571,8 @@ const _sfc_main$6 = {
4389
4571
  };
4390
4572
  }
4391
4573
  };
4392
- const _hoisted_1$4 = ["accept"];
4393
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4574
+ const _hoisted_1$5 = ["accept"];
4575
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4394
4576
  __name: "BasicUpload",
4395
4577
  props: {
4396
4578
  accept: { default: ".docx, .pdf, .html, .md" }
@@ -4411,15 +4593,15 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4411
4593
  id: "fileInput",
4412
4594
  onChange: onFileChange,
4413
4595
  accept: __props.accept
4414
- }, null, 40, _hoisted_1$4)
4596
+ }, null, 40, _hoisted_1$5)
4415
4597
  ]);
4416
4598
  };
4417
4599
  }
4418
4600
  });
4419
- const _hoisted_1$3 = { class: "numbering" };
4601
+ const _hoisted_1$4 = { class: "numbering" };
4420
4602
  const MIN_WIDTH = 200;
4421
4603
  const alignment = "flex-end";
4422
- const _sfc_main$4 = {
4604
+ const _sfc_main$6 = {
4423
4605
  __name: "Ruler",
4424
4606
  props: {
4425
4607
  orientation: {
@@ -4604,7 +4786,7 @@ const _sfc_main$4 = {
4604
4786
  class: normalizeClass(unit.className),
4605
4787
  style: normalizeStyle(getStyle.value(unit))
4606
4788
  }, [
4607
- createElementVNode("div", _hoisted_1$3, toDisplayString(unit.numbering), 1),
4789
+ createElementVNode("div", _hoisted_1$4, toDisplayString(unit.numbering), 1),
4608
4790
  (openBlock(true), createElementBlock(Fragment, null, renderList(unit.elements, (half) => {
4609
4791
  return openBlock(), createElementBlock("div", {
4610
4792
  class: normalizeClass(half.className),
@@ -4624,8 +4806,8 @@ const _sfc_main$4 = {
4624
4806
  };
4625
4807
  }
4626
4808
  };
4627
- const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-79f9a944"]]);
4628
- const _sfc_main$3 = {
4809
+ const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-79f9a944"]]);
4810
+ const _sfc_main$5 = {
4629
4811
  __name: "GenericPopover",
4630
4812
  props: {
4631
4813
  editor: { type: Object, required: true },
@@ -4653,22 +4835,22 @@ const _sfc_main$3 = {
4653
4835
  () => props.visible,
4654
4836
  (val) => {
4655
4837
  if (val) {
4656
- document.addEventListener("mousedown", handleClickOutside);
4838
+ document.addEventListener("pointerdown", handleClickOutside);
4657
4839
  document.addEventListener("keydown", handleEscape);
4658
4840
  } else {
4659
- document.removeEventListener("mousedown", handleClickOutside);
4841
+ document.removeEventListener("pointerdown", handleClickOutside);
4660
4842
  document.removeEventListener("keydown", handleEscape);
4661
4843
  }
4662
4844
  }
4663
4845
  );
4664
4846
  onMounted(() => {
4665
4847
  if (props.visible) {
4666
- document.addEventListener("mousedown", handleClickOutside);
4848
+ document.addEventListener("pointerdown", handleClickOutside);
4667
4849
  document.addEventListener("keydown", handleEscape);
4668
4850
  }
4669
4851
  });
4670
4852
  onBeforeUnmount(() => {
4671
- document.removeEventListener("mousedown", handleClickOutside);
4853
+ document.removeEventListener("pointerdown", handleClickOutside);
4672
4854
  document.removeEventListener("keydown", handleEscape);
4673
4855
  });
4674
4856
  const derivedStyles = computed(() => ({
@@ -4683,7 +4865,7 @@ const _sfc_main$3 = {
4683
4865
  style: normalizeStyle(derivedStyles.value),
4684
4866
  ref_key: "popover",
4685
4867
  ref: popover,
4686
- onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
4868
+ onPointerdown: _cache[0] || (_cache[0] = withModifiers(() => {
4687
4869
  }, ["stop"])),
4688
4870
  onClick: _cache[1] || (_cache[1] = withModifiers(() => {
4689
4871
  }, ["stop"]))
@@ -4693,9 +4875,15 @@ const _sfc_main$3 = {
4693
4875
  };
4694
4876
  }
4695
4877
  };
4696
- const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-cbddcc0f"]]);
4697
- const _hoisted_1$2 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
4698
- const _sfc_main$2 = {
4878
+ const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-157855b5"]]);
4879
+ const _hoisted_1$3 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
4880
+ const RESIZE_HANDLE_WIDTH_PX = 9;
4881
+ const RESIZE_HANDLE_OFFSET_PX = 4;
4882
+ const DRAG_OVERLAY_EXTENSION_PX = 1e3;
4883
+ const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
4884
+ const THROTTLE_INTERVAL_MS = 16;
4885
+ const MIN_RESIZE_DELTA_PX = 1;
4886
+ const _sfc_main$4 = {
4699
4887
  __name: "TableResizeOverlay",
4700
4888
  props: {
4701
4889
  /** Editor instance for dispatching transactions */
@@ -4718,26 +4906,73 @@ const _sfc_main$2 = {
4718
4906
  setup(__props, { emit: __emit }) {
4719
4907
  const props = __props;
4720
4908
  const emit = __emit;
4909
+ const overlayRect = ref(null);
4721
4910
  const tableMetadata = ref(null);
4722
4911
  const dragState = ref(null);
4723
4912
  const forcedCleanup = ref(false);
4913
+ let rafId = null;
4914
+ let isUnmounted = false;
4915
+ function startOverlayTracking() {
4916
+ if (rafId !== null) return;
4917
+ const step = () => {
4918
+ updateOverlayRect();
4919
+ rafId = requestAnimationFrame(step);
4920
+ };
4921
+ rafId = requestAnimationFrame(step);
4922
+ }
4923
+ function stopOverlayTracking() {
4924
+ if (rafId !== null) {
4925
+ cancelAnimationFrame(rafId);
4926
+ rafId = null;
4927
+ }
4928
+ }
4724
4929
  const overlayStyle = computed(() => {
4725
- if (!props.tableElement) return {};
4726
- const rect = props.tableElement.getBoundingClientRect();
4930
+ if (!overlayRect.value || !props.tableElement) return {};
4931
+ const rect = overlayRect.value;
4727
4932
  let overlayWidth = rect.width;
4728
4933
  if (dragState.value) {
4729
- overlayWidth = Math.max(rect.width + 1e3, 2e3);
4934
+ overlayWidth = Math.max(rect.width + DRAG_OVERLAY_EXTENSION_PX, MIN_DRAG_OVERLAY_WIDTH_PX);
4730
4935
  }
4731
4936
  return {
4732
4937
  position: "absolute",
4733
- left: `${props.tableElement.offsetLeft}px`,
4734
- top: `${props.tableElement.offsetTop}px`,
4938
+ left: `${rect.left}px`,
4939
+ top: `${rect.top}px`,
4735
4940
  width: `${overlayWidth}px`,
4736
4941
  height: `${rect.height}px`,
4737
4942
  pointerEvents: dragState.value ? "auto" : "none",
4738
4943
  zIndex: 10
4739
4944
  };
4740
4945
  });
4946
+ function updateOverlayRect() {
4947
+ if (!props.tableElement) {
4948
+ overlayRect.value = null;
4949
+ return;
4950
+ }
4951
+ const parent = props.tableElement.offsetParent;
4952
+ const tableRect = props.tableElement.getBoundingClientRect();
4953
+ if (tableRect.width === 0 || tableRect.height === 0) {
4954
+ overlayRect.value = null;
4955
+ return;
4956
+ }
4957
+ if (parent) {
4958
+ const parentRect = parent.getBoundingClientRect();
4959
+ const left = tableRect.left - parentRect.left + (parent.scrollLeft || 0);
4960
+ const top = tableRect.top - parentRect.top + (parent.scrollTop || 0);
4961
+ overlayRect.value = {
4962
+ left,
4963
+ top,
4964
+ width: tableRect.width,
4965
+ height: tableRect.height
4966
+ };
4967
+ } else {
4968
+ overlayRect.value = {
4969
+ left: props.tableElement.offsetLeft,
4970
+ top: props.tableElement.offsetTop,
4971
+ width: tableRect.width,
4972
+ height: tableRect.height
4973
+ };
4974
+ }
4975
+ }
4741
4976
  const resizableBoundaries = computed(() => {
4742
4977
  if (!tableMetadata.value?.columns) {
4743
4978
  return [];
@@ -4763,21 +4998,39 @@ const _sfc_main$2 = {
4763
4998
  });
4764
4999
  return boundaries;
4765
5000
  });
4766
- function getHandleStyle(boundary) {
5001
+ function getBoundarySegments(boundary) {
5002
+ if (boundary.type === "right-edge") {
5003
+ return [{ y: 0, h: null }];
5004
+ }
5005
+ const segmentsData = tableMetadata.value?.segments;
5006
+ if (!segmentsData || !Array.isArray(segmentsData)) {
5007
+ return [{ y: 0, h: null }];
5008
+ }
5009
+ const boundaryColIndex = boundary.index + 1;
5010
+ const colSegments = segmentsData[boundaryColIndex];
5011
+ if (!colSegments || colSegments.length === 0) {
5012
+ return [];
5013
+ }
5014
+ return colSegments.filter((seg) => seg && typeof seg === "object").map((seg) => ({
5015
+ y: typeof seg.y === "number" ? seg.y : 0,
5016
+ h: seg.h !== null && typeof seg.h === "number" ? seg.h : null
5017
+ }));
5018
+ }
5019
+ function getSegmentHandleStyle(boundary, segment) {
4767
5020
  return {
4768
5021
  position: "absolute",
4769
5022
  left: `${boundary.x}px`,
4770
- top: "0",
4771
- width: "9px",
4772
- height: "100%",
4773
- transform: "translateX(-4px)",
5023
+ top: segment.y != null ? `${segment.y}px` : "0",
5024
+ width: `${RESIZE_HANDLE_WIDTH_PX}px`,
5025
+ height: segment.h != null ? `${segment.h}px` : "100%",
5026
+ transform: `translateX(-${RESIZE_HANDLE_OFFSET_PX}px)`,
4774
5027
  cursor: "col-resize",
4775
5028
  pointerEvents: "auto"
4776
5029
  };
4777
5030
  }
4778
5031
  const guidelineStyle = computed(() => {
4779
5032
  if (!dragState.value || !tableMetadata.value) return { display: "none" };
4780
- const initialBoundary = resizableBoundaries.value[dragState.value.boundaryIndex];
5033
+ const initialBoundary = resizableBoundaries.value[dragState.value.resizableBoundaryIndex];
4781
5034
  if (!initialBoundary) return { display: "none" };
4782
5035
  const newX = initialBoundary.x + dragState.value.constrainedDelta;
4783
5036
  return {
@@ -4824,7 +5077,8 @@ const _sfc_main$2 = {
4824
5077
  });
4825
5078
  return;
4826
5079
  }
4827
- tableMetadata.value = { columns: validatedColumns };
5080
+ const segments = Array.isArray(parsed.segments) ? parsed.segments : void 0;
5081
+ tableMetadata.value = { columns: validatedColumns, segments };
4828
5082
  } catch (error) {
4829
5083
  tableMetadata.value = null;
4830
5084
  emit("resize-error", {
@@ -4833,11 +5087,11 @@ const _sfc_main$2 = {
4833
5087
  });
4834
5088
  }
4835
5089
  }
4836
- function onHandleMouseDown(event, boundaryIndex) {
5090
+ function onHandleMouseDown(event, resizableBoundaryIndex) {
4837
5091
  event.preventDefault();
4838
5092
  event.stopPropagation();
4839
5093
  if (!tableMetadata.value?.columns) return;
4840
- const boundary = resizableBoundaries.value[boundaryIndex];
5094
+ const boundary = resizableBoundaries.value[resizableBoundaryIndex];
4841
5095
  if (!boundary) return;
4842
5096
  const columns = tableMetadata.value.columns;
4843
5097
  const isRightEdge = boundary.type === "right-edge";
@@ -4845,7 +5099,7 @@ const _sfc_main$2 = {
4845
5099
  const rightColumn = isRightEdge ? null : columns[boundary.index + 1];
4846
5100
  dragState.value = {
4847
5101
  columnIndex: boundary.index,
4848
- boundaryIndex,
5102
+ resizableBoundaryIndex,
4849
5103
  isRightEdge,
4850
5104
  initialX: event.clientX,
4851
5105
  initialWidths: columns.map((col) => col.w),
@@ -4859,15 +5113,28 @@ const _sfc_main$2 = {
4859
5113
  } : null,
4860
5114
  constrainedDelta: 0
4861
5115
  };
5116
+ if (!props.editor?.view?.dom) {
5117
+ emit("resize-error", { error: "Editor view not available" });
5118
+ dragState.value = null;
5119
+ return;
5120
+ }
4862
5121
  const pmView = props.editor.view.dom;
4863
5122
  pmView.style.pointerEvents = "none";
4864
- document.addEventListener("mousemove", onDocumentMouseMove);
4865
- document.addEventListener("mouseup", onDocumentMouseUp);
4866
- emit("resize-start", {
4867
- columnIndex: boundary.index,
4868
- isRightEdge,
4869
- initialWidths: dragState.value.initialWidths
4870
- });
5123
+ try {
5124
+ document.addEventListener("mousemove", onDocumentMouseMove);
5125
+ document.addEventListener("mouseup", onDocumentMouseUp);
5126
+ emit("resize-start", {
5127
+ columnIndex: boundary.index,
5128
+ isRightEdge,
5129
+ initialWidths: dragState.value.initialWidths
5130
+ });
5131
+ } catch (error) {
5132
+ document.removeEventListener("mousemove", onDocumentMouseMove);
5133
+ document.removeEventListener("mouseup", onDocumentMouseUp);
5134
+ pmView.style.pointerEvents = "auto";
5135
+ dragState.value = null;
5136
+ emit("resize-error", { error: error instanceof Error ? error.message : String(error) });
5137
+ }
4871
5138
  }
4872
5139
  function throttle(func, limit) {
4873
5140
  let inThrottle;
@@ -4892,7 +5159,7 @@ const _sfc_main$2 = {
4892
5159
  return { throttled, cancel };
4893
5160
  }
4894
5161
  const mouseMoveThrottle = throttle((event) => {
4895
- if (!dragState.value) return;
5162
+ if (isUnmounted || !dragState.value) return;
4896
5163
  const delta = event.clientX - dragState.value.initialX;
4897
5164
  const minDelta = -(dragState.value.leftColumn.width - dragState.value.leftColumn.minWidth);
4898
5165
  let maxDelta;
@@ -4918,7 +5185,7 @@ const _sfc_main$2 = {
4918
5185
  columnIndex: dragState.value.columnIndex,
4919
5186
  delta: constrainedDelta
4920
5187
  });
4921
- }, 16);
5188
+ }, THROTTLE_INTERVAL_MS);
4922
5189
  const onDocumentMouseMove = mouseMoveThrottle.throttled;
4923
5190
  function onDocumentMouseUp(event) {
4924
5191
  if (!dragState.value) return;
@@ -4933,13 +5200,11 @@ const _sfc_main$2 = {
4933
5200
  }
4934
5201
  document.removeEventListener("mousemove", onDocumentMouseMove);
4935
5202
  document.removeEventListener("mouseup", onDocumentMouseUp);
4936
- if (props.editor?.view) {
5203
+ if (props.editor?.view?.dom) {
4937
5204
  const pmView = props.editor.view.dom;
4938
- if (pmView && pmView.style) {
4939
- pmView.style.pointerEvents = "auto";
4940
- }
5205
+ pmView.style.pointerEvents = "auto";
4941
5206
  }
4942
- if (!forcedCleanup.value && Math.abs(finalDelta) > 1) {
5207
+ if (!forcedCleanup.value && Math.abs(finalDelta) > MIN_RESIZE_DELTA_PX) {
4943
5208
  dispatchResizeTransaction(columnIndex, newWidths);
4944
5209
  emit("resize-end", {
4945
5210
  columnIndex,
@@ -4986,7 +5251,7 @@ const _sfc_main$2 = {
4986
5251
  updateCellColwidths(tr, tableNode, tablePos, affectedColumns, newWidths);
4987
5252
  dispatch(tr);
4988
5253
  const blockId = props.tableElement?.getAttribute("data-sd-block-id");
4989
- if (blockId) {
5254
+ if (blockId && blockId.trim()) {
4990
5255
  measureCache.invalidate([blockId]);
4991
5256
  }
4992
5257
  emit("resize-success", { columnIndex, newWidths });
@@ -5002,7 +5267,14 @@ const _sfc_main$2 = {
5002
5267
  if (!pmElement) {
5003
5268
  return null;
5004
5269
  }
5005
- const pmStart = parseInt(pmElement.getAttribute("data-pm-start"), 10);
5270
+ const pmStartAttr = pmElement.getAttribute("data-pm-start");
5271
+ if (!pmStartAttr) {
5272
+ return null;
5273
+ }
5274
+ const pmStart = parseInt(pmStartAttr, 10);
5275
+ if (!Number.isFinite(pmStart)) {
5276
+ return null;
5277
+ }
5006
5278
  let tablePos = null;
5007
5279
  state.doc.descendants((node, pos) => {
5008
5280
  if (node.type.name === "table") {
@@ -5054,6 +5326,12 @@ const _sfc_main$2 = {
5054
5326
  () => props.tableElement,
5055
5327
  () => {
5056
5328
  parseTableMetadata();
5329
+ updateOverlayRect();
5330
+ if (props.visible && props.tableElement) {
5331
+ startOverlayTracking();
5332
+ } else if (!props.tableElement) {
5333
+ stopOverlayTracking();
5334
+ }
5057
5335
  },
5058
5336
  { immediate: true }
5059
5337
  );
@@ -5062,7 +5340,10 @@ const _sfc_main$2 = {
5062
5340
  (visible) => {
5063
5341
  if (visible) {
5064
5342
  parseTableMetadata();
5343
+ updateOverlayRect();
5344
+ startOverlayTracking();
5065
5345
  } else {
5346
+ stopOverlayTracking();
5066
5347
  if (dragState.value) {
5067
5348
  forcedCleanup.value = true;
5068
5349
  onDocumentMouseUp(new MouseEvent("mouseup"));
@@ -5071,8 +5352,15 @@ const _sfc_main$2 = {
5071
5352
  }
5072
5353
  }
5073
5354
  );
5355
+ onMounted(() => {
5356
+ window.addEventListener("scroll", updateOverlayRect, true);
5357
+ window.addEventListener("resize", updateOverlayRect);
5358
+ updateOverlayRect();
5359
+ });
5074
5360
  onBeforeUnmount(() => {
5361
+ isUnmounted = true;
5075
5362
  mouseMoveThrottle.cancel();
5363
+ stopOverlayTracking();
5076
5364
  if (dragState.value) {
5077
5365
  document.removeEventListener("mousemove", onDocumentMouseMove);
5078
5366
  document.removeEventListener("mouseup", onDocumentMouseUp);
@@ -5080,6 +5368,8 @@ const _sfc_main$2 = {
5080
5368
  props.editor.view.dom.style.pointerEvents = "auto";
5081
5369
  }
5082
5370
  }
5371
+ window.removeEventListener("scroll", updateOverlayRect, true);
5372
+ window.removeEventListener("resize", updateOverlayRect);
5083
5373
  });
5084
5374
  return (_ctx, _cache) => {
5085
5375
  return __props.visible && tableMetadata.value ? (openBlock(), createElementBlock("div", {
@@ -5089,17 +5379,456 @@ const _sfc_main$2 = {
5089
5379
  onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
5090
5380
  }, ["stop"]))
5091
5381
  }, [
5092
- (openBlock(true), createElementBlock(Fragment, null, renderList(resizableBoundaries.value, (boundary, index) => {
5382
+ (openBlock(true), createElementBlock(Fragment, null, renderList(resizableBoundaries.value, (boundary, resizableBoundaryIndex) => {
5383
+ return openBlock(), createElementBlock(Fragment, {
5384
+ key: `boundary-${resizableBoundaryIndex}`
5385
+ }, [
5386
+ (openBlock(true), createElementBlock(Fragment, null, renderList(getBoundarySegments(boundary), (segment, segmentIndex) => {
5387
+ return openBlock(), createElementBlock("div", {
5388
+ key: `handle-${boundary.type}-${boundary.index}-${segmentIndex}`,
5389
+ class: normalizeClass(["resize-handle", {
5390
+ "resize-handle--active": dragState.value && dragState.value.resizableBoundaryIndex === resizableBoundaryIndex,
5391
+ "resize-handle--edge": boundary.type === "right-edge"
5392
+ }]),
5393
+ "data-boundary-index": resizableBoundaryIndex,
5394
+ "data-boundary-type": boundary.type,
5395
+ style: normalizeStyle(getSegmentHandleStyle(boundary, segment)),
5396
+ onMousedown: ($event) => onHandleMouseDown($event, resizableBoundaryIndex)
5397
+ }, null, 46, _hoisted_1$3);
5398
+ }), 128))
5399
+ ], 64);
5400
+ }), 128)),
5401
+ dragState.value ? (openBlock(), createElementBlock("div", {
5402
+ key: 0,
5403
+ class: "resize-guideline",
5404
+ style: normalizeStyle(guidelineStyle.value)
5405
+ }, null, 4)) : createCommentVNode("", true)
5406
+ ], 36)) : createCommentVNode("", true);
5407
+ };
5408
+ }
5409
+ };
5410
+ const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2fdf7836"]]);
5411
+ const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
5412
+ const OVERLAY_EXPANSION_PX = 2e3;
5413
+ const RESIZE_HANDLE_SIZE_PX = 12;
5414
+ const MOUSE_MOVE_THROTTLE_MS = 16;
5415
+ const DIMENSION_CHANGE_THRESHOLD_PX = 1;
5416
+ const Z_INDEX_OVERLAY = 10;
5417
+ const Z_INDEX_HANDLE = 15;
5418
+ const Z_INDEX_GUIDELINE = 20;
5419
+ const _sfc_main$3 = {
5420
+ __name: "ImageResizeOverlay",
5421
+ props: {
5422
+ /** Editor instance for dispatching transactions */
5423
+ editor: {
5424
+ type: Object,
5425
+ required: true
5426
+ },
5427
+ /** Show or hide the overlay */
5428
+ visible: {
5429
+ type: Boolean,
5430
+ default: false
5431
+ },
5432
+ /** Image fragment element containing data-image-metadata */
5433
+ imageElement: {
5434
+ type: Object,
5435
+ default: null
5436
+ }
5437
+ },
5438
+ emits: ["resize-start", "resize-move", "resize-end", "resize-success", "resize-error"],
5439
+ setup(__props, { emit: __emit }) {
5440
+ useCssVars((_ctx) => ({
5441
+ "v1e81f81d": RESIZE_HANDLE_SIZE_PX + "px",
5442
+ "v12763124": Z_INDEX_HANDLE
5443
+ }));
5444
+ function isValidEditor(editor) {
5445
+ return editor && typeof editor === "object" && editor.view && typeof editor.view === "object" && editor.view.dom instanceof HTMLElement && editor.view.state && typeof editor.view.dispatch === "function";
5446
+ }
5447
+ const props = __props;
5448
+ const emit = __emit;
5449
+ const imageMetadata = ref(null);
5450
+ const dragState = ref(null);
5451
+ const forcedCleanup = ref(false);
5452
+ const overlayStyle = computed(() => {
5453
+ if (!props.imageElement || !props.imageElement.isConnected) return {};
5454
+ const imageRect = props.imageElement.getBoundingClientRect();
5455
+ const wrapper = props.imageElement.closest(".super-editor");
5456
+ if (!wrapper) {
5457
+ return {
5458
+ position: "absolute",
5459
+ left: `${props.imageElement.offsetLeft}px`,
5460
+ top: `${props.imageElement.offsetTop}px`,
5461
+ width: `${imageRect.width}px`,
5462
+ height: `${imageRect.height}px`,
5463
+ pointerEvents: dragState.value ? "auto" : "none",
5464
+ zIndex: Z_INDEX_OVERLAY
5465
+ };
5466
+ }
5467
+ const wrapperRect = wrapper.getBoundingClientRect();
5468
+ const scrollLeft = wrapper.scrollLeft || 0;
5469
+ const scrollTop = wrapper.scrollTop || 0;
5470
+ const relativeLeft = imageRect.left - wrapperRect.left + scrollLeft;
5471
+ const relativeTop = imageRect.top - wrapperRect.top + scrollTop;
5472
+ let overlayWidth = imageRect.width;
5473
+ let overlayHeight = imageRect.height;
5474
+ let offsetX = 0;
5475
+ let offsetY = 0;
5476
+ if (dragState.value) {
5477
+ const expansion = OVERLAY_EXPANSION_PX;
5478
+ overlayWidth = imageRect.width + expansion * 2;
5479
+ overlayHeight = imageRect.height + expansion * 2;
5480
+ offsetX = -expansion;
5481
+ offsetY = -expansion;
5482
+ }
5483
+ return {
5484
+ position: "absolute",
5485
+ left: `${relativeLeft + offsetX}px`,
5486
+ top: `${relativeTop + offsetY}px`,
5487
+ width: `${overlayWidth}px`,
5488
+ height: `${overlayHeight}px`,
5489
+ pointerEvents: dragState.value ? "auto" : "none",
5490
+ zIndex: Z_INDEX_OVERLAY
5491
+ };
5492
+ });
5493
+ const resizeHandles = computed(() => {
5494
+ if (!imageMetadata.value || !props.imageElement) {
5495
+ return [];
5496
+ }
5497
+ const rect = props.imageElement.getBoundingClientRect();
5498
+ const width = rect.width;
5499
+ const height = rect.height;
5500
+ const handleSize = RESIZE_HANDLE_SIZE_PX;
5501
+ const offset = handleSize / 2;
5502
+ const expansion = dragState.value ? OVERLAY_EXPANSION_PX : 0;
5503
+ return [
5504
+ {
5505
+ position: "nw",
5506
+ style: {
5507
+ left: `${expansion - offset}px`,
5508
+ top: `${expansion - offset}px`,
5509
+ cursor: "nwse-resize"
5510
+ }
5511
+ },
5512
+ {
5513
+ position: "ne",
5514
+ style: {
5515
+ left: `${expansion + width - offset}px`,
5516
+ top: `${expansion - offset}px`,
5517
+ cursor: "nesw-resize"
5518
+ }
5519
+ },
5520
+ {
5521
+ position: "sw",
5522
+ style: {
5523
+ left: `${expansion - offset}px`,
5524
+ top: `${expansion + height - offset}px`,
5525
+ cursor: "nesw-resize"
5526
+ }
5527
+ },
5528
+ {
5529
+ position: "se",
5530
+ style: {
5531
+ left: `${expansion + width - offset}px`,
5532
+ top: `${expansion + height - offset}px`,
5533
+ cursor: "nwse-resize"
5534
+ }
5535
+ }
5536
+ ];
5537
+ });
5538
+ const guidelineStyle = computed(() => {
5539
+ if (!dragState.value || !props.imageElement) {
5540
+ return { display: "none" };
5541
+ }
5542
+ const expansion = OVERLAY_EXPANSION_PX;
5543
+ return {
5544
+ position: "absolute",
5545
+ left: `${expansion}px`,
5546
+ top: `${expansion}px`,
5547
+ width: `${dragState.value.constrainedWidth}px`,
5548
+ height: `${dragState.value.constrainedHeight}px`,
5549
+ border: "2px solid #4A90E2",
5550
+ pointerEvents: "none",
5551
+ zIndex: Z_INDEX_GUIDELINE,
5552
+ boxSizing: "border-box"
5553
+ };
5554
+ });
5555
+ function parseImageMetadata() {
5556
+ if (!props.imageElement || !props.imageElement.isConnected) {
5557
+ imageMetadata.value = null;
5558
+ return;
5559
+ }
5560
+ try {
5561
+ const metadataAttr = props.imageElement.getAttribute("data-image-metadata");
5562
+ if (!metadataAttr) {
5563
+ imageMetadata.value = null;
5564
+ return;
5565
+ }
5566
+ const parsed = JSON.parse(metadataAttr);
5567
+ if (!parsed || typeof parsed !== "object") {
5568
+ imageMetadata.value = null;
5569
+ return;
5570
+ }
5571
+ const required = [
5572
+ "originalWidth",
5573
+ "originalHeight",
5574
+ "maxWidth",
5575
+ "maxHeight",
5576
+ "aspectRatio",
5577
+ "minWidth",
5578
+ "minHeight"
5579
+ ];
5580
+ for (const field of required) {
5581
+ if (!Number.isFinite(parsed[field]) || parsed[field] <= 0) {
5582
+ console.warn(`[ImageResizeOverlay] Invalid or missing metadata field: ${field}`);
5583
+ imageMetadata.value = null;
5584
+ return;
5585
+ }
5586
+ }
5587
+ imageMetadata.value = parsed;
5588
+ } catch (error) {
5589
+ imageMetadata.value = null;
5590
+ emit("resize-error", {
5591
+ error: error instanceof Error ? error.message : "Failed to parse image metadata",
5592
+ rawMetadata: props.imageElement?.getAttribute("data-image-metadata")
5593
+ });
5594
+ }
5595
+ }
5596
+ function onHandleMouseDown(event, handlePosition) {
5597
+ event.preventDefault();
5598
+ event.stopPropagation();
5599
+ if (!isValidEditor(props.editor) || !imageMetadata.value || !props.imageElement) return;
5600
+ const rect = props.imageElement.getBoundingClientRect();
5601
+ dragState.value = {
5602
+ handle: handlePosition,
5603
+ initialX: event.clientX,
5604
+ initialY: event.clientY,
5605
+ initialWidth: rect.width,
5606
+ initialHeight: rect.height,
5607
+ aspectRatio: imageMetadata.value.aspectRatio,
5608
+ constrainedWidth: rect.width,
5609
+ constrainedHeight: rect.height
5610
+ };
5611
+ const pmView = props.editor.view.dom;
5612
+ pmView.style.pointerEvents = "none";
5613
+ document.addEventListener("mousemove", onDocumentMouseMove);
5614
+ document.addEventListener("mouseup", onDocumentMouseUp);
5615
+ document.addEventListener("keydown", onEscapeKey);
5616
+ emit("resize-start", {
5617
+ blockId: props.imageElement.getAttribute("data-sd-block-id"),
5618
+ initialWidth: rect.width,
5619
+ initialHeight: rect.height
5620
+ });
5621
+ }
5622
+ function throttle(func, limit) {
5623
+ let inThrottle;
5624
+ let timeoutId = null;
5625
+ const throttled = function(...args) {
5626
+ if (!inThrottle) {
5627
+ func.apply(this, args);
5628
+ inThrottle = true;
5629
+ timeoutId = setTimeout(() => {
5630
+ inThrottle = false;
5631
+ timeoutId = null;
5632
+ }, limit);
5633
+ }
5634
+ };
5635
+ const cancel = () => {
5636
+ if (timeoutId !== null) {
5637
+ clearTimeout(timeoutId);
5638
+ timeoutId = null;
5639
+ inThrottle = false;
5640
+ }
5641
+ };
5642
+ return { throttled, cancel };
5643
+ }
5644
+ const mouseMoveThrottle = throttle((event) => {
5645
+ if (!dragState.value || !imageMetadata.value) return;
5646
+ let deltaX = event.clientX - dragState.value.initialX;
5647
+ let deltaY = event.clientY - dragState.value.initialY;
5648
+ const handle = dragState.value.handle;
5649
+ if (handle === "nw") {
5650
+ deltaX = -deltaX;
5651
+ deltaY = -deltaY;
5652
+ } else if (handle === "ne") {
5653
+ deltaY = -deltaY;
5654
+ } else if (handle === "sw") {
5655
+ deltaX = -deltaX;
5656
+ }
5657
+ const scaleX = (dragState.value.initialWidth + deltaX) / dragState.value.initialWidth;
5658
+ const scaleY = (dragState.value.initialHeight + deltaY) / dragState.value.initialHeight;
5659
+ const scale = Math.max(scaleX, scaleY);
5660
+ let newWidth = dragState.value.initialWidth * scale;
5661
+ let newHeight = dragState.value.initialHeight * scale;
5662
+ const minWidth = imageMetadata.value.minWidth;
5663
+ const minHeight = imageMetadata.value.minHeight;
5664
+ const maxWidth = imageMetadata.value.maxWidth;
5665
+ const maxHeight = imageMetadata.value.maxHeight;
5666
+ if (newWidth < minWidth) {
5667
+ newWidth = minWidth;
5668
+ newHeight = newWidth / dragState.value.aspectRatio;
5669
+ }
5670
+ if (newHeight < minHeight) {
5671
+ newHeight = minHeight;
5672
+ newWidth = newHeight * dragState.value.aspectRatio;
5673
+ }
5674
+ if (newWidth > maxWidth) {
5675
+ newWidth = maxWidth;
5676
+ newHeight = newWidth / dragState.value.aspectRatio;
5677
+ }
5678
+ if (newHeight > maxHeight) {
5679
+ newHeight = maxHeight;
5680
+ newWidth = newHeight * dragState.value.aspectRatio;
5681
+ }
5682
+ dragState.value.constrainedWidth = newWidth;
5683
+ dragState.value.constrainedHeight = newHeight;
5684
+ emit("resize-move", {
5685
+ blockId: props.imageElement.getAttribute("data-sd-block-id"),
5686
+ width: newWidth,
5687
+ height: newHeight
5688
+ });
5689
+ }, MOUSE_MOVE_THROTTLE_MS);
5690
+ const onDocumentMouseMove = mouseMoveThrottle.throttled;
5691
+ function onEscapeKey(event) {
5692
+ if (event.key === "Escape" && dragState.value) {
5693
+ forcedCleanup.value = true;
5694
+ onDocumentMouseUp(new MouseEvent("mouseup"));
5695
+ forcedCleanup.value = false;
5696
+ }
5697
+ }
5698
+ function onDocumentMouseUp(event) {
5699
+ if (!dragState.value) return;
5700
+ const finalWidth = dragState.value.constrainedWidth;
5701
+ const finalHeight = dragState.value.constrainedHeight;
5702
+ const blockId = props.imageElement?.getAttribute("data-sd-block-id");
5703
+ document.removeEventListener("mousemove", onDocumentMouseMove);
5704
+ document.removeEventListener("mouseup", onDocumentMouseUp);
5705
+ document.removeEventListener("keydown", onEscapeKey);
5706
+ if (props.editor?.view) {
5707
+ const pmView = props.editor.view.dom;
5708
+ if (pmView && pmView.style) {
5709
+ pmView.style.pointerEvents = "auto";
5710
+ }
5711
+ }
5712
+ const widthDelta = Math.abs(finalWidth - dragState.value.initialWidth);
5713
+ const heightDelta = Math.abs(finalHeight - dragState.value.initialHeight);
5714
+ if (!forcedCleanup.value && (widthDelta > DIMENSION_CHANGE_THRESHOLD_PX || heightDelta > DIMENSION_CHANGE_THRESHOLD_PX)) {
5715
+ dispatchResizeTransaction(blockId, finalWidth, finalHeight);
5716
+ emit("resize-end", {
5717
+ blockId,
5718
+ finalWidth,
5719
+ finalHeight
5720
+ });
5721
+ }
5722
+ dragState.value = null;
5723
+ }
5724
+ function dispatchResizeTransaction(blockId, newWidth, newHeight) {
5725
+ if (!isValidEditor(props.editor) || !props.imageElement) {
5726
+ return;
5727
+ }
5728
+ if (!Number.isFinite(newWidth) || !Number.isFinite(newHeight) || newWidth <= 0 || newHeight <= 0) {
5729
+ emit("resize-error", {
5730
+ blockId,
5731
+ error: "Invalid dimensions: width and height must be positive finite numbers"
5732
+ });
5733
+ return;
5734
+ }
5735
+ try {
5736
+ const { state, dispatch } = props.editor.view;
5737
+ const tr = state.tr;
5738
+ const pmStartAttr = props.imageElement.getAttribute("data-pm-start");
5739
+ if (!pmStartAttr) {
5740
+ emit("resize-error", {
5741
+ blockId,
5742
+ error: "Image position marker (data-pm-start) not found"
5743
+ });
5744
+ return;
5745
+ }
5746
+ const imagePos = parseInt(pmStartAttr, 10);
5747
+ if (!Number.isFinite(imagePos) || imagePos < 0) {
5748
+ emit("resize-error", {
5749
+ blockId,
5750
+ error: "Invalid image position marker"
5751
+ });
5752
+ return;
5753
+ }
5754
+ const imageNode = state.doc.nodeAt(imagePos);
5755
+ if (!imageNode || imageNode.type.name !== "image") {
5756
+ emit("resize-error", {
5757
+ blockId,
5758
+ error: "Invalid image node at position"
5759
+ });
5760
+ return;
5761
+ }
5762
+ const newAttrs = {
5763
+ ...imageNode.attrs,
5764
+ size: {
5765
+ width: Math.round(newWidth),
5766
+ height: Math.round(newHeight)
5767
+ }
5768
+ };
5769
+ tr.setNodeMarkup(imagePos, null, newAttrs);
5770
+ dispatch(tr);
5771
+ if (blockId && blockId.trim()) {
5772
+ measureCache.invalidate([blockId]);
5773
+ }
5774
+ emit("resize-success", { blockId, newWidth, newHeight });
5775
+ } catch (error) {
5776
+ emit("resize-error", {
5777
+ blockId,
5778
+ error: error instanceof Error ? error.message : String(error)
5779
+ });
5780
+ }
5781
+ }
5782
+ watch(
5783
+ () => props.imageElement,
5784
+ () => {
5785
+ parseImageMetadata();
5786
+ },
5787
+ { immediate: true }
5788
+ );
5789
+ watch(
5790
+ () => props.visible,
5791
+ (visible) => {
5792
+ if (visible) {
5793
+ parseImageMetadata();
5794
+ } else {
5795
+ if (dragState.value) {
5796
+ forcedCleanup.value = true;
5797
+ onDocumentMouseUp(new MouseEvent("mouseup"));
5798
+ forcedCleanup.value = false;
5799
+ }
5800
+ }
5801
+ }
5802
+ );
5803
+ onBeforeUnmount(() => {
5804
+ mouseMoveThrottle.cancel();
5805
+ if (dragState.value) {
5806
+ document.removeEventListener("mousemove", onDocumentMouseMove);
5807
+ document.removeEventListener("mouseup", onDocumentMouseUp);
5808
+ document.removeEventListener("keydown", onEscapeKey);
5809
+ if (props.editor?.view?.dom) {
5810
+ props.editor.view.dom.style.pointerEvents = "auto";
5811
+ }
5812
+ }
5813
+ });
5814
+ return (_ctx, _cache) => {
5815
+ return __props.visible && imageMetadata.value ? (openBlock(), createElementBlock("div", {
5816
+ key: 0,
5817
+ class: "superdoc-image-resize-overlay",
5818
+ style: normalizeStyle(overlayStyle.value),
5819
+ onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
5820
+ }, ["stop"]))
5821
+ }, [
5822
+ (openBlock(true), createElementBlock(Fragment, null, renderList(resizeHandles.value, (handle) => {
5093
5823
  return openBlock(), createElementBlock("div", {
5094
- key: `handle-${boundary.type}-${boundary.index}`,
5824
+ key: handle.position,
5095
5825
  class: normalizeClass(["resize-handle", {
5096
- "resize-handle--active": dragState.value && dragState.value.boundaryIndex === index,
5097
- "resize-handle--edge": boundary.type === "right-edge"
5826
+ "resize-handle--active": dragState.value && dragState.value.handle === handle.position,
5827
+ [`resize-handle--${handle.position}`]: true
5098
5828
  }]),
5099
- "data-boundary-index": index,
5100
- "data-boundary-type": boundary.type,
5101
- style: normalizeStyle(getHandleStyle(boundary)),
5102
- onMousedown: ($event) => onHandleMouseDown($event, index)
5829
+ style: normalizeStyle(handle.style),
5830
+ "data-handle-position": handle.position,
5831
+ onMousedown: ($event) => onHandleMouseDown($event, handle.position)
5103
5832
  }, null, 46, _hoisted_1$2);
5104
5833
  }), 128)),
5105
5834
  dragState.value ? (openBlock(), createElementBlock("div", {
@@ -5111,7 +5840,81 @@ const _sfc_main$2 = {
5111
5840
  };
5112
5841
  }
5113
5842
  };
5114
- const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-acc51d8d"]]);
5843
+ const ImageResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-e66ec7bb"]]);
5844
+ const _sfc_main$2 = {
5845
+ __name: "LinkClickHandler",
5846
+ props: {
5847
+ editor: {
5848
+ type: Object,
5849
+ required: true
5850
+ },
5851
+ openPopover: {
5852
+ type: Function,
5853
+ required: true
5854
+ },
5855
+ closePopover: {
5856
+ type: Function,
5857
+ required: true
5858
+ },
5859
+ popoverVisible: {
5860
+ type: Boolean,
5861
+ default: false
5862
+ }
5863
+ },
5864
+ setup(__props) {
5865
+ const props = __props;
5866
+ const handleLinkClick = (event) => {
5867
+ if (props.popoverVisible) {
5868
+ props.closePopover();
5869
+ return;
5870
+ }
5871
+ if (!props.editor || !props.editor.state) {
5872
+ return;
5873
+ }
5874
+ const surface = getEditorSurfaceElement(props.editor);
5875
+ if (!surface) {
5876
+ return;
5877
+ }
5878
+ moveCursorToMouseEvent(event.detail, props.editor);
5879
+ setTimeout(() => {
5880
+ const currentState = props.editor.state;
5881
+ const hasLink = selectionHasNodeOrMark(currentState, "link", { requireEnds: true });
5882
+ if (hasLink) {
5883
+ const surfaceRect = surface.getBoundingClientRect();
5884
+ if (!surfaceRect) return;
5885
+ props.openPopover(
5886
+ markRaw(LinkInput),
5887
+ {
5888
+ showInput: true,
5889
+ editor: props.editor,
5890
+ closePopover: props.closePopover
5891
+ },
5892
+ {
5893
+ left: `${event.detail.clientX - surfaceRect.left}px`,
5894
+ top: `${event.detail.clientY - surfaceRect.top + 15}px`
5895
+ }
5896
+ );
5897
+ }
5898
+ }, 10);
5899
+ };
5900
+ let surfaceElement = null;
5901
+ onMounted(() => {
5902
+ if (!props.editor) return;
5903
+ surfaceElement = getEditorSurfaceElement(props.editor);
5904
+ if (surfaceElement) {
5905
+ surfaceElement.addEventListener("superdoc-link-click", handleLinkClick);
5906
+ }
5907
+ });
5908
+ onBeforeUnmount(() => {
5909
+ if (surfaceElement) {
5910
+ surfaceElement.removeEventListener("superdoc-link-click", handleLinkClick);
5911
+ }
5912
+ });
5913
+ return (_ctx, _cache) => {
5914
+ return null;
5915
+ };
5916
+ }
5917
+ };
5115
5918
  function adjustPaginationBreaks(editorElem, editor) {
5116
5919
  if (!editorElem.value || !editor?.value?.options?.scale || isHeadless(editor)) return;
5117
5920
  const zoom = editor.value.options.scale;
@@ -5136,6 +5939,8 @@ const _hoisted_2 = {
5136
5939
  };
5137
5940
  const _hoisted_3 = { class: "placeholder-title" };
5138
5941
  const DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
5942
+ const TABLE_RESIZE_HOVER_THRESHOLD = 8;
5943
+ const TABLE_RESIZE_THROTTLE_MS = 16;
5139
5944
  const _sfc_main$1 = {
5140
5945
  __name: "SuperEditor",
5141
5946
  props: {
@@ -5200,7 +6005,63 @@ const _sfc_main$1 = {
5200
6005
  visible: false,
5201
6006
  tableElement: null
5202
6007
  });
6008
+ const imageResizeState = reactive({
6009
+ visible: false,
6010
+ imageElement: null,
6011
+ blockId: null
6012
+ });
6013
+ let lastUpdateTableResizeTimestamp = 0;
6014
+ const isNearColumnBoundary = (event, tableElement) => {
6015
+ if (!event || typeof event.clientX !== "number" || typeof event.clientY !== "number") {
6016
+ console.warn("[isNearColumnBoundary] Invalid event: missing clientX or clientY", event);
6017
+ return false;
6018
+ }
6019
+ if (!tableElement || !(tableElement instanceof HTMLElement)) {
6020
+ console.warn("[isNearColumnBoundary] Invalid tableElement: not an HTMLElement", tableElement);
6021
+ return false;
6022
+ }
6023
+ const boundariesAttr = tableElement.getAttribute("data-table-boundaries");
6024
+ if (!boundariesAttr) return false;
6025
+ try {
6026
+ const metadata = JSON.parse(boundariesAttr);
6027
+ if (!metadata.columns || !Array.isArray(metadata.columns)) return false;
6028
+ const tableRect = tableElement.getBoundingClientRect();
6029
+ const mouseX = event.clientX - tableRect.left;
6030
+ const mouseY = event.clientY - tableRect.top;
6031
+ for (let i2 = 0; i2 < metadata.columns.length; i2++) {
6032
+ const col = metadata.columns[i2];
6033
+ const boundaryX = col.x + col.w;
6034
+ if (Math.abs(mouseX - boundaryX) <= TABLE_RESIZE_HOVER_THRESHOLD) {
6035
+ const segmentColIndex = i2 + 1;
6036
+ const segments = metadata.segments?.[segmentColIndex];
6037
+ if (!segments || segments.length === 0) {
6038
+ if (i2 === metadata.columns.length - 1) return true;
6039
+ continue;
6040
+ }
6041
+ for (const seg of segments) {
6042
+ const segTop = seg.y || 0;
6043
+ const segBottom = seg.h != null ? segTop + seg.h : tableRect.height;
6044
+ if (mouseY >= segTop && mouseY <= segBottom) {
6045
+ return true;
6046
+ }
6047
+ }
6048
+ }
6049
+ }
6050
+ if (Math.abs(mouseX) <= TABLE_RESIZE_HOVER_THRESHOLD) {
6051
+ return true;
6052
+ }
6053
+ return false;
6054
+ } catch (e) {
6055
+ console.warn("[isNearColumnBoundary] Failed to parse table boundary metadata:", e);
6056
+ return false;
6057
+ }
6058
+ };
5203
6059
  const updateTableResizeOverlay = (event) => {
6060
+ const now = Date.now();
6061
+ if (now - lastUpdateTableResizeTimestamp < TABLE_RESIZE_THROTTLE_MS) {
6062
+ return;
6063
+ }
6064
+ lastUpdateTableResizeTimestamp = now;
5204
6065
  if (!editorElem.value) return;
5205
6066
  let target = event.target;
5206
6067
  while (target && target !== editorElem.value) {
@@ -5208,8 +6069,13 @@ const _sfc_main$1 = {
5208
6069
  return;
5209
6070
  }
5210
6071
  if (target.classList?.contains("superdoc-table-fragment") && target.hasAttribute("data-table-boundaries")) {
5211
- tableResizeState.visible = true;
5212
- tableResizeState.tableElement = target;
6072
+ if (isNearColumnBoundary(event, target)) {
6073
+ tableResizeState.visible = true;
6074
+ tableResizeState.tableElement = target;
6075
+ } else {
6076
+ tableResizeState.visible = false;
6077
+ tableResizeState.tableElement = null;
6078
+ }
5213
6079
  return;
5214
6080
  }
5215
6081
  target = target.parentElement;
@@ -5221,6 +6087,38 @@ const _sfc_main$1 = {
5221
6087
  tableResizeState.visible = false;
5222
6088
  tableResizeState.tableElement = null;
5223
6089
  };
6090
+ const updateImageResizeOverlay = (event) => {
6091
+ if (!editorElem.value) return;
6092
+ let target = event.target;
6093
+ while (target && target !== document.body) {
6094
+ if (target.classList?.contains("superdoc-image-resize-overlay") || target.closest?.(".superdoc-image-resize-overlay")) {
6095
+ return;
6096
+ }
6097
+ if (target.classList?.contains("superdoc-image-fragment") && target.hasAttribute("data-image-metadata")) {
6098
+ imageResizeState.visible = true;
6099
+ imageResizeState.imageElement = target;
6100
+ imageResizeState.blockId = target.getAttribute("data-sd-block-id");
6101
+ return;
6102
+ }
6103
+ target = target.parentElement;
6104
+ }
6105
+ imageResizeState.visible = false;
6106
+ imageResizeState.imageElement = null;
6107
+ imageResizeState.blockId = null;
6108
+ };
6109
+ const hideImageResizeOverlay = () => {
6110
+ imageResizeState.visible = false;
6111
+ imageResizeState.imageElement = null;
6112
+ imageResizeState.blockId = null;
6113
+ };
6114
+ const handleOverlayUpdates = (event) => {
6115
+ updateTableResizeOverlay(event);
6116
+ updateImageResizeOverlay(event);
6117
+ };
6118
+ const handleOverlayHide = () => {
6119
+ hideTableResizeOverlay();
6120
+ hideImageResizeOverlay();
6121
+ };
5224
6122
  let dataPollTimeout;
5225
6123
  const stopPolling = () => {
5226
6124
  clearTimeout(dataPollTimeout);
@@ -5307,6 +6205,22 @@ const _sfc_main$1 = {
5307
6205
  const paginationTarget = editor.value?.editor ? { value: base } : editor;
5308
6206
  adjustPaginationBreaks(editorElem, paginationTarget);
5309
6207
  });
6208
+ if (editor.value instanceof PresentationEditor) {
6209
+ editor.value.on("layoutUpdated", () => {
6210
+ if (imageResizeState.visible && imageResizeState.blockId) {
6211
+ const newElement = editorElem.value?.querySelector(
6212
+ `.superdoc-image-fragment[data-sd-block-id="${imageResizeState.blockId}"]`
6213
+ );
6214
+ if (newElement) {
6215
+ imageResizeState.imageElement = newElement;
6216
+ } else {
6217
+ imageResizeState.visible = false;
6218
+ imageResizeState.imageElement = null;
6219
+ imageResizeState.blockId = null;
6220
+ }
6221
+ }
6222
+ });
6223
+ }
5310
6224
  editor.value.on("collaborationReady", () => {
5311
6225
  setTimeout(() => {
5312
6226
  editorReady.value = true;
@@ -5391,8 +6305,8 @@ const _sfc_main$1 = {
5391
6305
  onKeydown: handleSuperEditorKeydown,
5392
6306
  onClick: handleSuperEditorClick,
5393
6307
  onMousedown: handleMarginClick,
5394
- onMousemove: updateTableResizeOverlay,
5395
- onMouseleave: hideTableResizeOverlay
6308
+ onMousemove: handleOverlayUpdates,
6309
+ onMouseleave: handleOverlayHide
5396
6310
  }, [
5397
6311
  createElementVNode("div", {
5398
6312
  ref_key: "editorElem",
@@ -5400,19 +6314,32 @@ const _sfc_main$1 = {
5400
6314
  class: "editor-element super-editor__element",
5401
6315
  role: "presentation"
5402
6316
  }, null, 512),
5403
- !contextMenuDisabled.value && editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$6, {
6317
+ !contextMenuDisabled.value && editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$8, {
5404
6318
  key: 0,
5405
6319
  editor: activeEditor.value,
5406
6320
  popoverControls,
5407
6321
  openPopover,
5408
6322
  closePopover
5409
6323
  }, null, 8, ["editor", "popoverControls"])) : createCommentVNode("", true),
5410
- editorReady.value && activeEditor.value ? (openBlock(), createBlock(TableResizeOverlay, {
6324
+ editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$2, {
5411
6325
  key: 1,
5412
6326
  editor: activeEditor.value,
6327
+ openPopover,
6328
+ closePopover,
6329
+ popoverVisible: popoverControls.visible
6330
+ }, null, 8, ["editor", "popoverVisible"])) : createCommentVNode("", true),
6331
+ editorReady.value && activeEditor.value ? (openBlock(), createBlock(TableResizeOverlay, {
6332
+ key: 2,
6333
+ editor: activeEditor.value,
5413
6334
  visible: tableResizeState.visible,
5414
6335
  tableElement: tableResizeState.tableElement
5415
- }, null, 8, ["editor", "visible", "tableElement"])) : createCommentVNode("", true)
6336
+ }, null, 8, ["editor", "visible", "tableElement"])) : createCommentVNode("", true),
6337
+ editorReady.value && activeEditor.value ? (openBlock(), createBlock(ImageResizeOverlay, {
6338
+ key: 3,
6339
+ editor: activeEditor.value,
6340
+ visible: imageResizeState.visible,
6341
+ imageElement: imageResizeState.imageElement
6342
+ }, null, 8, ["editor", "visible", "imageElement"])) : createCommentVNode("", true)
5416
6343
  ], 544),
5417
6344
  !editorReady.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
5418
6345
  createElementVNode("div", _hoisted_3, [
@@ -5475,7 +6402,7 @@ const _sfc_main$1 = {
5475
6402
  };
5476
6403
  }
5477
6404
  };
5478
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-f1e98438"]]);
6405
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ed5a08ee"]]);
5479
6406
  const _hoisted_1 = ["innerHTML"];
5480
6407
  const _sfc_main = {
5481
6408
  __name: "SuperInput",
@@ -5567,98 +6494,6 @@ const _sfc_main = {
5567
6494
  }
5568
6495
  };
5569
6496
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
5570
- const additionalHandlers = Object.freeze({
5571
- "mc:AlternateContent": translator$1j,
5572
- "sd:pageReference": translator$1i,
5573
- "sd:tableOfContents": translator$1h,
5574
- "w:b": translator$1g,
5575
- "w:bCs": translator$1f,
5576
- "w:bidiVisual": translator$1e,
5577
- "w:bookmarkEnd": translator$1d,
5578
- "w:bookmarkStart": translator$1c,
5579
- "w:bottom": translator$1b,
5580
- "w:br": translator$1a,
5581
- "w:cantSplit": translator$19,
5582
- "w:caps": translator$18,
5583
- "w:cnfStyle": translator$17,
5584
- "w:color": translator$16,
5585
- "w:divId": translator$15,
5586
- "w:drawing": translator$14,
5587
- "w:end": translator$13,
5588
- "w:gridAfter": translator$12,
5589
- "w:gridBefore": translator$11,
5590
- "w:gridCol": translator$10,
5591
- "w:hidden": translator$$,
5592
- "w:highlight": translator$_,
5593
- "w:hyperlink": translator$Z,
5594
- "w:i": translator$Y,
5595
- "w:insideH": translator$X,
5596
- "w:insideV": translator$W,
5597
- "w:jc": translator$V,
5598
- "w:left": translator$U,
5599
- "w:p": translator$T,
5600
- "w:r": translator$S,
5601
- "w:rFonts": translator$R,
5602
- "w:rPr": translator$Q,
5603
- "w:rStyle": translator$P,
5604
- "w:right": translator$O,
5605
- "w:sdt": translator$N,
5606
- "w:shd": translator$M,
5607
- "w:start": translator$L,
5608
- "w:strike": translator$K,
5609
- "w:sz": translator$J,
5610
- "w:szCs": translator$I,
5611
- "w:tab": translator$H,
5612
- "w:tbl": translator$G,
5613
- "w:tblBorders": translator$F,
5614
- "w:tblCaption": translator$E,
5615
- "w:tblCellMar": translator$D,
5616
- "w:tblCellSpacing": translator$C,
5617
- "w:tblDescription": translator$B,
5618
- "w:tblGrid": translator$A,
5619
- "w:tblHeader": translator$z,
5620
- "w:tblInd": translator$y,
5621
- "w:tblLayout": translator$x,
5622
- "w:tblLook": translator$w,
5623
- "w:tblOverlap": translator$v,
5624
- "w:tblPr": translator$u,
5625
- "w:tblStyle": translator$t,
5626
- "w:tblStyleColBandSize": translator$s,
5627
- "w:tblStyleRowBandSize": translator$r,
5628
- "w:tblW": translator$q,
5629
- "w:tblpPr": translator$p,
5630
- "w:tc": translator$o,
5631
- "w:top": translator$n,
5632
- "w:tr": translator$m,
5633
- "w:trHeight": translator$l,
5634
- "w:trPr": translator$k,
5635
- "w:u": translator$j,
5636
- "w:wAfter": translator$i,
5637
- "w:wBefore": translator$h,
5638
- "wp:anchor": translator$g,
5639
- "wp:inline": translator$f,
5640
- "w:commentRangeStart": commentRangeStartTranslator,
5641
- "w:commentRangeEnd": commentRangeEndTranslator,
5642
- "w:vMerge": translator$e,
5643
- "w:gridSpan": translator$d,
5644
- "w:vAlign": translator$c,
5645
- "w:noWrap": translator$b,
5646
- "w:tcFitText": translator$a,
5647
- "w:tcW": translator$9,
5648
- "w:hideMark": translator$8,
5649
- "w:textDirection": translator$7,
5650
- "w:tl2br": translator$6,
5651
- "w:tr2bl": translator$5,
5652
- "w:header": translator$4,
5653
- "w:headers": translator$3,
5654
- "w:tcBorders": translator$2,
5655
- "w:tcMar": translator$1,
5656
- "w:tcPr": translator
5657
- });
5658
- const baseHandlers = {
5659
- ...additionalHandlers
5660
- };
5661
- const registeredHandlers = Object.freeze(baseHandlers);
5662
6497
  const Extensions = {
5663
6498
  Node,
5664
6499
  Attribute,
@@ -5673,14 +6508,14 @@ const Extensions = {
5673
6508
  export {
5674
6509
  AIWriter,
5675
6510
  z as AnnotatorHelpers,
5676
- _sfc_main$5 as BasicUpload,
6511
+ _sfc_main$7 as BasicUpload,
5677
6512
  F as CommentsPluginKey,
5678
6513
  D as DocxZipper,
5679
6514
  Editor,
5680
6515
  Extensions,
5681
6516
  PresentationEditor,
5682
6517
  B as SectionHelpers,
5683
- _sfc_main$6 as SlashMenu,
6518
+ _sfc_main$8 as SlashMenu,
5684
6519
  ac as SuperConverter,
5685
6520
  SuperEditor,
5686
6521
  SuperInput,
@@ -5695,6 +6530,6 @@ export {
5695
6530
  getRichTextExtensions,
5696
6531
  getStarterExtensions,
5697
6532
  a9 as helpers,
5698
- registeredHandlers,
6533
+ aQ as registeredHandlers,
5699
6534
  x as trackChangesHelpers
5700
6535
  };