superdoc 2.18.0 → 2.18.1-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.
@@ -1660,9 +1660,12 @@ function collectEntityHitsFromChain(start, stopAt) {
1660
1660
  const hits = [];
1661
1661
  const seen = /* @__PURE__ */ new Set();
1662
1662
  let pendingStory = [];
1663
+ let nearestStoryKey = null;
1664
+ let nearestLayoutStory = null;
1663
1665
  let el = start;
1664
1666
  while (el) {
1665
1667
  const node = el;
1668
+ nearestStoryKey ??= node.getAttribute("data-story-key");
1666
1669
  const trackChangeIds = getTrackChangeIds(node);
1667
1670
  const storyKey = trackChangeIds.length > 0 ? node.getAttribute("data-story-key") : null;
1668
1671
  for (const trackChangeId of trackChangeIds) {
@@ -1679,6 +1682,7 @@ function collectEntityHitsFromChain(start, stopAt) {
1679
1682
  }
1680
1683
  }
1681
1684
  const layoutStory = node.getAttribute("data-layout-story");
1685
+ nearestLayoutStory ??= layoutStory;
1682
1686
  if (layoutStory && pendingStory.length > 0) {
1683
1687
  for (const hit of pendingStory) hit.story = layoutStory;
1684
1688
  pendingStory = [];
@@ -1717,6 +1721,9 @@ function collectEntityHitsFromChain(start, stopAt) {
1717
1721
  type: "contentControl",
1718
1722
  id: sdtId
1719
1723
  };
1724
+ if (nearestStoryKey) hit.storyKey = nearestStoryKey;
1725
+ if (nearestLayoutStory) hit.story = nearestLayoutStory;
1726
+ else pendingStory.push(hit);
1720
1727
  if (scopeAttr === "block" || scopeAttr === "inline") hit.scope = scopeAttr;
1721
1728
  if (tag) hit.tag = tag;
1722
1729
  hits.push(hit);
@@ -2699,6 +2706,11 @@ function layoutStoryDatasetToStoryLocator(raw) {
2699
2706
  storyType: "headerFooterPart",
2700
2707
  refId: decoded.id
2701
2708
  } : void 0;
2709
+ case "textbox": return decoded.id ? {
2710
+ kind: "story",
2711
+ storyType: "textbox",
2712
+ textboxId: decoded.id
2713
+ } : void 0;
2702
2714
  default: return;
2703
2715
  }
2704
2716
  }
@@ -10619,10 +10631,18 @@ function createSuperDocUI(options) {
10619
10631
  const hits = [];
10620
10632
  for (const hit of rawHits) {
10621
10633
  if (hit.type !== "trackedChange") {
10622
- const key = `${hit.type}:${hit.id}`;
10634
+ const layoutStory = hit.type === "contentControl" ? layoutStoryDatasetToStoryLocator(hit.story) : void 0;
10635
+ const story = hit.type === "contentControl" ? isTextboxStory(layoutStory) ? layoutStory : storyKeyToStoryLocator(hit.storyKey) ?? layoutStory : void 0;
10636
+ const key = `${hit.type}:${hit.id}:${JSON.stringify(story ?? null)}`;
10623
10637
  if (seen.has(key)) continue;
10624
10638
  seen.add(key);
10625
- hits.push(hit);
10639
+ if (hit.type === "contentControl") {
10640
+ const { storyKey: _storyKey, story: _paintedStory, ...publicHit } = hit;
10641
+ hits.push(story ? {
10642
+ ...publicHit,
10643
+ story
10644
+ } : publicHit);
10645
+ } else hits.push(hit);
10626
10646
  continue;
10627
10647
  }
10628
10648
  const story = storyKeyToStoryLocator(hit.storyKey) ?? layoutStoryDatasetToStoryLocator(hit.story);
@@ -10828,20 +10848,25 @@ function createSuperDocUI(options) {
10828
10848
  return target && typeof target === "object" ? target : null;
10829
10849
  };
10830
10850
  const metadataResolveKey = (id) => `metadata:resolve:${id}`;
10851
+ const metadataResolutionToken = () => {
10852
+ const host = getHost();
10853
+ const localRevision = typeof host?.getLocalMutationRevision === "function" ? safeCall(() => host.getLocalMutationRevision(), null) : null;
10854
+ return `${contentToken()}|local:${typeof localRevision === "number" ? localRevision : "unknown"}`;
10855
+ };
10831
10856
  /** Resolve a metadata id to its SelectionTarget, or null when unresolved. */
10832
10857
  const resolveMetadataTarget = (id) => {
10833
10858
  const metaApi = getDoc()?.metadata;
10834
10859
  if (!metaApi || typeof metaApi.resolve !== "function") return null;
10835
- const { value } = readAsync(metadataResolveKey(id), contentToken(), () => metaApi.resolve({ id }), readMetadataResolvedTarget);
10836
- return value;
10860
+ const { value, status } = readAsync(metadataResolveKey(id), metadataResolutionToken(), () => metaApi.resolve({ id }), readMetadataResolvedTarget);
10861
+ return status === "ready" ? value : null;
10837
10862
  };
10838
10863
  const resolveMetadataTargetAsync = async (id) => {
10839
10864
  const metaApi = getDoc()?.metadata;
10840
10865
  if (!metaApi || typeof metaApi.resolve !== "function") return null;
10841
10866
  try {
10842
- const token = contentToken();
10867
+ const token = metadataResolutionToken();
10843
10868
  const resolved = await Promise.resolve(metaApi.resolve({ id }));
10844
- if (token !== contentToken()) return null;
10869
+ if (token !== metadataResolutionToken()) return null;
10845
10870
  const target = readMetadataResolvedTarget(resolved);
10846
10871
  asyncReads.set(metadataResolveKey(id), {
10847
10872
  token,
@@ -1660,9 +1660,12 @@ function collectEntityHitsFromChain(start, stopAt) {
1660
1660
  const hits = [];
1661
1661
  const seen = /* @__PURE__ */ new Set();
1662
1662
  let pendingStory = [];
1663
+ let nearestStoryKey = null;
1664
+ let nearestLayoutStory = null;
1663
1665
  let el = start;
1664
1666
  while (el) {
1665
1667
  const node = el;
1668
+ nearestStoryKey ??= node.getAttribute("data-story-key");
1666
1669
  const trackChangeIds = getTrackChangeIds(node);
1667
1670
  const storyKey = trackChangeIds.length > 0 ? node.getAttribute("data-story-key") : null;
1668
1671
  for (const trackChangeId of trackChangeIds) {
@@ -1679,6 +1682,7 @@ function collectEntityHitsFromChain(start, stopAt) {
1679
1682
  }
1680
1683
  }
1681
1684
  const layoutStory = node.getAttribute("data-layout-story");
1685
+ nearestLayoutStory ??= layoutStory;
1682
1686
  if (layoutStory && pendingStory.length > 0) {
1683
1687
  for (const hit of pendingStory) hit.story = layoutStory;
1684
1688
  pendingStory = [];
@@ -1717,6 +1721,9 @@ function collectEntityHitsFromChain(start, stopAt) {
1717
1721
  type: "contentControl",
1718
1722
  id: sdtId
1719
1723
  };
1724
+ if (nearestStoryKey) hit.storyKey = nearestStoryKey;
1725
+ if (nearestLayoutStory) hit.story = nearestLayoutStory;
1726
+ else pendingStory.push(hit);
1720
1727
  if (scopeAttr === "block" || scopeAttr === "inline") hit.scope = scopeAttr;
1721
1728
  if (tag) hit.tag = tag;
1722
1729
  hits.push(hit);
@@ -2699,6 +2706,11 @@ function layoutStoryDatasetToStoryLocator(raw) {
2699
2706
  storyType: "headerFooterPart",
2700
2707
  refId: decoded.id
2701
2708
  } : void 0;
2709
+ case "textbox": return decoded.id ? {
2710
+ kind: "story",
2711
+ storyType: "textbox",
2712
+ textboxId: decoded.id
2713
+ } : void 0;
2702
2714
  default: return;
2703
2715
  }
2704
2716
  }
@@ -10619,10 +10631,18 @@ function createSuperDocUI(options) {
10619
10631
  const hits = [];
10620
10632
  for (const hit of rawHits) {
10621
10633
  if (hit.type !== "trackedChange") {
10622
- const key = `${hit.type}:${hit.id}`;
10634
+ const layoutStory = hit.type === "contentControl" ? layoutStoryDatasetToStoryLocator(hit.story) : void 0;
10635
+ const story = hit.type === "contentControl" ? isTextboxStory(layoutStory) ? layoutStory : storyKeyToStoryLocator(hit.storyKey) ?? layoutStory : void 0;
10636
+ const key = `${hit.type}:${hit.id}:${JSON.stringify(story ?? null)}`;
10623
10637
  if (seen.has(key)) continue;
10624
10638
  seen.add(key);
10625
- hits.push(hit);
10639
+ if (hit.type === "contentControl") {
10640
+ const { storyKey: _storyKey, story: _paintedStory, ...publicHit } = hit;
10641
+ hits.push(story ? {
10642
+ ...publicHit,
10643
+ story
10644
+ } : publicHit);
10645
+ } else hits.push(hit);
10626
10646
  continue;
10627
10647
  }
10628
10648
  const story = storyKeyToStoryLocator(hit.storyKey) ?? layoutStoryDatasetToStoryLocator(hit.story);
@@ -10828,20 +10848,25 @@ function createSuperDocUI(options) {
10828
10848
  return target && typeof target === "object" ? target : null;
10829
10849
  };
10830
10850
  const metadataResolveKey = (id) => `metadata:resolve:${id}`;
10851
+ const metadataResolutionToken = () => {
10852
+ const host = getHost();
10853
+ const localRevision = typeof host?.getLocalMutationRevision === "function" ? safeCall(() => host.getLocalMutationRevision(), null) : null;
10854
+ return `${contentToken()}|local:${typeof localRevision === "number" ? localRevision : "unknown"}`;
10855
+ };
10831
10856
  /** Resolve a metadata id to its SelectionTarget, or null when unresolved. */
10832
10857
  const resolveMetadataTarget = (id) => {
10833
10858
  const metaApi = getDoc()?.metadata;
10834
10859
  if (!metaApi || typeof metaApi.resolve !== "function") return null;
10835
- const { value } = readAsync(metadataResolveKey(id), contentToken(), () => metaApi.resolve({ id }), readMetadataResolvedTarget);
10836
- return value;
10860
+ const { value, status } = readAsync(metadataResolveKey(id), metadataResolutionToken(), () => metaApi.resolve({ id }), readMetadataResolvedTarget);
10861
+ return status === "ready" ? value : null;
10837
10862
  };
10838
10863
  const resolveMetadataTargetAsync = async (id) => {
10839
10864
  const metaApi = getDoc()?.metadata;
10840
10865
  if (!metaApi || typeof metaApi.resolve !== "function") return null;
10841
10866
  try {
10842
- const token = contentToken();
10867
+ const token = metadataResolutionToken();
10843
10868
  const resolved = await Promise.resolve(metaApi.resolve({ id }));
10844
- if (token !== contentToken()) return null;
10869
+ if (token !== metadataResolutionToken()) return null;
10845
10870
  const target = readMetadataResolvedTarget(resolved);
10846
10871
  asyncReads.set(metadataResolveKey(id), {
10847
10872
  token,
@@ -19,7 +19,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
19
19
  var PRIVATE_ENGINE_INFO = (0, _superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
20
20
  var ENGINE_INFO = Object.freeze({
21
21
  ...PRIVATE_ENGINE_INFO,
22
- superdocVersion: "2.18.0",
22
+ superdocVersion: "2.18.1-next.2",
23
23
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
24
24
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
25
25
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -18,7 +18,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
18
18
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
19
19
  var ENGINE_INFO = Object.freeze({
20
20
  ...PRIVATE_ENGINE_INFO,
21
- superdocVersion: "2.18.0",
21
+ superdocVersion: "2.18.1-next.2",
22
22
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
23
23
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
24
24
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-wDvhW9Tz.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-DpNGRfzi.cjs");
3
3
  const require_slice_source = require("../chunks/slice-source-CFaqq0Vo.cjs");
4
4
  let react = require("react");
5
5
  //#region src/public/ui/react.ts
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-wKzxrztu.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-B-Zlfpi_.es.js";
2
2
  import { t as toSliceSource } from "../chunks/slice-source-gfOhG2MW.es.js";
3
3
  import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
4
4
  //#region src/public/ui/react.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-wDvhW9Tz.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-DpNGRfzi.cjs");
3
3
  const require_slice_source = require("../chunks/slice-source-CFaqq0Vo.cjs");
4
4
  let vue = require("vue");
5
5
  //#region src/public/ui/vue.ts
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-wKzxrztu.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-B-Zlfpi_.es.js";
2
2
  import { t as toSliceSource } from "../chunks/slice-source-gfOhG2MW.es.js";
3
3
  import { computed, inject, onScopeDispose, provide, shallowRef, toRaw, toValue, watch } from "vue";
4
4
  //#region src/public/ui/vue.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-wDvhW9Tz.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-DpNGRfzi.cjs");
3
3
  exports.BUILT_IN_COMMAND_IDS = require_create_super_doc_ui.BUILT_IN_COMMAND_IDS;
4
4
  exports.createSuperDocUI = require_create_super_doc_ui.createSuperDocUI;
5
5
  exports.shallowEqual = require_create_super_doc_ui.shallowEqual;
@@ -1,2 +1,2 @@
1
- import { i as BUILT_IN_COMMAND_IDS, s as shallowEqual, t as createSuperDocUI } from "../chunks/create-super-doc-ui-wKzxrztu.es.js";
1
+ import { i as BUILT_IN_COMMAND_IDS, s as shallowEqual, t as createSuperDocUI } from "../chunks/create-super-doc-ui-B-Zlfpi_.es.js";
2
2
  export { BUILT_IN_COMMAND_IDS, createSuperDocUI, shallowEqual };
@@ -370,11 +370,9 @@ export interface ViewportEntityHit {
370
370
  tag?: string;
371
371
  scope?: 'block' | 'inline';
372
372
  /**
373
- * Painted story locator for a tracked-change hit. Meaningful only for
374
- * `type: 'trackedChange'`; absent for body-only content and for comment,
375
- * content-control, and citation hits. Lets point hit-testing disambiguate a tracked-change
376
- * id that repeats across stories (body, footnote, header/footer, textbox) by
377
- * resolving to the occurrence actually under the point.
373
+ * Painted story locator for a tracked-change or content-control hit.
374
+ * Absent for body-only content and comment or citation hits. Disambiguates
375
+ * an id reused in another document story from the occurrence under the point.
378
376
  */
379
377
  story?: unknown;
380
378
  }
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-wDvhW9Tz.cjs");
4
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-DpNGRfzi.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_jszip = require("./chunks/jszip-D8mAFF-r.cjs");
@@ -316,7 +316,7 @@ var shuffleArray = (array) => {
316
316
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
317
317
  function getSuperdocVersion() {
318
318
  try {
319
- return "2.18.0";
319
+ return "2.18.1-next.2";
320
320
  } catch {
321
321
  return "unknown";
322
322
  }
@@ -45750,7 +45750,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
45750
45750
  this.config.colors = shuffleArray(this.config.colors);
45751
45751
  this.userColorMap = /* @__PURE__ */ new Map();
45752
45752
  this.colorIndex = 0;
45753
- this.version = "2.18.0";
45753
+ this.version = "2.18.1-next.2";
45754
45754
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45755
45755
  this.superdocId = config.superdocId || require_uuid.v4();
45756
45756
  this.colors = this.config.colors ?? [];
@@ -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 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";
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-B-Zlfpi_.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";
318
+ return "2.18.1-next.2";
319
319
  } catch {
320
320
  return "unknown";
321
321
  }
@@ -45681,7 +45681,7 @@ var SuperDoc = class extends import_eventemitter3.default {
45681
45681
  this.config.colors = shuffleArray(this.config.colors);
45682
45682
  this.userColorMap = /* @__PURE__ */ new Map();
45683
45683
  this.colorIndex = 0;
45684
- this.version = "2.18.0";
45684
+ this.version = "2.18.1-next.2";
45685
45685
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45686
45686
  this.superdocId = config.superdocId || v4();
45687
45687
  this.colors = this.config.colors ?? [];