@harbour-enterprises/superdoc 1.3.0-next.8 → 1.3.0

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,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-DoZiv8EQ.es.js";
2
- import "./SuperConverter-DwLhA2mM.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-BEA-hKnM.es.js";
2
+ import "./SuperConverter-z20LprsX.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";
@@ -5478,6 +5478,9 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5478
5478
  const handleEditorLocationsUpdate = (allCommentPositions) => {
5479
5479
  editorCommentPositions.value = allCommentPositions || {};
5480
5480
  };
5481
+ const clearEditorCommentPositions = () => {
5482
+ editorCommentPositions.value = {};
5483
+ };
5481
5484
  const getFloatingComments = computed(() => {
5482
5485
  const comments = getGroupedComments.value?.parentComments.filter((c2) => !c2.resolvedTime).filter((c2) => {
5483
5486
  const keys = Object.keys(editorCommentPositions.value);
@@ -5580,6 +5583,7 @@ const useCommentsStore = /* @__PURE__ */ defineStore("comments", () => {
5580
5583
  processLoadedDocxComments,
5581
5584
  translateCommentsForExport,
5582
5585
  handleEditorLocationsUpdate,
5586
+ clearEditorCommentPositions,
5583
5587
  handleTrackedChangeUpdate
5584
5588
  };
5585
5589
  });
@@ -7444,7 +7448,7 @@ const _sfc_main = {
7444
7448
  __name: "SuperDoc",
7445
7449
  emits: ["selection-update"],
7446
7450
  setup(__props, { emit: __emit }) {
7447
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CjwO2nPe.es.js"));
7451
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DfR5FJ1X.es.js"));
7448
7452
  const superdocStore = useSuperdocStore();
7449
7453
  const commentsStore = useCommentsStore();
7450
7454
  const {
@@ -7485,6 +7489,7 @@ const _sfc_main = {
7485
7489
  commentsStore.proxy = proxy;
7486
7490
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7487
7491
  const { uiFontFamily } = useUiFontFamily();
7492
+ const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7488
7493
  const commentsModuleConfig = computed(() => {
7489
7494
  const config = modules.comments;
7490
7495
  if (config === false || config == null) return null;
@@ -7579,6 +7584,10 @@ const _sfc_main = {
7579
7584
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7580
7585
  if (!commentsConfig || commentsConfig === false) return;
7581
7586
  if (!positions || Object.keys(positions).length === 0) return;
7587
+ if (isViewingMode()) {
7588
+ commentsStore.clearEditorCommentPositions?.();
7589
+ return;
7590
+ }
7582
7591
  const mappedPositions = presentationEditor.getCommentBounds(positions, layers.value);
7583
7592
  handleEditorLocationsUpdate(mappedPositions);
7584
7593
  });
@@ -7598,6 +7607,13 @@ const _sfc_main = {
7598
7607
  const onEditorSelectionChange = ({ editor, transaction }) => {
7599
7608
  if (skipSelectionUpdate.value) {
7600
7609
  skipSelectionUpdate.value = false;
7610
+ if (isViewingMode()) {
7611
+ resetSelection();
7612
+ }
7613
+ return;
7614
+ }
7615
+ if (isViewingMode()) {
7616
+ resetSelection();
7601
7617
  return;
7602
7618
  }
7603
7619
  const { documentId } = editor.options;
@@ -7776,6 +7792,10 @@ const _sfc_main = {
7776
7792
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7777
7793
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7778
7794
  if (!commentsConfig || commentsConfig === false) return;
7795
+ if (isViewingMode()) {
7796
+ commentsStore.clearEditorCommentPositions?.();
7797
+ return;
7798
+ }
7779
7799
  const presentation = PresentationEditor.getInstance(doc.id);
7780
7800
  if (!presentation) {
7781
7801
  handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
@@ -7831,11 +7851,12 @@ const _sfc_main = {
7831
7851
  };
7832
7852
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
7833
7853
  const showCommentsSidebar = computed(() => {
7854
+ if (isViewingMode()) return false;
7834
7855
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7835
7856
  });
7836
7857
  const showToolsFloatingMenu = computed(() => {
7837
7858
  if (!isCommentsEnabled.value) return false;
7838
- return toolsMenuPosition.top && !getConfig.value?.readOnly;
7859
+ return selectionPosition.value && toolsMenuPosition.top && !getConfig.value?.readOnly;
7839
7860
  });
7840
7861
  computed(() => {
7841
7862
  if (!isCommentsEnabled.value) return false;
@@ -7883,6 +7904,10 @@ const _sfc_main = {
7883
7904
  return style2;
7884
7905
  });
7885
7906
  const handleSelectionChange = (selection) => {
7907
+ if (isViewingMode()) {
7908
+ resetSelection();
7909
+ return;
7910
+ }
7886
7911
  if (!selection.selectionBounds || !isCommentsEnabled.value) return;
7887
7912
  resetSelection();
7888
7913
  const isMobileView = window.matchMedia("(max-width: 768px)").matches;
@@ -7908,12 +7933,14 @@ const _sfc_main = {
7908
7933
  };
7909
7934
  const resetSelection = () => {
7910
7935
  selectionPosition.value = null;
7936
+ toolsMenuPosition.top = null;
7911
7937
  };
7912
7938
  const updateSelection = ({ startX, startY, x, y, source }) => {
7913
7939
  const hasStartCoords = typeof startX === "number" || typeof startY === "number";
7914
7940
  const hasEndCoords = typeof x === "number" || typeof y === "number";
7915
7941
  if (!hasStartCoords && !hasEndCoords) {
7916
- return selectionPosition.value = null;
7942
+ resetSelection();
7943
+ return;
7917
7944
  }
7918
7945
  if (!selectionPosition.value) {
7919
7946
  if (startY == null || startX == null) return;
@@ -8166,7 +8193,7 @@ const _sfc_main = {
8166
8193
  };
8167
8194
  }
8168
8195
  };
8169
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1e96f708"]]);
8196
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8170
8197
  const createSuperdocVueApp = () => {
8171
8198
  const app = createApp(App);
8172
8199
  const pinia = createPinia();
@@ -8350,7 +8377,7 @@ class SuperDoc extends EventEmitter {
8350
8377
  this.config.colors = shuffleArray(this.config.colors);
8351
8378
  this.userColorMap = /* @__PURE__ */ new Map();
8352
8379
  this.colorIndex = 0;
8353
- this.version = "1.3.0-next.8";
8380
+ this.version = "1.3.0";
8354
8381
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8355
8382
  this.superdocId = config.superdocId || v4();
8356
8383
  this.colors = this.config.colors;
@@ -8867,7 +8894,8 @@ class SuperDoc extends EventEmitter {
8867
8894
  }
8868
8895
  #setModeViewing() {
8869
8896
  this.toolbar.activeEditor = null;
8870
- this.setTrackedChangesPreferences({ mode: "original", enabled: false });
8897
+ this.setTrackedChangesPreferences({ mode: "original", enabled: true });
8898
+ this.commentsStore?.clearEditorCommentPositions?.();
8871
8899
  this.superdocStore.documents.forEach((doc) => {
8872
8900
  doc.removeComments();
8873
8901
  this.#applyDocumentMode(doc, "viewing");