superdoc 1.0.0-beta.37 → 1.0.0-beta.39

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 (30) hide show
  1. package/dist/chunks/{PdfViewer-ioYMTqps.cjs → PdfViewer-Beeg4BCm.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-C7M9_O_G.es.js → PdfViewer-eV3LwCxv.es.js} +1 -1
  3. package/dist/chunks/{index-CVmL6SHD-DZlLqgFx.es.js → index-BqDEyWLQ-B3TrQVjX.es.js} +1 -1
  4. package/dist/chunks/{index-CVmL6SHD-LYqtvXZO.cjs → index-BqDEyWLQ-CCRXZcrp.cjs} +1 -1
  5. package/dist/chunks/{index-CEh5e5Sy.cjs → index-DdrGP1Py.cjs} +3 -3
  6. package/dist/chunks/{index-tgFI32Kk.es.js → index-DvGFHOzb.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-Bk7tbTHB.es.js → super-editor.es-CQM3jM5n.es.js} +633 -126
  8. package/dist/chunks/{super-editor.es-CqPIzvls.cjs → super-editor.es-Uiy2hAKb.cjs} +633 -126
  9. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/style.css +12 -12
  11. package/dist/super-editor/ai-writer.es.js +2 -2
  12. package/dist/super-editor/chunks/{converter-ubqPT9rF.js → converter-nztpWkGr.js} +31 -22
  13. package/dist/super-editor/chunks/{docx-zipper-w_7HFRZI.js → docx-zipper-DaYim92a.js} +1 -1
  14. package/dist/super-editor/chunks/{editor-Udi34-u-.js → editor-H7c-XUpw.js} +542 -66
  15. package/dist/super-editor/chunks/{index-CVmL6SHD.js → index-BqDEyWLQ.js} +1 -1
  16. package/dist/super-editor/chunks/{toolbar-CKT2hVa-.js → toolbar-MtmAPa0Z.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/style.css +12 -12
  22. package/dist/super-editor/super-editor.es.js +169 -46
  23. package/dist/super-editor/toolbar.es.js +2 -2
  24. package/dist/super-editor.cjs +1 -1
  25. package/dist/super-editor.es.js +1 -1
  26. package/dist/superdoc.cjs +2 -2
  27. package/dist/superdoc.es.js +2 -2
  28. package/dist/superdoc.umd.js +635 -128
  29. package/dist/superdoc.umd.js.map +1 -1
  30. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { aK as getDefaultExportFromCjs } from "./converter-ubqPT9rF.js";
1
+ import { aK as getDefaultExportFromCjs } from "./converter-nztpWkGr.js";
2
2
  import { V as VFile } from "./index-CvBqQJbG.js";
3
3
  function bail(error) {
4
4
  if (error) {
@@ -1,6 +1,6 @@
1
1
  import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, onMounted, onBeforeUnmount, createVNode, readonly, watch, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
2
- import { p as process$1 } from "./converter-ubqPT9rF.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-Udi34-u-.js";
2
+ import { p as process$1 } from "./converter-nztpWkGr.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-H7c-XUpw.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -1,4 +1,4 @@
1
- import { ac } from "./chunks/converter-ubqPT9rF.js";
1
+ import { ac } from "./chunks/converter-nztpWkGr.js";
2
2
  export {
3
3
  ac as SuperConverter
4
4
  };
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-ubqPT9rF.js";
2
- import { D } from "./chunks/docx-zipper-w_7HFRZI.js";
1
+ import "./chunks/converter-nztpWkGr.js";
2
+ import { D } from "./chunks/docx-zipper-DaYim92a.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-Udi34-u-.js";
2
- import "./chunks/converter-ubqPT9rF.js";
3
- import "./chunks/docx-zipper-w_7HFRZI.js";
1
+ import { E } from "./chunks/editor-H7c-XUpw.js";
2
+ import "./chunks/converter-nztpWkGr.js";
3
+ import "./chunks/docx-zipper-DaYim92a.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-w_7HFRZI.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-DaYim92a.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -1889,18 +1889,18 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
1889
1889
  min-height: 40px;
1890
1890
  }
1891
1891
 
1892
- .superdoc-table-resize-overlay[data-v-2fdf7836] {
1892
+ .superdoc-table-resize-overlay[data-v-814384b6] {
1893
1893
  position: absolute;
1894
1894
  pointer-events: none;
1895
1895
  user-select: none;
1896
1896
  }
1897
- .resize-handle[data-v-2fdf7836] {
1897
+ .resize-handle[data-v-814384b6] {
1898
1898
  position: absolute;
1899
1899
  cursor: col-resize;
1900
1900
  user-select: none;
1901
1901
  z-index: 15;
1902
1902
  }
1903
- .resize-handle[data-v-2fdf7836]::before {
1903
+ .resize-handle[data-v-814384b6]::before {
1904
1904
  content: '';
1905
1905
  position: absolute;
1906
1906
  left: 50%;
@@ -1913,17 +1913,17 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
1913
1913
  background-color 0.2s ease,
1914
1914
  width 0.2s ease;
1915
1915
  }
1916
- .resize-handle[data-v-2fdf7836]:hover::before {
1916
+ .resize-handle[data-v-814384b6]:hover::before {
1917
1917
  background-color: #4a90e2;
1918
1918
  width: 3px;
1919
1919
  transform: translateX(-1.5px);
1920
1920
  }
1921
- .resize-handle--active[data-v-2fdf7836]::before {
1921
+ .resize-handle--active[data-v-814384b6]::before {
1922
1922
  background-color: #4a90e2;
1923
1923
  width: 2px;
1924
1924
  transform: translateX(-1px);
1925
1925
  }
1926
- .resize-guideline[data-v-2fdf7836] {
1926
+ .resize-guideline[data-v-814384b6] {
1927
1927
  position: absolute;
1928
1928
  background-color: #4a90e2;
1929
1929
  pointer-events: none;
@@ -1969,10 +1969,10 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
1969
1969
  box-shadow: 0 0 4px rgba(74, 144, 226, 0.5);
1970
1970
  }
1971
1971
 
1972
- .editor-element[data-v-6cfd3305] {
1972
+ .editor-element[data-v-a935d3e2] {
1973
1973
  position: relative;
1974
1974
  }
1975
- .super-editor-container[data-v-6cfd3305] {
1975
+ .super-editor-container[data-v-a935d3e2] {
1976
1976
  width: auto;
1977
1977
  height: auto;
1978
1978
  min-width: 8in;
@@ -1981,14 +1981,14 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
1981
1981
  display: flex;
1982
1982
  flex-direction: column;
1983
1983
  }
1984
- .ruler[data-v-6cfd3305] {
1984
+ .ruler[data-v-a935d3e2] {
1985
1985
  margin-bottom: 2px;
1986
1986
  }
1987
- .super-editor[data-v-6cfd3305] {
1987
+ .super-editor[data-v-a935d3e2] {
1988
1988
  color: initial;
1989
1989
  overflow: hidden;
1990
1990
  }
1991
- .placeholder-editor[data-v-6cfd3305] {
1991
+ .placeholder-editor[data-v-a935d3e2] {
1992
1992
  position: absolute;
1993
1993
  top: 0;
1994
1994
  left: 0;
@@ -2000,7 +2000,7 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
2000
2000
  background-color: white;
2001
2001
  box-sizing: border-box;
2002
2002
  }
2003
- .placeholder-title[data-v-6cfd3305] {
2003
+ .placeholder-title[data-v-a935d3e2] {
2004
2004
  display: flex;
2005
2005
  justify-content: center;
2006
2006
  margin-bottom: 40px;
@@ -9,14 +9,14 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
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
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, O as findParentNode, ar as calculateResolvedParagraphProperties, a7 as twipsToLines, Q as isList, al as parseSizeUnit, a8 as pixelsToTwips, aP as getFileObject, P as PluginKey, a as Plugin } from "./chunks/converter-ubqPT9rF.js";
13
- import { ac, i, a9, aQ } from "./chunks/converter-ubqPT9rF.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-Udi34-u-.js";
15
- import { z, F, B, T, w, C, x } from "./chunks/editor-Udi34-u-.js";
12
+ import { aK as getDefaultExportFromCjs, a0 as v4, T as TextSelection$1, v as getMarkRange, aN as vClickOutside, aO as getActiveFormatting, aD as isInTable, O as findParentNode, ar as calculateResolvedParagraphProperties, a7 as twipsToLines, Q as isList, al as parseSizeUnit, a8 as pixelsToTwips, aP as getFileObject, P as PluginKey, a as Plugin } from "./chunks/converter-nztpWkGr.js";
13
+ import { ac, i, a9, aQ } from "./chunks/converter-nztpWkGr.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-H7c-XUpw.js";
15
+ import { z, F, B, T, w, C, x } from "./chunks/editor-H7c-XUpw.js";
16
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-CKT2hVa-.js";
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-MtmAPa0Z.js";
18
18
  import AIWriter from "./ai-writer.es.js";
19
- import { D } from "./chunks/docx-zipper-w_7HFRZI.js";
19
+ import { D } from "./chunks/docx-zipper-DaYim92a.js";
20
20
  import { createZip } from "./file-zipper.es.js";
21
21
  var eventemitter3 = { exports: {} };
22
22
  var hasRequiredEventemitter3;
@@ -2556,16 +2556,6 @@ const _SuperToolbar = class _SuperToolbar extends EventEmitter {
2556
2556
  if (!argument) return;
2557
2557
  item.onActivate({ zoom: argument });
2558
2558
  this.emit("superdoc-command", { item, argument });
2559
- const layers = this.superdoc.element?.querySelector(".layers");
2560
- if (!layers) return;
2561
- const isMobileDevice = typeof screen.orientation !== "undefined";
2562
- const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
2563
- if (isMobileDevice && isSmallScreen) {
2564
- layers.style.transformOrigin = "0 0";
2565
- layers.style.transform = `scale(${parseInt(argument, 10) / 100})`;
2566
- } else {
2567
- layers.style.zoom = parseInt(argument, 10) / 100;
2568
- }
2569
2559
  this.superdoc.superdocStore.activeZoom = parseInt(argument, 10);
2570
2560
  },
2571
2561
  /**
@@ -4912,6 +4902,19 @@ const _sfc_main$4 = {
4912
4902
  const emit = __emit;
4913
4903
  const overlayRect = ref(null);
4914
4904
  const tableMetadata = ref(null);
4905
+ const getZoom = () => {
4906
+ const editor = props.editor;
4907
+ if (editor && typeof editor.zoom === "number") {
4908
+ return editor.zoom;
4909
+ }
4910
+ if (editor?.presentationEditor && typeof editor.presentationEditor.zoom === "number") {
4911
+ return editor.presentationEditor.zoom;
4912
+ }
4913
+ console.warn(
4914
+ "[TableResizeOverlay] getZoom: Unable to retrieve zoom from editor instance, using fallback value of 1. This may indicate the editor is not fully initialized or is not a PresentationEditor instance. Table resize handles may be misaligned."
4915
+ );
4916
+ return 1;
4917
+ };
4915
4918
  const dragState = ref(null);
4916
4919
  const forcedCleanup = ref(false);
4917
4920
  let rafId = null;
@@ -5021,12 +5024,16 @@ const _sfc_main$4 = {
5021
5024
  }));
5022
5025
  }
5023
5026
  function getSegmentHandleStyle(boundary, segment) {
5027
+ const zoom = getZoom();
5028
+ const scaledX = boundary.x * zoom;
5029
+ const scaledY = segment.y != null ? segment.y * zoom : null;
5030
+ const scaledH = segment.h != null ? segment.h * zoom : null;
5024
5031
  return {
5025
5032
  position: "absolute",
5026
- left: `${boundary.x}px`,
5027
- top: segment.y != null ? `${segment.y}px` : "0",
5033
+ left: `${scaledX}px`,
5034
+ top: scaledY != null ? `${scaledY}px` : "0",
5028
5035
  width: `${RESIZE_HANDLE_WIDTH_PX}px`,
5029
- height: segment.h != null ? `${segment.h}px` : "100%",
5036
+ height: scaledH != null ? `${scaledH}px` : "100%",
5030
5037
  transform: `translateX(-${RESIZE_HANDLE_OFFSET_PX}px)`,
5031
5038
  cursor: "col-resize",
5032
5039
  pointerEvents: "auto"
@@ -5036,7 +5043,8 @@ const _sfc_main$4 = {
5036
5043
  if (!dragState.value || !tableMetadata.value) return { display: "none" };
5037
5044
  const initialBoundary = resizableBoundaries.value[dragState.value.resizableBoundaryIndex];
5038
5045
  if (!initialBoundary) return { display: "none" };
5039
- const newX = initialBoundary.x + dragState.value.constrainedDelta;
5046
+ const zoom = getZoom();
5047
+ const newX = (initialBoundary.x + dragState.value.constrainedDelta) * zoom;
5040
5048
  return {
5041
5049
  position: "absolute",
5042
5050
  left: `${newX}px`,
@@ -5164,7 +5172,9 @@ const _sfc_main$4 = {
5164
5172
  }
5165
5173
  const mouseMoveThrottle = throttle((event) => {
5166
5174
  if (isUnmounted || !dragState.value) return;
5167
- const delta = event.clientX - dragState.value.initialX;
5175
+ const zoom = getZoom();
5176
+ const screenDelta = event.clientX - dragState.value.initialX;
5177
+ const delta = screenDelta / zoom;
5168
5178
  const minDelta = -(dragState.value.leftColumn.width - dragState.value.leftColumn.minWidth);
5169
5179
  let maxDelta;
5170
5180
  if (dragState.value.isRightEdge) {
@@ -5175,7 +5185,7 @@ const _sfc_main$4 = {
5175
5185
  const tableLeftInPage = tableRect.left - pageRect.left;
5176
5186
  const rightMargin = tableLeftInPage;
5177
5187
  const maxRightPosition = pageRect.right - rightMargin;
5178
- const availableSpace = maxRightPosition - tableRect.right;
5188
+ const availableSpace = (maxRightPosition - tableRect.right) / zoom;
5179
5189
  maxDelta = Math.max(0, availableSpace);
5180
5190
  } else {
5181
5191
  maxDelta = Infinity;
@@ -5411,7 +5421,7 @@ const _sfc_main$4 = {
5411
5421
  };
5412
5422
  }
5413
5423
  };
5414
- const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2fdf7836"]]);
5424
+ const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-814384b6"]]);
5415
5425
  const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
5416
5426
  const OVERLAY_EXPANSION_PX = 2e3;
5417
5427
  const RESIZE_HANDLE_SIZE_PX = 12;
@@ -5845,6 +5855,8 @@ const _sfc_main$3 = {
5845
5855
  }
5846
5856
  };
5847
5857
  const ImageResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-e66ec7bb"]]);
5858
+ const LINK_CLICK_DEBOUNCE_MS = 300;
5859
+ const CURSOR_UPDATE_TIMEOUT_MS = 10;
5848
5860
  const _sfc_main$2 = {
5849
5861
  __name: "LinkClickHandler",
5850
5862
  props: {
@@ -5867,7 +5879,15 @@ const _sfc_main$2 = {
5867
5879
  },
5868
5880
  setup(__props) {
5869
5881
  const props = __props;
5882
+ let lastLinkClickTime = 0;
5870
5883
  const handleLinkClick = (event) => {
5884
+ const detail = event?.detail ?? {};
5885
+ const linkElement = detail.element;
5886
+ const now = Date.now();
5887
+ if (now - lastLinkClickTime < LINK_CLICK_DEBOUNCE_MS) {
5888
+ return;
5889
+ }
5890
+ lastLinkClickTime = now;
5871
5891
  if (props.popoverVisible) {
5872
5892
  props.closePopover();
5873
5893
  return;
@@ -5879,12 +5899,34 @@ const _sfc_main$2 = {
5879
5899
  if (!surface) {
5880
5900
  return;
5881
5901
  }
5882
- const detail = event?.detail ?? {};
5883
- moveCursorToMouseEvent(detail, props.editor);
5902
+ const pmStart = linkElement?.dataset?.pmStart;
5903
+ if (pmStart != null) {
5904
+ const pos = parseInt(pmStart, 10);
5905
+ const state = props.editor.state;
5906
+ const doc = state.doc;
5907
+ if (!isNaN(pos) && pos >= 0 && pos <= doc.content.size) {
5908
+ const tr = state.tr.setSelection(TextSelection$1.create(doc, pos));
5909
+ props.editor.dispatch(tr);
5910
+ } else {
5911
+ console.warn(`Invalid PM position from data-pm-start: ${pmStart}, falling back to coordinate-based positioning`);
5912
+ moveCursorToMouseEvent(detail, props.editor);
5913
+ }
5914
+ } else {
5915
+ moveCursorToMouseEvent(detail, props.editor);
5916
+ }
5884
5917
  setTimeout(() => {
5885
5918
  const currentState = props.editor.state;
5919
+ const $from = currentState.selection.$from;
5920
+ const linkMarkType = currentState.schema.marks.link;
5921
+ const nodeAfter = $from.nodeAfter;
5922
+ const nodeBefore = $from.nodeBefore;
5923
+ const marksOnNodeAfter = nodeAfter?.marks || [];
5924
+ const marksOnNodeBefore = nodeBefore?.marks || [];
5925
+ const linkOnNodeAfter = linkMarkType && marksOnNodeAfter.some((m) => m.type === linkMarkType);
5926
+ const linkOnNodeBefore = linkMarkType && marksOnNodeBefore.some((m) => m.type === linkMarkType);
5927
+ const hasLinkAdjacent = linkOnNodeAfter || linkOnNodeBefore;
5886
5928
  const hasLink = selectionHasNodeOrMark(currentState, "link", { requireEnds: true });
5887
- if (hasLink) {
5929
+ if (hasLink || hasLinkAdjacent) {
5888
5930
  const surfaceRect = surface.getBoundingClientRect();
5889
5931
  if (!surfaceRect) return;
5890
5932
  props.openPopover(
@@ -5900,7 +5942,7 @@ const _sfc_main$2 = {
5900
5942
  }
5901
5943
  );
5902
5944
  }
5903
- }, 10);
5945
+ }, CURSOR_UPDATE_TIMEOUT_MS);
5904
5946
  };
5905
5947
  let surfaceElement = null;
5906
5948
  onMounted(() => {
@@ -5946,7 +5988,7 @@ const _hoisted_3 = { class: "placeholder-title" };
5946
5988
  const DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
5947
5989
  const TABLE_RESIZE_HOVER_THRESHOLD = 8;
5948
5990
  const TABLE_RESIZE_THROTTLE_MS = 16;
5949
- const _sfc_main$1 = {
5991
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5950
5992
  __name: "SuperEditor",
5951
5993
  props: {
5952
5994
  documentId: {
@@ -6015,6 +6057,24 @@ const _sfc_main$1 = {
6015
6057
  imageElement: null,
6016
6058
  blockId: null
6017
6059
  });
6060
+ const selectedImageState = reactive({
6061
+ element: null,
6062
+ blockId: null,
6063
+ pmStart: null
6064
+ });
6065
+ const getEditorZoom = () => {
6066
+ const active = activeEditor.value;
6067
+ if (active && typeof active.zoom === "number") {
6068
+ return active.zoom;
6069
+ }
6070
+ if (active?.presentationEditor && typeof active.presentationEditor.zoom === "number") {
6071
+ return active.presentationEditor.zoom;
6072
+ }
6073
+ console.warn(
6074
+ "[SuperEditor] getEditorZoom: Unable to retrieve zoom from editor instance, using fallback value of 1. This may indicate the editor is not fully initialized or is not a PresentationEditor instance."
6075
+ );
6076
+ return 1;
6077
+ };
6018
6078
  let lastUpdateTableResizeTimestamp = 0;
6019
6079
  const isNearColumnBoundary = (event, tableElement) => {
6020
6080
  if (!event || typeof event.clientX !== "number" || typeof event.clientY !== "number") {
@@ -6030,13 +6090,26 @@ const _sfc_main$1 = {
6030
6090
  try {
6031
6091
  const metadata = JSON.parse(boundariesAttr);
6032
6092
  if (!metadata.columns || !Array.isArray(metadata.columns)) return false;
6093
+ const zoom = getEditorZoom();
6033
6094
  const tableRect = tableElement.getBoundingClientRect();
6034
- const mouseX = event.clientX - tableRect.left;
6035
- const mouseY = event.clientY - tableRect.top;
6095
+ const mouseXScreen = event.clientX - tableRect.left;
6096
+ const mouseYScreen = event.clientY - tableRect.top;
6036
6097
  for (let i2 = 0; i2 < metadata.columns.length; i2++) {
6037
6098
  const col = metadata.columns[i2];
6038
- const boundaryX = col.x + col.w;
6039
- if (Math.abs(mouseX - boundaryX) <= TABLE_RESIZE_HOVER_THRESHOLD) {
6099
+ if (!col || typeof col !== "object") {
6100
+ console.warn(`[isNearColumnBoundary] Invalid column at index ${i2}: not an object`, col);
6101
+ continue;
6102
+ }
6103
+ if (typeof col.x !== "number" || !Number.isFinite(col.x)) {
6104
+ console.warn(`[isNearColumnBoundary] Invalid column.x at index ${i2}:`, col.x);
6105
+ continue;
6106
+ }
6107
+ if (typeof col.w !== "number" || !Number.isFinite(col.w) || col.w <= 0) {
6108
+ console.warn(`[isNearColumnBoundary] Invalid column.w at index ${i2}:`, col.w);
6109
+ continue;
6110
+ }
6111
+ const boundaryXScreen = (col.x + col.w) * zoom;
6112
+ if (Math.abs(mouseXScreen - boundaryXScreen) <= TABLE_RESIZE_HOVER_THRESHOLD) {
6040
6113
  const segmentColIndex = i2 + 1;
6041
6114
  const segments = metadata.segments?.[segmentColIndex];
6042
6115
  if (!segments || segments.length === 0) {
@@ -6044,15 +6117,15 @@ const _sfc_main$1 = {
6044
6117
  continue;
6045
6118
  }
6046
6119
  for (const seg of segments) {
6047
- const segTop = seg.y || 0;
6048
- const segBottom = seg.h != null ? segTop + seg.h : tableRect.height;
6049
- if (mouseY >= segTop && mouseY <= segBottom) {
6120
+ const segTopScreen = (seg.y || 0) * zoom;
6121
+ const segBottomScreen = seg.h != null ? segTopScreen + seg.h * zoom : tableRect.height;
6122
+ if (mouseYScreen >= segTopScreen && mouseYScreen <= segBottomScreen) {
6050
6123
  return true;
6051
6124
  }
6052
6125
  }
6053
6126
  }
6054
6127
  }
6055
- if (Math.abs(mouseX) <= TABLE_RESIZE_HOVER_THRESHOLD) {
6128
+ if (Math.abs(mouseXScreen) <= TABLE_RESIZE_HOVER_THRESHOLD) {
6056
6129
  return true;
6057
6130
  }
6058
6131
  return false;
@@ -6116,6 +6189,27 @@ const _sfc_main$1 = {
6116
6189
  imageResizeState.imageElement = null;
6117
6190
  imageResizeState.blockId = null;
6118
6191
  };
6192
+ const clearSelectedImage = () => {
6193
+ if (selectedImageState.element?.classList?.contains("superdoc-image-selected")) {
6194
+ selectedImageState.element.classList.remove("superdoc-image-selected");
6195
+ }
6196
+ selectedImageState.element = null;
6197
+ selectedImageState.blockId = null;
6198
+ selectedImageState.pmStart = null;
6199
+ };
6200
+ const setSelectedImage = (element, blockId, pmStart) => {
6201
+ if (selectedImageState.element && selectedImageState.element !== element) {
6202
+ selectedImageState.element.classList.remove("superdoc-image-selected");
6203
+ }
6204
+ if (element && element.classList) {
6205
+ element.classList.add("superdoc-image-selected");
6206
+ selectedImageState.element = element;
6207
+ selectedImageState.blockId = blockId ?? null;
6208
+ selectedImageState.pmStart = typeof pmStart === "number" ? pmStart : null;
6209
+ } else {
6210
+ clearSelectedImage();
6211
+ }
6212
+ };
6119
6213
  const handleOverlayUpdates = (event) => {
6120
6214
  updateTableResizeOverlay(event);
6121
6215
  updateImageResizeOverlay(event);
@@ -6206,6 +6300,7 @@ const _sfc_main$1 = {
6206
6300
  const initEditor = async ({ content, media = {}, mediaFiles = {}, fonts = {} } = {}) => {
6207
6301
  const { editorCtor, ...editorOptions } = props.options || {};
6208
6302
  const EditorCtor = editorCtor ?? Editor;
6303
+ clearSelectedImage();
6209
6304
  editor.value = new EditorCtor({
6210
6305
  mode: "docx",
6211
6306
  element: editorElem.value,
@@ -6222,17 +6317,19 @@ const _sfc_main$1 = {
6222
6317
  editor: activeEditor.value,
6223
6318
  presentationEditor: editor.value instanceof PresentationEditor ? editor.value : null
6224
6319
  });
6225
- editor.value.on("paginationUpdate", () => {
6226
- const base = activeEditor.value;
6227
- if (isHeadless(base)) return;
6228
- const paginationTarget = editor.value?.editor ? { value: base } : editor;
6229
- adjustPaginationBreaks(editorElem, paginationTarget);
6230
- });
6231
6320
  if (editor.value instanceof PresentationEditor) {
6232
- editor.value.on("layoutUpdated", () => {
6321
+ const presentationEditor = editor.value;
6322
+ presentationEditor.on("imageSelected", ({ element, blockId, pmStart }) => {
6323
+ setSelectedImage(element, blockId ?? null, pmStart);
6324
+ });
6325
+ presentationEditor.on("imageDeselected", () => {
6326
+ clearSelectedImage();
6327
+ });
6328
+ presentationEditor.on("layoutUpdated", () => {
6233
6329
  if (imageResizeState.visible && imageResizeState.blockId) {
6330
+ const escapedBlockId = CSS.escape(imageResizeState.blockId);
6234
6331
  const newElement = editorElem.value?.querySelector(
6235
- `.superdoc-image-fragment[data-sd-block-id="${imageResizeState.blockId}"]`
6332
+ `.superdoc-image-fragment[data-sd-block-id="${escapedBlockId}"]`
6236
6333
  );
6237
6334
  if (newElement) {
6238
6335
  imageResizeState.imageElement = newElement;
@@ -6242,8 +6339,33 @@ const _sfc_main$1 = {
6242
6339
  imageResizeState.blockId = null;
6243
6340
  }
6244
6341
  }
6342
+ if (selectedImageState.blockId) {
6343
+ const escapedBlockId = CSS.escape(selectedImageState.blockId);
6344
+ const refreshed = editorElem.value?.querySelector(
6345
+ `.superdoc-image-fragment[data-sd-block-id="${escapedBlockId}"]`
6346
+ );
6347
+ if (refreshed) {
6348
+ setSelectedImage(refreshed, selectedImageState.blockId, selectedImageState.pmStart);
6349
+ } else {
6350
+ if (selectedImageState.pmStart != null) {
6351
+ const pmSelector = `.superdoc-image-fragment[data-pm-start="${selectedImageState.pmStart}"], .superdoc-inline-image[data-pm-start="${selectedImageState.pmStart}"]`;
6352
+ const pmElement = editorElem.value?.querySelector(pmSelector);
6353
+ if (pmElement) {
6354
+ setSelectedImage(pmElement, selectedImageState.blockId, selectedImageState.pmStart);
6355
+ return;
6356
+ }
6357
+ }
6358
+ clearSelectedImage();
6359
+ }
6360
+ }
6245
6361
  });
6246
6362
  }
6363
+ editor.value.on("paginationUpdate", () => {
6364
+ const base = activeEditor.value;
6365
+ if (isHeadless(base)) return;
6366
+ const paginationTarget = editor.value?.editor ? { value: base } : editor;
6367
+ adjustPaginationBreaks(editorElem, paginationTarget);
6368
+ });
6247
6369
  editor.value.on("collaborationReady", () => {
6248
6370
  setTimeout(() => {
6249
6371
  editorReady.value = true;
@@ -6310,6 +6432,7 @@ const _sfc_main$1 = {
6310
6432
  };
6311
6433
  onBeforeUnmount(() => {
6312
6434
  stopPolling();
6435
+ clearSelectedImage();
6313
6436
  editor.value?.destroy();
6314
6437
  editor.value = null;
6315
6438
  });
@@ -6424,8 +6547,8 @@ const _sfc_main$1 = {
6424
6547
  ]);
6425
6548
  };
6426
6549
  }
6427
- };
6428
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-6cfd3305"]]);
6550
+ });
6551
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-a935d3e2"]]);
6429
6552
  const _hoisted_1 = ["innerHTML"];
6430
6553
  const _sfc_main = {
6431
6554
  __name: "SuperInput",
@@ -1,6 +1,6 @@
1
1
  import "vue";
2
- import { T } from "./chunks/toolbar-CKT2hVa-.js";
3
- import "./chunks/editor-Udi34-u-.js";
2
+ import { T } from "./chunks/toolbar-MtmAPa0Z.js";
3
+ import "./chunks/editor-H7c-XUpw.js";
4
4
  export {
5
5
  T as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-CqPIzvls.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-Uiy2hAKb.cjs");
4
4
  require("./chunks/vue-jWLMl8Ts.cjs");
5
5
  exports.AIWriter = superEditor_es.AIWriter;
6
6
  exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
@@ -1,4 +1,4 @@
1
- import { A, a, _, C, D, E, b, P, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-Bk7tbTHB.es.js";
1
+ import { A, a, _, C, D, E, b, P, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-CQM3jM5n.es.js";
2
2
  import "./chunks/vue-Dysv_7z5.es.js";
3
3
  export {
4
4
  A as AIWriter,
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-CqPIzvls.cjs");
4
- const superdoc = require("./chunks/index-CEh5e5Sy.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-Uiy2hAKb.cjs");
4
+ const superdoc = require("./chunks/index-DdrGP1Py.cjs");
5
5
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
6
6
  exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
7
7
  exports.Editor = superEditor_es.Editor;
@@ -1,5 +1,5 @@
1
- import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-Bk7tbTHB.es.js";
2
- import { D, H, P, S as S2, m, l } from "./chunks/index-tgFI32Kk.es.js";
1
+ import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-CQM3jM5n.es.js";
2
+ import { D, H, P, S as S2, m, l } from "./chunks/index-DvGFHOzb.es.js";
3
3
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
4
4
  export {
5
5
  a as AnnotatorHelpers,