superdoc 1.0.0-beta.2 → 1.0.0-beta.4
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-saAhozRR.es.js → PdfViewer-DUns3s8O.es.js} +2 -2
- package/dist/chunks/{PdfViewer-CeuX3gOe.cjs → PdfViewer-ZtwLhE_8.cjs} +1 -1
- package/dist/chunks/{eventemitter3-BZXKb7j7.es.js → eventemitter3-ByBH0NYV.es.js} +1 -1
- package/dist/chunks/{index-Sn-JVHIg-BCItIT88.es.js → index-BNGaD3Up-CQuoo1EF.es.js} +1 -1
- package/dist/chunks/{index-Sn-JVHIg-BxOp3gSx.cjs → index-BNGaD3Up-D2cRHMMk.cjs} +1 -1
- package/dist/chunks/{index-Dh5oVJua.cjs → index-BW38mdZF.cjs} +3 -3
- package/dist/chunks/{index-C0OeGje6.es.js → index-DIccWgYh.es.js} +6 -6
- package/dist/chunks/{jszip-Duxs2YMV.es.js → jszip-BwsONqK5.es.js} +1 -1
- package/dist/chunks/{super-editor.es-BKljkYUU.cjs → super-editor.es-C06-V-Iy.cjs} +736 -215
- package/dist/chunks/{super-editor.es-Dcz39nKY.es.js → super-editor.es-CtCHBIPE.es.js} +737 -216
- package/dist/chunks/{vue-B5QAf5pA.es.js → vue-CztqUvm1.es.js} +17 -17
- package/dist/chunks/xml-js-BZPSMmVo.es.js +2 -0
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts +35 -2
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BFGB7hqj.js → converter-ZJiSHoiq.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-OPbzIk16.js → docx-zipper-B7FStorN.js} +1 -1
- package/dist/super-editor/chunks/{editor-CtI4XnMw.js → editor-DvepAjbe.js} +553 -181
- package/dist/super-editor/chunks/{index-Sn-JVHIg.js → index-BNGaD3Up.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-BydALv4o.js → toolbar-CKXXbIQO.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/super-editor.es.js +217 -41
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +738 -217
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/xml-js-CVyfrKaV.es.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
|
|
2
|
-
import { p as process$1 } from "./converter-
|
|
3
|
-
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-
|
|
2
|
+
import { p as process$1 } from "./converter-ZJiSHoiq.js";
|
|
3
|
+
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-DvepAjbe.js";
|
|
4
4
|
const sanitizeNumber = (value, defaultNumber) => {
|
|
5
5
|
let sanitized = value.replace(/[^0-9.]/g, "");
|
|
6
6
|
sanitized = parseFloat(sanitized);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E } from "./chunks/editor-
|
|
2
|
-
import "./chunks/converter-
|
|
3
|
-
import "./chunks/docx-zipper-
|
|
1
|
+
import { E } from "./chunks/editor-DvepAjbe.js";
|
|
2
|
+
import "./chunks/converter-ZJiSHoiq.js";
|
|
3
|
+
import "./chunks/docx-zipper-B7FStorN.js";
|
|
4
4
|
export {
|
|
5
5
|
E as Editor
|
|
6
6
|
};
|
|
@@ -8,15 +8,15 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
11
|
-
var _SuperToolbar_instances, initToolbarGroups_fn, _interceptedCommands, makeToolbarItems_fn, initDefaultFonts_fn, updateHighlightColors_fn, deactivateAll_fn, updateToolbarHistory_fn, enrichTrackedChanges_fn, runCommandWithArgumentOnly_fn;
|
|
12
|
-
import { aJ as getDefaultExportFromCjs, a0 as v4, T as TextSelection$1, v as getMarkRange, aM as vClickOutside, aN as getActiveFormatting, aC as isInTable, U as findParentNode, aq as calculateResolvedParagraphProperties, a7 as twipsToLines, V as isList, a8 as pixelsToTwips, aO as getFileObject, aP as translator, aQ as translator$1, aR as translator$2, aS as translator$3, aT as translator$4, aU as translator$5, aV as translator$6, aW as translator$7, aX as translator$8, aY as translator$9, aZ as translator$a, a_ as translator$b, a$ as translator$c, b0 as translator$d, b1 as translator$e, b2 as commentRangeEndTranslator, b3 as commentRangeStartTranslator, b4 as translator$f, b5 as translator$g, b6 as translator$h, b7 as translator$i, b8 as translator$j, b9 as translator$k, ba as translator$l, bb as translator$m, bc as translator$n, bd as translator$o, be as translator$p, bf as translator$q, bg as translator$r, bh as translator$s, bi as translator$t, bj as translator$u, bk as translator$v, bl as translator$w, bm as translator$x, bn as translator$y, bo as translator$z, bp as translator$A, bq as translator$B, br as translator$C, bs as translator$D, bt as translator$E, bu as translator$F, bv as translator$G, bw as translator$H, bx as translator$I, by as translator$J, bz as translator$K, bA as translator$L, bB as translator$M, bC as translator$N, bD as translator$O, bE as translator$P, bF as translator$Q, bG as translator$R, bH as translator$S, bI as translator$T, bJ as translator$U, bK as translator$V, bL as translator$W, bM as translator$X, bN as translator$Y, bO as translator$Z, bP as translator$_, bQ as translator$$, bR as translator$10, bS as translator$11, bT as translator$12, bU as translator$13, bV as translator$14, bW as translator$15, bX as translator$16, bY as translator$17, bZ as translator$18, b_ as translator$19, b$ as translator$1a, c0 as translator$1b, c1 as translator$1c, c2 as translator$1d, c3 as translator$1e, c4 as translator$1f, c5 as translator$1g, c6 as translator$1h, c7 as translator$1i, c8 as translator$1j, P as PluginKey, a as Plugin } from "./chunks/converter-
|
|
13
|
-
import { ac, i, a9 } from "./chunks/converter-
|
|
14
|
-
import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, d as checkAndProcessImage, r as replaceSelectionWithImagePlaceholder, e as uploadAndInsertImage, f as collectTrackedChanges, i as isTrackedChangeActionAllowed, y as yUndoPluginKey, h as undoDepth, j as redoDepth, k as getEditorSurfaceElement, l as collectTrackedChangesForContext, s as shouldBypassContextMenu, S as SlashMenuPluginKey, m as measureCache, n as isHeadless, E as Editor, o as getStarterExtensions, P as PresentationEditor, p as Placeholder, q as getRichTextExtensions, D as DecorationSet, t as Decoration, M as Mark, v as Extension, A as Attribute, N as Node } from "./chunks/editor-
|
|
15
|
-
import { z, F, B, T, w, C, x } from "./chunks/editor-
|
|
11
|
+
var _MARK_TOGGLE_NAMES, _SuperToolbar_instances, initToolbarGroups_fn, _interceptedCommands, makeToolbarItems_fn, initDefaultFonts_fn, updateHighlightColors_fn, deactivateAll_fn, updateToolbarHistory_fn, enrichTrackedChanges_fn, runCommandWithArgumentOnly_fn, syncStickyMarksFromState_fn, restoreStickyMarksIfNeeded_fn, ensureStoredMarksForMarkToggle_fn;
|
|
12
|
+
import { aJ as getDefaultExportFromCjs, a0 as v4, T as TextSelection$1, v as getMarkRange, aM as vClickOutside, aN as getActiveFormatting, aC as isInTable, U as findParentNode, aq as calculateResolvedParagraphProperties, a7 as twipsToLines, V as isList, al as parseSizeUnit, a8 as pixelsToTwips, aO as getFileObject, aP as translator, aQ as translator$1, aR as translator$2, aS as translator$3, aT as translator$4, aU as translator$5, aV as translator$6, aW as translator$7, aX as translator$8, aY as translator$9, aZ as translator$a, a_ as translator$b, a$ as translator$c, b0 as translator$d, b1 as translator$e, b2 as commentRangeEndTranslator, b3 as commentRangeStartTranslator, b4 as translator$f, b5 as translator$g, b6 as translator$h, b7 as translator$i, b8 as translator$j, b9 as translator$k, ba as translator$l, bb as translator$m, bc as translator$n, bd as translator$o, be as translator$p, bf as translator$q, bg as translator$r, bh as translator$s, bi as translator$t, bj as translator$u, bk as translator$v, bl as translator$w, bm as translator$x, bn as translator$y, bo as translator$z, bp as translator$A, bq as translator$B, br as translator$C, bs as translator$D, bt as translator$E, bu as translator$F, bv as translator$G, bw as translator$H, bx as translator$I, by as translator$J, bz as translator$K, bA as translator$L, bB as translator$M, bC as translator$N, bD as translator$O, bE as translator$P, bF as translator$Q, bG as translator$R, bH as translator$S, bI as translator$T, bJ as translator$U, bK as translator$V, bL as translator$W, bM as translator$X, bN as translator$Y, bO as translator$Z, bP as translator$_, bQ as translator$$, bR as translator$10, bS as translator$11, bT as translator$12, bU as translator$13, bV as translator$14, bW as translator$15, bX as translator$16, bY as translator$17, bZ as translator$18, b_ as translator$19, b$ as translator$1a, c0 as translator$1b, c1 as translator$1c, c2 as translator$1d, c3 as translator$1e, c4 as translator$1f, c5 as translator$1g, c6 as translator$1h, c7 as translator$1i, c8 as translator$1j, P as PluginKey, a as Plugin } from "./chunks/converter-ZJiSHoiq.js";
|
|
13
|
+
import { ac, i, a9 } from "./chunks/converter-ZJiSHoiq.js";
|
|
14
|
+
import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, d as checkAndProcessImage, r as replaceSelectionWithImagePlaceholder, e as uploadAndInsertImage, f as collectTrackedChanges, i as isTrackedChangeActionAllowed, y as yUndoPluginKey, h as undoDepth, j as redoDepth, k as getEditorSurfaceElement, l as collectTrackedChangesForContext, s as shouldBypassContextMenu, S as SlashMenuPluginKey, m as measureCache, n as isHeadless, E as Editor, o as getStarterExtensions, P as PresentationEditor, p as Placeholder, q as getRichTextExtensions, D as DecorationSet, t as Decoration, M as Mark, v as Extension, A as Attribute, N as Node } from "./chunks/editor-DvepAjbe.js";
|
|
15
|
+
import { z, F, B, T, w, C, x } from "./chunks/editor-DvepAjbe.js";
|
|
16
16
|
import { ref, onMounted, createElementBlock, openBlock, normalizeClass, unref, Fragment, renderList, createElementVNode, withModifiers, toDisplayString, createCommentVNode, normalizeStyle, computed, watch, withDirectives, withKeys, vModelText, createTextVNode, createVNode, h, createApp, markRaw, nextTick, onBeforeUnmount, defineComponent, reactive, onUnmounted, renderSlot, shallowRef, createBlock, withCtx, resolveDynamicComponent, normalizeProps, guardReactiveProps } from "vue";
|
|
17
|
-
import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, p as plusIconSvg, a as trashIconSvg, b as borderNoneIconSvg, c as arrowsToDotIconSvg, d as arrowsLeftRightIconSvg, w as wrenchIconSvg, m as magicWandIcon, e as checkIconSvg$1, x as xMarkIconSvg, l as linkIconSvg, f as tableIconSvg, g as scissorsIconSvg, h as copyIconSvg, i as pasteIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-
|
|
17
|
+
import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, p as plusIconSvg, a as trashIconSvg, b as borderNoneIconSvg, c as arrowsToDotIconSvg, d as arrowsLeftRightIconSvg, w as wrenchIconSvg, m as magicWandIcon, e as checkIconSvg$1, x as xMarkIconSvg, l as linkIconSvg, f as tableIconSvg, g as scissorsIconSvg, h as copyIconSvg, i as pasteIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-CKXXbIQO.js";
|
|
18
18
|
import AIWriter from "./ai-writer.es.js";
|
|
19
|
-
import { D } from "./chunks/docx-zipper-
|
|
19
|
+
import { D } from "./chunks/docx-zipper-B7FStorN.js";
|
|
20
20
|
import { createZip } from "./file-zipper.es.js";
|
|
21
21
|
var eventemitter3 = { exports: {} };
|
|
22
22
|
var hasRequiredEventemitter3;
|
|
@@ -236,7 +236,7 @@ const useToolbarItem = (options) => {
|
|
|
236
236
|
if (!Array.isArray(options.options)) throw new Error("Invalid toolbar item options - " + options.options);
|
|
237
237
|
nestedOptions.value?.push(...options.options);
|
|
238
238
|
}
|
|
239
|
-
const activate = (attrs, ...args) => {
|
|
239
|
+
const activate = (attrs = {}, ...args) => {
|
|
240
240
|
onActivate(attrs, ...args);
|
|
241
241
|
if (suppressActiveHighlight.value) return;
|
|
242
242
|
active.value = true;
|
|
@@ -2508,7 +2508,7 @@ const isNegatedMark = (name, attrs = {}) => {
|
|
|
2508
2508
|
if (typeof checker !== "function") return false;
|
|
2509
2509
|
return Boolean(checker(attrs));
|
|
2510
2510
|
};
|
|
2511
|
-
class
|
|
2511
|
+
const _SuperToolbar = class _SuperToolbar extends EventEmitter {
|
|
2512
2512
|
/**
|
|
2513
2513
|
* Creates a new SuperToolbar instance
|
|
2514
2514
|
* @param {ToolbarConfig} config - The configuration for the toolbar
|
|
@@ -2561,11 +2561,11 @@ class SuperToolbar extends EventEmitter {
|
|
|
2561
2561
|
const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
|
|
2562
2562
|
if (isMobileDevice && isSmallScreen) {
|
|
2563
2563
|
layers.style.transformOrigin = "0 0";
|
|
2564
|
-
layers.style.transform = `scale(${parseInt(argument) / 100})`;
|
|
2564
|
+
layers.style.transform = `scale(${parseInt(argument, 10) / 100})`;
|
|
2565
2565
|
} else {
|
|
2566
|
-
layers.style.zoom = parseInt(argument) / 100;
|
|
2566
|
+
layers.style.zoom = parseInt(argument, 10) / 100;
|
|
2567
2567
|
}
|
|
2568
|
-
this.superdoc.superdocStore.activeZoom = parseInt(argument);
|
|
2568
|
+
this.superdoc.superdocStore.activeZoom = parseInt(argument, 10);
|
|
2569
2569
|
},
|
|
2570
2570
|
/**
|
|
2571
2571
|
* Sets the document mode
|
|
@@ -2647,31 +2647,37 @@ class SuperToolbar extends EventEmitter {
|
|
|
2647
2647
|
* @returns {Promise<void>}
|
|
2648
2648
|
*/
|
|
2649
2649
|
startImageUpload: async () => {
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
file
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2650
|
+
try {
|
|
2651
|
+
let open = getFileOpener();
|
|
2652
|
+
let result = await open();
|
|
2653
|
+
if (!result?.file) {
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
const { size, file } = await checkAndProcessImage({
|
|
2657
|
+
file: result.file,
|
|
2658
|
+
getMaxContentSize: () => this.activeEditor.getMaxContentSize()
|
|
2659
|
+
});
|
|
2660
|
+
if (!file) {
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
const id = {};
|
|
2664
|
+
replaceSelectionWithImagePlaceholder({
|
|
2665
|
+
view: this.activeEditor.view,
|
|
2666
|
+
editorOptions: this.activeEditor.options,
|
|
2667
|
+
id
|
|
2668
|
+
});
|
|
2669
|
+
await uploadAndInsertImage({
|
|
2670
|
+
editor: this.activeEditor,
|
|
2671
|
+
view: this.activeEditor.view,
|
|
2672
|
+
file,
|
|
2673
|
+
size,
|
|
2674
|
+
id
|
|
2675
|
+
});
|
|
2676
|
+
} catch (error) {
|
|
2677
|
+
const err = new Error("[super-toolbar 🎨] Image upload failed");
|
|
2678
|
+
this.emit("exception", { error: err, editor: this.activeEditor, originalError: error });
|
|
2679
|
+
console.error(err, error);
|
|
2661
2680
|
}
|
|
2662
|
-
const id = {};
|
|
2663
|
-
replaceSelectionWithImagePlaceholder({
|
|
2664
|
-
view: this.activeEditor.view,
|
|
2665
|
-
editorOptions: this.activeEditor.options,
|
|
2666
|
-
id
|
|
2667
|
-
});
|
|
2668
|
-
await uploadAndInsertImage({
|
|
2669
|
-
editor: this.activeEditor,
|
|
2670
|
-
view: this.activeEditor.view,
|
|
2671
|
-
file,
|
|
2672
|
-
size,
|
|
2673
|
-
id
|
|
2674
|
-
});
|
|
2675
2681
|
},
|
|
2676
2682
|
/**
|
|
2677
2683
|
* Increases text indentation or list level
|
|
@@ -2844,6 +2850,13 @@ class SuperToolbar extends EventEmitter {
|
|
|
2844
2850
|
};
|
|
2845
2851
|
this.config.hideButtons = config.hideButtons ?? true;
|
|
2846
2852
|
this.config.responsiveToContainer = config.responsiveToContainer ?? false;
|
|
2853
|
+
this.pendingMarkCommands = [];
|
|
2854
|
+
this.stickyStoredMarks = null;
|
|
2855
|
+
this._boundEditorHandlers = {
|
|
2856
|
+
transaction: null,
|
|
2857
|
+
selectionUpdate: null,
|
|
2858
|
+
focus: null
|
|
2859
|
+
};
|
|
2847
2860
|
if (!this.config.selector && this.config.element) {
|
|
2848
2861
|
this.config.selector = this.config.element;
|
|
2849
2862
|
}
|
|
@@ -2903,12 +2916,28 @@ class SuperToolbar extends EventEmitter {
|
|
|
2903
2916
|
}
|
|
2904
2917
|
/**
|
|
2905
2918
|
* The toolbar expects an active Super Editor instance.
|
|
2906
|
-
*
|
|
2919
|
+
* Removes listeners from the previous editor (if any) before attaching to the new one.
|
|
2920
|
+
* @param {Object|null} editor - The editor instance to attach to the toolbar, or null to detach
|
|
2907
2921
|
* @returns {void}
|
|
2908
2922
|
*/
|
|
2909
2923
|
setActiveEditor(editor) {
|
|
2924
|
+
if (this.activeEditor && this._boundEditorHandlers.transaction) {
|
|
2925
|
+
this.activeEditor.off("transaction", this._boundEditorHandlers.transaction);
|
|
2926
|
+
this.activeEditor.off("selectionUpdate", this._boundEditorHandlers.selectionUpdate);
|
|
2927
|
+
this.activeEditor.off("focus", this._boundEditorHandlers.focus);
|
|
2928
|
+
this._boundEditorHandlers.transaction = null;
|
|
2929
|
+
this._boundEditorHandlers.selectionUpdate = null;
|
|
2930
|
+
this._boundEditorHandlers.focus = null;
|
|
2931
|
+
}
|
|
2910
2932
|
this.activeEditor = editor;
|
|
2911
|
-
|
|
2933
|
+
if (editor) {
|
|
2934
|
+
this._boundEditorHandlers.transaction = this.onEditorTransaction.bind(this);
|
|
2935
|
+
this._boundEditorHandlers.selectionUpdate = this.onEditorSelectionUpdate.bind(this);
|
|
2936
|
+
this._boundEditorHandlers.focus = this.onEditorFocus.bind(this);
|
|
2937
|
+
this.activeEditor.on("transaction", this._boundEditorHandlers.transaction);
|
|
2938
|
+
this.activeEditor.on("selectionUpdate", this._boundEditorHandlers.selectionUpdate);
|
|
2939
|
+
this.activeEditor.on("focus", this._boundEditorHandlers.focus);
|
|
2940
|
+
}
|
|
2912
2941
|
}
|
|
2913
2942
|
/**
|
|
2914
2943
|
* Get toolbar items by group name
|
|
@@ -3056,15 +3085,28 @@ class SuperToolbar extends EventEmitter {
|
|
|
3056
3085
|
* @returns {*} The result of the executed command, undefined if no result is returned
|
|
3057
3086
|
*/
|
|
3058
3087
|
emitCommand({ item, argument, option }) {
|
|
3088
|
+
const hasFocusFn = this.activeEditor?.view?.hasFocus;
|
|
3089
|
+
const wasFocused = Boolean(typeof hasFocusFn === "function" && hasFocusFn.call(this.activeEditor.view));
|
|
3090
|
+
const { command } = item;
|
|
3091
|
+
const isMarkToggle = this.isMarkToggle(item);
|
|
3092
|
+
if (!wasFocused && isMarkToggle) {
|
|
3093
|
+
this.pendingMarkCommands.push({ command, argument, item });
|
|
3094
|
+
item?.activate?.();
|
|
3095
|
+
if (this.activeEditor && !this.activeEditor.options.isHeaderOrFooter) {
|
|
3096
|
+
this.activeEditor.focus();
|
|
3097
|
+
}
|
|
3098
|
+
return;
|
|
3099
|
+
}
|
|
3059
3100
|
if (this.activeEditor && !this.activeEditor.options.isHeaderOrFooter) {
|
|
3060
3101
|
this.activeEditor.focus();
|
|
3061
3102
|
}
|
|
3062
|
-
const { command } = item;
|
|
3063
3103
|
if (!command) {
|
|
3064
3104
|
return;
|
|
3065
3105
|
}
|
|
3066
3106
|
if (command in __privateGet(this, _interceptedCommands)) {
|
|
3067
|
-
|
|
3107
|
+
const result = __privateGet(this, _interceptedCommands)[command]({ item, argument });
|
|
3108
|
+
if (isMarkToggle) __privateMethod(this, _SuperToolbar_instances, syncStickyMarksFromState_fn).call(this);
|
|
3109
|
+
return result;
|
|
3068
3110
|
}
|
|
3069
3111
|
if (this.activeEditor && this.activeEditor.commands && command in this.activeEditor.commands) {
|
|
3070
3112
|
this.activeEditor.commands[command](argument);
|
|
@@ -3075,9 +3117,67 @@ class SuperToolbar extends EventEmitter {
|
|
|
3075
3117
|
this.emit("exception", { error, editor: this.activeEditor });
|
|
3076
3118
|
throw error;
|
|
3077
3119
|
}
|
|
3120
|
+
if (isMarkToggle) __privateMethod(this, _SuperToolbar_instances, syncStickyMarksFromState_fn).call(this);
|
|
3078
3121
|
this.updateToolbarState();
|
|
3079
3122
|
}
|
|
3080
|
-
|
|
3123
|
+
/**
|
|
3124
|
+
* Processes and executes pending mark commands when editor selection updates.
|
|
3125
|
+
* This is triggered by the editor's 'selectionUpdate' event after focus is restored.
|
|
3126
|
+
* Clears the pending queue after execution.
|
|
3127
|
+
* @returns {void}
|
|
3128
|
+
*/
|
|
3129
|
+
onEditorSelectionUpdate() {
|
|
3130
|
+
if (!this.activeEditor) return;
|
|
3131
|
+
if (this.pendingMarkCommands.length) {
|
|
3132
|
+
const pending = this.pendingMarkCommands;
|
|
3133
|
+
this.pendingMarkCommands = [];
|
|
3134
|
+
pending.forEach(({ command, argument, item }) => {
|
|
3135
|
+
if (!command) return;
|
|
3136
|
+
try {
|
|
3137
|
+
if (command in __privateGet(this, _interceptedCommands)) {
|
|
3138
|
+
__privateGet(this, _interceptedCommands)[command]({ item, argument });
|
|
3139
|
+
} else if (this.activeEditor.commands && command in this.activeEditor.commands) {
|
|
3140
|
+
this.activeEditor.commands[command](argument);
|
|
3141
|
+
}
|
|
3142
|
+
__privateMethod(this, _SuperToolbar_instances, ensureStoredMarksForMarkToggle_fn).call(this, { command, argument });
|
|
3143
|
+
} catch (error) {
|
|
3144
|
+
const err = new Error(`[super-toolbar 🎨] Failed to execute pending command: ${command}`);
|
|
3145
|
+
this.emit("exception", { error: err, editor: this.activeEditor, originalError: error });
|
|
3146
|
+
console.error(err, error);
|
|
3147
|
+
}
|
|
3148
|
+
});
|
|
3149
|
+
__privateMethod(this, _SuperToolbar_instances, syncStickyMarksFromState_fn).call(this);
|
|
3150
|
+
this.updateToolbarState();
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
const restored = __privateMethod(this, _SuperToolbar_instances, restoreStickyMarksIfNeeded_fn).call(this);
|
|
3154
|
+
if (restored) this.updateToolbarState();
|
|
3155
|
+
}
|
|
3156
|
+
/**
|
|
3157
|
+
* Handles editor focus events by flushing any pending mark commands.
|
|
3158
|
+
* This is triggered by the editor's 'focus' event.
|
|
3159
|
+
* @returns {void}
|
|
3160
|
+
*/
|
|
3161
|
+
onEditorFocus() {
|
|
3162
|
+
if (this.pendingMarkCommands.length) {
|
|
3163
|
+
this.onEditorSelectionUpdate();
|
|
3164
|
+
return;
|
|
3165
|
+
}
|
|
3166
|
+
const restored = __privateMethod(this, _SuperToolbar_instances, restoreStickyMarksIfNeeded_fn).call(this);
|
|
3167
|
+
if (restored) this.updateToolbarState();
|
|
3168
|
+
}
|
|
3169
|
+
/**
|
|
3170
|
+
* Determines if a toolbar item represents a mark toggle command.
|
|
3171
|
+
* Mark toggles include text formatting commands like bold, italic, underline, etc.
|
|
3172
|
+
* @param {ToolbarItem} item - The toolbar item to check
|
|
3173
|
+
* @returns {boolean} True if the item is a mark toggle, false otherwise
|
|
3174
|
+
*/
|
|
3175
|
+
isMarkToggle(item) {
|
|
3176
|
+
const name = item?.name?.value;
|
|
3177
|
+
return __privateGet(_SuperToolbar, _MARK_TOGGLE_NAMES).has(name);
|
|
3178
|
+
}
|
|
3179
|
+
};
|
|
3180
|
+
_MARK_TOGGLE_NAMES = new WeakMap();
|
|
3081
3181
|
_SuperToolbar_instances = new WeakSet();
|
|
3082
3182
|
/**
|
|
3083
3183
|
* Initiate toolbar groups
|
|
@@ -3235,6 +3335,82 @@ runCommandWithArgumentOnly_fn = function({ item, argument, noArgumentCallback =
|
|
|
3235
3335
|
this.updateToolbarState();
|
|
3236
3336
|
}
|
|
3237
3337
|
};
|
|
3338
|
+
/**
|
|
3339
|
+
* Capture stored marks when a mark toggle is used on an empty selection
|
|
3340
|
+
* so they can be re-applied after focus/selection changes.
|
|
3341
|
+
* @private
|
|
3342
|
+
* @returns {void}
|
|
3343
|
+
*/
|
|
3344
|
+
syncStickyMarksFromState_fn = function() {
|
|
3345
|
+
if (!this.activeEditor) return;
|
|
3346
|
+
const { selection, storedMarks } = this.activeEditor.state || {};
|
|
3347
|
+
if (!selection?.empty) return;
|
|
3348
|
+
this.stickyStoredMarks = storedMarks?.length ? [...storedMarks] : null;
|
|
3349
|
+
};
|
|
3350
|
+
/**
|
|
3351
|
+
* Re-apply stored marks captured from toolbar toggles when the current
|
|
3352
|
+
* selection is empty and unformatted.
|
|
3353
|
+
* @private
|
|
3354
|
+
* @returns {boolean} True if marks were restored
|
|
3355
|
+
*/
|
|
3356
|
+
restoreStickyMarksIfNeeded_fn = function() {
|
|
3357
|
+
if (!this.activeEditor) return false;
|
|
3358
|
+
if (!this.stickyStoredMarks?.length) return false;
|
|
3359
|
+
const { state, view } = this.activeEditor;
|
|
3360
|
+
const { selection, storedMarks } = state || {};
|
|
3361
|
+
if (!selection?.empty) return false;
|
|
3362
|
+
if (storedMarks?.length) return false;
|
|
3363
|
+
if (!view?.dispatch || !state?.tr) return false;
|
|
3364
|
+
const hasActiveMarkToggle = getActiveFormatting(this.activeEditor).some(
|
|
3365
|
+
(mark) => __privateGet(_SuperToolbar, _MARK_TOGGLE_NAMES).has(mark.name)
|
|
3366
|
+
);
|
|
3367
|
+
if (hasActiveMarkToggle) return false;
|
|
3368
|
+
const tr = state.tr.setStoredMarks(this.stickyStoredMarks);
|
|
3369
|
+
view.dispatch(tr);
|
|
3370
|
+
return true;
|
|
3371
|
+
};
|
|
3372
|
+
/**
|
|
3373
|
+
* Fallback to ensure stored marks exist for mark toggles when executed off-focus.
|
|
3374
|
+
* Helps cases where a command doesn't set storedMarks (e.g., font size from toolbar before focus).
|
|
3375
|
+
* @private
|
|
3376
|
+
* @param {Object} params
|
|
3377
|
+
* @param {string} params.command
|
|
3378
|
+
* @param {*} params.argument
|
|
3379
|
+
* @returns {void}
|
|
3380
|
+
*/
|
|
3381
|
+
ensureStoredMarksForMarkToggle_fn = function({ command, argument }) {
|
|
3382
|
+
if (!this.activeEditor) return;
|
|
3383
|
+
if (!this.activeEditor.state?.selection?.empty) return;
|
|
3384
|
+
if (this.activeEditor.state?.storedMarks?.length) return;
|
|
3385
|
+
if (command !== "setFontSize") return;
|
|
3386
|
+
const { state, view } = this.activeEditor;
|
|
3387
|
+
const textStyleMark = state.schema?.marks?.textStyle;
|
|
3388
|
+
if (!textStyleMark || !view?.dispatch || !state?.tr) return;
|
|
3389
|
+
const [value, unit] = parseSizeUnit(argument ?? "");
|
|
3390
|
+
if (Number.isNaN(value)) return;
|
|
3391
|
+
const clamped = Math.min(96, Math.max(8, Number(value)));
|
|
3392
|
+
const resolvedUnit = unit || "pt";
|
|
3393
|
+
const mark = textStyleMark.create({ fontSize: `${clamped}${resolvedUnit}` });
|
|
3394
|
+
const tr = state.tr.setStoredMarks([mark]);
|
|
3395
|
+
view.dispatch(tr);
|
|
3396
|
+
};
|
|
3397
|
+
/**
|
|
3398
|
+
* Mark toggle names used to identify mark commands that need special handling
|
|
3399
|
+
* when the editor is not focused.
|
|
3400
|
+
* @type {Set<string>}
|
|
3401
|
+
* @private
|
|
3402
|
+
*/
|
|
3403
|
+
__privateAdd(_SuperToolbar, _MARK_TOGGLE_NAMES, /* @__PURE__ */ new Set([
|
|
3404
|
+
"bold",
|
|
3405
|
+
"italic",
|
|
3406
|
+
"underline",
|
|
3407
|
+
"strike",
|
|
3408
|
+
"highlight",
|
|
3409
|
+
"color",
|
|
3410
|
+
"fontSize",
|
|
3411
|
+
"fontFamily"
|
|
3412
|
+
]));
|
|
3413
|
+
let SuperToolbar = _SuperToolbar;
|
|
3238
3414
|
const onMarginClickCursorChange = (event, editor) => {
|
|
3239
3415
|
const y = event.clientY;
|
|
3240
3416
|
const x2 = event.clientX;
|
package/dist/super-editor.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./chunks/super-editor.es-
|
|
3
|
+
const superEditor_es = require("./chunks/super-editor.es-C06-V-Iy.cjs");
|
|
4
4
|
require("./chunks/vue-ARQSyfaw.cjs");
|
|
5
5
|
exports.AIWriter = superEditor_es.AIWriter;
|
|
6
6
|
exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
|
package/dist/super-editor.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A, a, _, C, D, E, b, P, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-
|
|
2
|
-
import "./chunks/vue-
|
|
1
|
+
import { A, a, _, C, D, E, b, P, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-CtCHBIPE.es.js";
|
|
2
|
+
import "./chunks/vue-CztqUvm1.es.js";
|
|
3
3
|
export {
|
|
4
4
|
A as AIWriter,
|
|
5
5
|
a as AnnotatorHelpers,
|
package/dist/superdoc.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./chunks/super-editor.es-
|
|
4
|
-
const superdoc = require("./chunks/index-
|
|
3
|
+
const superEditor_es = require("./chunks/super-editor.es-C06-V-Iy.cjs");
|
|
4
|
+
const superdoc = require("./chunks/index-BW38mdZF.cjs");
|
|
5
5
|
const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
|
|
6
6
|
exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
|
|
7
7
|
exports.Editor = superEditor_es.Editor;
|
package/dist/superdoc.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-
|
|
2
|
-
import { D, H, P, S as S2, m, l } from "./chunks/index-
|
|
1
|
+
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-CtCHBIPE.es.js";
|
|
2
|
+
import { D, H, P, S as S2, m, l } from "./chunks/index-DIccWgYh.es.js";
|
|
3
3
|
import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
|
|
4
4
|
export {
|
|
5
5
|
a as AnnotatorHelpers,
|