superdoc 2.23.0-next.12 → 2.23.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM$2 } from "./chunks/rolldown-runtime-0pSA04fp.es.js";
2
2
  import { t as blank_default } from "./chunks/blank-docx-DzQccOlW.es.js";
3
- import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-DHW9Toxn.es.js";
3
+ import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-B8N_IUG2.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 { $ as watch$1, A as onActivated, B as resolveDirective, C as isRef$1, D as normalizeClass, E as nextTick, F as openBlock, G as toRef, H as shallowRef$1, I as reactive, J as useAttrs, K as toRefs, L as ref, M as onDeactivated, N as onMounted, O as normalizeProps, P as onScopeDispose$1, Q as vModelText, R as renderList, S as isReactive$1, T as mergeProps, U as toDisplayString, V as resolveDynamicComponent, W as toRaw$2, X as vModelCheckbox, Y as useSlots, Z as vModelSelect, _ as getCurrentInstance, a as computed$1, b as hasInjectionContext, c as createCommentVNode, d as createStaticVNode, et as withCtx, f as createTextVNode, g as effectScope, h as defineComponent, i as Transition, j as onBeforeUnmount, k as normalizeStyle, l as createElementBlock, m as defineAsyncComponent, n as Fragment, nt as withKeys, o as createApp, p as createVNode, q as unref, r as Teleport, rt as withModifiers, s as createBlock, t as _plugin_vue_export_helper_default, tt as withDirectives, u as createElementVNode, v as getCurrentScope, w as markRaw, x as inject$1, y as h, z as renderSlot } from "./chunks/_plugin-vue_export-helper-DHiJKCsy.es.js";
@@ -302,7 +302,7 @@ var awarenessStatesToArray = (context, states) => {
302
302
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
303
303
  function getSuperdocVersion() {
304
304
  try {
305
- return "2.23.0-next.12";
305
+ return "2.23.0-next.14";
306
306
  } catch {
307
307
  return "unknown";
308
308
  }
@@ -13198,12 +13198,12 @@ var _hoisted_14$2 = {
13198
13198
  key: 0,
13199
13199
  class: "tracked-change-text"
13200
13200
  };
13201
- var _hoisted_15$1 = {
13201
+ var _hoisted_15$2 = {
13202
13202
  key: 1,
13203
13203
  class: "change-type"
13204
13204
  };
13205
- var _hoisted_16$1 = { class: "change-type" };
13206
- var _hoisted_17$1 = { key: 1 };
13205
+ var _hoisted_16$2 = { class: "change-type" };
13206
+ var _hoisted_17$2 = { key: 1 };
13207
13207
  var _hoisted_18$1 = { class: "tracked-change-text is-inserted" };
13208
13208
  var _hoisted_19$1 = { key: 2 };
13209
13209
  var _hoisted_20$1 = { class: "tracked-change-text is-inserted" };
@@ -14268,10 +14268,10 @@ var CommentDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
14268
14268
  class: "tracked-change-detail-line"
14269
14269
  }, [
14270
14270
  line.excerpt ? (openBlock(), createElementBlock("span", _hoisted_14$2, "\"" + toDisplayString(line.excerpt) + "\"", 1)) : createCommentVNode("", true),
14271
- line.excerpt ? (openBlock(), createElementBlock("span", _hoisted_15$1, " — ")) : createCommentVNode("", true),
14272
- createElementVNode("span", _hoisted_16$1, toDisplayString(line.label), 1)
14271
+ line.excerpt ? (openBlock(), createElementBlock("span", _hoisted_15$2, " — ")) : createCommentVNode("", true),
14272
+ createElementVNode("span", _hoisted_16$2, toDisplayString(line.label), 1)
14273
14273
  ]);
14274
- }), 128))])) : createCommentVNode("", true)])) : comment.trackedChangeDisplayType === "hyperlinkAdded" ? (openBlock(), createElementBlock("div", _hoisted_17$1, [_cache[2] || (_cache[2] = createElementVNode("span", { class: "change-type" }, "Added hyperlink ", -1)), createElementVNode("span", _hoisted_18$1, "\"" + toDisplayString(comment.trackedChangeText) + "\"", 1)])) : comment.trackedChangeDisplayType === "hyperlinkModified" ? (openBlock(), createElementBlock("div", _hoisted_19$1, [_cache[3] || (_cache[3] = createElementVNode("span", { class: "change-type" }, "Changed hyperlink to ", -1)), createElementVNode("span", _hoisted_20$1, "\"" + toDisplayString(comment.trackedChangeText) + "\"", 1)])) : comment.trackedChangeDisplayType === "paragraphSplit" ? (openBlock(), createElementBlock("div", _hoisted_21$1, [..._cache[4] || (_cache[4] = [createElementVNode("span", { class: "change-type" }, "Added new line", -1)])])) : comment.trackedChangeDisplayType === "tableInsert" ? (openBlock(), createElementBlock("div", _hoisted_22$1, [..._cache[5] || (_cache[5] = [createElementVNode("span", { class: "change-type" }, "Added table", -1)])])) : comment.trackedChangeDisplayType === "tableDelete" ? (openBlock(), createElementBlock("div", _hoisted_23$1, [..._cache[6] || (_cache[6] = [createElementVNode("span", { class: "change-type" }, "Deleted table", -1)])])) : comment.trackedChangeType === "trackFormat" ? (openBlock(), createElementBlock("div", _hoisted_24, [_cache[7] || (_cache[7] = createElementVNode("span", { class: "change-type" }, "Format: ", -1)), createElementVNode("span", _hoisted_25, toDisplayString(comment.trackedChangeText), 1)])) : comment.trackedChangeType === "both" ? (openBlock(), createElementBlock("div", _hoisted_26, [
14274
+ }), 128))])) : createCommentVNode("", true)])) : comment.trackedChangeDisplayType === "hyperlinkAdded" ? (openBlock(), createElementBlock("div", _hoisted_17$2, [_cache[2] || (_cache[2] = createElementVNode("span", { class: "change-type" }, "Added hyperlink ", -1)), createElementVNode("span", _hoisted_18$1, "\"" + toDisplayString(comment.trackedChangeText) + "\"", 1)])) : comment.trackedChangeDisplayType === "hyperlinkModified" ? (openBlock(), createElementBlock("div", _hoisted_19$1, [_cache[3] || (_cache[3] = createElementVNode("span", { class: "change-type" }, "Changed hyperlink to ", -1)), createElementVNode("span", _hoisted_20$1, "\"" + toDisplayString(comment.trackedChangeText) + "\"", 1)])) : comment.trackedChangeDisplayType === "paragraphSplit" ? (openBlock(), createElementBlock("div", _hoisted_21$1, [..._cache[4] || (_cache[4] = [createElementVNode("span", { class: "change-type" }, "Added new line", -1)])])) : comment.trackedChangeDisplayType === "tableInsert" ? (openBlock(), createElementBlock("div", _hoisted_22$1, [..._cache[5] || (_cache[5] = [createElementVNode("span", { class: "change-type" }, "Added table", -1)])])) : comment.trackedChangeDisplayType === "tableDelete" ? (openBlock(), createElementBlock("div", _hoisted_23$1, [..._cache[6] || (_cache[6] = [createElementVNode("span", { class: "change-type" }, "Deleted table", -1)])])) : comment.trackedChangeType === "trackFormat" ? (openBlock(), createElementBlock("div", _hoisted_24, [_cache[7] || (_cache[7] = createElementVNode("span", { class: "change-type" }, "Format: ", -1)), createElementVNode("span", _hoisted_25, toDisplayString(comment.trackedChangeText), 1)])) : comment.trackedChangeType === "both" ? (openBlock(), createElementBlock("div", _hoisted_26, [
14275
14275
  _cache[8] || (_cache[8] = createElementVNode("span", { class: "change-type" }, "Replaced ", -1)),
14276
14276
  createElementVNode("span", _hoisted_27, "\"" + toDisplayString(comment.deletedText) + "\"", 1),
14277
14277
  _cache[9] || (_cache[9] = createElementVNode("span", { class: "change-type" }, " with ", -1)),
@@ -18888,8 +18888,15 @@ var _hoisted_12$1 = {
18888
18888
  key: 0,
18889
18889
  class: "input-row link-buttons"
18890
18890
  };
18891
- var _hoisted_13$1 = ["innerHTML"];
18892
- var _hoisted_14$1 = {
18891
+ var _hoisted_13$1 = ["disabled"];
18892
+ var _hoisted_14$1 = ["innerHTML"];
18893
+ var _hoisted_15$1 = ["disabled"];
18894
+ var _hoisted_16$1 = {
18895
+ key: 1,
18896
+ role: "alert",
18897
+ class: "sd-error"
18898
+ };
18899
+ var _hoisted_17$1 = {
18893
18900
  key: 5,
18894
18901
  class: "input-row go-to-anchor clickable"
18895
18902
  };
@@ -18954,6 +18961,10 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
18954
18961
  type: Object,
18955
18962
  default: null
18956
18963
  },
18964
+ selectedText: {
18965
+ type: String,
18966
+ default: null
18967
+ },
18957
18968
  /**
18958
18969
  * Re-applies the toolbar's pre-interaction selection capture before the link
18959
18970
  * command runs. LinkInput executes the command directly (bypassing Toolbar.vue's
@@ -18974,8 +18985,11 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
18974
18985
  const props = __props;
18975
18986
  const { isHighContrastMode } = useHighContrastMode();
18976
18987
  const urlError = ref(false);
18988
+ const commandError = ref("");
18989
+ const isSubmitting = ref(false);
18977
18990
  const readSelectedText = () => {
18978
18991
  if (typeof props.hyperlinkText === "string" && props.hyperlinkText) return props.hyperlinkText;
18992
+ if (typeof props.selectedText === "string" && props.selectedText) return props.selectedText;
18979
18993
  const snapshot = props.ui?.selection?.getSnapshot?.();
18980
18994
  if (typeof snapshot?.quotedText === "string" && snapshot.quotedText) return snapshot.quotedText;
18981
18995
  const clickedText = props.clickedElement?.innerText ?? props.clickedElement?.textContent;
@@ -19006,7 +19020,7 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
19006
19020
  const validUrl = computed$1(() => sanitizedUrl.value !== null);
19007
19021
  const hadExistingLink = ref(false);
19008
19022
  const isEditing = computed$1(() => !isAnchor.value && hadExistingLink.value);
19009
- const isDisabled = computed$1(() => !validUrl.value);
19023
+ const isDisabled = computed$1(() => !validUrl.value || isSubmitting.value);
19010
19024
  const isViewingMode = computed$1(() => readDocumentMode() === "viewing");
19011
19025
  const openLink = () => {
19012
19026
  const href = sanitizedUrl.value?.href;
@@ -19025,20 +19039,36 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
19025
19039
  isAnchor.value = rawUrl.value.startsWith("#");
19026
19040
  if (props.showInput && !isViewingMode.value) focusInput();
19027
19041
  });
19028
- const runLinkCommand = (payload) => {
19042
+ const runLinkCommand = async (payload) => {
19029
19043
  const ui = props.ui;
19030
- if (!ui?.commands?.execute) return false;
19044
+ if (!ui?.commands?.executeAsync) return false;
19031
19045
  props.restoreSelection?.();
19032
- return ui.commands.execute("link", payload);
19046
+ return executeFirstPartyCommandAsync(ui, "link", payload);
19033
19047
  };
19034
- const handleSubmit = () => {
19035
- if (isViewingMode.value) return;
19048
+ const applyLinkCommand = async (payload) => {
19049
+ if (isSubmitting.value) return;
19050
+ isSubmitting.value = true;
19051
+ commandError.value = "";
19052
+ try {
19053
+ const result = await runLinkCommand(payload);
19054
+ if (result === false || result == null || typeof result === "object" && (result.success === false || result.status === "rejected")) {
19055
+ commandError.value = "Could not apply link. Check the selection and try again.";
19056
+ return;
19057
+ }
19058
+ props.closePopover();
19059
+ } catch {
19060
+ commandError.value = "Could not apply link. Check the selection and try again.";
19061
+ } finally {
19062
+ isSubmitting.value = false;
19063
+ }
19064
+ };
19065
+ const handleSubmit = async () => {
19066
+ if (isViewingMode.value || isSubmitting.value) return;
19036
19067
  if (!rawUrl.value) {
19037
- runLinkCommand({
19068
+ await applyLinkCommand({
19038
19069
  href: null,
19039
19070
  hyperlinkTarget: props.hyperlinkTarget
19040
19071
  });
19041
- props.closePopover();
19042
19072
  return;
19043
19073
  }
19044
19074
  if (!validUrl.value) {
@@ -19057,23 +19087,22 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
19057
19087
  textTarget: props.textTarget
19058
19088
  };
19059
19089
  if (text.value) payload.text = text.value;
19060
- else if (!isEditing.value) payload.text = href;
19061
- runLinkCommand(payload);
19062
- props.closePopover();
19090
+ else if (!isEditing.value && !props.textTarget) payload.text = href;
19091
+ await applyLinkCommand(payload);
19063
19092
  };
19064
- const handleRemove = () => {
19065
- runLinkCommand({
19093
+ const handleRemove = async () => {
19094
+ if (isViewingMode.value || isSubmitting.value) return;
19095
+ await applyLinkCommand({
19066
19096
  href: null,
19067
19097
  hyperlinkTarget: props.hyperlinkTarget
19068
19098
  });
19069
- props.closePopover();
19070
19099
  };
19071
19100
  const navigateToAnchor = (anchorUrl) => {
19072
19101
  if (props.goToAnchor) props.goToAnchor(anchorUrl);
19073
19102
  };
19074
19103
  return (_ctx, _cache) => {
19075
19104
  return openBlock(), createElementBlock("div", { class: normalizeClass(["link-input-ctn", { "high-contrast": unref(isHighContrastMode) }]) }, [isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_1$20, "Page anchor")) : isViewingMode.value ? (openBlock(), createElementBlock("div", _hoisted_2$16, "Link details")) : isEditing.value ? (openBlock(), createElementBlock("div", _hoisted_3$13, "Edit link")) : (openBlock(), createElementBlock("div", _hoisted_4$8, "Add link")), __props.showInput && !isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_5$6, [
19076
- createElementVNode("div", _hoisted_6$5, [_cache[4] || (_cache[4] = createElementVNode("div", { class: "input-icon text-input-icon" }, "T", -1)), withDirectives(createElementVNode("input", {
19105
+ createElementVNode("div", _hoisted_6$5, [_cache[5] || (_cache[5] = createElementVNode("div", { class: "input-icon text-input-icon" }, "T", -1)), withDirectives(createElementVNode("input", {
19077
19106
  type: "text",
19078
19107
  name: "text",
19079
19108
  placeholder: "Text",
@@ -19093,7 +19122,8 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
19093
19122
  class: normalizeClass({ "sd-error": urlError.value }),
19094
19123
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => rawUrl.value = $event),
19095
19124
  readonly: isViewingMode.value,
19096
- onKeydown: [withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"]), _cache[2] || (_cache[2] = ($event) => urlError.value = false)]
19125
+ onInput: _cache[2] || (_cache[2] = ($event) => commandError.value = ""),
19126
+ onKeydown: [withKeys(withModifiers(handleSubmit, ["stop", "prevent"]), ["enter"]), _cache[3] || (_cache[3] = ($event) => urlError.value = false)]
19097
19127
  }, null, 42, _hoisted_10$2), [[vModelText, rawUrl.value]]),
19098
19128
  createElementVNode("div", {
19099
19129
  class: normalizeClass(["open-link-icon", { "sd-disabled": !validUrl.value }]),
@@ -19106,19 +19136,22 @@ var LinkInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
19106
19136
  key: 0,
19107
19137
  class: "remove-btn",
19108
19138
  onClick: handleRemove,
19139
+ disabled: isSubmitting.value,
19109
19140
  "data-item": "btn-link-remove"
19110
19141
  }, [createElementVNode("div", {
19111
19142
  class: "remove-btn__icon",
19112
19143
  innerHTML: unref(toolbarIcons).removeLink
19113
- }, null, 8, _hoisted_13$1), _cache[5] || (_cache[5] = createTextVNode(" Remove ", -1))])) : createCommentVNode("", true), createElementVNode("button", {
19144
+ }, null, 8, _hoisted_14$1), _cache[6] || (_cache[6] = createTextVNode(" Remove ", -1))], 8, _hoisted_13$1)) : createCommentVNode("", true), createElementVNode("button", {
19114
19145
  class: normalizeClass(["sd-submit-btn", { "disable-btn": isDisabled.value }]),
19115
19146
  onClick: handleSubmit,
19147
+ disabled: isSubmitting.value,
19116
19148
  "data-item": "btn-link-apply"
19117
- }, " Apply ", 2)])) : createCommentVNode("", true)
19118
- ])) : isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_14$1, [createElementVNode("a", { onClick: _cache[3] || (_cache[3] = withModifiers(($event) => navigateToAnchor(rawUrl.value), ["stop", "prevent"])) }, "Go to " + toDisplayString(rawUrl.value.startsWith("#_") ? rawUrl.value.substring(2) : rawUrl.value), 1)])) : createCommentVNode("", true)], 2);
19149
+ }, " Apply ", 10, _hoisted_15$1)])) : createCommentVNode("", true),
19150
+ commandError.value ? (openBlock(), createElementBlock("div", _hoisted_16$1, toDisplayString(commandError.value), 1)) : createCommentVNode("", true)
19151
+ ])) : isAnchor.value ? (openBlock(), createElementBlock("div", _hoisted_17$1, [createElementVNode("a", { onClick: _cache[4] || (_cache[4] = withModifiers(($event) => navigateToAnchor(rawUrl.value), ["stop", "prevent"])) }, "Go to " + toDisplayString(rawUrl.value.startsWith("#_") ? rawUrl.value.substring(2) : rawUrl.value), 1)])) : createCommentVNode("", true)], 2);
19119
19152
  };
19120
19153
  }
19121
- }, [["__scopeId", "data-v-3e4bd44e"]]);
19154
+ }, [["__scopeId", "data-v-498a6e6e"]]);
19122
19155
  //#endregion
19123
19156
  //#region src/internal/toolbar/built-in/scroll-helpers.js
19124
19157
  function getScrollableParent(element) {
@@ -22206,6 +22239,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
22206
22239
  return () => {
22207
22240
  const linkItem = toolbar.getToolbarItemByName("link");
22208
22241
  if (!linkItem || linkItem.disabled?.value === true) return;
22242
+ toolbar.pendingSelectionCapture = toolbar.ui?.selection?.capture?.() ?? null;
22209
22243
  if (linkItem.expand && typeof linkItem.expand === "object" && "value" in linkItem.expand) linkItem.expand.value = true;
22210
22244
  toolbar.updateToolbarState?.();
22211
22245
  };
@@ -24568,7 +24602,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
24568
24602
  ], 38);
24569
24603
  };
24570
24604
  }
24571
- }, [["__scopeId", "data-v-3a8bc935"]]);
24605
+ }, [["__scopeId", "data-v-f53aafe0"]]);
24572
24606
  //#endregion
24573
24607
  //#region src/core/create-app.js
24574
24608
  var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
@@ -43910,16 +43944,18 @@ var makeDefaultItems = ({ superToolbar, toolbarIcons, toolbarTexts, toolbarFonts
43910
43944
  }
43911
43945
  });
43912
43946
  function renderLinkDropdown(link) {
43913
- const selection = currentSelectionSnapshot(superToolbar);
43914
- const selectionTarget = selection?.selectionTarget ?? selectionTargetFromTextTarget(selection?.target);
43947
+ const capture = superToolbar.pendingSelectionCapture;
43948
+ const liveSelection = currentSelectionSnapshot(superToolbar);
43949
+ const selection = liveSelection?.quotedText && JSON.stringify(liveSelection.selectionTarget ?? liveSelection.target) !== JSON.stringify(capture?.selectionTarget ?? capture?.target) ? liveSelection : capture ?? liveSelection;
43950
+ const selectionTarget = selection?.selectionTarget ?? selectionTargetFromTextTarget(selection?.target) ?? selection?.target;
43915
43951
  const restoreSelection = () => {
43916
- const capture = superToolbar.pendingSelectionCapture;
43917
- if (capture && typeof superToolbar.ui?.selection?.restore === "function") superToolbar.ui.selection.restore(capture);
43952
+ if (selection === capture && typeof superToolbar.ui?.selection?.restore === "function") superToolbar.ui.selection.restore(capture);
43918
43953
  };
43919
43954
  return h("div", {}, [h(LinkInput_default, {
43920
43955
  ui: superToolbar.ui,
43921
43956
  linkItem: link,
43922
43957
  textTarget: selectionTarget,
43958
+ selectedText: selection?.quotedText ?? null,
43923
43959
  restoreSelection,
43924
43960
  closePopover: () => {
43925
43961
  closeDropdown(link);
@@ -46362,7 +46398,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46362
46398
  }
46363
46399
  this.userColorMap = /* @__PURE__ */ new Map();
46364
46400
  this.colorIndex = 0;
46365
- this.version = "2.23.0-next.12";
46401
+ this.version = "2.23.0-next.14";
46366
46402
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46367
46403
  this.superdocId = config.superdocId || v4();
46368
46404
  this.colors = this.config.colors ?? [];