superdoc 2.19.0-next.1 → 2.19.0-next.11

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.
Files changed (34) hide show
  1. package/dist/chunks/{create-super-doc-ui-BFJ9Y0YV.cjs → create-super-doc-ui-CSZSAgxc.cjs} +58 -0
  2. package/dist/chunks/{create-super-doc-ui-Dfw1b6h_.es.js → create-super-doc-ui-DMe-GQEe.es.js} +58 -0
  3. package/dist/chunks/pdf.worker.min-BgWCk_Cj.cjs +4 -0
  4. package/dist/chunks/pdf.worker.min-t-CYmkGJ.es.js +4 -0
  5. package/dist/collaboration-upgrade-engine.cjs +1 -1
  6. package/dist/collaboration-upgrade-engine.es.js +1 -1
  7. package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
  8. package/dist/document-api/src/contract/metadata-types.d.ts +1 -1
  9. package/dist/document-api/src/contract/operation-definitions.d.ts +9 -0
  10. package/dist/document-api/src/diff/diff.types.d.ts +9 -1
  11. package/dist/document-api/src/diff/index.d.ts +1 -1
  12. package/dist/document-api/src/index.d.ts +3 -3
  13. package/dist/document-api/src/selection/selection.d.ts +6 -2
  14. package/dist/document-api/src/selection/selection.types.d.ts +75 -0
  15. package/dist/document-api/src/types/track-changes.types.d.ts +35 -2
  16. package/dist/layout-engine/contracts/src/index.d.ts +15 -0
  17. package/dist/layout-engine/contracts/src/resolved-layout.d.ts +3 -1
  18. package/dist/layout-engine/painters/dom/src/runs/tab-run.d.ts +1 -1
  19. package/dist/public/ui-react.cjs +1 -1
  20. package/dist/public/ui-react.es.js +1 -1
  21. package/dist/public/ui-vue.cjs +1 -1
  22. package/dist/public/ui-vue.es.js +1 -1
  23. package/dist/public/ui.cjs +1 -1
  24. package/dist/public/ui.es.js +1 -1
  25. package/dist/style.css +22 -22
  26. package/dist/style.layered.css +22 -22
  27. package/dist/superdoc/src/core/SuperDoc.d.ts +8 -7
  28. package/dist/superdoc/src/core/types/index.d.ts +32 -14
  29. package/dist/superdoc.cjs +12 -8
  30. package/dist/superdoc.es.js +12 -8
  31. package/dist-cdn/style.layered.css +1 -1
  32. package/dist-cdn/superdoc.min.css +1 -1
  33. package/dist-cdn/superdoc.min.js +36 -36
  34. package/package.json +3 -2
@@ -8898,6 +8898,7 @@ function createSuperDocUI(options) {
8898
8898
  syncTrackedChangeFocusFromHostReviewTarget(readHostActiveReviewTarget(readHostReviewSource()));
8899
8899
  state = computeState("initial");
8900
8900
  lastOptimisticInlineSelectionSignature = selectionInlineValueSignature(state.selection);
8901
+ let scheduleActiveSearchRefresh = () => {};
8901
8902
  const syncHostEventsSubscription = () => {
8902
8903
  const host = getEditor()?.host;
8903
8904
  const events = host?.events;
@@ -8917,6 +8918,7 @@ function createSuperDocUI(options) {
8917
8918
  const off = next.subscribe((event) => {
8918
8919
  const type = event?.type;
8919
8920
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
8921
+ if (isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0) scheduleActiveSearchRefresh();
8920
8922
  if ((type === "document:mutated" || type === "mutation:committed" && mutationCommittedEventChangedDocument(event)) && host && !dirtyHosts.has(host)) {
8921
8923
  dirtyHosts.add(host);
8922
8924
  recompute("document-dirty");
@@ -12318,6 +12320,12 @@ function createSuperDocUI(options) {
12318
12320
  * session is the one that says how to close it.
12319
12321
  */
12320
12322
  let releaseActiveSearchSession = null;
12323
+ let releaseRefreshShellSearch = null;
12324
+ const cancelRefreshShellSearch = () => {
12325
+ const release = releaseRefreshShellSearch;
12326
+ releaseRefreshShellSearch = null;
12327
+ if (release) safeCall(() => release(), null);
12328
+ };
12321
12329
  /** Release whatever session is open, then forget it. */
12322
12330
  const releaseSearchSession = () => {
12323
12331
  const release = releaseActiveSearchSession;
@@ -12349,6 +12357,7 @@ function createSuperDocUI(options) {
12349
12357
  searchRequestGeneration += 1;
12350
12358
  pendingFallbackGeneration = null;
12351
12359
  shellFallbackOutstanding = false;
12360
+ cancelRefreshShellSearch();
12352
12361
  releaseSearchSession();
12353
12362
  const available = searchIsAvailable();
12354
12363
  searchState = {
@@ -12530,6 +12539,7 @@ function createSuperDocUI(options) {
12530
12539
  },
12531
12540
  close: () => {
12532
12541
  searchRequestGeneration += 1;
12542
+ cancelRefreshShellSearch();
12533
12543
  if (releaseActiveSearchSession) releaseSearchSession();
12534
12544
  else {
12535
12545
  const host = getHostSearch();
@@ -12553,6 +12563,7 @@ function createSuperDocUI(options) {
12553
12563
  const includeDeletedText = (options?.includeTrackedDeletions ?? options?.includeDeletedText) === true;
12554
12564
  const regex = options?.regex === true;
12555
12565
  const generation = ++searchRequestGeneration;
12566
+ cancelRefreshShellSearch();
12556
12567
  cancelOutstandingShellFallback();
12557
12568
  if (!host || typeof host.setSession !== "function") {
12558
12569
  const editSearch = getEditCommandSearch();
@@ -12741,6 +12752,7 @@ function createSuperDocUI(options) {
12741
12752
  },
12742
12753
  clear: () => {
12743
12754
  searchRequestGeneration += 1;
12755
+ cancelRefreshShellSearch();
12744
12756
  cancelOutstandingShellFallback();
12745
12757
  const host = getHostSearch();
12746
12758
  if (host && typeof host.clear === "function") safeCall(() => host.clear(), null);
@@ -12856,6 +12868,49 @@ function createSuperDocUI(options) {
12856
12868
  return mapHostReplaceResult(result);
12857
12869
  }
12858
12870
  };
12871
+ let searchRefreshTimer = null;
12872
+ scheduleActiveSearchRefresh = () => {
12873
+ if (searchRefreshTimer !== null) clearTimeout(searchRefreshTimer);
12874
+ if (!searchState.open || !searchState.query) return;
12875
+ const scheduledGeneration = searchRequestGeneration;
12876
+ searchRefreshTimer = setTimeout(() => {
12877
+ searchRefreshTimer = null;
12878
+ if (disposed || scheduledGeneration !== searchRequestGeneration || !searchState.open || !searchState.query) return;
12879
+ const input = {
12880
+ query: searchState.query,
12881
+ caseSensitive: searchState.caseSensitive,
12882
+ includeDeletedText: searchState.includeDeletedText,
12883
+ regex: searchState.regex
12884
+ };
12885
+ const editSearch = getEditCommandSearch();
12886
+ const host = getHostSearch();
12887
+ if (typeof editSearch?.refresh !== "function" && typeof host?.refresh !== "function") return;
12888
+ const generation = ++searchRequestGeneration;
12889
+ cancelOutstandingShellFallback();
12890
+ if (typeof editSearch?.refresh === "function" && typeof editSearch.query === "function") {
12891
+ const capturedSearch = editSearch;
12892
+ releaseRefreshShellSearch = () => {
12893
+ capturedSearch.query({ query: "" });
12894
+ };
12895
+ }
12896
+ const result = typeof editSearch?.refresh === "function" ? safeCall(() => editSearch.refresh(input), null) : safeCall(() => host.refresh(), null);
12897
+ if (isPromiseLike(result)) {
12898
+ pendingFallbackGeneration = generation;
12899
+ Promise.resolve(result).then((resolved) => {
12900
+ if (generation !== searchRequestGeneration || disposed) return;
12901
+ pendingFallbackGeneration = null;
12902
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
12903
+ }, () => {
12904
+ if (generation !== searchRequestGeneration || disposed) return;
12905
+ pendingFallbackGeneration = null;
12906
+ setSearchState({
12907
+ available: false,
12908
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
12909
+ });
12910
+ });
12911
+ } else if (result !== null) applyHostSearchResult(result);
12912
+ }, 120);
12913
+ };
12859
12914
  const stylesSub = sliceHandle((s) => s.styles);
12860
12915
  const stylesSnap = snapshotHandle(stylesSub);
12861
12916
  const styles = {
@@ -12903,6 +12958,9 @@ function createSuperDocUI(options) {
12903
12958
  watermark.destroy();
12904
12959
  clearContentControlHighlight();
12905
12960
  disposed = true;
12961
+ if (searchRefreshTimer !== null) clearTimeout(searchRefreshTimer);
12962
+ searchRefreshTimer = null;
12963
+ cancelRefreshShellSearch();
12906
12964
  releaseSharedUiTrackedChangesCatalog(uiTrackedChangesCatalogHost, uiTrackedChangesCatalogState);
12907
12965
  if (foregroundAsyncRetryTimer) {
12908
12966
  clearTimeout(foregroundAsyncRetryTimer);
@@ -8897,6 +8897,7 @@ function createSuperDocUI(options) {
8897
8897
  syncTrackedChangeFocusFromHostReviewTarget(readHostActiveReviewTarget(readHostReviewSource()));
8898
8898
  state = computeState("initial");
8899
8899
  lastOptimisticInlineSelectionSignature = selectionInlineValueSignature(state.selection);
8900
+ let scheduleActiveSearchRefresh = () => {};
8900
8901
  const syncHostEventsSubscription = () => {
8901
8902
  const host = getEditor()?.host;
8902
8903
  const events = host?.events;
@@ -8916,6 +8917,7 @@ function createSuperDocUI(options) {
8916
8917
  const off = next.subscribe((event) => {
8917
8918
  const type = event?.type;
8918
8919
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
8920
+ if (isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0) scheduleActiveSearchRefresh();
8919
8921
  if ((type === "document:mutated" || type === "mutation:committed" && mutationCommittedEventChangedDocument(event)) && host && !dirtyHosts.has(host)) {
8920
8922
  dirtyHosts.add(host);
8921
8923
  recompute("document-dirty");
@@ -12317,6 +12319,12 @@ function createSuperDocUI(options) {
12317
12319
  * session is the one that says how to close it.
12318
12320
  */
12319
12321
  let releaseActiveSearchSession = null;
12322
+ let releaseRefreshShellSearch = null;
12323
+ const cancelRefreshShellSearch = () => {
12324
+ const release = releaseRefreshShellSearch;
12325
+ releaseRefreshShellSearch = null;
12326
+ if (release) safeCall(() => release(), null);
12327
+ };
12320
12328
  /** Release whatever session is open, then forget it. */
12321
12329
  const releaseSearchSession = () => {
12322
12330
  const release = releaseActiveSearchSession;
@@ -12348,6 +12356,7 @@ function createSuperDocUI(options) {
12348
12356
  searchRequestGeneration += 1;
12349
12357
  pendingFallbackGeneration = null;
12350
12358
  shellFallbackOutstanding = false;
12359
+ cancelRefreshShellSearch();
12351
12360
  releaseSearchSession();
12352
12361
  const available = searchIsAvailable();
12353
12362
  searchState = {
@@ -12529,6 +12538,7 @@ function createSuperDocUI(options) {
12529
12538
  },
12530
12539
  close: () => {
12531
12540
  searchRequestGeneration += 1;
12541
+ cancelRefreshShellSearch();
12532
12542
  if (releaseActiveSearchSession) releaseSearchSession();
12533
12543
  else {
12534
12544
  const host = getHostSearch();
@@ -12552,6 +12562,7 @@ function createSuperDocUI(options) {
12552
12562
  const includeDeletedText = (options?.includeTrackedDeletions ?? options?.includeDeletedText) === true;
12553
12563
  const regex = options?.regex === true;
12554
12564
  const generation = ++searchRequestGeneration;
12565
+ cancelRefreshShellSearch();
12555
12566
  cancelOutstandingShellFallback();
12556
12567
  if (!host || typeof host.setSession !== "function") {
12557
12568
  const editSearch = getEditCommandSearch();
@@ -12740,6 +12751,7 @@ function createSuperDocUI(options) {
12740
12751
  },
12741
12752
  clear: () => {
12742
12753
  searchRequestGeneration += 1;
12754
+ cancelRefreshShellSearch();
12743
12755
  cancelOutstandingShellFallback();
12744
12756
  const host = getHostSearch();
12745
12757
  if (host && typeof host.clear === "function") safeCall(() => host.clear(), null);
@@ -12855,6 +12867,49 @@ function createSuperDocUI(options) {
12855
12867
  return mapHostReplaceResult(result);
12856
12868
  }
12857
12869
  };
12870
+ let searchRefreshTimer = null;
12871
+ scheduleActiveSearchRefresh = () => {
12872
+ if (searchRefreshTimer !== null) clearTimeout(searchRefreshTimer);
12873
+ if (!searchState.open || !searchState.query) return;
12874
+ const scheduledGeneration = searchRequestGeneration;
12875
+ searchRefreshTimer = setTimeout(() => {
12876
+ searchRefreshTimer = null;
12877
+ if (disposed || scheduledGeneration !== searchRequestGeneration || !searchState.open || !searchState.query) return;
12878
+ const input = {
12879
+ query: searchState.query,
12880
+ caseSensitive: searchState.caseSensitive,
12881
+ includeDeletedText: searchState.includeDeletedText,
12882
+ regex: searchState.regex
12883
+ };
12884
+ const editSearch = getEditCommandSearch();
12885
+ const host = getHostSearch();
12886
+ if (typeof editSearch?.refresh !== "function" && typeof host?.refresh !== "function") return;
12887
+ const generation = ++searchRequestGeneration;
12888
+ cancelOutstandingShellFallback();
12889
+ if (typeof editSearch?.refresh === "function" && typeof editSearch.query === "function") {
12890
+ const capturedSearch = editSearch;
12891
+ releaseRefreshShellSearch = () => {
12892
+ capturedSearch.query({ query: "" });
12893
+ };
12894
+ }
12895
+ const result = typeof editSearch?.refresh === "function" ? safeCall(() => editSearch.refresh(input), null) : safeCall(() => host.refresh(), null);
12896
+ if (isPromiseLike(result)) {
12897
+ pendingFallbackGeneration = generation;
12898
+ Promise.resolve(result).then((resolved) => {
12899
+ if (generation !== searchRequestGeneration || disposed) return;
12900
+ pendingFallbackGeneration = null;
12901
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
12902
+ }, () => {
12903
+ if (generation !== searchRequestGeneration || disposed) return;
12904
+ pendingFallbackGeneration = null;
12905
+ setSearchState({
12906
+ available: false,
12907
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
12908
+ });
12909
+ });
12910
+ } else if (result !== null) applyHostSearchResult(result);
12911
+ }, 120);
12912
+ };
12858
12913
  const stylesSub = sliceHandle((s) => s.styles);
12859
12914
  const stylesSnap = snapshotHandle(stylesSub);
12860
12915
  const styles = {
@@ -12902,6 +12957,9 @@ function createSuperDocUI(options) {
12902
12957
  watermark.destroy();
12903
12958
  clearContentControlHighlight();
12904
12959
  disposed = true;
12960
+ if (searchRefreshTimer !== null) clearTimeout(searchRefreshTimer);
12961
+ searchRefreshTimer = null;
12962
+ cancelRefreshShellSearch();
12905
12963
  releaseSharedUiTrackedChangesCatalog(uiTrackedChangesCatalogHost, uiTrackedChangesCatalogState);
12906
12964
  if (foregroundAsyncRetryTimer) {
12907
12965
  clearTimeout(foregroundAsyncRetryTimer);