@harbour-enterprises/superdoc 1.3.0-next.12 → 1.3.0-next.14

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-BauKfBRr.cjs");
4
+ const superEditor_converter = require("./SuperConverter-kUELrLda.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15451,7 +15451,7 @@ const canUseDOM = () => {
15451
15451
  return false;
15452
15452
  }
15453
15453
  };
15454
- const summaryVersion = "1.3.0-next.12";
15454
+ const summaryVersion = "1.3.0-next.14";
15455
15455
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15456
15456
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15457
15457
  function mapAttributes(attrs) {
@@ -18083,7 +18083,7 @@ class Editor extends EventEmitter {
18083
18083
  * Process collaboration migrations
18084
18084
  */
18085
18085
  processCollaborationMigrations() {
18086
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.12");
18086
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.14");
18087
18087
  if (!this.options.ydoc) return;
18088
18088
  const metaMap = this.options.ydoc.getMap("meta");
18089
18089
  let docVersion = metaMap.get("version");
@@ -48742,10 +48742,13 @@ async function measureParagraphBlock(block, maxWidth) {
48742
48742
  };
48743
48743
  }
48744
48744
  const originX = currentLine.width;
48745
- const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
48745
+ const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
48746
+ const absCurrentX = currentLine.width + effectiveIndent;
48747
+ const { target, nextIndex, stop } = getNextTabStopPx(absCurrentX, tabStops, tabStopCursor);
48746
48748
  tabStopCursor = nextIndex;
48747
- const clampedTarget = Math.min(target, currentLine.maxWidth);
48748
- const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
48749
+ const maxAbsWidth = currentLine.maxWidth + effectiveIndent;
48750
+ const clampedTarget = Math.min(target, maxAbsWidth);
48751
+ const tabAdvance = Math.max(0, clampedTarget - absCurrentX);
48749
48752
  currentLine.width = roundValue(currentLine.width + tabAdvance);
48750
48753
  run.width = tabAdvance;
48751
48754
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
@@ -48753,8 +48756,9 @@ async function measureParagraphBlock(block, maxWidth) {
48753
48756
  currentLine.toChar = 1;
48754
48757
  if (stop && stop.leader && stop.leader !== "none") {
48755
48758
  const leaderStyle = stop.leader;
48756
- const from3 = Math.min(originX, clampedTarget);
48757
- const to = Math.max(originX, clampedTarget);
48759
+ const relativeTarget = clampedTarget - effectiveIndent;
48760
+ const from3 = Math.min(originX, relativeTarget);
48761
+ const to = Math.max(originX, relativeTarget);
48758
48762
  if (!currentLine.leaders) currentLine.leaders = [];
48759
48763
  currentLine.leaders.push({ from: from3, to, style: leaderStyle });
48760
48764
  }
@@ -48763,27 +48767,28 @@ async function measureParagraphBlock(block, maxWidth) {
48763
48767
  if (stop.val === "end" || stop.val === "center" || stop.val === "decimal") {
48764
48768
  const groupMeasure = measureTabAlignmentGroup(runIndex + 1, runsToProcess, ctx2, decimalSeparator);
48765
48769
  if (groupMeasure.totalWidth > 0) {
48770
+ const relativeTarget = clampedTarget - effectiveIndent;
48766
48771
  let groupStartX;
48767
48772
  if (stop.val === "end") {
48768
- groupStartX = Math.max(0, clampedTarget - groupMeasure.totalWidth);
48773
+ groupStartX = Math.max(0, relativeTarget - groupMeasure.totalWidth);
48769
48774
  } else if (stop.val === "center") {
48770
- groupStartX = Math.max(0, clampedTarget - groupMeasure.totalWidth / 2);
48775
+ groupStartX = Math.max(0, relativeTarget - groupMeasure.totalWidth / 2);
48771
48776
  } else {
48772
48777
  const beforeDecimal = groupMeasure.beforeDecimalWidth ?? groupMeasure.totalWidth;
48773
- groupStartX = Math.max(0, clampedTarget - beforeDecimal);
48778
+ groupStartX = Math.max(0, relativeTarget - beforeDecimal);
48774
48779
  }
48775
48780
  activeTabGroup = {
48776
48781
  measure: groupMeasure,
48777
48782
  startX: groupStartX,
48778
48783
  currentX: groupStartX,
48779
- target: clampedTarget,
48784
+ target: relativeTarget,
48780
48785
  val: stop.val
48781
48786
  };
48782
48787
  currentLine.width = roundValue(groupStartX);
48783
48788
  }
48784
48789
  pendingTabAlignment = null;
48785
48790
  } else {
48786
- pendingTabAlignment = { target: clampedTarget, val: stop.val };
48791
+ pendingTabAlignment = { target: clampedTarget - effectiveIndent, val: stop.val };
48787
48792
  }
48788
48793
  } else {
48789
48794
  pendingTabAlignment = null;
@@ -49424,10 +49429,13 @@ async function measureParagraphBlock(block, maxWidth) {
49424
49429
  };
49425
49430
  }
49426
49431
  const originX = currentLine.width;
49427
- const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
49432
+ const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
49433
+ const absCurrentX = currentLine.width + effectiveIndent;
49434
+ const { target, nextIndex, stop } = getNextTabStopPx(absCurrentX, tabStops, tabStopCursor);
49428
49435
  tabStopCursor = nextIndex;
49429
- const clampedTarget = Math.min(target, currentLine.maxWidth);
49430
- const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
49436
+ const maxAbsWidth = currentLine.maxWidth + effectiveIndent;
49437
+ const clampedTarget = Math.min(target, maxAbsWidth);
49438
+ const tabAdvance = Math.max(0, clampedTarget - absCurrentX);
49431
49439
  currentLine.width = roundValue(currentLine.width + tabAdvance);
49432
49440
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
49433
49441
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
@@ -49436,14 +49444,15 @@ async function measureParagraphBlock(block, maxWidth) {
49436
49444
  charPosInRun += 1;
49437
49445
  if (stop) {
49438
49446
  validateTabStopVal(stop);
49439
- pendingTabAlignment = { target: clampedTarget, val: stop.val };
49447
+ pendingTabAlignment = { target: clampedTarget - effectiveIndent, val: stop.val };
49440
49448
  } else {
49441
49449
  pendingTabAlignment = null;
49442
49450
  }
49443
49451
  if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
49444
49452
  const leaderStyle = stop.leader;
49445
- const from3 = Math.min(originX, clampedTarget);
49446
- const to = Math.max(originX, clampedTarget);
49453
+ const relativeTarget = clampedTarget - effectiveIndent;
49454
+ const from3 = Math.min(originX, relativeTarget);
49455
+ const to = Math.max(originX, relativeTarget);
49447
49456
  if (!currentLine.leaders) currentLine.leaders = [];
49448
49457
  currentLine.leaders.push({ from: from3, to, style: leaderStyle });
49449
49458
  }
@@ -54844,7 +54853,7 @@ class PresentationEditor extends EventEmitter {
54844
54853
  const zoom = this.#layoutOptions.zoom ?? 1;
54845
54854
  const layoutMode = this.#layoutOptions.layoutMode ?? "vertical";
54846
54855
  const pages = this.#layoutState.layout?.pages;
54847
- const pageGap = this.#layoutState.layout?.pageGap ?? this.#getEffectivePageGap();
54856
+ const pageGap = this.#getEffectivePageGap();
54848
54857
  const defaultWidth = this.#layoutOptions.pageSize?.w ?? DEFAULT_PAGE_SIZE.w;
54849
54858
  const defaultHeight = this.#layoutOptions.pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
54850
54859
  let maxWidth = defaultWidth;
@@ -58613,12 +58622,18 @@ function findParagraphContext($pos, cache2, helpers2) {
58613
58622
  return null;
58614
58623
  }
58615
58624
  function extractParagraphContext(node, startPos, helpers2, depth = 0) {
58616
- const paragraphProperties = superEditor_converter.getResolvedParagraphProperties(node) ?? {};
58625
+ const paragraphProperties = superEditor_converter.getResolvedParagraphProperties(node) ?? node.attrs?.paragraphProperties ?? {};
58617
58626
  const alignmentAliases = { left: "start", right: "end" };
58618
58627
  let tabStops = [];
58619
58628
  if (Array.isArray(paragraphProperties.tabStops)) {
58620
58629
  tabStops = paragraphProperties.tabStops.map((stop) => {
58621
58630
  const ref = stop?.tab;
58631
+ if (!ref && stop?.pos != null) {
58632
+ return {
58633
+ ...stop,
58634
+ pos: twipsToPixels(Number(stop.pos) || 0)
58635
+ };
58636
+ }
58622
58637
  if (!ref) return stop || null;
58623
58638
  const rawType = ref.tabType || "start";
58624
58639
  const mappedVal = alignmentAliases[rawType] || rawType;
@@ -59884,6 +59899,13 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
59884
59899
  pos: entry.pos,
59885
59900
  nodeSize: node.nodeSize
59886
59901
  });
59902
+ } else if (node.type.name === "lineBreak" || node.type.name === "hardBreak") {
59903
+ spans.push({
59904
+ type: node.type.name,
59905
+ spanId,
59906
+ pos: entry.pos,
59907
+ nodeSize: node.nodeSize
59908
+ });
59887
59909
  } else if (node.type.name === "text") {
59888
59910
  spans.push({
59889
59911
  type: "text",
@@ -59933,6 +59955,7 @@ function calculateTabLayout(request, measurement, view) {
59933
59955
  paragraphNode
59934
59956
  } = request;
59935
59957
  const tabs = {};
59958
+ const leftIndentPx = request.indents?.left ?? 0;
59936
59959
  let currentX = indentWidth;
59937
59960
  const measureText2 = (span) => {
59938
59961
  if (view && typeof span.from === "number" && typeof span.to === "number") {
@@ -59945,6 +59968,8 @@ function calculateTabLayout(request, measurement, view) {
59945
59968
  const span = spans[i];
59946
59969
  if (span.type === "text") {
59947
59970
  currentX += measureText2(span);
59971
+ } else if (span.type === "lineBreak" || span.type === "hardBreak") {
59972
+ currentX = leftIndentPx;
59948
59973
  } else if (span.type === "tab") {
59949
59974
  const followingText = collectFollowingText(spans, i + 1);
59950
59975
  let measureTextCallback;
@@ -60040,7 +60065,7 @@ function collectFollowingText(spans, startIndex) {
60040
60065
  let text = "";
60041
60066
  for (let i = startIndex; i < spans.length; i++) {
60042
60067
  const span = spans[i];
60043
- if (span.type === "tab") break;
60068
+ if (span.type === "tab" || span.type === "lineBreak" || span.type === "hardBreak") break;
60044
60069
  if (span.type === "text") text += span.text || "";
60045
60070
  }
60046
60071
  return text;
@@ -60050,7 +60075,7 @@ function getFollowingTextRange(spans, startIndex) {
60050
60075
  let to = null;
60051
60076
  for (let i = startIndex; i < spans.length; i++) {
60052
60077
  const span = spans[i];
60053
- if (span.type === "tab") break;
60078
+ if (span.type === "tab" || span.type === "lineBreak" || span.type === "hardBreak") break;
60054
60079
  if (span.type === "text" && typeof span.from === "number" && typeof span.to === "number") {
60055
60080
  if (from3 === null) from3 = span.from;
60056
60081
  to = span.to;
@@ -79004,7 +79029,7 @@ var ResizeObserverController = (function() {
79004
79029
  };
79005
79030
  return ResizeObserverController2;
79006
79031
  })();
79007
- var ResizeObserver = (function() {
79032
+ var ResizeObserver$1 = (function() {
79008
79033
  function ResizeObserver2(callback) {
79009
79034
  if (arguments.length === 0) {
79010
79035
  throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
@@ -79043,7 +79068,7 @@ var ResizeObserver = (function() {
79043
79068
  class ResizeObserverDelegate {
79044
79069
  constructor() {
79045
79070
  this.handleResize = this.handleResize.bind(this);
79046
- this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver)(this.handleResize);
79071
+ this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver$1)(this.handleResize);
79047
79072
  this.elHandlersMap = /* @__PURE__ */ new Map();
79048
79073
  }
79049
79074
  handleResize(entries) {
@@ -89912,6 +89937,31 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
89912
89937
  },
89913
89938
  { immediate: true, deep: true }
89914
89939
  );
89940
+ vue.watch(
89941
+ () => props.options?.rulerContainer,
89942
+ () => {
89943
+ vue.nextTick(() => {
89944
+ syncRulerOffset();
89945
+ setupRulerObservers();
89946
+ });
89947
+ },
89948
+ { immediate: true }
89949
+ );
89950
+ vue.watch(
89951
+ rulersVisible,
89952
+ (visible) => {
89953
+ vue.nextTick(() => {
89954
+ if (visible) {
89955
+ syncRulerOffset();
89956
+ setupRulerObservers();
89957
+ } else {
89958
+ rulerHostStyle.value = {};
89959
+ cleanupRulerObservers();
89960
+ }
89961
+ });
89962
+ },
89963
+ { immediate: true }
89964
+ );
89915
89965
  const containerStyle = vue.computed(() => {
89916
89966
  let maxWidth = 8.5 * 96;
89917
89967
  const ed = editor.value;
@@ -89936,6 +89986,71 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
89936
89986
  minWidth: `${scaledWidth}px`
89937
89987
  };
89938
89988
  });
89989
+ const rulerHostStyle = vue.ref({});
89990
+ const rulerContainerEl = vue.ref(null);
89991
+ let editorResizeObserver = null;
89992
+ let rulerContainerResizeObserver = null;
89993
+ let layoutUpdatedHandler = null;
89994
+ const resolveRulerContainer = () => {
89995
+ const container = props.options?.rulerContainer;
89996
+ if (!container) return null;
89997
+ if (typeof container === "string") {
89998
+ const doc2 = editorWrapper.value?.ownerDocument ?? document;
89999
+ return doc2.querySelector(container);
90000
+ }
90001
+ return container instanceof HTMLElement ? container : null;
90002
+ };
90003
+ const getViewportRect2 = () => {
90004
+ const host = editorWrapper.value;
90005
+ if (!host) return null;
90006
+ const viewport2 = host.querySelector(".presentation-editor__viewport");
90007
+ const target = viewport2 ?? host;
90008
+ return target.getBoundingClientRect();
90009
+ };
90010
+ const syncRulerOffset = () => {
90011
+ if (!rulersVisible.value) {
90012
+ rulerHostStyle.value = {};
90013
+ return;
90014
+ }
90015
+ rulerContainerEl.value = resolveRulerContainer();
90016
+ if (!rulerContainerEl.value) {
90017
+ rulerHostStyle.value = {};
90018
+ return;
90019
+ }
90020
+ const viewportRect = getViewportRect2();
90021
+ if (!viewportRect) return;
90022
+ const hostRect = rulerContainerEl.value.getBoundingClientRect();
90023
+ const paddingLeft = Math.max(0, viewportRect.left - hostRect.left);
90024
+ const paddingRight = Math.max(0, hostRect.right - viewportRect.right);
90025
+ rulerHostStyle.value = {
90026
+ paddingLeft: `${paddingLeft}px`,
90027
+ paddingRight: `${paddingRight}px`
90028
+ };
90029
+ };
90030
+ const cleanupRulerObservers = () => {
90031
+ if (editorResizeObserver) {
90032
+ editorResizeObserver.disconnect();
90033
+ editorResizeObserver = null;
90034
+ }
90035
+ if (rulerContainerResizeObserver) {
90036
+ rulerContainerResizeObserver.disconnect();
90037
+ rulerContainerResizeObserver = null;
90038
+ }
90039
+ };
90040
+ const setupRulerObservers = () => {
90041
+ cleanupRulerObservers();
90042
+ if (typeof ResizeObserver === "undefined") return;
90043
+ const viewportHost = editorWrapper.value;
90044
+ const rulerHost = resolveRulerContainer();
90045
+ if (viewportHost) {
90046
+ editorResizeObserver = new ResizeObserver(() => syncRulerOffset());
90047
+ editorResizeObserver.observe(viewportHost);
90048
+ }
90049
+ if (rulerHost) {
90050
+ rulerContainerResizeObserver = new ResizeObserver(() => syncRulerOffset());
90051
+ rulerContainerResizeObserver.observe(rulerHost);
90052
+ }
90053
+ };
89939
90054
  const message = useMessage();
89940
90055
  const editorWrapper = vue.ref(null);
89941
90056
  const editorElem = vue.ref(null);
@@ -90247,7 +90362,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90247
90362
  presentationEditor.on("imageDeselected", () => {
90248
90363
  clearSelectedImage();
90249
90364
  });
90250
- presentationEditor.on("layoutUpdated", () => {
90365
+ layoutUpdatedHandler = () => {
90251
90366
  if (imageResizeState.visible && imageResizeState.blockId) {
90252
90367
  const escapedBlockId = CSS.escape(imageResizeState.blockId);
90253
90368
  const newElement = editorElem.value?.querySelector(
@@ -90280,13 +90395,17 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90280
90395
  clearSelectedImage();
90281
90396
  }
90282
90397
  }
90283
- });
90398
+ vue.nextTick(() => syncRulerOffset());
90399
+ };
90400
+ presentationEditor.on("layoutUpdated", layoutUpdatedHandler);
90284
90401
  zoomChangeHandler = ({ zoom }) => {
90285
90402
  currentZoom.value = zoom;
90403
+ vue.nextTick(() => syncRulerOffset());
90286
90404
  };
90287
90405
  presentationEditor.on("zoomChange", zoomChangeHandler);
90288
90406
  if (typeof presentationEditor.zoom === "number") {
90289
90407
  currentZoom.value = presentationEditor.zoom;
90408
+ vue.nextTick(() => syncRulerOffset());
90290
90409
  }
90291
90410
  }
90292
90411
  editor.value.on("paginationUpdate", () => {
@@ -90346,6 +90465,11 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90346
90465
  vue.onMounted(() => {
90347
90466
  initializeData();
90348
90467
  if (props.options?.suppressSkeletonLoader || !props.options?.collaborationProvider) editorReady.value = true;
90468
+ window.addEventListener("resize", syncRulerOffset, { passive: true });
90469
+ vue.nextTick(() => {
90470
+ syncRulerOffset();
90471
+ setupRulerObservers();
90472
+ });
90349
90473
  });
90350
90474
  const handleMarginClick = (event) => {
90351
90475
  if (event.button !== 0) {
@@ -90376,6 +90500,12 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90376
90500
  editor.value.off("zoomChange", zoomChangeHandler);
90377
90501
  zoomChangeHandler = null;
90378
90502
  }
90503
+ if (editor.value instanceof PresentationEditor && layoutUpdatedHandler) {
90504
+ editor.value.off("layoutUpdated", layoutUpdatedHandler);
90505
+ layoutUpdatedHandler = null;
90506
+ }
90507
+ cleanupRulerObservers();
90508
+ window.removeEventListener("resize", syncRulerOffset);
90379
90509
  editor.value?.destroy();
90380
90510
  editor.value = null;
90381
90511
  });
@@ -90387,18 +90517,28 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90387
90517
  __props.options.rulerContainer && rulersVisible.value && !!activeEditor.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
90388
90518
  key: 0,
90389
90519
  to: __props.options.rulerContainer
90520
+ }, [
90521
+ vue.createBaseVNode("div", {
90522
+ class: "ruler-host",
90523
+ style: vue.normalizeStyle(rulerHostStyle.value)
90524
+ }, [
90525
+ vue.createVNode(Ruler, {
90526
+ class: "ruler superdoc-ruler",
90527
+ editor: activeEditor.value,
90528
+ onMarginChange: handleMarginChange
90529
+ }, null, 8, ["editor"])
90530
+ ], 4)
90531
+ ], 8, ["to"])) : rulersVisible.value && !!activeEditor.value ? (vue.openBlock(), vue.createElementBlock("div", {
90532
+ key: 1,
90533
+ class: "ruler-host",
90534
+ style: vue.normalizeStyle(rulerHostStyle.value)
90390
90535
  }, [
90391
90536
  vue.createVNode(Ruler, {
90392
- class: "ruler superdoc-ruler",
90537
+ class: "ruler",
90393
90538
  editor: activeEditor.value,
90394
90539
  onMarginChange: handleMarginChange
90395
90540
  }, null, 8, ["editor"])
90396
- ], 8, ["to"])) : rulersVisible.value && !!activeEditor.value ? (vue.openBlock(), vue.createBlock(Ruler, {
90397
- key: 1,
90398
- class: "ruler",
90399
- editor: activeEditor.value,
90400
- onMarginChange: handleMarginChange
90401
- }, null, 8, ["editor"])) : vue.createCommentVNode("", true),
90541
+ ], 4)) : vue.createCommentVNode("", true),
90402
90542
  vue.createBaseVNode("div", {
90403
90543
  class: "super-editor",
90404
90544
  ref_key: "editorWrapper",
@@ -90503,7 +90643,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90503
90643
  };
90504
90644
  }
90505
90645
  });
90506
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-3e9da07c"]]);
90646
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-f5c4f915"]]);
90507
90647
  const _hoisted_1 = ["innerHTML"];
90508
90648
  const _sfc_main = {
90509
90649
  __name: "SuperInput",
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-BRomAwaA.es.js";
2
- import "./SuperConverter-BQHQ2WON.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-B1GscRFR.es.js";
2
+ import "./SuperConverter-CD9khdbr.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -7448,7 +7448,7 @@ const _sfc_main = {
7448
7448
  __name: "SuperDoc",
7449
7449
  emits: ["selection-update"],
7450
7450
  setup(__props, { emit: __emit }) {
7451
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-D4-tXW9I.es.js"));
7451
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CMc0iPaz.es.js"));
7452
7452
  const superdocStore = useSuperdocStore();
7453
7453
  const commentsStore = useCommentsStore();
7454
7454
  const {
@@ -7489,6 +7489,7 @@ const _sfc_main = {
7489
7489
  commentsStore.proxy = proxy;
7490
7490
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7491
7491
  const { uiFontFamily } = useUiFontFamily();
7492
+ const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7492
7493
  const commentsModuleConfig = computed(() => {
7493
7494
  const config = modules.comments;
7494
7495
  if (config === false || config == null) return null;
@@ -7583,6 +7584,10 @@ const _sfc_main = {
7583
7584
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7584
7585
  if (!commentsConfig || commentsConfig === false) return;
7585
7586
  if (!positions || Object.keys(positions).length === 0) return;
7587
+ if (isViewingMode()) {
7588
+ commentsStore.clearEditorCommentPositions?.();
7589
+ return;
7590
+ }
7586
7591
  const mappedPositions = presentationEditor.getCommentBounds(positions, layers.value);
7587
7592
  handleEditorLocationsUpdate(mappedPositions);
7588
7593
  });
@@ -7602,6 +7607,13 @@ const _sfc_main = {
7602
7607
  const onEditorSelectionChange = ({ editor, transaction }) => {
7603
7608
  if (skipSelectionUpdate.value) {
7604
7609
  skipSelectionUpdate.value = false;
7610
+ if (isViewingMode()) {
7611
+ resetSelection();
7612
+ }
7613
+ return;
7614
+ }
7615
+ if (isViewingMode()) {
7616
+ resetSelection();
7605
7617
  return;
7606
7618
  }
7607
7619
  const { documentId } = editor.options;
@@ -7780,6 +7792,10 @@ const _sfc_main = {
7780
7792
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7781
7793
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7782
7794
  if (!commentsConfig || commentsConfig === false) return;
7795
+ if (isViewingMode()) {
7796
+ commentsStore.clearEditorCommentPositions?.();
7797
+ return;
7798
+ }
7783
7799
  const presentation = PresentationEditor.getInstance(doc.id);
7784
7800
  if (!presentation) {
7785
7801
  handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
@@ -7835,11 +7851,12 @@ const _sfc_main = {
7835
7851
  };
7836
7852
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
7837
7853
  const showCommentsSidebar = computed(() => {
7854
+ if (isViewingMode()) return false;
7838
7855
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7839
7856
  });
7840
7857
  const showToolsFloatingMenu = computed(() => {
7841
7858
  if (!isCommentsEnabled.value) return false;
7842
- return toolsMenuPosition.top && !getConfig.value?.readOnly;
7859
+ return selectionPosition.value && toolsMenuPosition.top && !getConfig.value?.readOnly;
7843
7860
  });
7844
7861
  computed(() => {
7845
7862
  if (!isCommentsEnabled.value) return false;
@@ -7887,6 +7904,10 @@ const _sfc_main = {
7887
7904
  return style2;
7888
7905
  });
7889
7906
  const handleSelectionChange = (selection) => {
7907
+ if (isViewingMode()) {
7908
+ resetSelection();
7909
+ return;
7910
+ }
7890
7911
  if (!selection.selectionBounds || !isCommentsEnabled.value) return;
7891
7912
  resetSelection();
7892
7913
  const isMobileView = window.matchMedia("(max-width: 768px)").matches;
@@ -7912,12 +7933,14 @@ const _sfc_main = {
7912
7933
  };
7913
7934
  const resetSelection = () => {
7914
7935
  selectionPosition.value = null;
7936
+ toolsMenuPosition.top = null;
7915
7937
  };
7916
7938
  const updateSelection = ({ startX, startY, x, y, source }) => {
7917
7939
  const hasStartCoords = typeof startX === "number" || typeof startY === "number";
7918
7940
  const hasEndCoords = typeof x === "number" || typeof y === "number";
7919
7941
  if (!hasStartCoords && !hasEndCoords) {
7920
- return selectionPosition.value = null;
7942
+ resetSelection();
7943
+ return;
7921
7944
  }
7922
7945
  if (!selectionPosition.value) {
7923
7946
  if (startY == null || startX == null) return;
@@ -8170,7 +8193,7 @@ const _sfc_main = {
8170
8193
  };
8171
8194
  }
8172
8195
  };
8173
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1e96f708"]]);
8196
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8174
8197
  const createSuperdocVueApp = () => {
8175
8198
  const app = createApp(App);
8176
8199
  const pinia = createPinia();
@@ -8354,7 +8377,7 @@ class SuperDoc extends EventEmitter {
8354
8377
  this.config.colors = shuffleArray(this.config.colors);
8355
8378
  this.userColorMap = /* @__PURE__ */ new Map();
8356
8379
  this.colorIndex = 0;
8357
- this.version = "1.3.0-next.12";
8380
+ this.version = "1.3.0-next.14";
8358
8381
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8359
8382
  this.superdocId = config.superdocId || v4();
8360
8383
  this.colors = this.config.colors;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-CCWqRqAf.cjs");
3
- require("./SuperConverter-BauKfBRr.cjs");
2
+ const index = require("./index-CyFX6QZq.cjs");
3
+ require("./SuperConverter-kUELrLda.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -7465,7 +7465,7 @@ const _sfc_main = {
7465
7465
  __name: "SuperDoc",
7466
7466
  emits: ["selection-update"],
7467
7467
  setup(__props, { emit: __emit }) {
7468
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-B4cw8sRa.cjs")));
7468
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DLGmNBgc.cjs")));
7469
7469
  const superdocStore = useSuperdocStore();
7470
7470
  const commentsStore = useCommentsStore();
7471
7471
  const {
@@ -7506,6 +7506,7 @@ const _sfc_main = {
7506
7506
  commentsStore.proxy = proxy;
7507
7507
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7508
7508
  const { uiFontFamily } = useUiFontFamily();
7509
+ const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7509
7510
  const commentsModuleConfig = vue.computed(() => {
7510
7511
  const config = modules.comments;
7511
7512
  if (config === false || config == null) return null;
@@ -7600,6 +7601,10 @@ const _sfc_main = {
7600
7601
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7601
7602
  if (!commentsConfig || commentsConfig === false) return;
7602
7603
  if (!positions || Object.keys(positions).length === 0) return;
7604
+ if (isViewingMode()) {
7605
+ commentsStore.clearEditorCommentPositions?.();
7606
+ return;
7607
+ }
7603
7608
  const mappedPositions = presentationEditor.getCommentBounds(positions, layers.value);
7604
7609
  handleEditorLocationsUpdate(mappedPositions);
7605
7610
  });
@@ -7619,6 +7624,13 @@ const _sfc_main = {
7619
7624
  const onEditorSelectionChange = ({ editor, transaction }) => {
7620
7625
  if (skipSelectionUpdate.value) {
7621
7626
  skipSelectionUpdate.value = false;
7627
+ if (isViewingMode()) {
7628
+ resetSelection();
7629
+ }
7630
+ return;
7631
+ }
7632
+ if (isViewingMode()) {
7633
+ resetSelection();
7622
7634
  return;
7623
7635
  }
7624
7636
  const { documentId } = editor.options;
@@ -7797,6 +7809,10 @@ const _sfc_main = {
7797
7809
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7798
7810
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7799
7811
  if (!commentsConfig || commentsConfig === false) return;
7812
+ if (isViewingMode()) {
7813
+ commentsStore.clearEditorCommentPositions?.();
7814
+ return;
7815
+ }
7800
7816
  const presentation = index.PresentationEditor.getInstance(doc.id);
7801
7817
  if (!presentation) {
7802
7818
  handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
@@ -7852,11 +7868,12 @@ const _sfc_main = {
7852
7868
  };
7853
7869
  const isCommentsEnabled = vue.computed(() => Boolean(commentsModuleConfig.value));
7854
7870
  const showCommentsSidebar = vue.computed(() => {
7871
+ if (isViewingMode()) return false;
7855
7872
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7856
7873
  });
7857
7874
  const showToolsFloatingMenu = vue.computed(() => {
7858
7875
  if (!isCommentsEnabled.value) return false;
7859
- return toolsMenuPosition.top && !getConfig.value?.readOnly;
7876
+ return selectionPosition.value && toolsMenuPosition.top && !getConfig.value?.readOnly;
7860
7877
  });
7861
7878
  vue.computed(() => {
7862
7879
  if (!isCommentsEnabled.value) return false;
@@ -7904,6 +7921,10 @@ const _sfc_main = {
7904
7921
  return style2;
7905
7922
  });
7906
7923
  const handleSelectionChange = (selection) => {
7924
+ if (isViewingMode()) {
7925
+ resetSelection();
7926
+ return;
7927
+ }
7907
7928
  if (!selection.selectionBounds || !isCommentsEnabled.value) return;
7908
7929
  resetSelection();
7909
7930
  const isMobileView = window.matchMedia("(max-width: 768px)").matches;
@@ -7929,12 +7950,14 @@ const _sfc_main = {
7929
7950
  };
7930
7951
  const resetSelection = () => {
7931
7952
  selectionPosition.value = null;
7953
+ toolsMenuPosition.top = null;
7932
7954
  };
7933
7955
  const updateSelection = ({ startX, startY, x, y, source }) => {
7934
7956
  const hasStartCoords = typeof startX === "number" || typeof startY === "number";
7935
7957
  const hasEndCoords = typeof x === "number" || typeof y === "number";
7936
7958
  if (!hasStartCoords && !hasEndCoords) {
7937
- return selectionPosition.value = null;
7959
+ resetSelection();
7960
+ return;
7938
7961
  }
7939
7962
  if (!selectionPosition.value) {
7940
7963
  if (startY == null || startX == null) return;
@@ -8187,7 +8210,7 @@ const _sfc_main = {
8187
8210
  };
8188
8211
  }
8189
8212
  };
8190
- const App = /* @__PURE__ */ index._export_sfc(_sfc_main, [["__scopeId", "data-v-1e96f708"]]);
8213
+ const App = /* @__PURE__ */ index._export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8191
8214
  const createSuperdocVueApp = () => {
8192
8215
  const app = vue.createApp(App);
8193
8216
  const pinia = createPinia();
@@ -8371,7 +8394,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8371
8394
  this.config.colors = shuffleArray(this.config.colors);
8372
8395
  this.userColorMap = /* @__PURE__ */ new Map();
8373
8396
  this.colorIndex = 0;
8374
- this.version = "1.3.0-next.12";
8397
+ this.version = "1.3.0-next.14";
8375
8398
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8376
8399
  this.superdocId = config.superdocId || uuid.v4();
8377
8400
  this.colors = this.config.colors;