@harbour-enterprises/superdoc 0.23.0-next.3 → 0.23.0-next.5
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.
- package/dist/chunks/{PdfViewer-BfGJJ5Fk.es.js → PdfViewer-BlOezZGN.es.js} +2 -2
- package/dist/chunks/{PdfViewer-Cm-ziNtE.cjs → PdfViewer-D89-VJvM.cjs} +2 -2
- package/dist/chunks/{eventemitter3-CZv6vEhA.es.js → eventemitter3-CR2eBWft.es.js} +1 -1
- package/dist/chunks/{eventemitter3-B_kO1Pxm.cjs → eventemitter3-DSRogsNq.cjs} +1 -1
- package/dist/chunks/{index-CJIVhJxE.cjs → index-9hY1WuxT.cjs} +30 -13
- package/dist/chunks/{index-Bl4NtKeS.es.js → index-DTw4eF5D.es.js} +30 -13
- package/dist/chunks/{jszip-b7l8QkfH.cjs → jszip-B4LDL19y.cjs} +1 -1
- package/dist/chunks/{jszip-B8KIZSNe.es.js → jszip-DAXEPCUv.es.js} +1 -1
- package/dist/chunks/{super-editor.es-C7stybby.cjs → super-editor.es-C8gNFcB_.cjs} +81 -23
- package/dist/chunks/{super-editor.es-DQnqUJZs.es.js → super-editor.es-C9Ql0kHS.es.js} +81 -23
- package/dist/chunks/{vue-DWle4Cai.cjs → vue-DKMj1I9B.cjs} +39 -42
- package/dist/chunks/{vue-CXxsqYcP.es.js → vue-ZWZLQtoU.es.js} +39 -42
- package/dist/chunks/xml-js-Bbc0NeKa.es.js +2 -0
- package/dist/chunks/xml-js-CWV8R-ek.cjs +3 -0
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/stores/superdoc-store.d.ts.map +1 -1
- package/dist/style.css +27 -27
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BVirrB35.js → converter-ClnqoStR.js} +16 -18
- package/dist/super-editor/chunks/{docx-zipper-Cpb9d2an.js → docx-zipper-DC28ucAi.js} +1 -1
- package/dist/super-editor/chunks/{editor-DIINh50j.js → editor-DLan-MJ6.js} +66 -6
- package/dist/super-editor/chunks/{toolbar-CmDmkPHL.js → toolbar-CekMv4Mk.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/Attribute.d.ts +2 -2
- package/dist/super-editor/src/core/Schema.d.ts +2 -2
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsByAlias.d.ts +8 -0
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +4 -4
- package/dist/superdoc.es.js +4 -4
- package/dist/superdoc.umd.js +139 -64
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/xml-js-CX8FH0He.cjs +0 -3
- package/dist/chunks/xml-js-D0tLGmKu.es.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-
|
|
2
|
-
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-
|
|
1
|
+
import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-ZWZLQtoU.es.js";
|
|
2
|
+
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-DTw4eF5D.es.js";
|
|
3
3
|
function self(vars) {
|
|
4
4
|
const {
|
|
5
5
|
opacityDisabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const vue = require("./vue-
|
|
4
|
-
const superdoc = require("./index-
|
|
3
|
+
const vue = require("./vue-DKMj1I9B.cjs");
|
|
4
|
+
const superdoc = require("./index-9hY1WuxT.cjs");
|
|
5
5
|
function self(vars) {
|
|
6
6
|
const {
|
|
7
7
|
opacityDisabled,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const superEditor_es = require("./super-editor.es-
|
|
3
|
-
const vue = require("./vue-
|
|
4
|
-
const jszip = require("./jszip-
|
|
2
|
+
const superEditor_es = require("./super-editor.es-C8gNFcB_.cjs");
|
|
3
|
+
const vue = require("./vue-DKMj1I9B.cjs");
|
|
4
|
+
const jszip = require("./jszip-B4LDL19y.cjs");
|
|
5
5
|
const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
|
|
6
|
-
const eventemitter3 = require("./eventemitter3-
|
|
6
|
+
const eventemitter3 = require("./eventemitter3-DSRogsNq.cjs");
|
|
7
7
|
const provider = require("@hocuspocus/provider");
|
|
8
8
|
const Y = require("yjs");
|
|
9
9
|
const uuid = require("./uuid-CQzaMNgL.cjs");
|
|
@@ -4025,6 +4025,9 @@ const useSuperdocStore = /* @__PURE__ */ defineStore("superdoc", () => {
|
|
|
4025
4025
|
documentUsers.value = configUsers || [];
|
|
4026
4026
|
Object.assign(user, configUser);
|
|
4027
4027
|
Object.assign(modules, configModules);
|
|
4028
|
+
if (!Object.prototype.hasOwnProperty.call(modules, "comments")) {
|
|
4029
|
+
modules.comments = {};
|
|
4030
|
+
}
|
|
4028
4031
|
if (!configDocs?.length && !config.modules.collaboration) {
|
|
4029
4032
|
const newDoc = await getFileObject(blankDocx.BlankDOCX, "blank.docx", DOCX);
|
|
4030
4033
|
const newDocConfig = {
|
|
@@ -17414,7 +17417,7 @@ const _sfc_main = {
|
|
|
17414
17417
|
__name: "SuperDoc",
|
|
17415
17418
|
emits: ["selection-update"],
|
|
17416
17419
|
setup(__props, { emit: __emit }) {
|
|
17417
|
-
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-
|
|
17420
|
+
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-D89-VJvM.cjs")));
|
|
17418
17421
|
const superdocStore = useSuperdocStore();
|
|
17419
17422
|
const commentsStore = useCommentsStore();
|
|
17420
17423
|
const {
|
|
@@ -17447,6 +17450,11 @@ const _sfc_main = {
|
|
|
17447
17450
|
const { proxy } = vue.getCurrentInstance();
|
|
17448
17451
|
commentsStore.proxy = proxy;
|
|
17449
17452
|
const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
|
|
17453
|
+
const commentsModuleConfig = vue.computed(() => {
|
|
17454
|
+
const config = modules.comments;
|
|
17455
|
+
if (config === false || config == null) return null;
|
|
17456
|
+
return config;
|
|
17457
|
+
});
|
|
17450
17458
|
const layers = vue.ref(null);
|
|
17451
17459
|
const commentsLayer = vue.ref(null);
|
|
17452
17460
|
const toolsMenuPosition = vue.reactive({ top: null, right: "-25px", zIndex: 101 });
|
|
@@ -17594,7 +17602,7 @@ const _sfc_main = {
|
|
|
17594
17602
|
rulers: doc.rulers,
|
|
17595
17603
|
isInternal: proxy.$superdoc.config.isInternal,
|
|
17596
17604
|
annotations: proxy.$superdoc.config.annotations,
|
|
17597
|
-
isCommentsEnabled:
|
|
17605
|
+
isCommentsEnabled: Boolean(commentsModuleConfig.value),
|
|
17598
17606
|
isAiEnabled: proxy.$superdoc.config.modules?.ai,
|
|
17599
17607
|
slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
|
|
17600
17608
|
onBeforeCreate: onEditorBeforeCreate,
|
|
@@ -17625,7 +17633,8 @@ const _sfc_main = {
|
|
|
17625
17633
|
return options;
|
|
17626
17634
|
};
|
|
17627
17635
|
const onEditorCommentLocationsUpdate = ({ allCommentIds: activeThreadId, allCommentPositions }) => {
|
|
17628
|
-
|
|
17636
|
+
const commentsConfig = proxy.$superdoc.config.modules?.comments;
|
|
17637
|
+
if (!commentsConfig || commentsConfig === false) return;
|
|
17629
17638
|
handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
|
|
17630
17639
|
};
|
|
17631
17640
|
const onEditorCommentsUpdate = (params2 = {}) => {
|
|
@@ -17647,7 +17656,7 @@ const _sfc_main = {
|
|
|
17647
17656
|
proxy.$superdoc.config.onTransaction({ editor, transaction, duration: duration2 });
|
|
17648
17657
|
}
|
|
17649
17658
|
};
|
|
17650
|
-
const isCommentsEnabled = vue.computed(() =>
|
|
17659
|
+
const isCommentsEnabled = vue.computed(() => Boolean(commentsModuleConfig.value));
|
|
17651
17660
|
const showCommentsSidebar = vue.computed(() => {
|
|
17652
17661
|
return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
|
|
17653
17662
|
});
|
|
@@ -17657,13 +17666,14 @@ const _sfc_main = {
|
|
|
17657
17666
|
});
|
|
17658
17667
|
vue.computed(() => {
|
|
17659
17668
|
if (!isCommentsEnabled.value) return false;
|
|
17660
|
-
!getConfig?.readOnly && selectionPosition.value;
|
|
17669
|
+
return !getConfig.value?.readOnly && selectionPosition.value;
|
|
17661
17670
|
});
|
|
17662
17671
|
vue.watch(showCommentsSidebar, (value) => {
|
|
17663
17672
|
proxy.$superdoc.broadcastSidebarToggle(value);
|
|
17664
17673
|
});
|
|
17665
17674
|
const scrollToComment = (commentId) => {
|
|
17666
|
-
|
|
17675
|
+
const commentsConfig = proxy.$superdoc.config?.modules?.comments;
|
|
17676
|
+
if (!commentsConfig || commentsConfig === false) return;
|
|
17667
17677
|
const element = document.querySelector(`[data-thread-id=${commentId}]`);
|
|
17668
17678
|
if (element) {
|
|
17669
17679
|
element.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
@@ -17671,7 +17681,8 @@ const _sfc_main = {
|
|
|
17671
17681
|
}
|
|
17672
17682
|
};
|
|
17673
17683
|
vue.onMounted(() => {
|
|
17674
|
-
|
|
17684
|
+
const config = commentsModuleConfig.value;
|
|
17685
|
+
if (config && !config.readOnly) {
|
|
17675
17686
|
document.addEventListener("mousedown", handleDocumentMouseDown);
|
|
17676
17687
|
}
|
|
17677
17688
|
});
|
|
@@ -17793,6 +17804,7 @@ const _sfc_main = {
|
|
|
17793
17804
|
};
|
|
17794
17805
|
const shouldShowSelection = vue.computed(() => {
|
|
17795
17806
|
const config = proxy.$superdoc.config.modules?.comments;
|
|
17807
|
+
if (!config || config === false) return false;
|
|
17796
17808
|
return !config.readOnly;
|
|
17797
17809
|
});
|
|
17798
17810
|
const handleSuperEditorPageMarginsChange = (doc, params2) => {
|
|
@@ -17959,7 +17971,7 @@ const _sfc_main = {
|
|
|
17959
17971
|
};
|
|
17960
17972
|
}
|
|
17961
17973
|
};
|
|
17962
|
-
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17974
|
+
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-45f44b6e"]]);
|
|
17963
17975
|
const createSuperdocVueApp = () => {
|
|
17964
17976
|
const app = vue.createApp(App);
|
|
17965
17977
|
const pinia = createPinia();
|
|
@@ -18058,6 +18070,10 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18058
18070
|
...this.config,
|
|
18059
18071
|
...config
|
|
18060
18072
|
};
|
|
18073
|
+
this.config.modules = this.config.modules || {};
|
|
18074
|
+
if (!Object.prototype.hasOwnProperty.call(this.config.modules, "comments")) {
|
|
18075
|
+
this.config.modules.comments = {};
|
|
18076
|
+
}
|
|
18061
18077
|
this.config.colors = shuffleArray(this.config.colors);
|
|
18062
18078
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
18063
18079
|
this.colorIndex = 0;
|
|
@@ -18192,7 +18208,8 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18192
18208
|
this.superdocStore.setExceptionHandler((payload) => this.emit("exception", payload));
|
|
18193
18209
|
}
|
|
18194
18210
|
this.superdocStore.init(this.config);
|
|
18195
|
-
this.
|
|
18211
|
+
const commentsModuleConfig = this.config.modules.comments;
|
|
18212
|
+
this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
|
|
18196
18213
|
}
|
|
18197
18214
|
#initListeners() {
|
|
18198
18215
|
this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-
|
|
2
|
-
import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-
|
|
3
|
-
import { B as Buffer$2 } from "./jszip-
|
|
1
|
+
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-C9Ql0kHS.es.js";
|
|
2
|
+
import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-ZWZLQtoU.es.js";
|
|
3
|
+
import { B as Buffer$2 } from "./jszip-DAXEPCUv.es.js";
|
|
4
4
|
import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
|
|
5
|
-
import { E as EventEmitter } from "./eventemitter3-
|
|
5
|
+
import { E as EventEmitter } from "./eventemitter3-CR2eBWft.es.js";
|
|
6
6
|
import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
|
|
7
7
|
import * as Y from "yjs";
|
|
8
8
|
import { Doc, Map as Map$2 } from "yjs";
|
|
@@ -4008,6 +4008,9 @@ const useSuperdocStore = /* @__PURE__ */ defineStore("superdoc", () => {
|
|
|
4008
4008
|
documentUsers.value = configUsers || [];
|
|
4009
4009
|
Object.assign(user, configUser);
|
|
4010
4010
|
Object.assign(modules, configModules);
|
|
4011
|
+
if (!Object.prototype.hasOwnProperty.call(modules, "comments")) {
|
|
4012
|
+
modules.comments = {};
|
|
4013
|
+
}
|
|
4011
4014
|
if (!configDocs?.length && !config.modules.collaboration) {
|
|
4012
4015
|
const newDoc = await getFileObject(BlankDOCX, "blank.docx", DOCX);
|
|
4013
4016
|
const newDocConfig = {
|
|
@@ -17397,7 +17400,7 @@ const _sfc_main = {
|
|
|
17397
17400
|
__name: "SuperDoc",
|
|
17398
17401
|
emits: ["selection-update"],
|
|
17399
17402
|
setup(__props, { emit: __emit }) {
|
|
17400
|
-
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-
|
|
17403
|
+
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BlOezZGN.es.js"));
|
|
17401
17404
|
const superdocStore = useSuperdocStore();
|
|
17402
17405
|
const commentsStore = useCommentsStore();
|
|
17403
17406
|
const {
|
|
@@ -17430,6 +17433,11 @@ const _sfc_main = {
|
|
|
17430
17433
|
const { proxy } = getCurrentInstance();
|
|
17431
17434
|
commentsStore.proxy = proxy;
|
|
17432
17435
|
const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
|
|
17436
|
+
const commentsModuleConfig = computed(() => {
|
|
17437
|
+
const config = modules.comments;
|
|
17438
|
+
if (config === false || config == null) return null;
|
|
17439
|
+
return config;
|
|
17440
|
+
});
|
|
17433
17441
|
const layers = ref(null);
|
|
17434
17442
|
const commentsLayer = ref(null);
|
|
17435
17443
|
const toolsMenuPosition = reactive({ top: null, right: "-25px", zIndex: 101 });
|
|
@@ -17577,7 +17585,7 @@ const _sfc_main = {
|
|
|
17577
17585
|
rulers: doc.rulers,
|
|
17578
17586
|
isInternal: proxy.$superdoc.config.isInternal,
|
|
17579
17587
|
annotations: proxy.$superdoc.config.annotations,
|
|
17580
|
-
isCommentsEnabled:
|
|
17588
|
+
isCommentsEnabled: Boolean(commentsModuleConfig.value),
|
|
17581
17589
|
isAiEnabled: proxy.$superdoc.config.modules?.ai,
|
|
17582
17590
|
slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
|
|
17583
17591
|
onBeforeCreate: onEditorBeforeCreate,
|
|
@@ -17608,7 +17616,8 @@ const _sfc_main = {
|
|
|
17608
17616
|
return options;
|
|
17609
17617
|
};
|
|
17610
17618
|
const onEditorCommentLocationsUpdate = ({ allCommentIds: activeThreadId, allCommentPositions }) => {
|
|
17611
|
-
|
|
17619
|
+
const commentsConfig = proxy.$superdoc.config.modules?.comments;
|
|
17620
|
+
if (!commentsConfig || commentsConfig === false) return;
|
|
17612
17621
|
handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
|
|
17613
17622
|
};
|
|
17614
17623
|
const onEditorCommentsUpdate = (params2 = {}) => {
|
|
@@ -17630,7 +17639,7 @@ const _sfc_main = {
|
|
|
17630
17639
|
proxy.$superdoc.config.onTransaction({ editor, transaction, duration: duration2 });
|
|
17631
17640
|
}
|
|
17632
17641
|
};
|
|
17633
|
-
const isCommentsEnabled = computed(() =>
|
|
17642
|
+
const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
|
|
17634
17643
|
const showCommentsSidebar = computed(() => {
|
|
17635
17644
|
return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
|
|
17636
17645
|
});
|
|
@@ -17640,13 +17649,14 @@ const _sfc_main = {
|
|
|
17640
17649
|
});
|
|
17641
17650
|
computed(() => {
|
|
17642
17651
|
if (!isCommentsEnabled.value) return false;
|
|
17643
|
-
!getConfig?.readOnly && selectionPosition.value;
|
|
17652
|
+
return !getConfig.value?.readOnly && selectionPosition.value;
|
|
17644
17653
|
});
|
|
17645
17654
|
watch(showCommentsSidebar, (value) => {
|
|
17646
17655
|
proxy.$superdoc.broadcastSidebarToggle(value);
|
|
17647
17656
|
});
|
|
17648
17657
|
const scrollToComment = (commentId) => {
|
|
17649
|
-
|
|
17658
|
+
const commentsConfig = proxy.$superdoc.config?.modules?.comments;
|
|
17659
|
+
if (!commentsConfig || commentsConfig === false) return;
|
|
17650
17660
|
const element = document.querySelector(`[data-thread-id=${commentId}]`);
|
|
17651
17661
|
if (element) {
|
|
17652
17662
|
element.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
@@ -17654,7 +17664,8 @@ const _sfc_main = {
|
|
|
17654
17664
|
}
|
|
17655
17665
|
};
|
|
17656
17666
|
onMounted(() => {
|
|
17657
|
-
|
|
17667
|
+
const config = commentsModuleConfig.value;
|
|
17668
|
+
if (config && !config.readOnly) {
|
|
17658
17669
|
document.addEventListener("mousedown", handleDocumentMouseDown);
|
|
17659
17670
|
}
|
|
17660
17671
|
});
|
|
@@ -17776,6 +17787,7 @@ const _sfc_main = {
|
|
|
17776
17787
|
};
|
|
17777
17788
|
const shouldShowSelection = computed(() => {
|
|
17778
17789
|
const config = proxy.$superdoc.config.modules?.comments;
|
|
17790
|
+
if (!config || config === false) return false;
|
|
17779
17791
|
return !config.readOnly;
|
|
17780
17792
|
});
|
|
17781
17793
|
const handleSuperEditorPageMarginsChange = (doc, params2) => {
|
|
@@ -17942,7 +17954,7 @@ const _sfc_main = {
|
|
|
17942
17954
|
};
|
|
17943
17955
|
}
|
|
17944
17956
|
};
|
|
17945
|
-
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17957
|
+
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-45f44b6e"]]);
|
|
17946
17958
|
const createSuperdocVueApp = () => {
|
|
17947
17959
|
const app = createApp(App);
|
|
17948
17960
|
const pinia = createPinia();
|
|
@@ -18041,6 +18053,10 @@ class SuperDoc extends EventEmitter {
|
|
|
18041
18053
|
...this.config,
|
|
18042
18054
|
...config
|
|
18043
18055
|
};
|
|
18056
|
+
this.config.modules = this.config.modules || {};
|
|
18057
|
+
if (!Object.prototype.hasOwnProperty.call(this.config.modules, "comments")) {
|
|
18058
|
+
this.config.modules.comments = {};
|
|
18059
|
+
}
|
|
18044
18060
|
this.config.colors = shuffleArray(this.config.colors);
|
|
18045
18061
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
18046
18062
|
this.colorIndex = 0;
|
|
@@ -18175,7 +18191,8 @@ class SuperDoc extends EventEmitter {
|
|
|
18175
18191
|
this.superdocStore.setExceptionHandler((payload) => this.emit("exception", payload));
|
|
18176
18192
|
}
|
|
18177
18193
|
this.superdocStore.init(this.config);
|
|
18178
|
-
this.
|
|
18194
|
+
const commentsModuleConfig = this.config.modules.comments;
|
|
18195
|
+
this.commentsStore.init(commentsModuleConfig && commentsModuleConfig !== false ? commentsModuleConfig : {});
|
|
18179
18196
|
}
|
|
18180
18197
|
#initListeners() {
|
|
18181
18198
|
this.on("editorBeforeCreate", this.config.onEditorBeforeCreate);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const vue = require("./vue-
|
|
2
|
+
const vue = require("./vue-DKMj1I9B.cjs");
|
|
3
3
|
const Y = require("yjs");
|
|
4
4
|
function _interopNamespaceDefault(e) {
|
|
5
5
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -5111,6 +5111,19 @@ function requireSafeRegexTest() {
|
|
|
5111
5111
|
};
|
|
5112
5112
|
return safeRegexTest;
|
|
5113
5113
|
}
|
|
5114
|
+
var generatorFunction;
|
|
5115
|
+
var hasRequiredGeneratorFunction;
|
|
5116
|
+
function requireGeneratorFunction() {
|
|
5117
|
+
if (hasRequiredGeneratorFunction) return generatorFunction;
|
|
5118
|
+
hasRequiredGeneratorFunction = 1;
|
|
5119
|
+
const cached = (
|
|
5120
|
+
/** @type {GeneratorFunctionConstructor} */
|
|
5121
|
+
function* () {
|
|
5122
|
+
}.constructor
|
|
5123
|
+
);
|
|
5124
|
+
generatorFunction = () => cached;
|
|
5125
|
+
return generatorFunction;
|
|
5126
|
+
}
|
|
5114
5127
|
var isGeneratorFunction;
|
|
5115
5128
|
var hasRequiredIsGeneratorFunction;
|
|
5116
5129
|
function requireIsGeneratorFunction() {
|
|
@@ -5123,16 +5136,7 @@ function requireIsGeneratorFunction() {
|
|
|
5123
5136
|
var getProto2 = requireGetProto();
|
|
5124
5137
|
var toStr = callBound2("Object.prototype.toString");
|
|
5125
5138
|
var fnToStr = callBound2("Function.prototype.toString");
|
|
5126
|
-
var
|
|
5127
|
-
if (!hasToStringTag) {
|
|
5128
|
-
return false;
|
|
5129
|
-
}
|
|
5130
|
-
try {
|
|
5131
|
-
return Function("return function*() {}")();
|
|
5132
|
-
} catch (e) {
|
|
5133
|
-
}
|
|
5134
|
-
};
|
|
5135
|
-
var GeneratorFunction;
|
|
5139
|
+
var getGeneratorFunction = /* @__PURE__ */ requireGeneratorFunction();
|
|
5136
5140
|
isGeneratorFunction = function isGeneratorFunction2(fn2) {
|
|
5137
5141
|
if (typeof fn2 !== "function") {
|
|
5138
5142
|
return false;
|
|
@@ -5147,14 +5151,8 @@ function requireIsGeneratorFunction() {
|
|
|
5147
5151
|
if (!getProto2) {
|
|
5148
5152
|
return false;
|
|
5149
5153
|
}
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
GeneratorFunction = generatorFunc ? (
|
|
5153
|
-
/** @type {GeneratorFunctionConstructor} */
|
|
5154
|
-
getProto2(generatorFunc)
|
|
5155
|
-
) : false;
|
|
5156
|
-
}
|
|
5157
|
-
return getProto2(fn2) === GeneratorFunction;
|
|
5154
|
+
var GeneratorFunction = getGeneratorFunction();
|
|
5155
|
+
return GeneratorFunction && getProto2(fn2) === GeneratorFunction.prototype;
|
|
5158
5156
|
};
|
|
5159
5157
|
return isGeneratorFunction;
|
|
5160
5158
|
}
|
|
@@ -42092,8 +42090,7 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
|
|
|
42092
42090
|
let $to = parse.doc.resolveNoCache(change.endB - parse.from);
|
|
42093
42091
|
let $fromA = doc2.resolve(change.start);
|
|
42094
42092
|
let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
|
|
42095
|
-
|
|
42096
|
-
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) && (nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) && nextSel.head > $from.pos) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
42093
|
+
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
42097
42094
|
view.input.lastIOSEnter = 0;
|
|
42098
42095
|
return;
|
|
42099
42096
|
}
|
|
@@ -54237,6 +54234,17 @@ function getStructuredContentTagsById(idOrIds, state2) {
|
|
|
54237
54234
|
});
|
|
54238
54235
|
return result;
|
|
54239
54236
|
}
|
|
54237
|
+
function getStructuredContentTagsByAlias(aliasOrAliases, state2) {
|
|
54238
|
+
const result = findChildren$5(state2.doc, (node) => {
|
|
54239
|
+
const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
|
|
54240
|
+
if (Array.isArray(aliasOrAliases)) {
|
|
54241
|
+
return isStructuredContent && aliasOrAliases.includes(node.attrs.alias);
|
|
54242
|
+
} else {
|
|
54243
|
+
return isStructuredContent && node.attrs.alias === aliasOrAliases;
|
|
54244
|
+
}
|
|
54245
|
+
});
|
|
54246
|
+
return result;
|
|
54247
|
+
}
|
|
54240
54248
|
function getStructuredContentTags(state2) {
|
|
54241
54249
|
const result = findChildren$5(state2.doc, (node) => {
|
|
54242
54250
|
return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
|
|
@@ -54256,6 +54264,7 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
|
|
|
54256
54264
|
getStructuredContentBlockTags,
|
|
54257
54265
|
getStructuredContentInlineTags,
|
|
54258
54266
|
getStructuredContentTags,
|
|
54267
|
+
getStructuredContentTagsByAlias,
|
|
54259
54268
|
getStructuredContentTagsById
|
|
54260
54269
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
54261
54270
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
@@ -54344,10 +54353,11 @@ const StructuredContentCommands = Extension.create({
|
|
|
54344
54353
|
return true;
|
|
54345
54354
|
},
|
|
54346
54355
|
/**
|
|
54347
|
-
* Updates a structured content
|
|
54356
|
+
* Updates a single structured content field by its unique ID.
|
|
54357
|
+
* IDs are unique identifiers, so this will update at most one field.
|
|
54348
54358
|
* If the updated node does not match the schema, it will not be updated.
|
|
54349
54359
|
* @category Command
|
|
54350
|
-
* @param {string} id
|
|
54360
|
+
* @param {string} id - Unique identifier of the field
|
|
54351
54361
|
* @param {StructuredContentUpdate} options
|
|
54352
54362
|
*/
|
|
54353
54363
|
updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
@@ -54387,6 +54397,54 @@ const StructuredContentCommands = Extension.create({
|
|
|
54387
54397
|
}
|
|
54388
54398
|
return true;
|
|
54389
54399
|
},
|
|
54400
|
+
/**
|
|
54401
|
+
* Updates all structured content fields with the same alias.
|
|
54402
|
+
* Unlike IDs (which are unique), aliases can be shared across multiple fields.
|
|
54403
|
+
* This will update every field that matches the given alias.
|
|
54404
|
+
* If any updated node does not match the schema, no updates will be applied.
|
|
54405
|
+
* @category Command
|
|
54406
|
+
* @param {string} alias - Shared identifier for fields (e.g., "customer_name")
|
|
54407
|
+
* @param {StructuredContentUpdate} options
|
|
54408
|
+
*/
|
|
54409
|
+
updateStructuredContentByAlias: (alias, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
54410
|
+
const structuredContentTags = getStructuredContentTagsByAlias(alias, state2);
|
|
54411
|
+
if (!structuredContentTags.length) {
|
|
54412
|
+
return true;
|
|
54413
|
+
}
|
|
54414
|
+
const { schema } = editor;
|
|
54415
|
+
const updates = [];
|
|
54416
|
+
for (const { pos, node } of structuredContentTags) {
|
|
54417
|
+
let content = null;
|
|
54418
|
+
if (options.text) {
|
|
54419
|
+
content = schema.text(options.text);
|
|
54420
|
+
}
|
|
54421
|
+
if (options.html) {
|
|
54422
|
+
const html = htmlHandler(options.html, editor);
|
|
54423
|
+
const doc2 = DOMParser$1.fromSchema(schema).parse(html);
|
|
54424
|
+
content = doc2.content;
|
|
54425
|
+
}
|
|
54426
|
+
if (options.json) {
|
|
54427
|
+
content = schema.nodeFromJSON(options.json);
|
|
54428
|
+
}
|
|
54429
|
+
if (!content) {
|
|
54430
|
+
content = node.content;
|
|
54431
|
+
}
|
|
54432
|
+
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
54433
|
+
try {
|
|
54434
|
+
updatedNode.check();
|
|
54435
|
+
updates.push({ pos, node: updatedNode, size: node.nodeSize });
|
|
54436
|
+
} catch {
|
|
54437
|
+
console.error("Updated node does not conform to the schema");
|
|
54438
|
+
return false;
|
|
54439
|
+
}
|
|
54440
|
+
}
|
|
54441
|
+
if (dispatch) {
|
|
54442
|
+
updates.reverse().forEach(({ pos, node, size: size2 }) => {
|
|
54443
|
+
tr.replaceWith(pos, pos + size2, node);
|
|
54444
|
+
});
|
|
54445
|
+
}
|
|
54446
|
+
return true;
|
|
54447
|
+
},
|
|
54390
54448
|
/**
|
|
54391
54449
|
* Removes a structured content.
|
|
54392
54450
|
* @category Command
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as global$2, c as createElementBlock, o as openBlock, a as createBaseVNode, r as ref$1, b as createApp, d as computed, F as Fragment$1, e as renderList, n as normalizeClass, w as withModifiers, f as createCommentVNode, t as toDisplayString, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, p as getCurrentInstance, q as onDeactivated, s as nextTick, u as createBlock, v as createVNode, x as unref, y as withCtx, z as createTextVNode, A as normalizeStyle, B as h$1, C as toRef, D as provide, E as mergeProps, G as cloneVNode, T as Text$2, H as withDirectives, I as watchEffect, J as shallowRef, K as vModelText, L as withKeys, M as reactive, N as readonly, O as Transition, P as vShow, Q as Comment, R as renderSlot, S as onActivated, U as Teleport, V as isVNode, W as onUnmounted, X as resolveDynamicComponent, Y as normalizeProps, Z as guardReactiveProps, _ as markRaw } from "./vue-
|
|
1
|
+
import { g as global$2, c as createElementBlock, o as openBlock, a as createBaseVNode, r as ref$1, b as createApp, d as computed, F as Fragment$1, e as renderList, n as normalizeClass, w as withModifiers, f as createCommentVNode, t as toDisplayString, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, p as getCurrentInstance, q as onDeactivated, s as nextTick, u as createBlock, v as createVNode, x as unref, y as withCtx, z as createTextVNode, A as normalizeStyle, B as h$1, C as toRef, D as provide, E as mergeProps, G as cloneVNode, T as Text$2, H as withDirectives, I as watchEffect, J as shallowRef, K as vModelText, L as withKeys, M as reactive, N as readonly, O as Transition, P as vShow, Q as Comment, R as renderSlot, S as onActivated, U as Teleport, V as isVNode, W as onUnmounted, X as resolveDynamicComponent, Y as normalizeProps, Z as guardReactiveProps, _ as markRaw } from "./vue-ZWZLQtoU.es.js";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { UndoManager, Item as Item$2, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
4
4
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -5094,6 +5094,19 @@ function requireSafeRegexTest() {
|
|
|
5094
5094
|
};
|
|
5095
5095
|
return safeRegexTest;
|
|
5096
5096
|
}
|
|
5097
|
+
var generatorFunction;
|
|
5098
|
+
var hasRequiredGeneratorFunction;
|
|
5099
|
+
function requireGeneratorFunction() {
|
|
5100
|
+
if (hasRequiredGeneratorFunction) return generatorFunction;
|
|
5101
|
+
hasRequiredGeneratorFunction = 1;
|
|
5102
|
+
const cached = (
|
|
5103
|
+
/** @type {GeneratorFunctionConstructor} */
|
|
5104
|
+
function* () {
|
|
5105
|
+
}.constructor
|
|
5106
|
+
);
|
|
5107
|
+
generatorFunction = () => cached;
|
|
5108
|
+
return generatorFunction;
|
|
5109
|
+
}
|
|
5097
5110
|
var isGeneratorFunction;
|
|
5098
5111
|
var hasRequiredIsGeneratorFunction;
|
|
5099
5112
|
function requireIsGeneratorFunction() {
|
|
@@ -5106,16 +5119,7 @@ function requireIsGeneratorFunction() {
|
|
|
5106
5119
|
var getProto2 = requireGetProto();
|
|
5107
5120
|
var toStr = callBound2("Object.prototype.toString");
|
|
5108
5121
|
var fnToStr = callBound2("Function.prototype.toString");
|
|
5109
|
-
var
|
|
5110
|
-
if (!hasToStringTag) {
|
|
5111
|
-
return false;
|
|
5112
|
-
}
|
|
5113
|
-
try {
|
|
5114
|
-
return Function("return function*() {}")();
|
|
5115
|
-
} catch (e) {
|
|
5116
|
-
}
|
|
5117
|
-
};
|
|
5118
|
-
var GeneratorFunction;
|
|
5122
|
+
var getGeneratorFunction = /* @__PURE__ */ requireGeneratorFunction();
|
|
5119
5123
|
isGeneratorFunction = function isGeneratorFunction2(fn2) {
|
|
5120
5124
|
if (typeof fn2 !== "function") {
|
|
5121
5125
|
return false;
|
|
@@ -5130,14 +5134,8 @@ function requireIsGeneratorFunction() {
|
|
|
5130
5134
|
if (!getProto2) {
|
|
5131
5135
|
return false;
|
|
5132
5136
|
}
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
GeneratorFunction = generatorFunc ? (
|
|
5136
|
-
/** @type {GeneratorFunctionConstructor} */
|
|
5137
|
-
getProto2(generatorFunc)
|
|
5138
|
-
) : false;
|
|
5139
|
-
}
|
|
5140
|
-
return getProto2(fn2) === GeneratorFunction;
|
|
5137
|
+
var GeneratorFunction = getGeneratorFunction();
|
|
5138
|
+
return GeneratorFunction && getProto2(fn2) === GeneratorFunction.prototype;
|
|
5141
5139
|
};
|
|
5142
5140
|
return isGeneratorFunction;
|
|
5143
5141
|
}
|
|
@@ -42075,8 +42073,7 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
|
|
|
42075
42073
|
let $to = parse.doc.resolveNoCache(change.endB - parse.from);
|
|
42076
42074
|
let $fromA = doc2.resolve(change.start);
|
|
42077
42075
|
let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
|
|
42078
|
-
|
|
42079
|
-
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) && (nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) && nextSel.head > $from.pos) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
42076
|
+
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
42080
42077
|
view.input.lastIOSEnter = 0;
|
|
42081
42078
|
return;
|
|
42082
42079
|
}
|
|
@@ -54220,6 +54217,17 @@ function getStructuredContentTagsById(idOrIds, state2) {
|
|
|
54220
54217
|
});
|
|
54221
54218
|
return result;
|
|
54222
54219
|
}
|
|
54220
|
+
function getStructuredContentTagsByAlias(aliasOrAliases, state2) {
|
|
54221
|
+
const result = findChildren$5(state2.doc, (node) => {
|
|
54222
|
+
const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
|
|
54223
|
+
if (Array.isArray(aliasOrAliases)) {
|
|
54224
|
+
return isStructuredContent && aliasOrAliases.includes(node.attrs.alias);
|
|
54225
|
+
} else {
|
|
54226
|
+
return isStructuredContent && node.attrs.alias === aliasOrAliases;
|
|
54227
|
+
}
|
|
54228
|
+
});
|
|
54229
|
+
return result;
|
|
54230
|
+
}
|
|
54223
54231
|
function getStructuredContentTags(state2) {
|
|
54224
54232
|
const result = findChildren$5(state2.doc, (node) => {
|
|
54225
54233
|
return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
|
|
@@ -54239,6 +54247,7 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
|
|
|
54239
54247
|
getStructuredContentBlockTags,
|
|
54240
54248
|
getStructuredContentInlineTags,
|
|
54241
54249
|
getStructuredContentTags,
|
|
54250
|
+
getStructuredContentTagsByAlias,
|
|
54242
54251
|
getStructuredContentTagsById
|
|
54243
54252
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
54244
54253
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
@@ -54327,10 +54336,11 @@ const StructuredContentCommands = Extension.create({
|
|
|
54327
54336
|
return true;
|
|
54328
54337
|
},
|
|
54329
54338
|
/**
|
|
54330
|
-
* Updates a structured content
|
|
54339
|
+
* Updates a single structured content field by its unique ID.
|
|
54340
|
+
* IDs are unique identifiers, so this will update at most one field.
|
|
54331
54341
|
* If the updated node does not match the schema, it will not be updated.
|
|
54332
54342
|
* @category Command
|
|
54333
|
-
* @param {string} id
|
|
54343
|
+
* @param {string} id - Unique identifier of the field
|
|
54334
54344
|
* @param {StructuredContentUpdate} options
|
|
54335
54345
|
*/
|
|
54336
54346
|
updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
@@ -54370,6 +54380,54 @@ const StructuredContentCommands = Extension.create({
|
|
|
54370
54380
|
}
|
|
54371
54381
|
return true;
|
|
54372
54382
|
},
|
|
54383
|
+
/**
|
|
54384
|
+
* Updates all structured content fields with the same alias.
|
|
54385
|
+
* Unlike IDs (which are unique), aliases can be shared across multiple fields.
|
|
54386
|
+
* This will update every field that matches the given alias.
|
|
54387
|
+
* If any updated node does not match the schema, no updates will be applied.
|
|
54388
|
+
* @category Command
|
|
54389
|
+
* @param {string} alias - Shared identifier for fields (e.g., "customer_name")
|
|
54390
|
+
* @param {StructuredContentUpdate} options
|
|
54391
|
+
*/
|
|
54392
|
+
updateStructuredContentByAlias: (alias, options = {}) => ({ editor, dispatch, state: state2, tr }) => {
|
|
54393
|
+
const structuredContentTags = getStructuredContentTagsByAlias(alias, state2);
|
|
54394
|
+
if (!structuredContentTags.length) {
|
|
54395
|
+
return true;
|
|
54396
|
+
}
|
|
54397
|
+
const { schema } = editor;
|
|
54398
|
+
const updates = [];
|
|
54399
|
+
for (const { pos, node } of structuredContentTags) {
|
|
54400
|
+
let content = null;
|
|
54401
|
+
if (options.text) {
|
|
54402
|
+
content = schema.text(options.text);
|
|
54403
|
+
}
|
|
54404
|
+
if (options.html) {
|
|
54405
|
+
const html = htmlHandler(options.html, editor);
|
|
54406
|
+
const doc2 = DOMParser$1.fromSchema(schema).parse(html);
|
|
54407
|
+
content = doc2.content;
|
|
54408
|
+
}
|
|
54409
|
+
if (options.json) {
|
|
54410
|
+
content = schema.nodeFromJSON(options.json);
|
|
54411
|
+
}
|
|
54412
|
+
if (!content) {
|
|
54413
|
+
content = node.content;
|
|
54414
|
+
}
|
|
54415
|
+
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
54416
|
+
try {
|
|
54417
|
+
updatedNode.check();
|
|
54418
|
+
updates.push({ pos, node: updatedNode, size: node.nodeSize });
|
|
54419
|
+
} catch {
|
|
54420
|
+
console.error("Updated node does not conform to the schema");
|
|
54421
|
+
return false;
|
|
54422
|
+
}
|
|
54423
|
+
}
|
|
54424
|
+
if (dispatch) {
|
|
54425
|
+
updates.reverse().forEach(({ pos, node, size: size2 }) => {
|
|
54426
|
+
tr.replaceWith(pos, pos + size2, node);
|
|
54427
|
+
});
|
|
54428
|
+
}
|
|
54429
|
+
return true;
|
|
54430
|
+
},
|
|
54373
54431
|
/**
|
|
54374
54432
|
* Removes a structured content.
|
|
54375
54433
|
* @category Command
|