superdoc 2.23.0-next.1 → 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.
@@ -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.23.0-next.1";
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.23.0-next.1";
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 = {