superdoc 2.18.0-next.13 → 2.18.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,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 { a as getV2TrackedChangeMutationImpact, c as createInteractionHistory, i as applyV2CommentInvalidationFromMutation, l as recordInteraction, o as DOM_CLASS_NAMES, s as closeInteractionHistory, t as createSuperDocUI } from "./chunks/create-super-doc-ui-Ci7OxbXV.es.js";
3
+ import { a as applyV2CommentInvalidationFromMutation, c as DOM_CLASS_NAMES, d as recordInteraction, l as closeInteractionHistory, n as executeFirstPartyCommandAsync, o as getV2TrackedChangeMutationImpact, r as registerFirstPartyCommandMutation, t as createSuperDocUI, u as createInteractionHistory } from "./chunks/create-super-doc-ui-wKzxrztu.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 { a as init_dist$1, i as global, n as init_dist$2, o as Buffer, r as process$1, s as init_dist, t as require_jszip_min } from "./chunks/jszip-BzJ3CyxR.es.js";
@@ -315,7 +315,7 @@ var shuffleArray = (array) => {
315
315
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
316
316
  function getSuperdocVersion() {
317
317
  try {
318
- return "2.18.0-next.13";
318
+ return "2.18.0-next.14";
319
319
  } catch {
320
320
  return "unknown";
321
321
  }
@@ -14970,6 +14970,79 @@ function useViewportFit({ getSuperdoc, superdocContainerWidth, isReady, activeZo
14970
14970
  return { evaluateViewport };
14971
14971
  }
14972
14972
  //#endregion
14973
+ //#region ../layout-engine/contracts/src/author-colors.ts
14974
+ /**
14975
+ * Curated, high-contrast fallback palette. Used when neither `overrides` nor
14976
+ * `resolve` produces a color so imported/discovered authors the host did not
14977
+ * configure ahead of time still get a stable, distinct color.
14978
+ */
14979
+ var FALLBACK_PALETTE = [
14980
+ "#1f6feb",
14981
+ "#d1242f",
14982
+ "#8250df",
14983
+ "#bf3989",
14984
+ "#1a7f37",
14985
+ "#9a6700",
14986
+ "#bc4c00",
14987
+ "#0969da",
14988
+ "#cf222e",
14989
+ "#6639ba",
14990
+ "#116329",
14991
+ "#7d4e00"
14992
+ ];
14993
+ /** Stable identity string for an author (used for hashing + dedupe). */
14994
+ var authorIdentityKey = (author) => {
14995
+ if (!author) return "";
14996
+ return `${typeof author.name === "string" ? author.name : ""} ${typeof author.email === "string" ? author.email : ""}`;
14997
+ };
14998
+ /** Deterministic 32-bit FNV-1a hash of a string. */
14999
+ var hashString = (value) => {
15000
+ let hash = 2166136261;
15001
+ for (let i = 0; i < value.length; i += 1) {
15002
+ hash ^= value.charCodeAt(i);
15003
+ hash = Math.imul(hash, 16777619);
15004
+ }
15005
+ return hash >>> 0;
15006
+ };
15007
+ /**
15008
+ * Deterministic fallback color derived from the author identity. The same
15009
+ * identity always maps to the same palette entry, so colors stay stable across
15010
+ * reloads and across the paint / snapshot surfaces.
15011
+ */
15012
+ var fallbackAuthorColor = (author) => {
15013
+ return FALLBACK_PALETTE[hashString(authorIdentityKey(author)) % FALLBACK_PALETTE.length];
15014
+ };
15015
+ var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
15016
+ /**
15017
+ * Composes the host `authorColors` config into a single resolver.
15018
+ *
15019
+ * Resolution order per author:
15020
+ * 1. `overrides` by identity — `email` first, then `name` (exact match).
15021
+ * 2. `resolve(author)`.
15022
+ * 3. A deterministic fallback color from the author identity.
15023
+ *
15024
+ * Returns `undefined` when colors are disabled (`enabled === false`) or no
15025
+ * config was provided, so callers can leave the existing default palette in
15026
+ * place by simply not threading a resolver.
15027
+ */
15028
+ var composeAuthorColorResolver = (config) => {
15029
+ if (!config || config.enabled === false) return void 0;
15030
+ const overrides = config.overrides && typeof config.overrides === "object" ? config.overrides : void 0;
15031
+ const resolve = typeof config.resolve === "function" ? config.resolve : void 0;
15032
+ return (author) => {
15033
+ const safeAuthor = author ?? {};
15034
+ if (overrides) {
15035
+ if (isNonEmptyString(safeAuthor.email) && isNonEmptyString(overrides[safeAuthor.email])) return overrides[safeAuthor.email];
15036
+ if (isNonEmptyString(safeAuthor.name) && isNonEmptyString(overrides[safeAuthor.name])) return overrides[safeAuthor.name];
15037
+ }
15038
+ if (resolve) try {
15039
+ const resolved = resolve(safeAuthor);
15040
+ if (isNonEmptyString(resolved)) return resolved;
15041
+ } catch {}
15042
+ return fallbackAuthorColor(safeAuthor);
15043
+ };
15044
+ };
15045
+ //#endregion
14973
15046
  //#region src/components/CommentsLayer/floating-comment-positioning.js
14974
15047
  var isPersistentReviewSidebarItem = (comment) => {
14975
15048
  return Boolean(comment?.trackedChange);
@@ -16378,79 +16451,6 @@ var WhiteboardLayer_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
16378
16451
  }
16379
16452
  }, [["__scopeId", "data-v-54546c3d"]]);
16380
16453
  //#endregion
16381
- //#region ../layout-engine/contracts/src/author-colors.ts
16382
- /**
16383
- * Curated, high-contrast fallback palette. Used when neither `overrides` nor
16384
- * `resolve` produces a color so imported/discovered authors the host did not
16385
- * configure ahead of time still get a stable, distinct color.
16386
- */
16387
- var FALLBACK_PALETTE = [
16388
- "#1f6feb",
16389
- "#d1242f",
16390
- "#8250df",
16391
- "#bf3989",
16392
- "#1a7f37",
16393
- "#9a6700",
16394
- "#bc4c00",
16395
- "#0969da",
16396
- "#cf222e",
16397
- "#6639ba",
16398
- "#116329",
16399
- "#7d4e00"
16400
- ];
16401
- /** Stable identity string for an author (used for hashing + dedupe). */
16402
- var authorIdentityKey = (author) => {
16403
- if (!author) return "";
16404
- return `${typeof author.name === "string" ? author.name : ""} ${typeof author.email === "string" ? author.email : ""}`;
16405
- };
16406
- /** Deterministic 32-bit FNV-1a hash of a string. */
16407
- var hashString = (value) => {
16408
- let hash = 2166136261;
16409
- for (let i = 0; i < value.length; i += 1) {
16410
- hash ^= value.charCodeAt(i);
16411
- hash = Math.imul(hash, 16777619);
16412
- }
16413
- return hash >>> 0;
16414
- };
16415
- /**
16416
- * Deterministic fallback color derived from the author identity. The same
16417
- * identity always maps to the same palette entry, so colors stay stable across
16418
- * reloads and across the paint / snapshot surfaces.
16419
- */
16420
- var fallbackAuthorColor = (author) => {
16421
- return FALLBACK_PALETTE[hashString(authorIdentityKey(author)) % FALLBACK_PALETTE.length];
16422
- };
16423
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
16424
- /**
16425
- * Composes the host `authorColors` config into a single resolver.
16426
- *
16427
- * Resolution order per author:
16428
- * 1. `overrides` by identity — `email` first, then `name` (exact match).
16429
- * 2. `resolve(author)`.
16430
- * 3. A deterministic fallback color from the author identity.
16431
- *
16432
- * Returns `undefined` when colors are disabled (`enabled === false`) or no
16433
- * config was provided, so callers can leave the existing default palette in
16434
- * place by simply not threading a resolver.
16435
- */
16436
- var composeAuthorColorResolver = (config) => {
16437
- if (!config || config.enabled === false) return void 0;
16438
- const overrides = config.overrides && typeof config.overrides === "object" ? config.overrides : void 0;
16439
- const resolve = typeof config.resolve === "function" ? config.resolve : void 0;
16440
- return (author) => {
16441
- const safeAuthor = author ?? {};
16442
- if (overrides) {
16443
- if (isNonEmptyString(safeAuthor.email) && isNonEmptyString(overrides[safeAuthor.email])) return overrides[safeAuthor.email];
16444
- if (isNonEmptyString(safeAuthor.name) && isNonEmptyString(overrides[safeAuthor.name])) return overrides[safeAuthor.name];
16445
- }
16446
- if (resolve) try {
16447
- const resolved = resolve(safeAuthor);
16448
- if (isNonEmptyString(resolved)) return resolved;
16449
- } catch {}
16450
- return fallbackAuthorColor(safeAuthor);
16451
- };
16452
- };
16453
- //#endregion
16454
16454
  //#region src/components/HtmlViewer/HtmlViewer.vue
16455
16455
  var _hoisted_1$20 = { class: "superdoc-html-viewer" };
16456
16456
  var _hoisted_2$16 = { class: "superdoc-html-viewer__document" };
@@ -22131,7 +22131,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
22131
22131
  executeAsync: (commandId, payload) => {
22132
22132
  const ui = getSuperDocUI();
22133
22133
  if (!ui) return Promise.resolve(UNAVAILABLE_COMMAND_RESULT);
22134
- return ui.commands.executeAsync(commandId, payload);
22134
+ return executeFirstPartyCommandAsync(ui, commandId, payload);
22135
22135
  },
22136
22136
  getState: (commandId) => getSuperDocUI()?.commands.get(commandId).getState() ?? UNAVAILABLE_COMMAND_STATE
22137
22137
  },
@@ -22332,7 +22332,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
22332
22332
  if (!payload) return;
22333
22333
  clearV2EditorFailure(payload.documentId ?? null);
22334
22334
  clearV2MutationRejectionNotifications(payload.documentId ?? null);
22335
- const { host, mount, documentId, capabilities, editCommands, bindEditShortcuts, bindSessionShortcuts, commentsAdapter, trackedChangesAdapter, contextMenu, documentApi, documentMutationReadiness, documentApiUnavailableReason, pageMetrics, pageLayout, pageFurniture, presence, lock, connection, collaborationProvider, fonts, replaceFile, upgradeToCollaboration, documentOpenToken } = payload;
22335
+ const { host, firstPartyCommandMutation, mount, documentId, capabilities, editCommands, bindEditShortcuts, bindSessionShortcuts, commentsAdapter, trackedChangesAdapter, contextMenu, documentApi, documentMutationReadiness, documentApiUnavailableReason, pageMetrics, pageLayout, pageFurniture, presence, lock, connection, collaborationProvider, fonts, replaceFile, upgradeToCollaboration, documentOpenToken } = payload;
22336
22336
  documentOpenTelemetry?.trackDocumentOpen(documentOpenToken ?? null, documentId ?? null);
22337
22337
  const saveV2Bytes = createV2SaveQueue(async (saveOptions = {}) => {
22338
22338
  if (!host || typeof host.save !== "function") throw new Error("v2-editor: save unavailable");
@@ -22648,6 +22648,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
22648
22648
  if (doc) doc.provider = provider;
22649
22649
  }
22650
22650
  proxy.$superdoc.broadcastEditorCreate(facade);
22651
+ if (host && firstPartyCommandMutation) registerFirstPartyCommandMutation(proxy.$superdoc, host, firstPartyCommandMutation);
22651
22652
  installV2CommandShortcutBinding({
22652
22653
  documentId,
22653
22654
  bindEditShortcuts
@@ -24455,7 +24456,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
24455
24456
  ], 38);
24456
24457
  };
24457
24458
  }
24458
- }, [["__scopeId", "data-v-9da02d58"]]);
24459
+ }, [["__scopeId", "data-v-202b7646"]]);
24459
24460
  //#endregion
24460
24461
  //#region src/core/create-app.js
24461
24462
  var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
@@ -44299,7 +44300,7 @@ function executeCommand(ui, commandId, argument, options = {}) {
44299
44300
  if (typeof ui.commands.has === "function" && !ui.commands.has(commandId)) return false;
44300
44301
  const execute = typeof ui.commands.executeAsync === "function" ? ui.commands.executeAsync : ui.commands.execute;
44301
44302
  if (typeof execute !== "function") return false;
44302
- const result = argument === void 0 ? execute.call(ui.commands, commandId) : execute.call(ui.commands, commandId, argument);
44303
+ const result = options.firstParty ? executeFirstPartyCommandAsync(ui, commandId, argument) : argument === void 0 ? execute.call(ui.commands, commandId) : execute.call(ui.commands, commandId, argument);
44303
44304
  const reportFailure = (settled) => {
44304
44305
  if (!options.reportUnhandled || settled !== false) return;
44305
44306
  options.onError?.(/* @__PURE__ */ new Error(`[superdoc toolbar] Command "${commandId}" did not run. Check that it is enabled and has the required input.`));
@@ -44947,6 +44948,7 @@ var BuiltInToolbar = class extends import_eventemitter3.default {
44947
44948
  const name = item?.name?.value;
44948
44949
  if (!name) return false;
44949
44950
  const callbacks = {
44951
+ firstParty: true,
44950
44952
  onSettled: () => this.updateToolbarState(),
44951
44953
  onError: (error) => this.#emitCommandException(error, name)
44952
44954
  };
@@ -44975,6 +44977,7 @@ var BuiltInToolbar = class extends import_eventemitter3.default {
44975
44977
  onPick: async (file) => {
44976
44978
  const src = await resolveImageSrc(file, this.superdoc?.config?.handleImageUpload);
44977
44979
  executeCommand(this.ui, "image", { src }, {
44980
+ firstParty: true,
44978
44981
  onSettled: () => this.updateToolbarState(),
44979
44982
  onError: (error) => this.#emitCommandException(error, "image")
44980
44983
  });
@@ -45677,7 +45680,7 @@ var SuperDoc = class extends import_eventemitter3.default {
45677
45680
  this.config.colors = shuffleArray(this.config.colors);
45678
45681
  this.userColorMap = /* @__PURE__ */ new Map();
45679
45682
  this.colorIndex = 0;
45680
- this.version = "2.18.0-next.13";
45683
+ this.version = "2.18.0-next.14";
45681
45684
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45682
45685
  this.superdocId = config.superdocId || v4();
45683
45686
  this.colors = this.config.colors ?? [];