superdoc 2.22.1-next.2 → 2.23.0-next.2

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.
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./chunks/rolldown-runtime-74VwNCz7.cjs");
3
3
  const require_blank_docx = require("./chunks/blank-docx-BuFAbRjs.cjs");
4
- const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-MSiU8Kg0.cjs");
4
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-CbiiPcgr.cjs");
5
5
  const require_eventemitter3 = require("./chunks/eventemitter3-C_TAnXOl.cjs");
6
6
  const require_uuid = require("./chunks/uuid-BhG0ngwk.cjs");
7
7
  const require__plugin_vue_export_helper = require("./chunks/_plugin-vue_export-helper-CYxINHh_.cjs");
@@ -299,24 +299,12 @@ var awarenessStatesToArray = (context, states) => {
299
299
  };
300
300
  });
301
301
  };
302
- /**
303
- * Shuffle an array of hex colors
304
- * @param array - List of hex colors
305
- * @returns Shuffled array of hex colors
306
- */
307
- var shuffleArray = (array) => {
308
- for (let i = array.length - 1; i > 0; i--) {
309
- const j = Math.floor(Math.random() * (i + 1));
310
- [array[i], array[j]] = [array[j], array[i]];
311
- }
312
- return array;
313
- };
314
302
  //#endregion
315
303
  //#region ../../shared/common/Telemetry.ts
316
304
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
317
305
  function getSuperdocVersion() {
318
306
  try {
319
- return "2.22.1-next.2";
307
+ return "2.23.0-next.2";
320
308
  } catch {
321
309
  return "unknown";
322
310
  }
@@ -7946,6 +7934,14 @@ var useCommentsStore = defineStore("comments", () => {
7946
7934
  if (!normalizedId) return null;
7947
7935
  return normalizedId.startsWith("imported:") ? normalizedId : `imported:${normalizedId}`;
7948
7936
  };
7937
+ const positionEntriesByAlias = require__plugin_vue_export_helper.computed(() => {
7938
+ const aliases = /* @__PURE__ */ new Map();
7939
+ for (const [key, entry] of Object.entries(editorCommentPositions.value || {})) for (const alias of [normalizeCommentId(entry?.key), normalizeCommentId(entry?.threadId)]) if (alias && !aliases.has(alias)) aliases.set(alias, {
7940
+ key,
7941
+ entry
7942
+ });
7943
+ return aliases;
7944
+ });
7949
7945
  const getPositionEntryByAlias = (id) => {
7950
7946
  const normalizedId = normalizeCommentId(id);
7951
7947
  if (!normalizedId) return {
@@ -7957,15 +7953,7 @@ var useCommentsStore = defineStore("comments", () => {
7957
7953
  key: normalizedId,
7958
7954
  entry: positions[normalizedId]
7959
7955
  };
7960
- for (const [key, entry] of Object.entries(positions)) {
7961
- const entryKey = normalizeCommentId(entry?.key);
7962
- const threadId = normalizeCommentId(entry?.threadId);
7963
- if (entryKey === normalizedId || threadId === normalizedId) return {
7964
- key,
7965
- entry
7966
- };
7967
- }
7968
- return {
7956
+ return positionEntriesByAlias.value.get(normalizedId) ?? {
7969
7957
  key: null,
7970
7958
  entry: null
7971
7959
  };
@@ -8014,6 +8002,41 @@ var useCommentsStore = defineStore("comments", () => {
8014
8002
  });
8015
8003
  return matches.length === 1 ? matches[0] : null;
8016
8004
  };
8005
+ const commentIdentityIndex = require__plugin_vue_export_helper.computed(() => {
8006
+ const list = commentsList.value;
8007
+ if (!require__plugin_vue_export_helper.isReactive(list)) return null;
8008
+ const primary = /* @__PURE__ */ new Map();
8009
+ const aliases = /* @__PURE__ */ new Map();
8010
+ for (const comment of list) {
8011
+ if (!require__plugin_vue_export_helper.isReactive(comment)) return null;
8012
+ for (const key of [
8013
+ "commentId",
8014
+ "importedId",
8015
+ "trackedChangeAnchorKey",
8016
+ "trackedChange"
8017
+ ]) {
8018
+ const descriptor = Object.getOwnPropertyDescriptor(comment, key);
8019
+ if (descriptor?.get || descriptor?.set || !descriptor && key in comment) return null;
8020
+ }
8021
+ const ids = [
8022
+ comment.commentId,
8023
+ comment.importedId,
8024
+ comment.trackedChangeAnchorKey
8025
+ ];
8026
+ if (ids.some((id) => id != null && typeof id !== "string")) return null;
8027
+ if (ids[0] != null && !primary.has(ids[0])) primary.set(ids[0], comment);
8028
+ const importedPositionId = comment.trackedChange ? buildTrackedChangeImportedPositionId(ids[1]) : null;
8029
+ for (const alias of [
8030
+ ids[1],
8031
+ ids[2],
8032
+ importedPositionId
8033
+ ]) if (alias != null && !aliases.has(alias)) aliases.set(alias, comment);
8034
+ }
8035
+ return {
8036
+ primary,
8037
+ aliases
8038
+ };
8039
+ });
8017
8040
  /**
8018
8041
  * Get a comment by either ID or imported ID
8019
8042
  *
@@ -8025,7 +8048,8 @@ var useCommentsStore = defineStore("comments", () => {
8025
8048
  const byPrimaryId = (c) => c.commentId == id;
8026
8049
  const byAliasId = (c) => c.importedId == id || c.trackedChangeAnchorKey == id || c?.trackedChange && buildTrackedChangeImportedPositionId(c.importedId) == id;
8027
8050
  const findIn = (list) => list.find(byPrimaryId) ?? list.find(byAliasId);
8028
- return findIn(commentsList.value) ?? findIn(reviewDirectoryList.value) ?? getTrackedChangeCommentByPositionAlias(id);
8051
+ const index = typeof id === "string" ? commentIdentityIndex.value : null;
8052
+ return (index ? index.primary.get(id) ?? index.aliases.get(id) : findIn(commentsList.value)) ?? findIn(reviewDirectoryList.value) ?? getTrackedChangeCommentByPositionAlias(id);
8029
8053
  };
8030
8054
  const getThreadParent = (comment) => {
8031
8055
  if (!comment?.parentCommentId) return comment;
@@ -12525,6 +12549,19 @@ var pickResolver = (context = {}) => {
12525
12549
  if (typeof deprecatedResolver === "function") return deprecatedResolver;
12526
12550
  return null;
12527
12551
  };
12552
+ var BUILT_IN_PERMISSION_METHOD = Symbol.for("superdoc.internal.permission-method.builtin");
12553
+ var BUILT_IN_PERMISSION_RESOLVER = Symbol.for("superdoc.internal.permission-resolver.builtin");
12554
+ /** Create the shell's internal, live tracked-change permission shim. */
12555
+ var createTrackedChangePermissionResolver = (superdoc) => {
12556
+ const isBuiltInPolicy = () => superdoc.canPerformPermission?.[BUILT_IN_PERMISSION_METHOD] === true && pickResolver({ superdoc }) === null;
12557
+ const resolver = (payload = {}) => isBuiltInPolicy() ? defaultDecisionFor(payload.permission, superdoc.config.role, superdoc.config.isInternal) : superdoc.canPerformPermission({
12558
+ ...payload,
12559
+ role: superdoc.config.role,
12560
+ isInternal: superdoc.config.isInternal
12561
+ });
12562
+ Object.defineProperty(resolver, BUILT_IN_PERMISSION_RESOLVER, { value: isBuiltInPolicy });
12563
+ return resolver;
12564
+ };
12528
12565
  var defaultDecisionFor = (permission, role, isInternal) => {
12529
12566
  const internalExternal = isInternal ? "internal" : "external";
12530
12567
  return PERMISSION_MATRIX[permission]?.[internalExternal]?.includes(role) ?? false;
@@ -23523,11 +23560,7 @@ var SuperDoc_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_v
23523
23560
  contentControlsChrome: proxy.$superdoc.uiConfig.contentControls.options.chrome,
23524
23561
  resolveTrackedChangeColor: composeAuthorColorResolver(proxy.$superdoc.config.modules?.trackChanges?.authorColors)
23525
23562
  } : void 0,
23526
- permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
23527
- role: proxy.$superdoc.config.role,
23528
- isInternal: proxy.$superdoc.config.isInternal,
23529
- ...payload
23530
- })
23563
+ permissionResolver: createTrackedChangePermissionResolver(proxy.$superdoc)
23531
23564
  };
23532
23565
  };
23533
23566
  const REPLAY_MUTABLE_COMMENT_FIELDS = /* @__PURE__ */ new Set([
@@ -24570,7 +24603,7 @@ var SuperDoc_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_v
24570
24603
  ], 38);
24571
24604
  };
24572
24605
  }
24573
- }, [["__scopeId", "data-v-99399849"]]);
24606
+ }, [["__scopeId", "data-v-3a8081b4"]]);
24574
24607
  //#endregion
24575
24608
  //#region src/core/create-app.js
24576
24609
  var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
@@ -46384,13 +46417,13 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46384
46417
  commentsBlock.allowResolve = this.#interactionConfig.comments.allowResolve;
46385
46418
  }
46386
46419
  }
46387
- this.config.colors = shuffleArray(this.config.colors);
46388
46420
  this.userColorMap = /* @__PURE__ */ new Map();
46389
46421
  this.colorIndex = 0;
46390
- this.version = "2.22.1-next.2";
46422
+ this.version = "2.23.0-next.2";
46391
46423
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46392
46424
  this.superdocId = config.superdocId || require_uuid.v4();
46393
46425
  this.colors = this.config.colors ?? [];
46426
+ this.#assignUserColor();
46394
46427
  this.#initDocuments();
46395
46428
  await loadDefaultV2IntegrationOrFallback();
46396
46429
  if (this.#destroyed) return;
@@ -48799,6 +48832,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
48799
48832
  this.highContrastModeStore?.setHighContrastMode(isHighContrast);
48800
48833
  }
48801
48834
  };
48835
+ Object.defineProperty(SuperDoc.prototype.canPerformPermission, Symbol.for("superdoc.internal.permission-method.builtin"), { value: true });
48802
48836
  //#endregion
48803
48837
  //#region src/core/theme/create-theme.ts
48804
48838
  var COLORS_TO_VARS = {
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM$2 } from "./chunks/rolldown-runtime-0pSA04fp.es.js";
2
2
  import { t as blank_default } from "./chunks/blank-docx-DzQccOlW.es.js";
3
- import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-DmGX1w-i.es.js";
3
+ import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-DHW9Toxn.es.js";
4
4
  import { t as import_eventemitter3 } from "./chunks/eventemitter3-DEIiXiH2.es.js";
5
5
  import { t as v4 } from "./chunks/uuid-H0Xcmmhy.es.js";
6
6
  import { $ as watch$1, A as onActivated, B as resolveDirective, C as isRef$1, D as normalizeClass, E as nextTick, F as openBlock, G as toRef, H as shallowRef$1, I as reactive, J as useAttrs, K as toRefs, L as ref, M as onDeactivated, N as onMounted, O as normalizeProps, P as onScopeDispose$1, Q as vModelText, R as renderList, S as isReactive$1, T as mergeProps, U as toDisplayString, V as resolveDynamicComponent, W as toRaw$2, X as vModelCheckbox, Y as useSlots, Z as vModelSelect, _ as getCurrentInstance, a as computed$1, b as hasInjectionContext, c as createCommentVNode, d as createStaticVNode, et as withCtx, f as createTextVNode, g as effectScope, h as defineComponent, i as Transition, j as onBeforeUnmount, k as normalizeStyle, l as createElementBlock, m as defineAsyncComponent, n as Fragment, nt as withKeys, o as createApp, p as createVNode, q as unref, r as Teleport, rt as withModifiers, s as createBlock, t as _plugin_vue_export_helper_default, tt as withDirectives, u as createElementVNode, v as getCurrentScope, w as markRaw, x as inject$1, y as h, z as renderSlot } from "./chunks/_plugin-vue_export-helper-DHiJKCsy.es.js";
@@ -297,24 +297,12 @@ var awarenessStatesToArray = (context, states) => {
297
297
  };
298
298
  });
299
299
  };
300
- /**
301
- * Shuffle an array of hex colors
302
- * @param array - List of hex colors
303
- * @returns Shuffled array of hex colors
304
- */
305
- var shuffleArray = (array) => {
306
- for (let i = array.length - 1; i > 0; i--) {
307
- const j = Math.floor(Math.random() * (i + 1));
308
- [array[i], array[j]] = [array[j], array[i]];
309
- }
310
- return array;
311
- };
312
300
  //#endregion
313
301
  //#region ../../shared/common/Telemetry.ts
314
302
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
315
303
  function getSuperdocVersion() {
316
304
  try {
317
- return "2.22.1-next.2";
305
+ return "2.23.0-next.2";
318
306
  } catch {
319
307
  return "unknown";
320
308
  }
@@ -7944,6 +7932,14 @@ var useCommentsStore = defineStore("comments", () => {
7944
7932
  if (!normalizedId) return null;
7945
7933
  return normalizedId.startsWith("imported:") ? normalizedId : `imported:${normalizedId}`;
7946
7934
  };
7935
+ const positionEntriesByAlias = computed$1(() => {
7936
+ const aliases = /* @__PURE__ */ new Map();
7937
+ for (const [key, entry] of Object.entries(editorCommentPositions.value || {})) for (const alias of [normalizeCommentId(entry?.key), normalizeCommentId(entry?.threadId)]) if (alias && !aliases.has(alias)) aliases.set(alias, {
7938
+ key,
7939
+ entry
7940
+ });
7941
+ return aliases;
7942
+ });
7947
7943
  const getPositionEntryByAlias = (id) => {
7948
7944
  const normalizedId = normalizeCommentId(id);
7949
7945
  if (!normalizedId) return {
@@ -7955,15 +7951,7 @@ var useCommentsStore = defineStore("comments", () => {
7955
7951
  key: normalizedId,
7956
7952
  entry: positions[normalizedId]
7957
7953
  };
7958
- for (const [key, entry] of Object.entries(positions)) {
7959
- const entryKey = normalizeCommentId(entry?.key);
7960
- const threadId = normalizeCommentId(entry?.threadId);
7961
- if (entryKey === normalizedId || threadId === normalizedId) return {
7962
- key,
7963
- entry
7964
- };
7965
- }
7966
- return {
7954
+ return positionEntriesByAlias.value.get(normalizedId) ?? {
7967
7955
  key: null,
7968
7956
  entry: null
7969
7957
  };
@@ -8012,6 +8000,41 @@ var useCommentsStore = defineStore("comments", () => {
8012
8000
  });
8013
8001
  return matches.length === 1 ? matches[0] : null;
8014
8002
  };
8003
+ const commentIdentityIndex = computed$1(() => {
8004
+ const list = commentsList.value;
8005
+ if (!isReactive$1(list)) return null;
8006
+ const primary = /* @__PURE__ */ new Map();
8007
+ const aliases = /* @__PURE__ */ new Map();
8008
+ for (const comment of list) {
8009
+ if (!isReactive$1(comment)) return null;
8010
+ for (const key of [
8011
+ "commentId",
8012
+ "importedId",
8013
+ "trackedChangeAnchorKey",
8014
+ "trackedChange"
8015
+ ]) {
8016
+ const descriptor = Object.getOwnPropertyDescriptor(comment, key);
8017
+ if (descriptor?.get || descriptor?.set || !descriptor && key in comment) return null;
8018
+ }
8019
+ const ids = [
8020
+ comment.commentId,
8021
+ comment.importedId,
8022
+ comment.trackedChangeAnchorKey
8023
+ ];
8024
+ if (ids.some((id) => id != null && typeof id !== "string")) return null;
8025
+ if (ids[0] != null && !primary.has(ids[0])) primary.set(ids[0], comment);
8026
+ const importedPositionId = comment.trackedChange ? buildTrackedChangeImportedPositionId(ids[1]) : null;
8027
+ for (const alias of [
8028
+ ids[1],
8029
+ ids[2],
8030
+ importedPositionId
8031
+ ]) if (alias != null && !aliases.has(alias)) aliases.set(alias, comment);
8032
+ }
8033
+ return {
8034
+ primary,
8035
+ aliases
8036
+ };
8037
+ });
8015
8038
  /**
8016
8039
  * Get a comment by either ID or imported ID
8017
8040
  *
@@ -8023,7 +8046,8 @@ var useCommentsStore = defineStore("comments", () => {
8023
8046
  const byPrimaryId = (c) => c.commentId == id;
8024
8047
  const byAliasId = (c) => c.importedId == id || c.trackedChangeAnchorKey == id || c?.trackedChange && buildTrackedChangeImportedPositionId(c.importedId) == id;
8025
8048
  const findIn = (list) => list.find(byPrimaryId) ?? list.find(byAliasId);
8026
- return findIn(commentsList.value) ?? findIn(reviewDirectoryList.value) ?? getTrackedChangeCommentByPositionAlias(id);
8049
+ const index = typeof id === "string" ? commentIdentityIndex.value : null;
8050
+ return (index ? index.primary.get(id) ?? index.aliases.get(id) : findIn(commentsList.value)) ?? findIn(reviewDirectoryList.value) ?? getTrackedChangeCommentByPositionAlias(id);
8027
8051
  };
8028
8052
  const getThreadParent = (comment) => {
8029
8053
  if (!comment?.parentCommentId) return comment;
@@ -12521,6 +12545,19 @@ var pickResolver = (context = {}) => {
12521
12545
  if (typeof deprecatedResolver === "function") return deprecatedResolver;
12522
12546
  return null;
12523
12547
  };
12548
+ var BUILT_IN_PERMISSION_METHOD = Symbol.for("superdoc.internal.permission-method.builtin");
12549
+ var BUILT_IN_PERMISSION_RESOLVER = Symbol.for("superdoc.internal.permission-resolver.builtin");
12550
+ /** Create the shell's internal, live tracked-change permission shim. */
12551
+ var createTrackedChangePermissionResolver = (superdoc) => {
12552
+ const isBuiltInPolicy = () => superdoc.canPerformPermission?.[BUILT_IN_PERMISSION_METHOD] === true && pickResolver({ superdoc }) === null;
12553
+ const resolver = (payload = {}) => isBuiltInPolicy() ? defaultDecisionFor(payload.permission, superdoc.config.role, superdoc.config.isInternal) : superdoc.canPerformPermission({
12554
+ ...payload,
12555
+ role: superdoc.config.role,
12556
+ isInternal: superdoc.config.isInternal
12557
+ });
12558
+ Object.defineProperty(resolver, BUILT_IN_PERMISSION_RESOLVER, { value: isBuiltInPolicy });
12559
+ return resolver;
12560
+ };
12524
12561
  var defaultDecisionFor = (permission, role, isInternal) => {
12525
12562
  const internalExternal = isInternal ? "internal" : "external";
12526
12563
  return PERMISSION_MATRIX[permission]?.[internalExternal]?.includes(role) ?? false;
@@ -23482,11 +23519,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
23482
23519
  contentControlsChrome: proxy.$superdoc.uiConfig.contentControls.options.chrome,
23483
23520
  resolveTrackedChangeColor: composeAuthorColorResolver(proxy.$superdoc.config.modules?.trackChanges?.authorColors)
23484
23521
  } : void 0,
23485
- permissionResolver: (payload = {}) => proxy.$superdoc.canPerformPermission({
23486
- role: proxy.$superdoc.config.role,
23487
- isInternal: proxy.$superdoc.config.isInternal,
23488
- ...payload
23489
- })
23522
+ permissionResolver: createTrackedChangePermissionResolver(proxy.$superdoc)
23490
23523
  };
23491
23524
  };
23492
23525
  const REPLAY_MUTABLE_COMMENT_FIELDS = /* @__PURE__ */ new Set([
@@ -24529,7 +24562,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
24529
24562
  ], 38);
24530
24563
  };
24531
24564
  }
24532
- }, [["__scopeId", "data-v-99399849"]]);
24565
+ }, [["__scopeId", "data-v-3a8081b4"]]);
24533
24566
  //#endregion
24534
24567
  //#region src/core/create-app.js
24535
24568
  var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
@@ -46313,13 +46346,13 @@ var SuperDoc = class extends import_eventemitter3.default {
46313
46346
  commentsBlock.allowResolve = this.#interactionConfig.comments.allowResolve;
46314
46347
  }
46315
46348
  }
46316
- this.config.colors = shuffleArray(this.config.colors);
46317
46349
  this.userColorMap = /* @__PURE__ */ new Map();
46318
46350
  this.colorIndex = 0;
46319
- this.version = "2.22.1-next.2";
46351
+ this.version = "2.23.0-next.2";
46320
46352
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46321
46353
  this.superdocId = config.superdocId || v4();
46322
46354
  this.colors = this.config.colors ?? [];
46355
+ this.#assignUserColor();
46323
46356
  this.#initDocuments();
46324
46357
  await loadDefaultV2IntegrationOrFallback();
46325
46358
  if (this.#destroyed) return;
@@ -48728,6 +48761,7 @@ var SuperDoc = class extends import_eventemitter3.default {
48728
48761
  this.highContrastModeStore?.setHighContrastMode(isHighContrast);
48729
48762
  }
48730
48763
  };
48764
+ Object.defineProperty(SuperDoc.prototype.canPerformPermission, Symbol.for("superdoc.internal.permission-method.builtin"), { value: true });
48731
48765
  //#endregion
48732
48766
  //#region src/core/theme/create-theme.ts
48733
48767
  var COLORS_TO_VARS = {