superdoc 2.29.0-next.13 → 2.29.0-next.17

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 (67) hide show
  1. package/dist/chunks/{FindReplaceSurface-BKVHzhQ4.es.js → FindReplaceSurface-B_5ggdWg.es.js} +1 -1
  2. package/dist/chunks/{FindReplaceSurface-BNDrJ6VS.cjs → FindReplaceSurface-fVHxPXtn.cjs} +1 -1
  3. package/dist/chunks/{PasswordPromptSurface-6mF6Azda.es.js → PasswordPromptSurface-CZqhDQQ1.es.js} +1 -1
  4. package/dist/chunks/{PasswordPromptSurface-BNkaztaP.cjs → PasswordPromptSurface-x8GNmMJT.cjs} +1 -1
  5. package/dist/chunks/{PdfViewer-aOWhUVI7.es.js → PdfViewer-CW09MNrB.es.js} +4 -10
  6. package/dist/chunks/{PdfViewer-DmSkZehl.cjs → PdfViewer-CkrAHpC-.cjs} +4 -10
  7. package/dist/chunks/{_plugin-vue_export-helper-6MBoygIY.cjs → _plugin-vue_export-helper-BkbCxNeT.cjs} +31 -7
  8. package/dist/chunks/{_plugin-vue_export-helper-CsJQtMvr.es.js → _plugin-vue_export-helper-DRPRMkeA.es.js} +20 -8
  9. package/dist/chunks/{create-super-doc-ui-DdT4b29f.es.js → create-super-doc-ui-Dc8dQAMc.es.js} +54 -77
  10. package/dist/chunks/{create-super-doc-ui-_SbygYQ4.cjs → create-super-doc-ui-L60GhVAX.cjs} +177 -206
  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/command-catalog.d.ts +1 -1
  14. package/dist/public/ui-react.cjs +1 -1
  15. package/dist/public/ui-react.es.js +1 -1
  16. package/dist/public/ui-vue.cjs +1 -1
  17. package/dist/public/ui-vue.es.js +1 -1
  18. package/dist/public/ui.cjs +1 -1
  19. package/dist/public/ui.es.js +1 -1
  20. package/dist/style.css +1 -1
  21. package/dist/style.layered.css +1 -1
  22. package/dist/superdoc/src/components/CommentsLayer/collect-removed-comment-ids.d.ts +11 -1
  23. package/dist/superdoc/src/components/CommentsLayer/collect-tracked-change-thread.d.ts +19 -2
  24. package/dist/superdoc/src/components/CommentsLayer/comment-urls.d.ts +1 -1
  25. package/dist/superdoc/src/components/CommentsLayer/commentsList/super-comments-list.d.ts +23 -20
  26. package/dist/superdoc/src/components/CommentsLayer/helpers.d.ts +1 -4
  27. package/dist/superdoc/src/components/CommentsLayer/tracked-change-threading.d.ts +16 -1
  28. package/dist/superdoc/src/components/Whiteboard/WhiteboardLayer.vue.d.ts +4 -5
  29. package/dist/superdoc/src/components/Whiteboard/WhiteboardPage.vue.d.ts +3 -4
  30. package/dist/superdoc/src/components/Whiteboard/whiteboard-types.d.ts +2 -0
  31. package/dist/superdoc/src/composables/use-find-replace.d.ts +13 -3
  32. package/dist/superdoc/src/composables/use-password-prompt.d.ts +1 -1
  33. package/dist/superdoc/src/composables/use-viewport-fit.d.ts +27 -5
  34. package/dist/superdoc/src/core/SuperDoc.d.ts +3 -3
  35. package/dist/superdoc/src/core/pdf/pdf-adapter.d.ts +6 -2
  36. package/dist/superdoc/src/core/types/index.d.ts +36 -4
  37. package/dist/superdoc/src/core/v2-integration/browser-peer-runtime.d.ts +5 -3
  38. package/dist/superdoc/src/core/v2-integration/cdn-engine-loader.d.ts +3 -13
  39. package/dist/superdoc/src/core/v2-integration/internal-vue-runtime.d.ts +64 -59
  40. package/dist/superdoc/src/helpers/object-guards.d.ts +1 -0
  41. package/dist/superdoc/src/internal/diagnostics/translate-diagnostic.d.ts +6 -4
  42. package/dist/superdoc/src/internal/toolbar/built-in/PageNumberMenu.vue.d.ts +25 -15
  43. package/dist/superdoc/src/internal/toolbar/built-in/constants.d.ts +3 -1
  44. package/dist/superdoc/src/internal/toolbar/built-in/font-options.d.ts +15 -1
  45. package/dist/superdoc/src/internal/toolbar/built-in/font-typeahead.d.ts +37 -7
  46. package/dist/superdoc/src/internal/toolbar/built-in/format-negation.d.ts +10 -4
  47. package/dist/superdoc/src/internal/toolbar/built-in/general.d.ts +12 -1
  48. package/dist/superdoc/src/internal/toolbar/built-in/helpers.d.ts +9 -4
  49. package/dist/superdoc/src/internal/toolbar/built-in/list-style-buttons.d.ts +2 -2
  50. package/dist/superdoc/src/internal/toolbar/built-in/page-number-feedback.d.ts +4 -5
  51. package/dist/superdoc/src/internal/toolbar/built-in/scroll-helpers.d.ts +3 -4
  52. package/dist/superdoc/src/internal/toolbar/built-in/toolbarIcons.d.ts +78 -145
  53. package/dist/superdoc/src/internal/toolbar/built-in/url-safety.d.ts +11 -3
  54. package/dist/superdoc/src/internal/toolbar/built-in-toolbar.d.ts +4 -3
  55. package/dist/superdoc/src/internal/toolbar/image-upload.d.ts +29 -39
  56. package/dist/superdoc/src/stores/comments-store.d.ts +7 -7
  57. package/dist/superdoc/src/stores/helpers/comment-document-scope.d.ts +22 -0
  58. package/dist/superdoc/src/stores/helpers/pending-selection-snapshot.d.ts +17 -0
  59. package/dist/superdoc/src/stores/helpers/tracked-change-compaction.d.ts +16 -0
  60. package/dist/superdoc/src/stores/helpers/tracked-change-decision.d.ts +45 -0
  61. package/dist/superdoc/src/stores/superdoc-store.d.ts +21 -21
  62. package/dist/superdoc.cjs +396 -423
  63. package/dist/superdoc.es.js +303 -330
  64. package/dist-cdn/style.layered.css +1 -1
  65. package/dist-cdn/superdoc.min.css +1 -1
  66. package/dist-cdn/superdoc.min.js +41 -41
  67. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import { D as normalizeClass, F as openBlock, G as toDisplayString, N as onMounted, a as computed, at as withModifiers, c as createCommentVNode, h as defineComponent, 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";
1
+ import { D as normalizeClass, F as openBlock, G as toDisplayString, N as onMounted, a as computed, at as withModifiers, c as createCommentVNode, h as defineComponent, it as withKeys, l as createElementBlock, t as _plugin_vue_export_helper_default, u as createElementVNode, z as ref } from "./_plugin-vue_export-helper-DRPRMkeA.es.js";
2
2
  //#region src/components/surfaces/FindReplaceSurface.vue?vue&type=script&setup=true&lang.ts
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-6MBoygIY.cjs");
1
+ const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-BkbCxNeT.cjs");
2
2
  //#region src/components/surfaces/FindReplaceSurface.vue?vue&type=script&setup=true&lang.ts
3
3
  var _hoisted_1 = ["onKeydown"];
4
4
  var _hoisted_2 = { class: "sd-find-replace__row" };
@@ -1,4 +1,4 @@
1
- import { F as openBlock, G as toDisplayString, a as computed, at as withModifiers, c as createCommentVNode, et as vModelText, h as defineComponent, 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";
1
+ import { F as openBlock, G as toDisplayString, a as computed, at as withModifiers, c as createCommentVNode, et as vModelText, h as defineComponent, 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-DRPRMkeA.es.js";
2
2
  //#region src/components/surfaces/PasswordPromptSurface.vue?vue&type=script&setup=true&lang.ts
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-6MBoygIY.cjs");
1
+ const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-BkbCxNeT.cjs");
2
2
  //#region src/components/surfaces/PasswordPromptSurface.vue?vue&type=script&setup=true&lang.ts
3
3
  var _hoisted_1 = ["onKeydown"];
4
4
  var _hoisted_2 = ["id"];
@@ -1,4 +1,4 @@
1
- import { B as renderList, F as openBlock, N as onMounted, T as mergeProps, W as shallowRef, a as computed, c as createCommentVNode, h as defineComponent, 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";
1
+ import { B as renderList, F as openBlock, N as onMounted, T as mergeProps, W as shallowRef, a as computed, c as createCommentVNode, h as defineComponent, 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-DRPRMkeA.es.js";
2
2
  import { t as isFiniteNumber } from "./is-finite-number-BpL4F38c.es.js";
3
3
  import { t as PDF_TO_CSS_UNITS } from "./constants-BvNs_ybI.es.js";
4
4
  //#region src/core/pdf/helpers/floor.ts
@@ -71,15 +71,9 @@ var PDFJSAdapter = class extends PDFAdapter {
71
71
  };
72
72
  var PDFAdapterFactory = class {
73
73
  static create(config) {
74
- const adapters = {
75
- pdfjs: () => {
76
- return new PDFJSAdapter(config);
77
- },
78
- default: () => {
79
- throw new Error("Unsupported adapter");
80
- }
81
- };
82
- return (adapters[config.adapter] ?? adapters.default)();
74
+ const adapter = (/* @__PURE__ */ new Map([["pdfjs", () => new PDFJSAdapter(config)]])).get(config.adapter);
75
+ if (!adapter) throw new Error("Unsupported adapter");
76
+ return adapter();
83
77
  }
84
78
  };
85
79
  function getWorkerSrcFromCDN(version) {
@@ -1,4 +1,4 @@
1
- const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-6MBoygIY.cjs");
1
+ const require__plugin_vue_export_helper = require("./_plugin-vue_export-helper-BkbCxNeT.cjs");
2
2
  const require_is_finite_number = require("./is-finite-number-BEXgTRgc.cjs");
3
3
  const require_constants = require("./constants-BeeNZoQp.cjs");
4
4
  //#region src/core/pdf/helpers/floor.ts
@@ -71,15 +71,9 @@ var PDFJSAdapter = class extends PDFAdapter {
71
71
  };
72
72
  var PDFAdapterFactory = class {
73
73
  static create(config) {
74
- const adapters = {
75
- pdfjs: () => {
76
- return new PDFJSAdapter(config);
77
- },
78
- default: () => {
79
- throw new Error("Unsupported adapter");
80
- }
81
- };
82
- return (adapters[config.adapter] ?? adapters.default)();
74
+ const adapter = (/* @__PURE__ */ new Map([["pdfjs", () => new PDFJSAdapter(config)]])).get(config.adapter);
75
+ if (!adapter) throw new Error("Unsupported adapter");
76
+ return adapter();
83
77
  }
84
78
  };
85
79
  function getWorkerSrcFromCDN(version) {
@@ -1,17 +1,29 @@
1
- //#region src/core/v2-integration/internal-vue-runtime.js
1
+ //#region src/helpers/object-guards.ts
2
+ function isPlainObject(value) {
3
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4
+ }
5
+ function isThenable(value) {
6
+ return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
7
+ }
8
+ //#endregion
9
+ //#region src/core/v2-integration/internal-vue-runtime.ts
2
10
  var runtimeKey = "__SUPERDOC_V2_BROWSER_RUNTIME__";
11
+ function isVueRuntime(value) {
12
+ return isPlainObject(value) && typeof value.createApp === "function";
13
+ }
3
14
  function runtime() {
4
- const vue = globalThis[runtimeKey]?.vue;
5
- if (!vue) throw new Error("SuperDoc rendering runtime is unavailable; initialize SuperDoc before rendering built-in surfaces.");
15
+ const installed = Reflect.get(globalThis, runtimeKey);
16
+ const vue = isPlainObject(installed) ? installed.vue : void 0;
17
+ if (!isVueRuntime(vue)) throw new Error("SuperDoc rendering runtime is unavailable; initialize SuperDoc before rendering built-in surfaces.");
6
18
  return vue;
7
19
  }
8
20
  function component(name) {
9
21
  return new Proxy({}, {
10
22
  get(_target, key) {
11
- return runtime()[name][key];
23
+ return Reflect.get(runtime()[name], key);
12
24
  },
13
25
  set(_target, key, value) {
14
- runtime()[name][key] = value;
26
+ Reflect.set(runtime()[name], key, value);
15
27
  return true;
16
28
  },
17
29
  has(_target, key) {
@@ -38,10 +50,10 @@ function defineComponent(options, extraOptions) {
38
50
  }
39
51
  var Transition = new Proxy((props, context) => runtime().Transition(props, context), {
40
52
  get(_target, key) {
41
- return runtime().Transition[key];
53
+ return Reflect.get(runtime().Transition, key);
42
54
  },
43
55
  set(_target, key, value) {
44
- runtime().Transition[key] = value;
56
+ Reflect.set(runtime().Transition, key, value);
45
57
  return true;
46
58
  },
47
59
  has(_target, key) {
@@ -340,6 +352,12 @@ Object.defineProperty(exports, "inject", {
340
352
  return inject;
341
353
  }
342
354
  });
355
+ Object.defineProperty(exports, "isPlainObject", {
356
+ enumerable: true,
357
+ get: function() {
358
+ return isPlainObject;
359
+ }
360
+ });
343
361
  Object.defineProperty(exports, "isReactive", {
344
362
  enumerable: true,
345
363
  get: function() {
@@ -352,6 +370,12 @@ Object.defineProperty(exports, "isRef", {
352
370
  return isRef;
353
371
  }
354
372
  });
373
+ Object.defineProperty(exports, "isThenable", {
374
+ enumerable: true,
375
+ get: function() {
376
+ return isThenable;
377
+ }
378
+ });
355
379
  Object.defineProperty(exports, "markRaw", {
356
380
  enumerable: true,
357
381
  get: function() {
@@ -1,17 +1,29 @@
1
- //#region src/core/v2-integration/internal-vue-runtime.js
1
+ //#region src/helpers/object-guards.ts
2
+ function isPlainObject(value) {
3
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4
+ }
5
+ function isThenable(value) {
6
+ return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
7
+ }
8
+ //#endregion
9
+ //#region src/core/v2-integration/internal-vue-runtime.ts
2
10
  var runtimeKey = "__SUPERDOC_V2_BROWSER_RUNTIME__";
11
+ function isVueRuntime(value) {
12
+ return isPlainObject(value) && typeof value.createApp === "function";
13
+ }
3
14
  function runtime() {
4
- const vue = globalThis[runtimeKey]?.vue;
5
- if (!vue) throw new Error("SuperDoc rendering runtime is unavailable; initialize SuperDoc before rendering built-in surfaces.");
15
+ const installed = Reflect.get(globalThis, runtimeKey);
16
+ const vue = isPlainObject(installed) ? installed.vue : void 0;
17
+ if (!isVueRuntime(vue)) throw new Error("SuperDoc rendering runtime is unavailable; initialize SuperDoc before rendering built-in surfaces.");
6
18
  return vue;
7
19
  }
8
20
  function component(name) {
9
21
  return new Proxy({}, {
10
22
  get(_target, key) {
11
- return runtime()[name][key];
23
+ return Reflect.get(runtime()[name], key);
12
24
  },
13
25
  set(_target, key, value) {
14
- runtime()[name][key] = value;
26
+ Reflect.set(runtime()[name], key, value);
15
27
  return true;
16
28
  },
17
29
  has(_target, key) {
@@ -38,10 +50,10 @@ function defineComponent(options, extraOptions) {
38
50
  }
39
51
  var Transition = new Proxy((props, context) => runtime().Transition(props, context), {
40
52
  get(_target, key) {
41
- return runtime().Transition[key];
53
+ return Reflect.get(runtime().Transition, key);
42
54
  },
43
55
  set(_target, key, value) {
44
- runtime().Transition[key] = value;
56
+ Reflect.set(runtime().Transition, key, value);
45
57
  return true;
46
58
  },
47
59
  has(_target, key) {
@@ -214,4 +226,4 @@ var _plugin_vue_export_helper_default = (sfc, props) => {
214
226
  return target;
215
227
  };
216
228
  //#endregion
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 };
229
+ 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, isPlainObject as ot, createVNode as p, toRef as q, Teleport as r, withDirectives as rt, createBlock as s, isThenable as st, _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 { 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";
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, ot as isPlainObject, t as _plugin_vue_export_helper_default, tt as watch, u as createElementVNode, z as ref } from "./_plugin-vue_export-helper-DRPRMkeA.es.js";
2
2
  import { t as isFiniteNumber } from "./is-finite-number-BpL4F38c.es.js";
3
3
  //#region src/internal/diagnostics/workflow-recording.ts
4
4
  var fields$1 = /* @__PURE__ */ new Set([
@@ -1079,11 +1079,6 @@ var decodeLayoutStoryDataset = (raw) => {
1079
1079
  `${DOM_CLASS_NAMES.BLOCK_SDT}${DATA_ATTRS.SDT_ID}`;
1080
1080
  `${DATA_ATTRS.DRAGGABLE}`;
1081
1081
  //#endregion
1082
- //#region src/helpers/object-guards.ts
1083
- function isPlainObject(value) {
1084
- return typeof value === "object" && value !== null && !Array.isArray(value);
1085
- }
1086
- //#endregion
1087
1082
  //#region src/helpers/tracked-change-comment-lane.ts
1088
1083
  var TRACKED_CHANGE_COMMENT_LANE_ID_PREFIX = "tc-comment:";
1089
1084
  function isSyntheticTrackedChangeCommentLaneItem(item) {
@@ -1304,7 +1299,7 @@ function shallowEqual(a, b) {
1304
1299
  return true;
1305
1300
  }
1306
1301
  //#endregion
1307
- //#region src/internal/toolbar/image-upload.js
1302
+ //#region src/internal/toolbar/image-upload.ts
1308
1303
  /**
1309
1304
  * Interactive image acquisition for the built-in toolbar (SD-3567).
1310
1305
  *
@@ -1325,8 +1320,6 @@ var SUPPORTED_IMAGE_EXTENSIONS = /\.(png|jpe?g)$/i;
1325
1320
  /**
1326
1321
  * Whether a picked/dropped file is an insertable image (PNG/JPEG). Falls back
1327
1322
  * to the file extension when the browser reports no MIME type.
1328
- * @param {File | null | undefined} file
1329
- * @returns {boolean}
1330
1323
  */
1331
1324
  function isSupportedImageFile(file) {
1332
1325
  if (!file) return false;
@@ -1341,8 +1334,6 @@ function isSupportedImageFile(file) {
1341
1334
  * accepts those by extension, but `readAsDataURL` would then produce an
1342
1335
  * `application/octet-stream` data URI that `create.image` rejects. Rewrite
1343
1336
  * the media type from the filename so extension-accepted files still insert.
1344
- * @param {Blob & { name?: string }} file
1345
- * @returns {Promise<string>}
1346
1337
  */
1347
1338
  function fileToDataUri(file) {
1348
1339
  return new Promise((resolve, reject) => {
@@ -1355,9 +1346,6 @@ function fileToDataUri(file) {
1355
1346
  /**
1356
1347
  * Ensure a data URI read from a supported file carries a PNG/JPEG media type.
1357
1348
  * Leaves URIs already typed as a supported image (or uninferable ones) alone.
1358
- * @param {string} dataUri
1359
- * @param {(Blob & { name?: string }) | null | undefined} file
1360
- * @returns {string}
1361
1349
  */
1362
1350
  function normalizeImageDataUri(dataUri, file) {
1363
1351
  const match = /^data:([^;,]*);base64,/.exec(dataUri);
@@ -1374,9 +1362,6 @@ function normalizeImageDataUri(dataUri, file) {
1374
1362
  * `handleImageUpload` callback when configured (V1 contract:
1375
1363
  * `(file: File) => Promise<string>`). A returned non-data URL is fetched and
1376
1364
  * embedded, because `create.image` requires an embedded base64 data URI.
1377
- * @param {File} file
1378
- * @param {((file: File) => Promise<string>) | null | undefined} handleImageUpload
1379
- * @returns {Promise<string>}
1380
1365
  */
1381
1366
  async function resolveImageSrc(file, handleImageUpload) {
1382
1367
  if (typeof handleImageUpload === "function") {
@@ -1392,9 +1377,6 @@ async function resolveImageSrc(file, handleImageUpload) {
1392
1377
  * presigned URLs often respond `application/octet-stream`, so keep a filename
1393
1378
  * hint (URL path, falling back to the originally picked file) for the media
1394
1379
  * type normalization in `fileToDataUri`.
1395
- * @param {string} url
1396
- * @param {File | null | undefined} pickedFile
1397
- * @returns {Promise<string>}
1398
1380
  */
1399
1381
  async function embedRemoteImage(url, pickedFile) {
1400
1382
  const response = await fetch(url);
@@ -1408,13 +1390,6 @@ async function embedRemoteImage(url, pickedFile) {
1408
1390
  * stays attached (hidden) so automation and tests can drive it; `destroy()`
1409
1391
  * removes it. Picking a file calls `onPick(file)`; an unsupported type or a
1410
1392
  * failed pick routes through `onError(error)`.
1411
- *
1412
- * @param {{
1413
- * ownerDocument?: Document,
1414
- * onPick?: (file: File) => unknown,
1415
- * onError?: (error: Error) => void,
1416
- * }} options
1417
- * @returns {{ input: HTMLInputElement, open: () => void, destroy: () => void }}
1418
1393
  */
1419
1394
  function createImageFilePicker({ ownerDocument = document, onPick, onError } = {}) {
1420
1395
  const input = ownerDocument.createElement("input");
@@ -7536,6 +7511,23 @@ function createSuperDocUI(options) {
7536
7511
  const clearAsyncReadKeys = (predicate) => {
7537
7512
  for (const key of asyncReads.keys()) if (predicate(key)) asyncReads.delete(key);
7538
7513
  };
7514
+ const seedAsyncRead = (key, token, value, inflightToken = null) => {
7515
+ asyncReads.set(key, {
7516
+ token,
7517
+ value,
7518
+ hasSettled: true,
7519
+ inflightToken
7520
+ });
7521
+ };
7522
+ const selectionValidationSnapshot = () => ({
7523
+ held: typedCaretValidationHeld,
7524
+ pendingToken: pendingSelectionSeedValidationToken
7525
+ });
7526
+ const setSelectionValidation = (next) => {
7527
+ typedCaretValidationHeld = next.held;
7528
+ pendingSelectionSeedValidationToken = next.pendingToken;
7529
+ };
7530
+ const typingIsRecent = () => Date.now() - lastTypingMutationAtMs < HEAVY_READ_IDLE_MS;
7539
7531
  const selectionScopedAsyncReadKeys = (selection) => {
7540
7532
  const signature = selectionSignature(selection);
7541
7533
  const effectiveUniformityKey = effectiveInlineUniformityCacheKey(selection);
@@ -7803,16 +7795,13 @@ function createSuperDocUI(options) {
7803
7795
  const foreground = foregroundMutationState();
7804
7796
  if (isNonCollapsedHostSelection(hostSelectionSnapshot) && readHostSelectionSnapshot() === hostSelectionSnapshot) {
7805
7797
  const seed = normalizeSelectionInfo(safeCall(() => hostMethod(host, "readLiveSelectionSyncSnapshot")?.(), null));
7806
- if (seed && !seed.selectionTarget && captureWholeTableParagraphSeed(host, seed, hostSelectionSnapshot)) asyncReads.set("selection", {
7807
- token: asyncReads.get("selection")?.token ?? null,
7808
- value: seed,
7809
- hasSettled: true,
7810
- inflightToken: null
7811
- });
7798
+ if (seed && !seed.selectionTarget && captureWholeTableParagraphSeed(host, seed, hostSelectionSnapshot)) seedAsyncRead("selection", asyncReads.get("selection")?.token ?? null, seed);
7812
7799
  }
7813
7800
  if (isNonCollapsedHostSelection(hostSelectionSnapshot) && !(foreground && foreground.active > 0)) {
7814
- typedCaretValidationHeld = false;
7815
- pendingSelectionSeedValidationToken = null;
7801
+ setSelectionValidation({
7802
+ held: false,
7803
+ pendingToken: null
7804
+ });
7816
7805
  issueAsyncRead("selection", selectionReadToken(), selectionCurrentRun, normalizeSelectionInfo);
7817
7806
  return;
7818
7807
  }
@@ -7821,17 +7810,14 @@ function createSuperDocUI(options) {
7821
7810
  const seed = normalizeSelectionInfo(safeCall(() => read.call(host), null));
7822
7811
  if (!seed) return;
7823
7812
  if (wholeTableSelectionChanged) {
7824
- typedCaretValidationHeld = false;
7825
- pendingSelectionSeedValidationToken = null;
7813
+ setSelectionValidation({
7814
+ held: false,
7815
+ pendingToken: null
7816
+ });
7826
7817
  wholeTableParagraphSeed = null;
7827
7818
  captureWholeTableParagraphSeed(host, seed, initialTableSelection);
7828
7819
  const token = selectionReadToken();
7829
- asyncReads.set("selection", {
7830
- token,
7831
- value: seed,
7832
- hasSettled: true,
7833
- inflightToken: null
7834
- });
7820
+ seedAsyncRead("selection", token, seed);
7835
7821
  issueAsyncRead("selection", token, selectionCurrentRun, normalizeSelectionInfo);
7836
7822
  return;
7837
7823
  }
@@ -7841,14 +7827,25 @@ function createSuperDocUI(options) {
7841
7827
  const previousRange = previousCaret?.range;
7842
7828
  const nextRange = nextCaret?.range;
7843
7829
  const sameSeedCaret = Boolean(previousCaret && nextCaret && previousCaret.blockId === nextCaret.blockId && storyLocatorSignature(previousCaret.story) === storyLocatorSignature(nextCaret.story) && previousRange?.start === nextRange?.start);
7844
- typedCaretValidationHeld = Boolean(foreground && foreground.active > 0) || typedCaretValidationHeld && (afterTypingPaint || sameSeedCaret);
7830
+ const validation = selectionValidationSnapshot();
7831
+ const held = Boolean(foreground && foreground.active > 0) || validation.held && (afterTypingPaint || sameSeedCaret);
7832
+ setSelectionValidation({
7833
+ held,
7834
+ pendingToken: validation.pendingToken
7835
+ });
7845
7836
  const token = selectionReadToken();
7846
- const deferAuthoritativeRead = Boolean(foreground && (foreground.active > 0 || foreground.pending > 0)) || typedCaretValidationHeld && Date.now() - lastTypingMutationAtMs < HEAVY_READ_IDLE_MS;
7837
+ const deferAuthoritativeRead = Boolean(foreground && (foreground.active > 0 || foreground.pending > 0)) || held && typingIsRecent();
7847
7838
  if (!deferAuthoritativeRead) {
7848
- pendingSelectionSeedValidationToken = null;
7839
+ setSelectionValidation({
7840
+ held,
7841
+ pendingToken: null
7842
+ });
7849
7843
  if (issueAsyncRead("selection", token, selectionCurrentRun, normalizeSelectionInfo)) return;
7850
7844
  } else {
7851
- pendingSelectionSeedValidationToken = token;
7845
+ setSelectionValidation({
7846
+ held,
7847
+ pendingToken: token
7848
+ });
7852
7849
  scheduleForegroundAsyncRetry();
7853
7850
  }
7854
7851
  const prev = asyncReads.get("selection");
@@ -7858,17 +7855,12 @@ function createSuperDocUI(options) {
7858
7855
  const sameActiveTypingCaret = Boolean(foreground && foreground.active > 0 && previousCaret && nextCaret && previousCaret.blockId === nextCaret.blockId && storyLocatorSignature(previousCaret.story) === storyLocatorSignature(nextCaret.story) && typeof previousRange?.start === "number" && typeof nextRange?.start === "number" && Math.abs(nextRange.start - previousRange.start) <= 2);
7859
7856
  const carriedChangeIds = paintedTrackChangeId != null || sameActiveTypingCaret ? state.selection.activeChangeIds.filter((id) => paintedTrackChangeId == null || buildTrackedChangeIdContext(state.trackChanges.items).aliasesFor(id).includes(paintedTrackChangeId)) : [];
7860
7857
  const seedChangeIds = Array.isArray(seed.activeChangeIds) && seed.activeChangeIds.length > 0 ? seed.activeChangeIds : carriedChangeIds;
7861
- asyncReads.set("selection", {
7862
- token,
7863
- value: {
7864
- ...seed,
7865
- activeMarks: seedMarks,
7866
- activeCommentIds: seedCommentIds,
7867
- activeChangeIds: seedChangeIds
7868
- },
7869
- hasSettled: true,
7870
- inflightToken: deferAuthoritativeRead ? null : prev?.inflightToken ?? null
7871
- });
7858
+ seedAsyncRead("selection", token, {
7859
+ ...seed,
7860
+ activeMarks: seedMarks,
7861
+ activeCommentIds: seedCommentIds,
7862
+ activeChangeIds: seedChangeIds
7863
+ }, deferAuthoritativeRead ? null : prev?.inflightToken ?? null);
7872
7864
  };
7873
7865
  const selectionInfoMatchesHost = (info) => {
7874
7866
  const snapshot = readHostSelectionSnapshot();
@@ -7890,12 +7882,7 @@ function createSuperDocUI(options) {
7890
7882
  const sourceToken = contentToken();
7891
7883
  const mode = readDocumentMode();
7892
7884
  if (typeof current !== "function") {
7893
- asyncReads.set("selection", {
7894
- token,
7895
- value: null,
7896
- hasSettled: true,
7897
- inflightToken: null
7898
- });
7885
+ seedAsyncRead("selection", token, null);
7899
7886
  recompute();
7900
7887
  return selectionSliceFromInfo(null, "pending");
7901
7888
  }
@@ -7912,12 +7899,7 @@ function createSuperDocUI(options) {
7912
7899
  if (disposed) return selectionSliceFromInfo(null, "pending");
7913
7900
  const info = normalizeSelectionInfo(raw);
7914
7901
  if (selectionReadToken() !== token && !(getDoc() === doc && contentToken() === sourceToken && readDocumentMode() === mode && selectionInfoMatchesHost(info))) return attempt < 1 ? readSelectionInfoFresh(attempt + 1) : selectionSliceFromInfo(null, "pending");
7915
- asyncReads.set("selection", {
7916
- token: selectionReadToken(),
7917
- value: info,
7918
- hasSettled: true,
7919
- inflightToken: null
7920
- });
7902
+ seedAsyncRead("selection", selectionReadToken(), info);
7921
7903
  const selection = selectionSliceFromInfo(info, info ? "ready" : "pending");
7922
7904
  recompute();
7923
7905
  return selection;
@@ -14590,12 +14572,7 @@ function createSuperDocUI(options) {
14590
14572
  const resolved = await Promise.resolve(resolveMetadata({ id }));
14591
14573
  if (token !== localContentToken()) return null;
14592
14574
  const target = readMetadataResolvedTarget(resolved);
14593
- asyncReads.set(metadataResolveKey(id), {
14594
- token,
14595
- value: target,
14596
- hasSettled: true,
14597
- inflightToken: null
14598
- });
14575
+ seedAsyncRead(metadataResolveKey(id), token, target);
14599
14576
  return target;
14600
14577
  } catch {
14601
14578
  return null;
@@ -15851,4 +15828,4 @@ function commandIsActive(descriptor, selection) {
15851
15828
  return descriptor.activeMark ? selection.activeMarks.includes(descriptor.activeMark) : false;
15852
15829
  }
15853
15830
  //#endregion
15854
- export { createInteractionHistory as C, recordInteraction as E, closeInteractionHistory as S, isWorkflowRecordingEnabled as T, createTrackedChangePermissionResolver as _, registerFirstPartyCommandMutation as a, isPlainObject as b, getCommandDescriptor as c, mutationCommittedEventChangedDocument as d, createImageFilePicker as f, PERMISSIONS as g, BUILT_IN_PERMISSION_METHOD 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, isAllowed as v, getWorkflowRecording as w, DOM_CLASS_NAMES as x, isSyntheticTrackedChangeCommentLaneItem as y };
15831
+ export { getWorkflowRecording as C, createInteractionHistory as S, recordInteraction as T, createTrackedChangePermissionResolver as _, registerFirstPartyCommandMutation as a, DOM_CLASS_NAMES as b, getCommandDescriptor as c, mutationCommittedEventChangedDocument as d, createImageFilePicker as f, PERMISSIONS as g, BUILT_IN_PERMISSION_METHOD 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, isAllowed as v, isWorkflowRecordingEnabled as w, closeInteractionHistory as x, isSyntheticTrackedChangeCommentLaneItem as y };