superdoc 2.28.0-next.9 → 2.28.0

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 (64) hide show
  1. package/dist/chunks/{FindReplaceSurface-8V8AjgR4.cjs → FindReplaceSurface-BRs3JrCq.cjs} +1 -1
  2. package/dist/chunks/{FindReplaceSurface-RUiTFDt3.es.js → FindReplaceSurface-Dm043CZP.es.js} +1 -1
  3. package/dist/chunks/{PasswordPromptSurface-B5DHV6qr.cjs → PasswordPromptSurface-BpqP4pUa.cjs} +1 -1
  4. package/dist/chunks/{PasswordPromptSurface-BDpxqdzp.es.js → PasswordPromptSurface-DGjmN7A-.es.js} +1 -1
  5. package/dist/chunks/{PdfViewer-omriDChK.cjs → PdfViewer-Cg072l5d.cjs} +1 -1
  6. package/dist/chunks/{PdfViewer-DjdsIh6n.es.js → PdfViewer-JHXZQZ9x.es.js} +1 -1
  7. package/dist/chunks/{_plugin-vue_export-helper-BUdjGKyl.cjs → _plugin-vue_export-helper-6MBoygIY.cjs} +9 -0
  8. package/dist/chunks/{_plugin-vue_export-helper-7ZiLY07t.es.js → _plugin-vue_export-helper-CsJQtMvr.es.js} +4 -1
  9. package/dist/chunks/{create-super-doc-ui-C4Ka5Ph3.es.js → create-super-doc-ui-BbjHD1ul.es.js} +184 -28
  10. package/dist/chunks/{create-super-doc-ui-B4c55pFy.cjs → create-super-doc-ui-BfgYblyI.cjs} +195 -27
  11. package/dist/collaboration-upgrade-engine.cjs +1 -1
  12. package/dist/collaboration-upgrade-engine.es.js +1 -1
  13. package/dist/document-api/src/contract/operation-definitions.d.ts +2 -2
  14. package/dist/document-api/src/lists/lists.types.d.ts +1 -0
  15. package/dist/document-api/src/sections/sections.types.d.ts +5 -1
  16. package/dist/document-api/src/types/clipboard.d.ts +5 -1
  17. package/dist/document-api/src/types/receipt.d.ts +2 -1
  18. package/dist/layout-engine/contracts/src/index.d.ts +5 -1
  19. package/dist/layout-engine/contracts/src/run-helpers.d.ts +1 -0
  20. package/dist/layout-engine/layout-bridge/src/index.d.ts +1 -0
  21. package/dist/layout-engine/layout-bridge/src/place-inline-drawings.d.ts +9 -0
  22. package/dist/layout-engine/layout-engine/src/layout-drawing.d.ts +2 -1
  23. package/dist/layout-engine/layout-engine/src/paginator.d.ts +1 -0
  24. package/dist/layout-engine/style-engine/src/ooxml/index.d.ts +1 -1
  25. package/dist/public/ui-react.cjs +1 -1
  26. package/dist/public/ui-react.es.js +1 -1
  27. package/dist/public/ui-vue.cjs +1 -1
  28. package/dist/public/ui-vue.es.js +1 -1
  29. package/dist/public/ui.cjs +3 -2
  30. package/dist/public/ui.es.js +3 -2
  31. package/dist/shared/font-system/src/resolver.d.ts +3 -3
  32. package/dist/style.css +1 -1
  33. package/dist/style.layered.css +1 -1
  34. package/dist/superdoc/src/components/CommentsLayer/FloatingComments.vue.d.ts +11 -0
  35. package/dist/superdoc/src/components/CommentsLayer/PdfCommentsLayer.vue.d.ts +4 -0
  36. package/dist/superdoc/src/composables/use-high-contrast-mode.d.ts +8 -4
  37. package/dist/superdoc/src/composables/use-superdoc-instance.d.ts +7 -0
  38. package/dist/superdoc/src/core/SuperDoc.d.ts +1 -5
  39. package/dist/superdoc/src/core/collaboration/helpers.d.ts +0 -5
  40. package/dist/superdoc/src/core/collaboration/resolve-v2-collaboration-target.d.ts +2 -1
  41. package/dist/superdoc/src/core/create-app.d.ts +2 -6
  42. package/dist/superdoc/src/core/editor-runtime/types.d.ts +2 -0
  43. package/dist/superdoc/src/core/editor-runtime/v2/v2-editor-runtime-adapter.d.ts +2 -0
  44. package/dist/superdoc/src/core/types/index.d.ts +1 -0
  45. package/dist/superdoc/src/core/v2-integration/internal-vue-runtime.d.ts +1 -0
  46. package/dist/superdoc/src/core/v2-integration/v2-integration.d.ts +104 -84
  47. package/dist/superdoc/src/helpers/v2-review-mutation-impact.d.ts +2 -0
  48. package/dist/superdoc/src/internal/diagnostics/translate-diagnostic.d.ts +5 -0
  49. package/dist/superdoc/src/internal/toolbar/built-in/constants.d.ts +0 -48
  50. package/dist/superdoc/src/internal/toolbar/built-in-toolbar.d.ts +4 -1
  51. package/dist/superdoc/src/internal/toolbar/compatibility-catalog.d.ts +16 -0
  52. package/dist/superdoc/src/public/ui/types.d.ts +39 -1
  53. package/dist/superdoc/src/public/ui.d.cts +12 -0
  54. package/dist/superdoc/src/public/ui.d.ts +1 -1
  55. package/dist/superdoc/src/stores/comments-store.d.ts +7 -97
  56. package/dist/superdoc/src/stores/superdoc-store.d.ts +21 -291
  57. package/dist/superdoc.cjs +262 -1462
  58. package/dist/superdoc.es.js +538 -12833
  59. package/dist-cdn/style.layered.css +1 -1
  60. package/dist-cdn/superdoc.min.css +1 -1
  61. package/dist-cdn/superdoc.min.js +42 -42
  62. package/package.json +4 -3
  63. package/dist/superdoc/src/core/collaboration/collaboration.d.ts +0 -18
  64. package/dist/superdoc/src/helpers/group-changes.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-BUdjGKyl.cjs");
1
+ const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-6MBoygIY.cjs");
2
2
  //#region src/components/surfaces/FindReplaceSurface.vue
3
3
  var _hoisted_1 = ["onKeydown"];
4
4
  var _hoisted_2 = { class: "sd-find-replace__row" };
@@ -1,4 +1,4 @@
1
- import { D as normalizeClass, F as openBlock, N as onMounted, R as ref, W as toDisplayString, a as computed, c as createCommentVNode, it as withModifiers, l as createElementBlock, rt as withKeys, t as _plugin_vue_export_helper_default, u as createElementVNode } from "./_plugin-vue_export-helper-7ZiLY07t.es.js";
1
+ import { D as normalizeClass, F as openBlock, G as toDisplayString, N as onMounted, a as computed, at as withModifiers, c as createCommentVNode, it as withKeys, l as createElementBlock, t as _plugin_vue_export_helper_default, u as createElementVNode, z as ref } from "./_plugin-vue_export-helper-CsJQtMvr.es.js";
2
2
  //#region src/components/surfaces/FindReplaceSurface.vue
3
3
  var _hoisted_1 = ["onKeydown"];
4
4
  var _hoisted_2 = { class: "sd-find-replace__row" };
@@ -1,4 +1,4 @@
1
- const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-BUdjGKyl.cjs");
1
+ const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-6MBoygIY.cjs");
2
2
  //#region src/components/surfaces/PasswordPromptSurface.vue
3
3
  var _hoisted_1 = ["onKeydown"];
4
4
  var _hoisted_2 = ["id"];
@@ -1,4 +1,4 @@
1
- import { $ as vModelText, F as openBlock, R as ref, W as toDisplayString, a as computed, c as createCommentVNode, it as withModifiers, l as createElementBlock, nt as withDirectives, rt as withKeys, t as _plugin_vue_export_helper_default, u as createElementVNode } from "./_plugin-vue_export-helper-7ZiLY07t.es.js";
1
+ import { F as openBlock, G as toDisplayString, a as computed, at as withModifiers, c as createCommentVNode, et as vModelText, it as withKeys, l as createElementBlock, rt as withDirectives, t as _plugin_vue_export_helper_default, u as createElementVNode, z as ref } from "./_plugin-vue_export-helper-CsJQtMvr.es.js";
2
2
  //#region src/components/surfaces/PasswordPromptSurface.vue
3
3
  var _hoisted_1 = ["onKeydown"];
4
4
  var _hoisted_2 = ["id"];
@@ -1,4 +1,4 @@
1
- const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-BUdjGKyl.cjs");
1
+ const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-6MBoygIY.cjs");
2
2
  const require_constants = require("./constants-DpXuDx_g.cjs");
3
3
  //#region src/core/pdf/helpers/floor.js
4
4
  var floor = (val, precision) => {
@@ -1,4 +1,4 @@
1
- import { F as openBlock, N as onMounted, R as ref, T as mergeProps, U as shallowRef, a as computed, c as createCommentVNode, et as watch, j as onBeforeUnmount, k as normalizeStyle, l as createElementBlock, n as Fragment, p as createVNode, s as createBlock, t as _plugin_vue_export_helper_default, u as createElementVNode, w as markRaw, z as renderList } from "./_plugin-vue_export-helper-7ZiLY07t.es.js";
1
+ import { B as renderList, F as openBlock, N as onMounted, T as mergeProps, W as shallowRef, a as computed, c as createCommentVNode, j as onBeforeUnmount, k as normalizeStyle, l as createElementBlock, n as Fragment, p as createVNode, s as createBlock, t as _plugin_vue_export_helper_default, tt as watch, u as createElementVNode, w as markRaw, z as ref } from "./_plugin-vue_export-helper-CsJQtMvr.es.js";
2
2
  import { t as PDF_TO_CSS_UNITS } from "./constants-B6VBlmKp.es.js";
3
3
  //#region src/core/pdf/helpers/floor.js
4
4
  var floor = (val, precision) => {
@@ -146,6 +146,9 @@ function provide(...args) {
146
146
  function reactive(...args) {
147
147
  return runtime().reactive(...args);
148
148
  }
149
+ function readonly(...args) {
150
+ return runtime().readonly(...args);
151
+ }
149
152
  function ref(...args) {
150
153
  return runtime().ref(...args);
151
154
  }
@@ -433,6 +436,12 @@ Object.defineProperty(exports, "reactive", {
433
436
  return reactive;
434
437
  }
435
438
  });
439
+ Object.defineProperty(exports, "readonly", {
440
+ enumerable: true,
441
+ get: function() {
442
+ return readonly;
443
+ }
444
+ });
436
445
  Object.defineProperty(exports, "ref", {
437
446
  enumerable: true,
438
447
  get: function() {
@@ -146,6 +146,9 @@ function provide(...args) {
146
146
  function reactive(...args) {
147
147
  return runtime().reactive(...args);
148
148
  }
149
+ function readonly(...args) {
150
+ return runtime().readonly(...args);
151
+ }
149
152
  function ref(...args) {
150
153
  return runtime().ref(...args);
151
154
  }
@@ -211,4 +214,4 @@ var _plugin_vue_export_helper_default = (sfc, props) => {
211
214
  return target;
212
215
  };
213
216
  //#endregion
214
- export { vModelText as $, onActivated as A, renderSlot as B, isRef as C, normalizeClass as D, nextTick as E, openBlock as F, toRaw as G, resolveDynamicComponent as H, provide as I, unref as J, toRef as K, reactive as L, onDeactivated as M, onMounted as N, normalizeProps as O, onScopeDispose as P, vModelSelect as Q, ref as R, isReactive as S, mergeProps as T, shallowRef as U, resolveDirective as V, toDisplayString as W, useSlots as X, useAttrs as Y, vModelCheckbox as Z, getCurrentInstance as _, computed as a, hasInjectionContext as b, createCommentVNode as c, createStaticVNode as d, watch as et, createTextVNode as f, effectScope as g, defineComponent as h, Transition as i, withModifiers as it, onBeforeUnmount as j, normalizeStyle as k, createElementBlock as l, defineAsyncComponent as m, Fragment as n, withDirectives as nt, createApp as o, createVNode as p, toRefs as q, Teleport as r, withKeys as rt, createBlock as s, _plugin_vue_export_helper_default as t, withCtx as tt, createElementVNode as u, getCurrentScope as v, markRaw as w, inject as x, h as y, renderList as z };
217
+ export { vModelSelect as $, onActivated as A, renderList as B, isRef as C, normalizeClass as D, nextTick as E, openBlock as F, toDisplayString as G, resolveDirective as H, provide as I, toRefs as J, toRaw as K, reactive as L, onDeactivated as M, onMounted as N, normalizeProps as O, onScopeDispose as P, vModelCheckbox as Q, readonly as R, isReactive as S, mergeProps as T, resolveDynamicComponent as U, renderSlot as V, shallowRef as W, useAttrs as X, unref as Y, useSlots as Z, getCurrentInstance as _, computed as a, withModifiers as at, hasInjectionContext as b, createCommentVNode as c, createStaticVNode as d, vModelText as et, createTextVNode as f, effectScope as g, defineComponent as h, Transition as i, withKeys as it, onBeforeUnmount as j, normalizeStyle as k, createElementBlock as l, defineAsyncComponent as m, Fragment as n, withCtx as nt, createApp as o, createVNode as p, toRef as q, Teleport as r, withDirectives as rt, createBlock as s, _plugin_vue_export_helper_default as t, watch as tt, createElementVNode as u, getCurrentScope as v, markRaw as w, inject as x, h as y, ref as z };
@@ -1,4 +1,4 @@
1
- import { D as normalizeClass, E as nextTick, F as openBlock, J as unref, N as onMounted, R as ref, U as shallowRef, W as toDisplayString, a as computed, c as createCommentVNode, et as watch, f as createTextVNode, h as defineComponent, it as withModifiers, j as onBeforeUnmount, l as createElementBlock, n as Fragment, t as _plugin_vue_export_helper_default, u as createElementVNode, z as renderList } from "./_plugin-vue_export-helper-7ZiLY07t.es.js";
1
+ import { B as renderList, D as normalizeClass, E as nextTick, F as openBlock, G as toDisplayString, N as onMounted, W as shallowRef, Y as unref, a as computed, at as withModifiers, c as createCommentVNode, f as createTextVNode, h as defineComponent, j as onBeforeUnmount, l as createElementBlock, n as Fragment, t as _plugin_vue_export_helper_default, tt as watch, u as createElementVNode, z as ref } from "./_plugin-vue_export-helper-CsJQtMvr.es.js";
2
2
  //#region src/internal/diagnostics/workflow-recording.ts
3
3
  var fields$1 = /* @__PURE__ */ new Set([
4
4
  "documentId",
@@ -1087,6 +1087,15 @@ function isSyntheticTrackedChangeCommentLaneItem(item) {
1087
1087
  return typeof itemId === "string" && itemId.startsWith(TRACKED_CHANGE_COMMENT_LANE_ID_PREFIX);
1088
1088
  }
1089
1089
  //#endregion
1090
+ //#region src/helpers/object-guards.js
1091
+ /**
1092
+ * @param {unknown} value
1093
+ * @returns {value is Record<string, unknown>}
1094
+ */
1095
+ function isPlainObject(value) {
1096
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1097
+ }
1098
+ //#endregion
1090
1099
  //#region src/public/ui/viewport-batch.ts
1091
1100
  /** No rendering or scrolling: read only geometry already acknowledged by the host. */
1092
1101
  async function readViewportBatch(input, read, generation, disposed) {
@@ -2640,16 +2649,17 @@ function selectionKey(selection) {
2640
2649
  }
2641
2650
  }
2642
2651
  //#endregion
2643
- //#region src/helpers/object-guards.js
2644
- /**
2645
- * @param {unknown} value
2646
- * @returns {value is Record<string, unknown>}
2647
- */
2648
- function isPlainObject(value) {
2649
- return typeof value === "object" && value !== null && !Array.isArray(value);
2650
- }
2651
- //#endregion
2652
2652
  //#region src/helpers/v2-review-mutation-impact.ts
2653
+ function mutationCommittedEventChangedVisibleContent(event) {
2654
+ if (event.dryRun === true) return false;
2655
+ if (isPlainObject(event.result) && event.result.noop === true) return false;
2656
+ const receipt = isPlainObject(event.receipt) ? event.receipt : null;
2657
+ if (receipt?.changed === false || receipt?.noop === true || receipt?.status === "NO_OP") return false;
2658
+ return true;
2659
+ }
2660
+ function mutationCommittedEventChangedDocument(event) {
2661
+ return event.cause !== "preview" && mutationCommittedEventChangedVisibleContent(event);
2662
+ }
2653
2663
  /**
2654
2664
  * Classify the tracked-change identities carried by a v2 mutation event.
2655
2665
  *
@@ -5762,17 +5772,42 @@ function commandResultFromOperationResult(result) {
5762
5772
  function isSuccessfulReceipt(result) {
5763
5773
  return Boolean(result) && typeof result === "object" && result.success === true;
5764
5774
  }
5765
- /**
5766
- * The host also emits `mutation:committed` for previews and no-op receipts;
5767
- * those events must not mark the document as having unsaved edits.
5768
- */
5769
- function mutationCommittedEventChangedDocument(event) {
5770
- if (event.dryRun === true) return false;
5771
- const receipt = event.receipt;
5772
- if (receipt && typeof receipt === "object" && receipt.changed === false) return false;
5773
- if (receipt && typeof receipt === "object" && receipt.noop === true) return false;
5774
- if (receipt && typeof receipt === "object" && receipt.status === "NO_OP") return false;
5775
- return true;
5775
+ function readTxId(value) {
5776
+ return typeof value === "string" && value.length > 0 ? value : null;
5777
+ }
5778
+ function documentChangeScope(stories) {
5779
+ return Array.isArray(stories) && stories.length > 0 ? {
5780
+ kind: "known",
5781
+ stories
5782
+ } : { kind: "unknown" };
5783
+ }
5784
+ function documentChangeFromHostEvent(event) {
5785
+ if (event.type === "collaboration:remote-changed") return {
5786
+ cause: "remote",
5787
+ changeTag: null,
5788
+ txId: null,
5789
+ scope: { kind: "unknown" }
5790
+ };
5791
+ if (event.type !== "mutation:committed") return null;
5792
+ if (event.origin === "history") {
5793
+ const result = isPlainObject(event.result) ? event.result : null;
5794
+ if (!result || result.noop === true) return null;
5795
+ const history = isPlainObject(result.history) ? result.history : null;
5796
+ return {
5797
+ cause: event.direction === "redo" ? "redo" : "undo",
5798
+ changeTag: null,
5799
+ txId: readTxId(history?.txId),
5800
+ scope: documentChangeScope(result.affectedStories)
5801
+ };
5802
+ }
5803
+ if (!mutationCommittedEventChangedDocument(event)) return null;
5804
+ const receipt = isPlainObject(event.receipt) ? event.receipt : {};
5805
+ return {
5806
+ cause: event.cause === "user" ? "user" : "api",
5807
+ changeTag: typeof receipt.changeTag === "string" ? receipt.changeTag : null,
5808
+ txId: readTxId(receipt.txId),
5809
+ scope: documentChangeScope(receipt.affectedStories)
5810
+ };
5776
5811
  }
5777
5812
  function commandResultSucceeded(result) {
5778
5813
  if (result === false) return false;
@@ -6681,9 +6716,19 @@ function createSuperDocUI(options) {
6681
6716
  if (seeded > 0) dirtyHosts.add(host);
6682
6717
  else if (revision === 0) dirtyHosts.delete(host);
6683
6718
  };
6684
- const hasLocalDocumentMutation = () => {
6719
+ const savedPoint = () => {
6685
6720
  const host = getHost();
6721
+ return {
6722
+ host,
6723
+ isDirty: hostMethod(host, "isDirty"),
6724
+ getDocumentVersion: hostMethod(host, "getDocumentVersion"),
6725
+ markSaved: hostMethod(host, "markSaved")
6726
+ };
6727
+ };
6728
+ const hasLocalDocumentMutation = () => {
6729
+ const { host, isDirty } = savedPoint();
6686
6730
  if (!host) return false;
6731
+ if (isDirty) return Boolean(safeCall(() => isDirty(), false));
6687
6732
  seedLocalDocumentMutation(host);
6688
6733
  return dirtyHosts.has(host);
6689
6734
  };
@@ -8094,6 +8139,33 @@ function createSuperDocUI(options) {
8094
8139
  sizeOptions: DEFAULT_FONT_SIZE_OPTIONS
8095
8140
  };
8096
8141
  };
8142
+ const EMPTY_HISTORY = {
8143
+ canUndo: false,
8144
+ canRedo: false,
8145
+ undoDepth: 0,
8146
+ redoDepth: 0
8147
+ };
8148
+ let historySlice = EMPTY_HISTORY;
8149
+ let historySource = null;
8150
+ const computeHistory = () => {
8151
+ const source = getEditCommands();
8152
+ if (source !== historySource) {
8153
+ historySource = source;
8154
+ historySlice = EMPTY_HISTORY;
8155
+ }
8156
+ const getSnapshot = hostMethod(source, "getSnapshot");
8157
+ const snapshot = getSnapshot ? safeCall(() => getSnapshot(), null) : null;
8158
+ const { undoDepth, redoDepth } = (isPlainObject(snapshot) && isPlainObject(snapshot.history) ? snapshot.history : null) ?? {};
8159
+ if (typeof undoDepth !== "number" || typeof redoDepth !== "number") return historySlice;
8160
+ const next = {
8161
+ canUndo: undoDepth > 0,
8162
+ canRedo: redoDepth > 0,
8163
+ undoDepth,
8164
+ redoDepth
8165
+ };
8166
+ if (!shallowEqual(next, historySlice)) historySlice = next;
8167
+ return historySlice;
8168
+ };
8097
8169
  let zoomFitWidth;
8098
8170
  const computeZoom = () => {
8099
8171
  const getZoomState = hostMethod(superdoc, "getZoomState");
@@ -9906,6 +9978,7 @@ function createSuperDocUI(options) {
9906
9978
  trackChanges: measure("trackChanges", () => computeTrackChanges(selection)),
9907
9979
  contentControls: measure("contentControls", () => computeContentControls(selection)),
9908
9980
  zoom: measure("zoom", computeZoom),
9981
+ history: measure("history", computeHistory),
9909
9982
  fonts: measure("fonts", computeFonts),
9910
9983
  styles: measure("styles", () => computeStyles(selection))
9911
9984
  };
@@ -10195,6 +10268,41 @@ function createSuperDocUI(options) {
10195
10268
  state = computeState("initial");
10196
10269
  lastOptimisticInlineSelectionSignature = selectionInlineValueSignature(state.selection);
10197
10270
  let scheduleActiveSearchRefresh = () => {};
10271
+ const documentChangeListeners = /* @__PURE__ */ new Set();
10272
+ const documentChangeCounters = /* @__PURE__ */ new WeakMap();
10273
+ let documentEpochCount = 0;
10274
+ const readDocumentReplacement = (host) => safeCall(() => hostMethod(host, "getDocumentReplacementVersion")?.(), null);
10275
+ const startDocumentChangeEpoch = (host) => {
10276
+ documentEpochCount += 1;
10277
+ const counter = {
10278
+ epoch: `document-${documentEpochCount}`,
10279
+ seq: 0,
10280
+ replacement: readDocumentReplacement(host)
10281
+ };
10282
+ documentChangeCounters.set(host, counter);
10283
+ return counter;
10284
+ };
10285
+ const currentDocumentChangeCounter = (host) => {
10286
+ const counter = documentChangeCounters.get(host);
10287
+ return counter && counter.replacement === readDocumentReplacement(host) ? counter : startDocumentChangeEpoch(host);
10288
+ };
10289
+ const publishDocumentChange = (host, event) => {
10290
+ if (event.type === "collaboration:document-replaced" || event.documentReplaced === true) {
10291
+ startDocumentChangeEpoch(host);
10292
+ return;
10293
+ }
10294
+ if (documentChangeListeners.size === 0) return;
10295
+ const facts = documentChangeFromHostEvent(event);
10296
+ if (!facts) return;
10297
+ const counter = currentDocumentChangeCounter(host);
10298
+ counter.seq += 1;
10299
+ const change = {
10300
+ documentEpoch: counter.epoch,
10301
+ seq: counter.seq,
10302
+ ...facts
10303
+ };
10304
+ for (const listener of Array.from(documentChangeListeners)) safeCall(() => listener(change), void 0);
10305
+ };
10198
10306
  const syncHostEventsSubscription = () => {
10199
10307
  const host = getEditor()?.host;
10200
10308
  const events = host?.events;
@@ -10213,15 +10321,19 @@ function createSuperDocUI(options) {
10213
10321
  try {
10214
10322
  const off = hostMethod(next, "subscribe")?.((event) => {
10215
10323
  const type = event?.type;
10324
+ if (host) publishDocumentChange(host, event);
10216
10325
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
10217
- if (type === "collaboration:document-replaced" || isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed") {
10326
+ if (type === "collaboration:document-replaced" || isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedVisibleContent(event) || type === "collaboration:remote-changed") {
10218
10327
  for (const [commandId, optimistic] of optimisticInlineToggles) if (optimistic.settled || type === "collaboration:document-replaced") optimisticInlineToggles.delete(commandId);
10219
10328
  }
10220
- if (isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0) scheduleActiveSearchRefresh();
10221
- if ((type === "document:mutated" || type === "mutation:committed" && mutationCommittedEventChangedDocument(event)) && host && !dirtyHosts.has(host)) {
10329
+ if (isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedVisibleContent(event) || type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0) scheduleActiveSearchRefresh();
10330
+ const documentEdited = type === "document:mutated" || type === "mutation:committed" && mutationCommittedEventChangedDocument(event);
10331
+ if (documentEdited && host && hostMethod(host, "isDirty")) recompute("document-dirty");
10332
+ else if (documentEdited && host && !dirtyHosts.has(host)) {
10222
10333
  dirtyHosts.add(host);
10223
10334
  recompute("document-dirty");
10224
10335
  }
10336
+ if (type === "document:saved-point-changed") recompute("document-dirty");
10225
10337
  if (type === "collaboration:document-replaced" && host) {
10226
10338
  dirtyHosts.delete(host);
10227
10339
  hostSeededMutationRevision.delete(host);
@@ -10253,6 +10365,7 @@ function createSuperDocUI(options) {
10253
10365
  if (impact?.allResolved) {
10254
10366
  replaceTrackedChangeItemsInCache([]);
10255
10367
  publishAllTrackedChangesResolved(event.receipt);
10368
+ if (event.cause === "preview") invalidateDocumentContent();
10256
10369
  return;
10257
10370
  }
10258
10371
  if (impact?.removedIds.size) markPostDecisionTrackChanges(new Set(impact.removedIds), event.receipt);
@@ -10262,7 +10375,10 @@ function createSuperDocUI(options) {
10262
10375
  scheduleTypingDocumentContentInvalidation();
10263
10376
  return;
10264
10377
  }
10265
- if (impact?.removedIds.size && impact.upsertIds.size === 0) return;
10378
+ if (impact?.removedIds.size && impact.upsertIds.size === 0) {
10379
+ if (event.cause === "preview") invalidateDocumentContent();
10380
+ return;
10381
+ }
10266
10382
  if (isStandaloneDocumentMutation || type === "collaboration:remote-changed" || type === "mutation:committed" && !isTypingBurst) schedulePostPaintContentRefresh();
10267
10383
  const remoteCommentsPartChanged = type === "collaboration:remote-changed" && Array.isArray(event.changedPartUris) && event.changedPartUris.some((partUri) => typeof partUri === "string" && COMMENTS_CATALOG_PART_URIS.has(partUri));
10268
10384
  const loadedCommentAnchorsMayHaveChanged = type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0 && commentsCatalogMayHaveRows();
@@ -12160,6 +12276,12 @@ function createSuperDocUI(options) {
12160
12276
  keys: [...EFFECTIVE_INLINE_UNIFORMITY_KEYS, "highlight"],
12161
12277
  includeCaret: true
12162
12278
  } : null);
12279
+ if (effective?.fontFamily?.state === "mixed") {
12280
+ delete inlinePatch.fontFamily;
12281
+ delete inlinePatch.rFonts;
12282
+ mixedInlineKeys.add("fontFamily");
12283
+ mixedInlineKeys.add("rFonts");
12284
+ }
12163
12285
  for (const [markName, patchKey] of Object.entries(MARK_TO_PATCH)) {
12164
12286
  const entry = effective?.[markName];
12165
12287
  if (!entry) continue;
@@ -12353,7 +12475,11 @@ function createSuperDocUI(options) {
12353
12475
  const node = (await readBlockNode(paragraphTarget(segment.blockId, targetStory)))?.node;
12354
12476
  const para = node ? getParagraphLikeData(node) : null;
12355
12477
  const runs = Array.isArray(para?.inlines) ? para.inlines : [];
12356
- for (const props of sliceRunProps(runs, segment.range)) for (const key of Object.keys(sdRunPropsToInlineRunPatch(props))) if (!(key in inline) && !snap.mixedInlineKeys.includes(key)) inline[key] = FORMAT_PAINTER_BOOLEAN_KEYS.has(key) ? false : null;
12478
+ for (const props of sliceRunProps(runs, segment.range)) for (const key of Object.keys(sdRunPropsToInlineRunPatch(props))) {
12479
+ const fontAlias = key === "rFonts" ? "fontFamily" : key === "fontFamily" ? "rFonts" : null;
12480
+ const capturedFontAlias = fontAlias && (fontAlias in inline || snap.mixedInlineKeys.includes(fontAlias));
12481
+ if (!(key in inline) && !snap.mixedInlineKeys.includes(key) && !capturedFontAlias) inline[key] = FORMAT_PAINTER_BOOLEAN_KEYS.has(key) ? false : null;
12482
+ }
12357
12483
  }
12358
12484
  if (disposed || painter.snapshot !== snap || getEditor() !== ownerEditor || ownerEditor?.doc !== ownerDoc || readDocumentMode() !== ownerMode) return;
12359
12485
  }
@@ -13694,6 +13820,7 @@ function createSuperDocUI(options) {
13694
13820
  getFamilyOptions: () => state.fonts.options,
13695
13821
  getSizeOptions: () => state.fonts.sizeOptions
13696
13822
  };
13823
+ const history = snapshotHandle(sliceHandle((s) => s.history));
13697
13824
  const zoomSnap = snapshotHandle(sliceHandle((s) => s.zoom));
13698
13825
  const zoom = {
13699
13826
  get: zoomSnap.get,
@@ -13754,6 +13881,28 @@ function createSuperDocUI(options) {
13754
13881
  } catch {
13755
13882
  return;
13756
13883
  }
13884
+ },
13885
+ onChange: (listener) => {
13886
+ if (disposed) return () => {};
13887
+ documentChangeListeners.add(listener);
13888
+ return () => documentChangeListeners.delete(listener);
13889
+ },
13890
+ getVersion: () => {
13891
+ const { getDocumentVersion } = savedPoint();
13892
+ const version = getDocumentVersion ? safeCall(() => getDocumentVersion(), null) : null;
13893
+ return typeof version === "string" ? version : null;
13894
+ },
13895
+ markClean: (version) => {
13896
+ const { markSaved } = savedPoint();
13897
+ if (!markSaved) return {
13898
+ ok: false,
13899
+ reason: "unavailable"
13900
+ };
13901
+ const result = safeCall(() => markSaved(version), null);
13902
+ return isPlainObject(result) && result.ok === true ? { ok: true } : {
13903
+ ok: false,
13904
+ reason: isPlainObject(result) && result.reason === "document-changed" ? "document-changed" : "unavailable"
13905
+ };
13757
13906
  }
13758
13907
  };
13759
13908
  const resolveVisibleHost = () => {
@@ -15236,6 +15385,11 @@ function createSuperDocUI(options) {
15236
15385
  const scopeUnsubs = [];
15237
15386
  return {
15238
15387
  decorations: createDecorationsHandle((handle) => scopeUnsubs.push(() => handle.dispose())),
15388
+ document: { onChange: (listener) => {
15389
+ const unsub = documentHandle.onChange(listener);
15390
+ scopeUnsubs.push(unsub);
15391
+ return unsub;
15392
+ } },
15239
15393
  select: (selector, equality) => {
15240
15394
  const sub = select(selector, equality);
15241
15395
  return {
@@ -15322,6 +15476,7 @@ function createSuperDocUI(options) {
15322
15476
  painterCaptureEpoch += 1;
15323
15477
  painterCommandDoc = null;
15324
15478
  painterModeListeners.clear();
15479
+ documentChangeListeners.clear();
15325
15480
  searchRequestGeneration += 1;
15326
15481
  customCommands.clear();
15327
15482
  };
@@ -15339,6 +15494,7 @@ function createSuperDocUI(options) {
15339
15494
  bookmarks,
15340
15495
  fonts,
15341
15496
  zoom,
15497
+ history,
15342
15498
  document: documentHandle,
15343
15499
  viewport,
15344
15500
  decorations,
@@ -15560,4 +15716,4 @@ function commandIsActive(descriptor, selection) {
15560
15716
  return descriptor.activeMark ? selection.activeMarks.includes(descriptor.activeMark) : false;
15561
15717
  }
15562
15718
  //#endregion
15563
- export { createInteractionHistory as _, registerFirstPartyCommandMutation as a, recordInteraction as b, applyV2CommentInvalidationFromMutation as c, createImageFilePicker as d, resolveImageSrc as f, closeInteractionHistory as g, DOM_CLASS_NAMES as h, readFirstPartyPageNumbers as i, getV2TrackedChangeMutationImpact as l, isSyntheticTrackedChangeCommentLaneItem as m, executeFirstPartyCommandAsync as n, isRecord as o, shallowEqual as p, executeFirstPartyShortcutAsync as r, BUILT_IN_COMMAND_IDS as s, createSuperDocUI as t, isPlainObject as u, getWorkflowRecording as v, isWorkflowRecordingEnabled as y };
15719
+ export { recordInteraction as S, DOM_CLASS_NAMES as _, registerFirstPartyCommandMutation as a, getWorkflowRecording as b, getCommandDescriptor as c, mutationCommittedEventChangedDocument as d, createImageFilePicker as f, isSyntheticTrackedChangeCommentLaneItem as g, isPlainObject as h, readFirstPartyPageNumbers as i, applyV2CommentInvalidationFromMutation as l, shallowEqual as m, executeFirstPartyCommandAsync as n, isRecord as o, resolveImageSrc as p, executeFirstPartyShortcutAsync as r, BUILT_IN_COMMAND_IDS as s, createSuperDocUI as t, getV2TrackedChangeMutationImpact as u, closeInteractionHistory as v, isWorkflowRecordingEnabled as x, createInteractionHistory as y };