@superdoc-dev/cli 0.7.0-next.17 → 0.7.0-next.18
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/index.js +1366 -551
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -76859,7 +76859,7 @@ function checkTextSelection($pos) {
|
|
|
76859
76859
|
}
|
|
76860
76860
|
function findSelectionIn(doc$2, node3, pos, index2, dir, text$2 = false) {
|
|
76861
76861
|
if (node3.inlineContent)
|
|
76862
|
-
return
|
|
76862
|
+
return TextSelection.create(doc$2, pos);
|
|
76863
76863
|
for (let i$1 = index2 - (dir > 0 ? 0 : 1);dir > 0 ? i$1 < node3.childCount : i$1 >= 0; i$1 += dir) {
|
|
76864
76864
|
let child = node3.child(i$1);
|
|
76865
76865
|
if (!child.isAtom) {
|
|
@@ -80044,7 +80044,7 @@ function selectionToDOM(view, force = false) {
|
|
|
80044
80044
|
selectCursorWrapper(view);
|
|
80045
80045
|
else {
|
|
80046
80046
|
let { anchor, head } = sel, resetEditableFrom, resetEditableTo;
|
|
80047
|
-
if (brokenSelectBetweenUneditable && !(sel instanceof
|
|
80047
|
+
if (brokenSelectBetweenUneditable && !(sel instanceof TextSelection)) {
|
|
80048
80048
|
if (!sel.$from.parent.inlineContent)
|
|
80049
80049
|
resetEditableFrom = temporarilyEditableNear(view, sel.from);
|
|
80050
80050
|
if (!sel.empty && !sel.$from.parent.inlineContent)
|
|
@@ -80145,7 +80145,7 @@ function clearNodeSelection(view) {
|
|
|
80145
80145
|
}
|
|
80146
80146
|
}
|
|
80147
80147
|
function selectionBetween(view, $anchor, $head, bias) {
|
|
80148
|
-
return view.someProp("createSelectionBetween", (f2) => f2(view, $anchor, $head)) ||
|
|
80148
|
+
return view.someProp("createSelectionBetween", (f2) => f2(view, $anchor, $head)) || TextSelection.between($anchor, $head, bias);
|
|
80149
80149
|
}
|
|
80150
80150
|
function hasFocusAndSelection(view) {
|
|
80151
80151
|
if (view.editable && !view.hasFocus())
|
|
@@ -80179,13 +80179,13 @@ function apply(view, sel) {
|
|
|
80179
80179
|
}
|
|
80180
80180
|
function selectHorizontally(view, dir, mods) {
|
|
80181
80181
|
let sel = view.state.selection;
|
|
80182
|
-
if (sel instanceof
|
|
80182
|
+
if (sel instanceof TextSelection) {
|
|
80183
80183
|
if (mods.indexOf("s") > -1) {
|
|
80184
80184
|
let { $head } = sel, node3 = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter;
|
|
80185
80185
|
if (!node3 || node3.isText || !node3.isLeaf)
|
|
80186
80186
|
return false;
|
|
80187
80187
|
let $newHead = view.state.doc.resolve($head.pos + node3.nodeSize * (dir < 0 ? -1 : 1));
|
|
80188
|
-
return apply(view, new
|
|
80188
|
+
return apply(view, new TextSelection(sel.$anchor, $newHead));
|
|
80189
80189
|
} else if (!sel.empty)
|
|
80190
80190
|
return false;
|
|
80191
80191
|
else if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
|
|
@@ -80203,12 +80203,12 @@ function selectHorizontally(view, dir, mods) {
|
|
|
80203
80203
|
if (NodeSelection.isSelectable(node3))
|
|
80204
80204
|
return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node3.nodeSize) : $head));
|
|
80205
80205
|
else if (webkit)
|
|
80206
|
-
return apply(view, new
|
|
80206
|
+
return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node3.nodeSize)));
|
|
80207
80207
|
else
|
|
80208
80208
|
return false;
|
|
80209
80209
|
}
|
|
80210
80210
|
} else if (sel instanceof NodeSelection && sel.node.isInline)
|
|
80211
|
-
return apply(view, new
|
|
80211
|
+
return apply(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
|
|
80212
80212
|
else {
|
|
80213
80213
|
let next = moveSelectionBlock(view.state, dir);
|
|
80214
80214
|
if (next)
|
|
@@ -80397,7 +80397,7 @@ function findDirection(view, pos) {
|
|
|
80397
80397
|
}
|
|
80398
80398
|
function selectVertically(view, dir, mods) {
|
|
80399
80399
|
let sel = view.state.selection;
|
|
80400
|
-
if (sel instanceof
|
|
80400
|
+
if (sel instanceof TextSelection && !sel.empty || mods.indexOf("s") > -1)
|
|
80401
80401
|
return false;
|
|
80402
80402
|
if (mac$2 && mods.indexOf("m") > -1)
|
|
80403
80403
|
return false;
|
|
@@ -80415,7 +80415,7 @@ function selectVertically(view, dir, mods) {
|
|
|
80415
80415
|
return false;
|
|
80416
80416
|
}
|
|
80417
80417
|
function stopNativeHorizontalDelete(view, dir) {
|
|
80418
|
-
if (!(view.state.selection instanceof
|
|
80418
|
+
if (!(view.state.selection instanceof TextSelection))
|
|
80419
80419
|
return true;
|
|
80420
80420
|
let { $head, $anchor, empty: empty$1 } = view.state.selection;
|
|
80421
80421
|
if (!$head.sameParent($anchor))
|
|
@@ -80846,7 +80846,7 @@ function defaultTripleClick(view, inside, event) {
|
|
|
80846
80846
|
let doc$2 = view.state.doc;
|
|
80847
80847
|
if (inside == -1) {
|
|
80848
80848
|
if (doc$2.inlineContent) {
|
|
80849
|
-
updateSelection(view,
|
|
80849
|
+
updateSelection(view, TextSelection.create(doc$2, 0, doc$2.content.size), "pointer");
|
|
80850
80850
|
return true;
|
|
80851
80851
|
}
|
|
80852
80852
|
return false;
|
|
@@ -80856,7 +80856,7 @@ function defaultTripleClick(view, inside, event) {
|
|
|
80856
80856
|
let node3 = i$1 > $pos.depth ? $pos.nodeAfter : $pos.node(i$1);
|
|
80857
80857
|
let nodePos = $pos.before(i$1);
|
|
80858
80858
|
if (node3.inlineContent)
|
|
80859
|
-
updateSelection(view,
|
|
80859
|
+
updateSelection(view, TextSelection.create(doc$2, nodePos + 1, nodePos + 1 + node3.content.size), "pointer");
|
|
80860
80860
|
else if (NodeSelection.isSelectable(node3))
|
|
80861
80861
|
updateSelection(view, NodeSelection.create(doc$2, nodePos), "pointer");
|
|
80862
80862
|
else
|
|
@@ -81441,7 +81441,7 @@ function readDOMChange(view, from4, to, typeOver, addedNodes) {
|
|
|
81441
81441
|
return;
|
|
81442
81442
|
}
|
|
81443
81443
|
if (!change)
|
|
81444
|
-
if (typeOver && sel instanceof
|
|
81444
|
+
if (typeOver && sel instanceof TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse$1.sel && parse$1.sel.anchor != parse$1.sel.head))
|
|
81445
81445
|
change = {
|
|
81446
81446
|
start: sel.from,
|
|
81447
81447
|
endA: sel.to,
|
|
@@ -81459,7 +81459,7 @@ function readDOMChange(view, from4, to, typeOver, addedNodes) {
|
|
|
81459
81459
|
}
|
|
81460
81460
|
return;
|
|
81461
81461
|
}
|
|
81462
|
-
if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof
|
|
81462
|
+
if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
|
|
81463
81463
|
if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse$1.from)
|
|
81464
81464
|
change.start = view.state.selection.from;
|
|
81465
81465
|
else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 && view.state.selection.to <= parse$1.to) {
|
|
@@ -82099,10 +82099,10 @@ function normalizeSelection(state, tr, allowTableNodeSelection) {
|
|
|
82099
82099
|
const lastCell = start + map4.map[map4.width * map4.height - 1];
|
|
82100
82100
|
normalize$1 = CellSelection.create(doc$2, start + 1, lastCell);
|
|
82101
82101
|
}
|
|
82102
|
-
} else if (sel instanceof
|
|
82103
|
-
normalize$1 =
|
|
82104
|
-
else if (sel instanceof
|
|
82105
|
-
normalize$1 =
|
|
82102
|
+
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel))
|
|
82103
|
+
normalize$1 = TextSelection.create(doc$2, sel.from);
|
|
82104
|
+
else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel))
|
|
82105
|
+
normalize$1 = TextSelection.create(doc$2, sel.$from.start(), sel.$from.end());
|
|
82106
82106
|
if (normalize$1)
|
|
82107
82107
|
(tr || (tr = state.tr)).setSelection(normalize$1);
|
|
82108
82108
|
return tr;
|
|
@@ -82632,7 +82632,7 @@ function goToNextCell(direction) {
|
|
|
82632
82632
|
return false;
|
|
82633
82633
|
if (dispatch) {
|
|
82634
82634
|
const $cell = state.doc.resolve(cell);
|
|
82635
|
-
dispatch(state.tr.setSelection(
|
|
82635
|
+
dispatch(state.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());
|
|
82636
82636
|
}
|
|
82637
82637
|
return true;
|
|
82638
82638
|
};
|
|
@@ -83021,7 +83021,7 @@ function handleMouseDown$1(view, startEvent) {
|
|
|
83021
83021
|
view.root.addEventListener("mousemove", move);
|
|
83022
83022
|
}
|
|
83023
83023
|
function atEndOfCell(view, axis, dir) {
|
|
83024
|
-
if (!(view.state.selection instanceof
|
|
83024
|
+
if (!(view.state.selection instanceof TextSelection))
|
|
83025
83025
|
return null;
|
|
83026
83026
|
const { $head } = view.state.selection;
|
|
83027
83027
|
for (let d = $head.depth - 1;d >= 0; d--) {
|
|
@@ -83521,7 +83521,7 @@ function stableStringifyInlineProps(inlineProps) {
|
|
|
83521
83521
|
function createSelectionPreserver(tr, originalSelection, originalStoredMarks = null) {
|
|
83522
83522
|
if (!originalSelection)
|
|
83523
83523
|
return null;
|
|
83524
|
-
const isTextSelection$1 = originalSelection instanceof
|
|
83524
|
+
const isTextSelection$1 = originalSelection instanceof TextSelection;
|
|
83525
83525
|
let preservedAnchor = isTextSelection$1 ? originalSelection.anchor : null;
|
|
83526
83526
|
let preservedHead = isTextSelection$1 ? originalSelection.head : null;
|
|
83527
83527
|
const anchorAssoc = preservedAnchor != null && preservedHead != null && preservedAnchor <= preservedHead ? -1 : 1;
|
|
@@ -83561,7 +83561,7 @@ function createSelectionPreserver(tr, originalSelection, originalStoredMarks = n
|
|
|
83561
83561
|
if (!tr.docChanged)
|
|
83562
83562
|
return;
|
|
83563
83563
|
if (isTextSelection$1 && preservedAnchor != null && preservedHead != null) {
|
|
83564
|
-
tr.setSelection(
|
|
83564
|
+
tr.setSelection(TextSelection.create(tr.doc, preservedAnchor, preservedHead));
|
|
83565
83565
|
if (preservedAnchor === preservedHead && originalStoredMarks !== null)
|
|
83566
83566
|
tr.setStoredMarks(originalStoredMarks);
|
|
83567
83567
|
return;
|
|
@@ -84817,7 +84817,7 @@ function canAllocateRels(editor) {
|
|
|
84817
84817
|
function handlePlainTextUrlPaste(editor, view, plainText, detected) {
|
|
84818
84818
|
const { state } = view;
|
|
84819
84819
|
const { selection } = state;
|
|
84820
|
-
if (!(selection instanceof
|
|
84820
|
+
if (!(selection instanceof TextSelection))
|
|
84821
84821
|
return false;
|
|
84822
84822
|
const linkMarkType = editor.schema.marks.link;
|
|
84823
84823
|
const underlineMarkType = editor.schema.marks.underline;
|
|
@@ -104784,7 +104784,7 @@ var isRegExp = (value) => {
|
|
|
104784
104784
|
}
|
|
104785
104785
|
}
|
|
104786
104786
|
static findFrom($pos, dir, textOnly = false) {
|
|
104787
|
-
let inner = $pos.parent.inlineContent ? new
|
|
104787
|
+
let inner = $pos.parent.inlineContent ? new TextSelection($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
|
|
104788
104788
|
if (inner)
|
|
104789
104789
|
return inner;
|
|
104790
104790
|
for (let depth = $pos.depth - 1;depth >= 0; depth--) {
|
|
@@ -104819,14 +104819,14 @@ var isRegExp = (value) => {
|
|
|
104819
104819
|
return selectionClass;
|
|
104820
104820
|
}
|
|
104821
104821
|
getBookmark() {
|
|
104822
|
-
return
|
|
104822
|
+
return TextSelection.between(this.$anchor, this.$head).getBookmark();
|
|
104823
104823
|
}
|
|
104824
104824
|
}, SelectionRange = class {
|
|
104825
104825
|
constructor($from, $to) {
|
|
104826
104826
|
this.$from = $from;
|
|
104827
104827
|
this.$to = $to;
|
|
104828
104828
|
}
|
|
104829
|
-
}, warnedAboutTextSelection = false,
|
|
104829
|
+
}, warnedAboutTextSelection = false, TextSelection, TextBookmark = class TextBookmark2 {
|
|
104830
104830
|
constructor(anchor, head) {
|
|
104831
104831
|
this.anchor = anchor;
|
|
104832
104832
|
this.head = head;
|
|
@@ -104835,7 +104835,7 @@ var isRegExp = (value) => {
|
|
|
104835
104835
|
return new TextBookmark2(mapping.map(this.anchor), mapping.map(this.head));
|
|
104836
104836
|
}
|
|
104837
104837
|
resolve(doc$2) {
|
|
104838
|
-
return
|
|
104838
|
+
return TextSelection.between(doc$2.resolve(this.anchor), doc$2.resolve(this.head));
|
|
104839
104839
|
}
|
|
104840
104840
|
}, NodeSelection, NodeBookmark = class NodeBookmark2 {
|
|
104841
104841
|
constructor(anchor) {
|
|
@@ -109287,7 +109287,7 @@ var isRegExp = (value) => {
|
|
|
109287
109287
|
return false;
|
|
109288
109288
|
return group.split(" ").includes("list");
|
|
109289
109289
|
}, isTextSelection = (value) => {
|
|
109290
|
-
return value instanceof
|
|
109290
|
+
return value instanceof TextSelection;
|
|
109291
109291
|
}, domIndex = function(node3) {
|
|
109292
109292
|
for (var index2 = 0;; index2++) {
|
|
109293
109293
|
node3 = node3.previousSibling;
|
|
@@ -133399,7 +133399,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
133399
133399
|
TransformError.prototype.name = "TransformError";
|
|
133400
133400
|
classesById = Object.create(null);
|
|
133401
133401
|
Selection.prototype.visible = true;
|
|
133402
|
-
|
|
133402
|
+
TextSelection = class TextSelection2 extends Selection {
|
|
133403
133403
|
constructor($anchor, $head = $anchor) {
|
|
133404
133404
|
checkTextSelection($anchor);
|
|
133405
133405
|
checkTextSelection($head);
|
|
@@ -133413,7 +133413,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
133413
133413
|
if (!$head.parent.inlineContent)
|
|
133414
133414
|
return Selection.near($head);
|
|
133415
133415
|
let $anchor = doc$2.resolve(mapping.map(this.anchor));
|
|
133416
|
-
return new
|
|
133416
|
+
return new TextSelection2($anchor.parent.inlineContent ? $anchor : $head, $head);
|
|
133417
133417
|
}
|
|
133418
133418
|
replace(tr, content$2 = Slice.empty) {
|
|
133419
133419
|
super.replace(tr, content$2);
|
|
@@ -133424,7 +133424,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
133424
133424
|
}
|
|
133425
133425
|
}
|
|
133426
133426
|
eq(other) {
|
|
133427
|
-
return other instanceof
|
|
133427
|
+
return other instanceof TextSelection2 && other.anchor == this.anchor && other.head == this.head;
|
|
133428
133428
|
}
|
|
133429
133429
|
getBookmark() {
|
|
133430
133430
|
return new TextBookmark(this.anchor, this.head);
|
|
@@ -133439,7 +133439,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
133439
133439
|
static fromJSON(doc$2, json) {
|
|
133440
133440
|
if (typeof json.anchor != "number" || typeof json.head != "number")
|
|
133441
133441
|
throw new RangeError("Invalid input for TextSelection.fromJSON");
|
|
133442
|
-
return new
|
|
133442
|
+
return new TextSelection2(doc$2.resolve(json.anchor), doc$2.resolve(json.head));
|
|
133443
133443
|
}
|
|
133444
133444
|
static create(doc$2, anchor, head = anchor) {
|
|
133445
133445
|
let $anchor = doc$2.resolve(anchor);
|
|
@@ -133464,10 +133464,10 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
133464
133464
|
if ($anchor.pos < $head.pos != dPos < 0)
|
|
133465
133465
|
$anchor = $head;
|
|
133466
133466
|
}
|
|
133467
|
-
return new
|
|
133467
|
+
return new TextSelection2($anchor, $head);
|
|
133468
133468
|
}
|
|
133469
133469
|
};
|
|
133470
|
-
Selection.jsonID("text",
|
|
133470
|
+
Selection.jsonID("text", TextSelection);
|
|
133471
133471
|
NodeSelection = class NodeSelection2 extends Selection {
|
|
133472
133472
|
constructor($pos) {
|
|
133473
133473
|
let node3 = $pos.nodeAfter;
|
|
@@ -145118,7 +145118,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
145118
145118
|
}
|
|
145119
145119
|
localCompositionInfo(view, pos) {
|
|
145120
145120
|
let { from: from4, to } = view.state.selection;
|
|
145121
|
-
if (!(view.state.selection instanceof
|
|
145121
|
+
if (!(view.state.selection instanceof TextSelection) || from4 < pos || to > pos + this.node.content.size)
|
|
145122
145122
|
return null;
|
|
145123
145123
|
let textNode = view.input.compositionNode;
|
|
145124
145124
|
if (!textNode || !this.dom.contains(textNode.parentNode))
|
|
@@ -145380,7 +145380,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
145380
145380
|
return;
|
|
145381
145381
|
}
|
|
145382
145382
|
let sel = view.state.selection;
|
|
145383
|
-
if (!(sel instanceof
|
|
145383
|
+
if (!(sel instanceof TextSelection) || !sel.$from.sameParent(sel.$to)) {
|
|
145384
145384
|
let text$2 = String.fromCharCode(event.charCode);
|
|
145385
145385
|
let deflt = () => view.state.tr.insertText(text$2).scrollIntoView();
|
|
145386
145386
|
if (!/[\r\n]/.test(text$2) && !view.someProp("handleTextInput", (f2) => f2(view, sel.$from.pos, sel.$to.pos, text$2, deflt)))
|
|
@@ -145434,7 +145434,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
145434
145434
|
if (!view.composing) {
|
|
145435
145435
|
view.domObserver.flush();
|
|
145436
145436
|
let { state } = view, $pos = state.selection.$to;
|
|
145437
|
-
if (state.selection instanceof
|
|
145437
|
+
if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
|
|
145438
145438
|
view.markCursor = view.state.storedMarks || $pos.marks();
|
|
145439
145439
|
endComposition(view, true);
|
|
145440
145440
|
view.markCursor = null;
|
|
@@ -145767,7 +145767,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
145767
145767
|
else
|
|
145768
145768
|
return new CellSelection$1($anchorCell, $headCell);
|
|
145769
145769
|
}
|
|
145770
|
-
return
|
|
145770
|
+
return TextSelection.between($anchorCell, $headCell);
|
|
145771
145771
|
}
|
|
145772
145772
|
content() {
|
|
145773
145773
|
const table = this.$anchorCell.node(-1);
|
|
@@ -154465,7 +154465,7 @@ var init_SuperConverter_BgwP1GeS_es = __esm(() => {
|
|
|
154465
154465
|
};
|
|
154466
154466
|
});
|
|
154467
154467
|
|
|
154468
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
154468
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-Dcw4Hyt2.es.js
|
|
154469
154469
|
function parseSizeUnit(val = "0") {
|
|
154470
154470
|
const length3 = val.toString() || "0";
|
|
154471
154471
|
const value = Number.parseFloat(length3);
|
|
@@ -154476,7 +154476,7 @@ function getPreservedSelection(state) {
|
|
|
154476
154476
|
return CustomSelectionPluginKey.getState(state)?.preservedSelection ?? null;
|
|
154477
154477
|
}
|
|
154478
154478
|
function createSelectionTrackingBookmark(selection) {
|
|
154479
|
-
if (selection instanceof
|
|
154479
|
+
if (selection instanceof TextSelection && !selection.empty)
|
|
154480
154480
|
return new InclusiveTextSelectionBookmark(selection.anchor, selection.head);
|
|
154481
154481
|
return selection.getBookmark();
|
|
154482
154482
|
}
|
|
@@ -154763,7 +154763,7 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
|
|
|
154763
154763
|
return new InclusiveTextSelectionBookmark2(mapping.map(this.anchor, isForward ? -1 : 1), mapping.map(this.head, isForward ? 1 : -1));
|
|
154764
154764
|
}
|
|
154765
154765
|
resolve(doc2) {
|
|
154766
|
-
return
|
|
154766
|
+
return TextSelection.between(doc2.resolve(this.anchor), doc2.resolve(this.head));
|
|
154767
154767
|
}
|
|
154768
154768
|
}, nextHandleId = 1, SelectionHandlePluginKey, DEFAULT_MIME_TYPE = "application/octet-stream", simpleHash2 = (str) => {
|
|
154769
154769
|
let hash = 0;
|
|
@@ -156065,6 +156065,246 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
|
|
|
156065
156065
|
comment: change.comment ?? null
|
|
156066
156066
|
}) !== false;
|
|
156067
156067
|
});
|
|
156068
|
+
}, resolveSurface = (activeEditor) => {
|
|
156069
|
+
if (activeEditor?.options?.isHeaderOrFooter) {
|
|
156070
|
+
const headerFooterType = activeEditor.options?.headerFooterType;
|
|
156071
|
+
if (headerFooterType === "footer")
|
|
156072
|
+
return "footer";
|
|
156073
|
+
if (headerFooterType === "header")
|
|
156074
|
+
return "header";
|
|
156075
|
+
}
|
|
156076
|
+
return "body";
|
|
156077
|
+
}, resolveSelectionEmpty = (editor) => {
|
|
156078
|
+
return editor.state?.selection?.empty ?? true;
|
|
156079
|
+
}, createEditorToolbarTarget = (editor) => {
|
|
156080
|
+
return {
|
|
156081
|
+
commands: editor.commands ?? {},
|
|
156082
|
+
doc: editor.doc
|
|
156083
|
+
};
|
|
156084
|
+
}, createPresentationToolbarTarget = (editor) => {
|
|
156085
|
+
return {
|
|
156086
|
+
commands: editor.commands ?? {},
|
|
156087
|
+
doc: editor.getActiveEditor()?.doc
|
|
156088
|
+
};
|
|
156089
|
+
}, resolvePresentationEditor = (superdoc) => {
|
|
156090
|
+
const documentId = superdoc.activeEditor?.options?.documentId;
|
|
156091
|
+
if (!documentId)
|
|
156092
|
+
return null;
|
|
156093
|
+
return (superdoc.superdocStore?.documents ?? []).find((doc2) => doc2.getEditor?.()?.options?.documentId === documentId)?.getPresentationEditor?.() ?? null;
|
|
156094
|
+
}, resolveToolbarSources = (superdoc) => {
|
|
156095
|
+
const presentationEditor = resolvePresentationEditor(superdoc);
|
|
156096
|
+
if (presentationEditor) {
|
|
156097
|
+
const routedEditor = presentationEditor.getActiveEditor();
|
|
156098
|
+
return {
|
|
156099
|
+
activeEditor: routedEditor ?? null,
|
|
156100
|
+
presentationEditor,
|
|
156101
|
+
context: {
|
|
156102
|
+
target: createPresentationToolbarTarget(presentationEditor),
|
|
156103
|
+
surface: resolveSurface(routedEditor),
|
|
156104
|
+
isEditable: presentationEditor.isEditable,
|
|
156105
|
+
selectionEmpty: resolveSelectionEmpty(presentationEditor),
|
|
156106
|
+
editor: routedEditor ?? undefined,
|
|
156107
|
+
presentationEditor
|
|
156108
|
+
}
|
|
156109
|
+
};
|
|
156110
|
+
}
|
|
156111
|
+
const activeEditor = superdoc.activeEditor;
|
|
156112
|
+
if (!activeEditor)
|
|
156113
|
+
return {
|
|
156114
|
+
activeEditor: null,
|
|
156115
|
+
presentationEditor: null,
|
|
156116
|
+
context: null
|
|
156117
|
+
};
|
|
156118
|
+
return {
|
|
156119
|
+
activeEditor,
|
|
156120
|
+
presentationEditor: null,
|
|
156121
|
+
context: {
|
|
156122
|
+
target: createEditorToolbarTarget(activeEditor),
|
|
156123
|
+
surface: "body",
|
|
156124
|
+
isEditable: activeEditor.isEditable,
|
|
156125
|
+
selectionEmpty: resolveSelectionEmpty(activeEditor),
|
|
156126
|
+
editor: activeEditor
|
|
156127
|
+
}
|
|
156128
|
+
};
|
|
156129
|
+
}, buildCommandStateMap = ({ commands = [], superdoc, context, toolbarRegistry }) => {
|
|
156130
|
+
const entries2 = commands.map((command) => {
|
|
156131
|
+
const entry = toolbarRegistry[command];
|
|
156132
|
+
if (!entry)
|
|
156133
|
+
return [command, {
|
|
156134
|
+
active: false,
|
|
156135
|
+
disabled: true
|
|
156136
|
+
}];
|
|
156137
|
+
return [command, entry.state({
|
|
156138
|
+
context,
|
|
156139
|
+
superdoc
|
|
156140
|
+
})];
|
|
156141
|
+
});
|
|
156142
|
+
return Object.fromEntries(entries2);
|
|
156143
|
+
}, createToolbarSnapshot = ({ superdoc, commands = [], toolbarRegistry }) => {
|
|
156144
|
+
const { context } = resolveToolbarSources(superdoc);
|
|
156145
|
+
return {
|
|
156146
|
+
context,
|
|
156147
|
+
commands: buildCommandStateMap({
|
|
156148
|
+
commands,
|
|
156149
|
+
superdoc,
|
|
156150
|
+
context,
|
|
156151
|
+
toolbarRegistry
|
|
156152
|
+
})
|
|
156153
|
+
};
|
|
156154
|
+
}, subscribeToSuperdocEvents = (superdoc, onChange3) => {
|
|
156155
|
+
if (!superdoc?.on || !superdoc?.off)
|
|
156156
|
+
return null;
|
|
156157
|
+
superdoc.on("editorCreate", onChange3);
|
|
156158
|
+
superdoc.on("document-mode-change", onChange3);
|
|
156159
|
+
superdoc.on("zoomChange", onChange3);
|
|
156160
|
+
return () => {
|
|
156161
|
+
superdoc.off?.("editorCreate", onChange3);
|
|
156162
|
+
superdoc.off?.("document-mode-change", onChange3);
|
|
156163
|
+
superdoc.off?.("zoomChange", onChange3);
|
|
156164
|
+
};
|
|
156165
|
+
}, subscribeToEditorEvents = (editor, onChange3) => {
|
|
156166
|
+
if (!editor?.on || !editor?.off)
|
|
156167
|
+
return null;
|
|
156168
|
+
editor.on("focus", onChange3);
|
|
156169
|
+
editor.on("selectionUpdate", onChange3);
|
|
156170
|
+
editor.on("transaction", onChange3);
|
|
156171
|
+
return () => {
|
|
156172
|
+
editor.off?.("focus", onChange3);
|
|
156173
|
+
editor.off?.("selectionUpdate", onChange3);
|
|
156174
|
+
editor.off?.("transaction", onChange3);
|
|
156175
|
+
};
|
|
156176
|
+
}, subscribeToPresentationEvents = (presentationEditor, onChange3) => {
|
|
156177
|
+
if (!presentationEditor?.on || !presentationEditor?.off)
|
|
156178
|
+
return null;
|
|
156179
|
+
presentationEditor.on("headerFooterEditingContext", onChange3);
|
|
156180
|
+
presentationEditor.on("headerFooterUpdate", onChange3);
|
|
156181
|
+
presentationEditor.on("headerFooterTransaction", onChange3);
|
|
156182
|
+
return () => {
|
|
156183
|
+
presentationEditor.off?.("headerFooterEditingContext", onChange3);
|
|
156184
|
+
presentationEditor.off?.("headerFooterUpdate", onChange3);
|
|
156185
|
+
presentationEditor.off?.("headerFooterTransaction", onChange3);
|
|
156186
|
+
};
|
|
156187
|
+
}, subscribeToolbarEvents = (options, onChange3) => {
|
|
156188
|
+
const { activeEditor: editor, presentationEditor } = resolveToolbarSources(options.superdoc);
|
|
156189
|
+
const unbindSuperdocEvents = subscribeToSuperdocEvents(options.superdoc, onChange3);
|
|
156190
|
+
const unbindEditorEvents = subscribeToEditorEvents(editor, onChange3);
|
|
156191
|
+
const unbindPresentationEvents = subscribeToPresentationEvents(presentationEditor, onChange3);
|
|
156192
|
+
return () => {
|
|
156193
|
+
unbindEditorEvents?.();
|
|
156194
|
+
unbindPresentationEvents?.();
|
|
156195
|
+
unbindSuperdocEvents?.();
|
|
156196
|
+
};
|
|
156197
|
+
}, resolveStateEditor = (context) => {
|
|
156198
|
+
if (!context)
|
|
156199
|
+
return null;
|
|
156200
|
+
return context.editor ?? context.presentationEditor?.getActiveEditor() ?? null;
|
|
156201
|
+
}, getCurrentParagraphParent = (context) => {
|
|
156202
|
+
const stateEditor = resolveStateEditor(context);
|
|
156203
|
+
const selection = stateEditor?.state?.selection;
|
|
156204
|
+
if (!stateEditor || !selection)
|
|
156205
|
+
return null;
|
|
156206
|
+
return findParentNode((node3) => node3.type.name === "paragraph")(selection);
|
|
156207
|
+
}, getCurrentResolvedParagraphProperties = (context) => {
|
|
156208
|
+
const paragraphParent = getCurrentParagraphParent(context);
|
|
156209
|
+
const stateEditor = resolveStateEditor(context);
|
|
156210
|
+
if (!stateEditor || !paragraphParent)
|
|
156211
|
+
return null;
|
|
156212
|
+
return calculateResolvedParagraphProperties(stateEditor, paragraphParent.node, stateEditor.state.doc.resolve(paragraphParent.pos));
|
|
156213
|
+
}, isFieldAnnotationSelection = (context) => {
|
|
156214
|
+
const selection = resolveStateEditor(context)?.state?.selection;
|
|
156215
|
+
return selection instanceof NodeSelection && selection?.node?.type?.name === "fieldAnnotation";
|
|
156216
|
+
}, isCommandDisabled = (context) => {
|
|
156217
|
+
if (!context || !context.isEditable)
|
|
156218
|
+
return true;
|
|
156219
|
+
return (context.presentationEditor?.editor ?? context.editor)?.options?.documentMode === "viewing";
|
|
156220
|
+
}, createDisabledStateDeriver = (options) => ({ context }) => {
|
|
156221
|
+
const disabled = isCommandDisabled(context);
|
|
156222
|
+
if (options?.withValue)
|
|
156223
|
+
return {
|
|
156224
|
+
active: false,
|
|
156225
|
+
disabled,
|
|
156226
|
+
value: null
|
|
156227
|
+
};
|
|
156228
|
+
return {
|
|
156229
|
+
active: false,
|
|
156230
|
+
disabled
|
|
156231
|
+
};
|
|
156232
|
+
}, createDirectCommandExecute = (commandName) => ({ context, payload }) => {
|
|
156233
|
+
const editor = resolveStateEditor(context);
|
|
156234
|
+
const command = commandName ? editor?.commands[commandName] : null;
|
|
156235
|
+
if (typeof command !== "function")
|
|
156236
|
+
return false;
|
|
156237
|
+
const result = payload === undefined ? command() : command(payload);
|
|
156238
|
+
return Boolean(result);
|
|
156239
|
+
}, getCurrentUndoDepth = (context) => {
|
|
156240
|
+
const stateEditor = resolveStateEditor(context);
|
|
156241
|
+
if (!stateEditor?.state)
|
|
156242
|
+
return 0;
|
|
156243
|
+
try {
|
|
156244
|
+
if (stateEditor.options?.ydoc)
|
|
156245
|
+
return yUndoPluginKey.getState(stateEditor.state)?.undoManager?.undoStack?.length ?? 0;
|
|
156246
|
+
return undoDepth(stateEditor.state);
|
|
156247
|
+
} catch {
|
|
156248
|
+
return 0;
|
|
156249
|
+
}
|
|
156250
|
+
}, getCurrentRedoDepth = (context) => {
|
|
156251
|
+
const stateEditor = resolveStateEditor(context);
|
|
156252
|
+
if (!stateEditor?.state)
|
|
156253
|
+
return 0;
|
|
156254
|
+
try {
|
|
156255
|
+
if (stateEditor.options?.ydoc)
|
|
156256
|
+
return yUndoPluginKey.getState(stateEditor.state)?.undoManager?.redoStack?.length ?? 0;
|
|
156257
|
+
return redoDepth(stateEditor.state);
|
|
156258
|
+
} catch {
|
|
156259
|
+
return 0;
|
|
156260
|
+
}
|
|
156261
|
+
}, createHistoryStateDeriver = (kind) => ({ context }) => {
|
|
156262
|
+
if (isCommandDisabled(context))
|
|
156263
|
+
return {
|
|
156264
|
+
active: false,
|
|
156265
|
+
disabled: true
|
|
156266
|
+
};
|
|
156267
|
+
return {
|
|
156268
|
+
active: false,
|
|
156269
|
+
disabled: (kind === "undo" ? getCurrentUndoDepth(context) : getCurrentRedoDepth(context)) === 0
|
|
156270
|
+
};
|
|
156271
|
+
}, createRulerStateDeriver = () => ({ context, superdoc }) => {
|
|
156272
|
+
return {
|
|
156273
|
+
active: Boolean(superdoc?.config?.rulers),
|
|
156274
|
+
disabled: isCommandDisabled(context)
|
|
156275
|
+
};
|
|
156276
|
+
}, createZoomStateDeriver = () => ({ context, superdoc }) => {
|
|
156277
|
+
return {
|
|
156278
|
+
active: false,
|
|
156279
|
+
disabled: !context,
|
|
156280
|
+
value: typeof superdoc?.getZoom === "function" ? superdoc.getZoom() : 100
|
|
156281
|
+
};
|
|
156282
|
+
}, createDocumentModeStateDeriver = () => ({ context, superdoc }) => {
|
|
156283
|
+
return {
|
|
156284
|
+
active: false,
|
|
156285
|
+
disabled: !context,
|
|
156286
|
+
value: superdoc?.config?.documentMode ?? "editing"
|
|
156287
|
+
};
|
|
156288
|
+
}, createRulerExecute = () => ({ superdoc }) => {
|
|
156289
|
+
superdoc.toggleRuler?.();
|
|
156290
|
+
return true;
|
|
156291
|
+
}, createZoomExecute = () => ({ superdoc, payload }) => {
|
|
156292
|
+
const normalizedPayload = Number.parseInt(String(payload), 10);
|
|
156293
|
+
if (!Number.isFinite(normalizedPayload) || normalizedPayload <= 0)
|
|
156294
|
+
return false;
|
|
156295
|
+
superdoc.setZoom?.(normalizedPayload);
|
|
156296
|
+
return true;
|
|
156297
|
+
}, createDocumentModeExecute = () => ({ superdoc, payload }) => {
|
|
156298
|
+
const validModes = [
|
|
156299
|
+
"editing",
|
|
156300
|
+
"suggesting",
|
|
156301
|
+
"viewing"
|
|
156302
|
+
];
|
|
156303
|
+
const normalizedPayload = typeof payload === "string" ? payload.toLowerCase() : payload;
|
|
156304
|
+
if (typeof superdoc?.setDocumentMode !== "function" || typeof normalizedPayload !== "string" || !validModes.includes(normalizedPayload))
|
|
156305
|
+
return false;
|
|
156306
|
+
superdoc.setDocumentMode(normalizedPayload);
|
|
156307
|
+
return true;
|
|
156068
156308
|
}, isOffValue = (value) => {
|
|
156069
156309
|
if (value == null)
|
|
156070
156310
|
return false;
|
|
@@ -156075,8 +156315,749 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
|
|
|
156075
156315
|
if (typeof checker !== "function")
|
|
156076
156316
|
return false;
|
|
156077
156317
|
return Boolean(checker(attrs));
|
|
156318
|
+
}, normalizeFontSizeValue = (value) => {
|
|
156319
|
+
if (typeof value === "number")
|
|
156320
|
+
return `${value}pt`;
|
|
156321
|
+
if (typeof value === "string") {
|
|
156322
|
+
const [numericValue, unit] = parseSizeUnit(value);
|
|
156323
|
+
if (!Number.isNaN(numericValue))
|
|
156324
|
+
return `${numericValue}${unit || "pt"}`;
|
|
156325
|
+
}
|
|
156326
|
+
return value;
|
|
156327
|
+
}, normalizeFontFamilyValue = (value) => {
|
|
156328
|
+
if (typeof value !== "string")
|
|
156329
|
+
return value;
|
|
156330
|
+
return value;
|
|
156331
|
+
}, normalizeLinkHrefValue = (value) => {
|
|
156332
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
156333
|
+
}, normalizeColorValue = (value) => {
|
|
156334
|
+
if (typeof value === "string" && value.length > 0)
|
|
156335
|
+
return value.toLowerCase();
|
|
156336
|
+
return null;
|
|
156337
|
+
}, isFormattingActivatedFromLinkedStyle = (context, styleKey) => {
|
|
156338
|
+
const stateEditor = resolveStateEditor(context);
|
|
156339
|
+
if (!stateEditor?.state?.selection?.$from)
|
|
156340
|
+
return false;
|
|
156341
|
+
const styleId = getCurrentResolvedParagraphProperties(context)?.styleId;
|
|
156342
|
+
const linkedStyle = stateEditor?.converter?.linkedStyles?.find((style) => style.id === styleId);
|
|
156343
|
+
return Boolean(linkedStyle?.definition?.styles && styleKey in linkedStyle.definition.styles);
|
|
156344
|
+
}, hasNegatedFormattingMark = (formatting, markName) => {
|
|
156345
|
+
const rawActiveMark = formatting.find((mark) => mark.name === markName);
|
|
156346
|
+
return rawActiveMark ? isNegatedMark(rawActiveMark.name, rawActiveMark.attrs) : false;
|
|
156347
|
+
}, createBoldStateDeriver = () => ({ context }) => {
|
|
156348
|
+
const stateEditor = resolveStateEditor(context);
|
|
156349
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156350
|
+
if (isCommandDisabled(context))
|
|
156351
|
+
return {
|
|
156352
|
+
active: false,
|
|
156353
|
+
disabled: true
|
|
156354
|
+
};
|
|
156355
|
+
const isActiveFromMark = formatting.some((mark) => mark.name === "bold");
|
|
156356
|
+
const markNegated = hasNegatedFormattingMark(formatting, "bold");
|
|
156357
|
+
const activeFromLinkedStyle = !isActiveFromMark && !markNegated ? isFormattingActivatedFromLinkedStyle(context, "bold") : false;
|
|
156358
|
+
return {
|
|
156359
|
+
active: isActiveFromMark || activeFromLinkedStyle,
|
|
156360
|
+
disabled: false
|
|
156361
|
+
};
|
|
156362
|
+
}, createItalicStateDeriver = () => ({ context }) => {
|
|
156363
|
+
const stateEditor = resolveStateEditor(context);
|
|
156364
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156365
|
+
if (isCommandDisabled(context))
|
|
156366
|
+
return {
|
|
156367
|
+
active: false,
|
|
156368
|
+
disabled: true
|
|
156369
|
+
};
|
|
156370
|
+
return {
|
|
156371
|
+
active: !hasNegatedFormattingMark(formatting, "italic") && formatting.some((mark) => mark.name === "italic"),
|
|
156372
|
+
disabled: false
|
|
156373
|
+
};
|
|
156374
|
+
}, createUnderlineStateDeriver = () => ({ context }) => {
|
|
156375
|
+
const stateEditor = resolveStateEditor(context);
|
|
156376
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156377
|
+
if (isCommandDisabled(context))
|
|
156378
|
+
return {
|
|
156379
|
+
active: false,
|
|
156380
|
+
disabled: true
|
|
156381
|
+
};
|
|
156382
|
+
return {
|
|
156383
|
+
active: !hasNegatedFormattingMark(formatting, "underline") && formatting.some((mark) => mark.name === "underline"),
|
|
156384
|
+
disabled: false
|
|
156385
|
+
};
|
|
156386
|
+
}, createStrikethroughStateDeriver = () => ({ context }) => {
|
|
156387
|
+
const stateEditor = resolveStateEditor(context);
|
|
156388
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156389
|
+
if (isCommandDisabled(context))
|
|
156390
|
+
return {
|
|
156391
|
+
active: false,
|
|
156392
|
+
disabled: true
|
|
156393
|
+
};
|
|
156394
|
+
return {
|
|
156395
|
+
active: !hasNegatedFormattingMark(formatting, "strike") && formatting.some((mark) => mark.name === "strike"),
|
|
156396
|
+
disabled: false
|
|
156397
|
+
};
|
|
156398
|
+
}, createFontSizeStateDeriver = () => ({ context }) => {
|
|
156399
|
+
const stateEditor = resolveStateEditor(context);
|
|
156400
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156401
|
+
if (isCommandDisabled(context))
|
|
156402
|
+
return {
|
|
156403
|
+
active: false,
|
|
156404
|
+
disabled: true,
|
|
156405
|
+
value: null
|
|
156406
|
+
};
|
|
156407
|
+
const normalizedValues = formatting.filter((mark) => mark.name === "fontSize").map((mark) => mark.attrs?.fontSize).filter((value$1) => value$1 != null).map((value$1) => normalizeFontSizeValue(value$1));
|
|
156408
|
+
const uniqueValues = [...new Set(normalizedValues)];
|
|
156409
|
+
const hasDirectValue = uniqueValues.length > 0;
|
|
156410
|
+
const canUseLinkedStyle = !hasDirectValue && isFormattingActivatedFromLinkedStyle(context, "font-size");
|
|
156411
|
+
const paragraphProps = canUseLinkedStyle ? getCurrentResolvedParagraphProperties(context) : null;
|
|
156412
|
+
const documentEditor = context?.presentationEditor?.editor ?? context?.editor ?? null;
|
|
156413
|
+
const linkedStyleValue = normalizeFontSizeValue((canUseLinkedStyle ? documentEditor?.converter?.linkedStyles?.find((style) => style.id === paragraphProps?.styleId) : null)?.definition?.styles?.["font-size"]) ?? null;
|
|
156414
|
+
const value = uniqueValues.length === 1 ? uniqueValues[0] : linkedStyleValue;
|
|
156415
|
+
return {
|
|
156416
|
+
active: hasDirectValue || linkedStyleValue != null,
|
|
156417
|
+
disabled: false,
|
|
156418
|
+
value
|
|
156419
|
+
};
|
|
156420
|
+
}, createFontFamilyStateDeriver = () => ({ context }) => {
|
|
156421
|
+
const stateEditor = resolveStateEditor(context);
|
|
156422
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156423
|
+
if (isCommandDisabled(context))
|
|
156424
|
+
return {
|
|
156425
|
+
active: false,
|
|
156426
|
+
disabled: true,
|
|
156427
|
+
value: null
|
|
156428
|
+
};
|
|
156429
|
+
const normalizedValues = formatting.filter((mark) => mark.name === "fontFamily").map((mark) => mark.attrs?.fontFamily).filter((value$1) => value$1 != null).map((value$1) => normalizeFontFamilyValue(value$1));
|
|
156430
|
+
const uniqueValues = [...new Set(normalizedValues)];
|
|
156431
|
+
const canUseLinkedStyle = !(uniqueValues.length > 0) && isFormattingActivatedFromLinkedStyle(context, "font-family");
|
|
156432
|
+
const paragraphProps = canUseLinkedStyle ? getCurrentResolvedParagraphProperties(context) : null;
|
|
156433
|
+
const documentEditor = context?.presentationEditor?.editor ?? context?.editor ?? null;
|
|
156434
|
+
const linkedStyleValue = normalizeFontFamilyValue((canUseLinkedStyle ? documentEditor?.converter?.linkedStyles?.find((style) => style.id === paragraphProps?.styleId) : null)?.definition?.styles?.["font-family"]) ?? null;
|
|
156435
|
+
const value = uniqueValues.length === 1 ? uniqueValues[0] : linkedStyleValue;
|
|
156436
|
+
return {
|
|
156437
|
+
active: uniqueValues.length > 0 || linkedStyleValue != null,
|
|
156438
|
+
disabled: false,
|
|
156439
|
+
value
|
|
156440
|
+
};
|
|
156441
|
+
}, createTextColorStateDeriver = () => ({ context }) => {
|
|
156442
|
+
const stateEditor = resolveStateEditor(context);
|
|
156443
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156444
|
+
if (isCommandDisabled(context))
|
|
156445
|
+
return {
|
|
156446
|
+
active: false,
|
|
156447
|
+
disabled: true,
|
|
156448
|
+
value: null
|
|
156449
|
+
};
|
|
156450
|
+
const values = formatting.filter((mark) => mark.name === "color").map((mark) => mark.attrs?.color).filter((value$1) => value$1 != null);
|
|
156451
|
+
const markNegated = hasNegatedFormattingMark(formatting, "color");
|
|
156452
|
+
const normalizedValues = values.map((value$1) => normalizeColorValue(value$1));
|
|
156453
|
+
const uniqueValues = [...new Set(normalizedValues)];
|
|
156454
|
+
const value = uniqueValues.length === 1 ? uniqueValues[0] : null;
|
|
156455
|
+
return {
|
|
156456
|
+
active: !markNegated && uniqueValues.length > 0,
|
|
156457
|
+
disabled: false,
|
|
156458
|
+
value
|
|
156459
|
+
};
|
|
156460
|
+
}, createHighlightColorStateDeriver = () => ({ context }) => {
|
|
156461
|
+
const stateEditor = resolveStateEditor(context);
|
|
156462
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156463
|
+
if (isCommandDisabled(context))
|
|
156464
|
+
return {
|
|
156465
|
+
active: false,
|
|
156466
|
+
disabled: true,
|
|
156467
|
+
value: null
|
|
156468
|
+
};
|
|
156469
|
+
const values = formatting.filter((mark) => mark.name === "highlight").map((mark) => mark.attrs?.color).filter((value$1) => value$1 != null);
|
|
156470
|
+
const markNegated = hasNegatedFormattingMark(formatting, "highlight");
|
|
156471
|
+
const normalizedValues = values.map((value$1) => normalizeColorValue(value$1));
|
|
156472
|
+
const uniqueValues = [...new Set(normalizedValues)];
|
|
156473
|
+
const value = uniqueValues.length === 1 ? uniqueValues[0] : null;
|
|
156474
|
+
return {
|
|
156475
|
+
active: !markNegated && uniqueValues.length > 0,
|
|
156476
|
+
disabled: false,
|
|
156477
|
+
value
|
|
156478
|
+
};
|
|
156479
|
+
}, createLinkStateDeriver = () => ({ context }) => {
|
|
156480
|
+
const stateEditor = resolveStateEditor(context);
|
|
156481
|
+
const formatting = stateEditor ? getActiveFormatting(stateEditor) : [];
|
|
156482
|
+
if (isCommandDisabled(context))
|
|
156483
|
+
return {
|
|
156484
|
+
active: false,
|
|
156485
|
+
disabled: true,
|
|
156486
|
+
value: null
|
|
156487
|
+
};
|
|
156488
|
+
const normalizedValues = formatting.filter((mark) => mark.name === "link").map((mark) => mark.attrs?.href).filter((value$1) => value$1 != null).map((value$1) => normalizeLinkHrefValue(value$1));
|
|
156489
|
+
const uniqueValues = [...new Set(normalizedValues)];
|
|
156490
|
+
const value = uniqueValues.length === 1 ? uniqueValues[0] : null;
|
|
156491
|
+
return {
|
|
156492
|
+
active: uniqueValues.length > 0,
|
|
156493
|
+
disabled: false,
|
|
156494
|
+
value
|
|
156495
|
+
};
|
|
156496
|
+
}, createBoldExecute = () => ({ context, payload }) => {
|
|
156497
|
+
const editor = resolveStateEditor(context);
|
|
156498
|
+
if (isFieldAnnotationSelection(context)) {
|
|
156499
|
+
editor?.commands?.toggleFieldAnnotationsFormat?.("bold", true);
|
|
156500
|
+
return true;
|
|
156501
|
+
}
|
|
156502
|
+
if (!createDirectCommandExecute("toggleBold")({
|
|
156503
|
+
context,
|
|
156504
|
+
payload
|
|
156505
|
+
}))
|
|
156506
|
+
return false;
|
|
156507
|
+
editor?.commands?.toggleFieldAnnotationsFormat?.("bold", true);
|
|
156508
|
+
return true;
|
|
156509
|
+
}, createItalicExecute = () => ({ context, payload }) => {
|
|
156510
|
+
const editor = resolveStateEditor(context);
|
|
156511
|
+
if (isFieldAnnotationSelection(context)) {
|
|
156512
|
+
editor?.commands?.toggleFieldAnnotationsFormat?.("italic", true);
|
|
156513
|
+
return true;
|
|
156514
|
+
}
|
|
156515
|
+
if (!createDirectCommandExecute("toggleItalic")({
|
|
156516
|
+
context,
|
|
156517
|
+
payload
|
|
156518
|
+
}))
|
|
156519
|
+
return false;
|
|
156520
|
+
editor?.commands?.toggleFieldAnnotationsFormat?.("italic", true);
|
|
156521
|
+
return true;
|
|
156522
|
+
}, createUnderlineExecute = () => ({ context, payload }) => {
|
|
156523
|
+
const editor = resolveStateEditor(context);
|
|
156524
|
+
if (isFieldAnnotationSelection(context)) {
|
|
156525
|
+
editor?.commands?.toggleFieldAnnotationsFormat?.("underline", true);
|
|
156526
|
+
return true;
|
|
156527
|
+
}
|
|
156528
|
+
if (!createDirectCommandExecute("toggleUnderline")({
|
|
156529
|
+
context,
|
|
156530
|
+
payload
|
|
156531
|
+
}))
|
|
156532
|
+
return false;
|
|
156533
|
+
editor?.commands?.toggleFieldAnnotationsFormat?.("underline", true);
|
|
156534
|
+
return true;
|
|
156535
|
+
}, createFontSizeExecute = () => ({ context, payload }) => {
|
|
156536
|
+
if (payload === undefined)
|
|
156537
|
+
return false;
|
|
156538
|
+
const editor = resolveStateEditor(context);
|
|
156539
|
+
if (isFieldAnnotationSelection(context)) {
|
|
156540
|
+
editor?.commands?.setFieldAnnotationsFontSize?.(payload, true);
|
|
156541
|
+
return true;
|
|
156542
|
+
}
|
|
156543
|
+
if (!createDirectCommandExecute("setFontSize")({
|
|
156544
|
+
context,
|
|
156545
|
+
payload
|
|
156546
|
+
}))
|
|
156547
|
+
return false;
|
|
156548
|
+
editor?.commands?.setFieldAnnotationsFontSize?.(payload, true);
|
|
156549
|
+
return true;
|
|
156550
|
+
}, createFontFamilyExecute = () => ({ context, payload }) => {
|
|
156551
|
+
if (payload === undefined)
|
|
156552
|
+
return false;
|
|
156553
|
+
const editor = resolveStateEditor(context);
|
|
156554
|
+
if (isFieldAnnotationSelection(context)) {
|
|
156555
|
+
editor?.commands?.setFieldAnnotationsFontFamily?.(payload, true);
|
|
156556
|
+
return true;
|
|
156557
|
+
}
|
|
156558
|
+
if (!createDirectCommandExecute("setFontFamily")({
|
|
156559
|
+
context,
|
|
156560
|
+
payload
|
|
156561
|
+
}))
|
|
156562
|
+
return false;
|
|
156563
|
+
editor?.commands?.setFieldAnnotationsFontFamily?.(payload, true);
|
|
156564
|
+
return true;
|
|
156565
|
+
}, createTextColorExecute = () => ({ context, payload }) => {
|
|
156566
|
+
const editor = resolveStateEditor(context);
|
|
156567
|
+
if (typeof payload !== "string" || payload.length === 0)
|
|
156568
|
+
return false;
|
|
156569
|
+
const isNone = payload === "none";
|
|
156570
|
+
const inlineValue = isNone ? "inherit" : payload;
|
|
156571
|
+
const result = createDirectCommandExecute("setColor")({
|
|
156572
|
+
context,
|
|
156573
|
+
payload: inlineValue
|
|
156574
|
+
});
|
|
156575
|
+
editor?.commands?.setFieldAnnotationsTextColor?.(isNone ? null : payload, true);
|
|
156576
|
+
return result;
|
|
156577
|
+
}, createHighlightColorExecute = () => ({ context, payload }) => {
|
|
156578
|
+
const editor = resolveStateEditor(context);
|
|
156579
|
+
if (typeof payload !== "string" || payload.length === 0)
|
|
156580
|
+
return false;
|
|
156581
|
+
const isNone = payload === "none";
|
|
156582
|
+
const inlineValue = isNone ? "transparent" : payload;
|
|
156583
|
+
const result = createDirectCommandExecute("setHighlight")({
|
|
156584
|
+
context,
|
|
156585
|
+
payload: inlineValue
|
|
156586
|
+
});
|
|
156587
|
+
const argValue = isNone ? null : payload;
|
|
156588
|
+
editor?.commands?.setFieldAnnotationsTextHighlight?.(argValue, true);
|
|
156589
|
+
editor?.commands?.setCellBackground?.(argValue);
|
|
156590
|
+
return result;
|
|
156591
|
+
}, applyLinkPostExecute = (editor) => {
|
|
156592
|
+
const { view } = editor;
|
|
156593
|
+
let selection = view.state.selection;
|
|
156594
|
+
if (editor.options?.isHeaderOrFooter && editor.options?.lastSelection)
|
|
156595
|
+
selection = editor.options.lastSelection;
|
|
156596
|
+
const endPos = selection?.$to?.pos;
|
|
156597
|
+
if (typeof endPos !== "number")
|
|
156598
|
+
return;
|
|
156599
|
+
try {
|
|
156600
|
+
const newSelection = new TextSelection(view.state.doc.resolve(endPos));
|
|
156601
|
+
const tr = view.state.tr.setSelection(newSelection);
|
|
156602
|
+
const state = view.state.apply(tr);
|
|
156603
|
+
view.updateState(state);
|
|
156604
|
+
if (!editor.options?.isHeaderOrFooter)
|
|
156605
|
+
setTimeout(() => {
|
|
156606
|
+
view.focus();
|
|
156607
|
+
}, 100);
|
|
156608
|
+
} catch {
|
|
156609
|
+
return;
|
|
156610
|
+
}
|
|
156611
|
+
}, createLinkExecute = () => ({ context, payload }) => {
|
|
156612
|
+
const editor = resolveStateEditor(context);
|
|
156613
|
+
const result = createDirectCommandExecute("toggleLink")({
|
|
156614
|
+
context,
|
|
156615
|
+
payload
|
|
156616
|
+
});
|
|
156617
|
+
if (!result || !editor?.view)
|
|
156618
|
+
return result;
|
|
156619
|
+
applyLinkPostExecute(editor);
|
|
156620
|
+
return true;
|
|
156621
|
+
}, createImageExecute = () => ({ context }) => {
|
|
156622
|
+
const editor = resolveStateEditor(context);
|
|
156623
|
+
if (!editor?.view)
|
|
156624
|
+
return false;
|
|
156625
|
+
getFileOpener()().then(async (result) => {
|
|
156626
|
+
if (!result?.file)
|
|
156627
|
+
return;
|
|
156628
|
+
await processAndInsertImageFile({
|
|
156629
|
+
file: result.file,
|
|
156630
|
+
editor,
|
|
156631
|
+
view: editor.view,
|
|
156632
|
+
editorOptions: editor.options,
|
|
156633
|
+
getMaxContentSize: () => editor.getMaxContentSize()
|
|
156634
|
+
});
|
|
156635
|
+
}).catch((err) => {
|
|
156636
|
+
const originalError = err instanceof Error ? err : new Error(String(err));
|
|
156637
|
+
const error3 = /* @__PURE__ */ new Error(`[headless-toolbar] Image insertion failed: ${originalError.message}`);
|
|
156638
|
+
editor?.emit?.("exception", {
|
|
156639
|
+
error: error3,
|
|
156640
|
+
editor
|
|
156641
|
+
});
|
|
156642
|
+
console.error(error3, originalError);
|
|
156643
|
+
});
|
|
156644
|
+
return true;
|
|
156645
|
+
}, getCurrentParagraphJustification = (context) => {
|
|
156646
|
+
const justification = getCurrentResolvedParagraphProperties(context)?.justification ?? null;
|
|
156647
|
+
if (justification === "both")
|
|
156648
|
+
return "justify";
|
|
156649
|
+
return justification;
|
|
156650
|
+
}, createTextAlignStateDeriver = () => ({ context }) => {
|
|
156651
|
+
if (isCommandDisabled(context))
|
|
156652
|
+
return {
|
|
156653
|
+
active: false,
|
|
156654
|
+
disabled: true,
|
|
156655
|
+
value: null
|
|
156656
|
+
};
|
|
156657
|
+
const value = getCurrentParagraphJustification(context) ?? null;
|
|
156658
|
+
return {
|
|
156659
|
+
active: value != null,
|
|
156660
|
+
disabled: false,
|
|
156661
|
+
value
|
|
156662
|
+
};
|
|
156663
|
+
}, createLineHeightStateDeriver = () => ({ context }) => {
|
|
156664
|
+
if (isCommandDisabled(context))
|
|
156665
|
+
return {
|
|
156666
|
+
active: false,
|
|
156667
|
+
disabled: true,
|
|
156668
|
+
value: null
|
|
156669
|
+
};
|
|
156670
|
+
const line = getCurrentResolvedParagraphProperties(context)?.spacing?.line;
|
|
156671
|
+
const value = line != null ? twipsToLines(line) : null;
|
|
156672
|
+
return {
|
|
156673
|
+
active: value != null,
|
|
156674
|
+
disabled: false,
|
|
156675
|
+
value
|
|
156676
|
+
};
|
|
156677
|
+
}, createLinkedStyleStateDeriver = () => ({ context }) => {
|
|
156678
|
+
const isDisabled = isCommandDisabled(context);
|
|
156679
|
+
const stateEditor = resolveStateEditor(context);
|
|
156680
|
+
if (isDisabled || !stateEditor)
|
|
156681
|
+
return {
|
|
156682
|
+
active: false,
|
|
156683
|
+
disabled: true,
|
|
156684
|
+
value: null
|
|
156685
|
+
};
|
|
156686
|
+
if (!getQuickFormatList(stateEditor).length)
|
|
156687
|
+
return {
|
|
156688
|
+
active: false,
|
|
156689
|
+
disabled: true,
|
|
156690
|
+
value: null
|
|
156691
|
+
};
|
|
156692
|
+
const value = getCurrentResolvedParagraphProperties(context)?.styleId ?? null;
|
|
156693
|
+
return {
|
|
156694
|
+
active: value != null,
|
|
156695
|
+
disabled: false,
|
|
156696
|
+
value
|
|
156697
|
+
};
|
|
156698
|
+
}, createListStateDeriver = (numberingType) => ({ context }) => {
|
|
156699
|
+
if (isCommandDisabled(context))
|
|
156700
|
+
return {
|
|
156701
|
+
active: false,
|
|
156702
|
+
disabled: true
|
|
156703
|
+
};
|
|
156704
|
+
const paragraphNode = getCurrentParagraphParent(context)?.node ?? null;
|
|
156705
|
+
const paragraphProperties = getCurrentResolvedParagraphProperties(context);
|
|
156706
|
+
const activeNumberingType = isList(paragraphNode) || Boolean(paragraphProperties?.numberingProperties && paragraphNode?.attrs?.listRendering) ? paragraphNode?.attrs?.listRendering?.numberingType : null;
|
|
156707
|
+
return {
|
|
156708
|
+
active: numberingType === "bullet" ? activeNumberingType === "bullet" : activeNumberingType != null && activeNumberingType !== "bullet",
|
|
156709
|
+
disabled: false
|
|
156710
|
+
};
|
|
156711
|
+
}, createIndentIncreaseExecute = () => ({ context }) => {
|
|
156712
|
+
if (resolveStateEditor(context)?.commands?.increaseListIndent?.())
|
|
156713
|
+
return true;
|
|
156714
|
+
return createDirectCommandExecute("increaseTextIndent")({ context });
|
|
156715
|
+
}, createIndentDecreaseExecute = () => ({ context }) => {
|
|
156716
|
+
if (resolveStateEditor(context)?.commands?.decreaseListIndent?.())
|
|
156717
|
+
return true;
|
|
156718
|
+
return createDirectCommandExecute("decreaseTextIndent")({ context });
|
|
156719
|
+
}, createTableActionsStateDeriver = () => ({ context }) => {
|
|
156720
|
+
const editor = resolveStateEditor(context);
|
|
156721
|
+
const inTable = editor?.state?.selection?.$head ? isInTable(editor.state) : false;
|
|
156722
|
+
return {
|
|
156723
|
+
active: false,
|
|
156724
|
+
disabled: isCommandDisabled(context) || !inTable
|
|
156725
|
+
};
|
|
156726
|
+
}, enrichTrackedChanges = (trackedChanges = [], superdoc) => {
|
|
156727
|
+
if (!trackedChanges.length)
|
|
156728
|
+
return trackedChanges;
|
|
156729
|
+
const store = superdoc?.commentsStore;
|
|
156730
|
+
if (!store?.getComment)
|
|
156731
|
+
return trackedChanges;
|
|
156732
|
+
return trackedChanges.map((change) => {
|
|
156733
|
+
const commentId = change.id;
|
|
156734
|
+
if (!commentId)
|
|
156735
|
+
return change;
|
|
156736
|
+
const storeComment = store.getComment(commentId);
|
|
156737
|
+
if (!storeComment)
|
|
156738
|
+
return change;
|
|
156739
|
+
const comment = typeof storeComment.getValues === "function" ? storeComment.getValues() : storeComment;
|
|
156740
|
+
return {
|
|
156741
|
+
...change,
|
|
156742
|
+
comment
|
|
156743
|
+
};
|
|
156744
|
+
});
|
|
156745
|
+
}, createTrackChangesSelectionActionStateDeriver = (action) => ({ context, superdoc }) => {
|
|
156746
|
+
if (isCommandDisabled(context))
|
|
156747
|
+
return {
|
|
156748
|
+
active: false,
|
|
156749
|
+
disabled: true
|
|
156750
|
+
};
|
|
156751
|
+
const editor = resolveStateEditor(context);
|
|
156752
|
+
const state = editor?.state;
|
|
156753
|
+
const selection = state?.selection;
|
|
156754
|
+
if (!editor || !state?.doc || !selection)
|
|
156755
|
+
return {
|
|
156756
|
+
active: false,
|
|
156757
|
+
disabled: true
|
|
156758
|
+
};
|
|
156759
|
+
const trackedChanges = enrichTrackedChanges(collectTrackedChanges({
|
|
156760
|
+
state,
|
|
156761
|
+
from: selection.from,
|
|
156762
|
+
to: selection.to
|
|
156763
|
+
}), superdoc);
|
|
156764
|
+
if (!trackedChanges.length)
|
|
156765
|
+
return {
|
|
156766
|
+
active: false,
|
|
156767
|
+
disabled: true
|
|
156768
|
+
};
|
|
156769
|
+
return {
|
|
156770
|
+
active: false,
|
|
156771
|
+
disabled: !isTrackedChangeActionAllowed({
|
|
156772
|
+
editor,
|
|
156773
|
+
action,
|
|
156774
|
+
trackedChanges
|
|
156775
|
+
})
|
|
156776
|
+
};
|
|
156777
|
+
}, createToolbarRegistry = () => {
|
|
156778
|
+
return {
|
|
156779
|
+
bold: {
|
|
156780
|
+
id: "bold",
|
|
156781
|
+
directCommandName: "toggleBold",
|
|
156782
|
+
state: createBoldStateDeriver(),
|
|
156783
|
+
execute: createBoldExecute()
|
|
156784
|
+
},
|
|
156785
|
+
italic: {
|
|
156786
|
+
id: "italic",
|
|
156787
|
+
directCommandName: "toggleItalic",
|
|
156788
|
+
state: createItalicStateDeriver(),
|
|
156789
|
+
execute: createItalicExecute()
|
|
156790
|
+
},
|
|
156791
|
+
underline: {
|
|
156792
|
+
id: "underline",
|
|
156793
|
+
directCommandName: "toggleUnderline",
|
|
156794
|
+
state: createUnderlineStateDeriver(),
|
|
156795
|
+
execute: createUnderlineExecute()
|
|
156796
|
+
},
|
|
156797
|
+
strikethrough: {
|
|
156798
|
+
id: "strikethrough",
|
|
156799
|
+
directCommandName: "toggleStrike",
|
|
156800
|
+
state: createStrikethroughStateDeriver()
|
|
156801
|
+
},
|
|
156802
|
+
"font-size": {
|
|
156803
|
+
id: "font-size",
|
|
156804
|
+
directCommandName: "setFontSize",
|
|
156805
|
+
state: createFontSizeStateDeriver(),
|
|
156806
|
+
execute: createFontSizeExecute()
|
|
156807
|
+
},
|
|
156808
|
+
"font-family": {
|
|
156809
|
+
id: "font-family",
|
|
156810
|
+
directCommandName: "setFontFamily",
|
|
156811
|
+
state: createFontFamilyStateDeriver(),
|
|
156812
|
+
execute: createFontFamilyExecute()
|
|
156813
|
+
},
|
|
156814
|
+
"text-color": {
|
|
156815
|
+
id: "text-color",
|
|
156816
|
+
directCommandName: "setColor",
|
|
156817
|
+
state: createTextColorStateDeriver(),
|
|
156818
|
+
execute: createTextColorExecute()
|
|
156819
|
+
},
|
|
156820
|
+
"highlight-color": {
|
|
156821
|
+
id: "highlight-color",
|
|
156822
|
+
directCommandName: "setHighlight",
|
|
156823
|
+
state: createHighlightColorStateDeriver(),
|
|
156824
|
+
execute: createHighlightColorExecute()
|
|
156825
|
+
},
|
|
156826
|
+
link: {
|
|
156827
|
+
id: "link",
|
|
156828
|
+
directCommandName: "toggleLink",
|
|
156829
|
+
state: createLinkStateDeriver(),
|
|
156830
|
+
execute: createLinkExecute()
|
|
156831
|
+
},
|
|
156832
|
+
"text-align": {
|
|
156833
|
+
id: "text-align",
|
|
156834
|
+
directCommandName: "setTextAlign",
|
|
156835
|
+
state: createTextAlignStateDeriver()
|
|
156836
|
+
},
|
|
156837
|
+
"line-height": {
|
|
156838
|
+
id: "line-height",
|
|
156839
|
+
directCommandName: "setLineHeight",
|
|
156840
|
+
state: createLineHeightStateDeriver()
|
|
156841
|
+
},
|
|
156842
|
+
"linked-style": {
|
|
156843
|
+
id: "linked-style",
|
|
156844
|
+
directCommandName: "setLinkedStyle",
|
|
156845
|
+
state: createLinkedStyleStateDeriver(),
|
|
156846
|
+
execute: createDirectCommandExecute("setLinkedStyle")
|
|
156847
|
+
},
|
|
156848
|
+
"bullet-list": {
|
|
156849
|
+
id: "bullet-list",
|
|
156850
|
+
directCommandName: "toggleBulletList",
|
|
156851
|
+
state: createListStateDeriver("bullet")
|
|
156852
|
+
},
|
|
156853
|
+
"numbered-list": {
|
|
156854
|
+
id: "numbered-list",
|
|
156855
|
+
directCommandName: "toggleOrderedList",
|
|
156856
|
+
state: createListStateDeriver("ordered")
|
|
156857
|
+
},
|
|
156858
|
+
"indent-increase": {
|
|
156859
|
+
id: "indent-increase",
|
|
156860
|
+
state: createDisabledStateDeriver(),
|
|
156861
|
+
execute: createIndentIncreaseExecute()
|
|
156862
|
+
},
|
|
156863
|
+
"indent-decrease": {
|
|
156864
|
+
id: "indent-decrease",
|
|
156865
|
+
state: createDisabledStateDeriver(),
|
|
156866
|
+
execute: createIndentDecreaseExecute()
|
|
156867
|
+
},
|
|
156868
|
+
undo: {
|
|
156869
|
+
id: "undo",
|
|
156870
|
+
directCommandName: "undo",
|
|
156871
|
+
state: createHistoryStateDeriver("undo")
|
|
156872
|
+
},
|
|
156873
|
+
redo: {
|
|
156874
|
+
id: "redo",
|
|
156875
|
+
directCommandName: "redo",
|
|
156876
|
+
state: createHistoryStateDeriver("redo")
|
|
156877
|
+
},
|
|
156878
|
+
ruler: {
|
|
156879
|
+
id: "ruler",
|
|
156880
|
+
state: createRulerStateDeriver(),
|
|
156881
|
+
execute: createRulerExecute()
|
|
156882
|
+
},
|
|
156883
|
+
zoom: {
|
|
156884
|
+
id: "zoom",
|
|
156885
|
+
state: createZoomStateDeriver(),
|
|
156886
|
+
execute: createZoomExecute()
|
|
156887
|
+
},
|
|
156888
|
+
"document-mode": {
|
|
156889
|
+
id: "document-mode",
|
|
156890
|
+
state: createDocumentModeStateDeriver(),
|
|
156891
|
+
execute: createDocumentModeExecute()
|
|
156892
|
+
},
|
|
156893
|
+
"clear-formatting": {
|
|
156894
|
+
id: "clear-formatting",
|
|
156895
|
+
directCommandName: "clearFormat",
|
|
156896
|
+
state: createDisabledStateDeriver()
|
|
156897
|
+
},
|
|
156898
|
+
"copy-format": {
|
|
156899
|
+
id: "copy-format",
|
|
156900
|
+
directCommandName: "copyFormat",
|
|
156901
|
+
state: createDisabledStateDeriver()
|
|
156902
|
+
},
|
|
156903
|
+
"track-changes-accept-selection": {
|
|
156904
|
+
id: "track-changes-accept-selection",
|
|
156905
|
+
directCommandName: "acceptTrackedChangeFromToolbar",
|
|
156906
|
+
state: createTrackChangesSelectionActionStateDeriver("accept")
|
|
156907
|
+
},
|
|
156908
|
+
"track-changes-reject-selection": {
|
|
156909
|
+
id: "track-changes-reject-selection",
|
|
156910
|
+
directCommandName: "rejectTrackedChangeFromToolbar",
|
|
156911
|
+
state: createTrackChangesSelectionActionStateDeriver("reject")
|
|
156912
|
+
},
|
|
156913
|
+
image: {
|
|
156914
|
+
id: "image",
|
|
156915
|
+
state: createDisabledStateDeriver(),
|
|
156916
|
+
execute: createImageExecute()
|
|
156917
|
+
},
|
|
156918
|
+
"table-insert": {
|
|
156919
|
+
id: "table-insert",
|
|
156920
|
+
directCommandName: "insertTable",
|
|
156921
|
+
state: createDisabledStateDeriver(),
|
|
156922
|
+
execute: createDirectCommandExecute("insertTable")
|
|
156923
|
+
},
|
|
156924
|
+
"table-add-row-before": {
|
|
156925
|
+
id: "table-add-row-before",
|
|
156926
|
+
directCommandName: "addRowBefore",
|
|
156927
|
+
state: createTableActionsStateDeriver()
|
|
156928
|
+
},
|
|
156929
|
+
"table-add-row-after": {
|
|
156930
|
+
id: "table-add-row-after",
|
|
156931
|
+
directCommandName: "addRowAfter",
|
|
156932
|
+
state: createTableActionsStateDeriver()
|
|
156933
|
+
},
|
|
156934
|
+
"table-delete-row": {
|
|
156935
|
+
id: "table-delete-row",
|
|
156936
|
+
directCommandName: "deleteRow",
|
|
156937
|
+
state: createTableActionsStateDeriver()
|
|
156938
|
+
},
|
|
156939
|
+
"table-add-column-before": {
|
|
156940
|
+
id: "table-add-column-before",
|
|
156941
|
+
directCommandName: "addColumnBefore",
|
|
156942
|
+
state: createTableActionsStateDeriver()
|
|
156943
|
+
},
|
|
156944
|
+
"table-add-column-after": {
|
|
156945
|
+
id: "table-add-column-after",
|
|
156946
|
+
directCommandName: "addColumnAfter",
|
|
156947
|
+
state: createTableActionsStateDeriver()
|
|
156948
|
+
},
|
|
156949
|
+
"table-delete-column": {
|
|
156950
|
+
id: "table-delete-column",
|
|
156951
|
+
directCommandName: "deleteColumn",
|
|
156952
|
+
state: createTableActionsStateDeriver()
|
|
156953
|
+
},
|
|
156954
|
+
"table-delete": {
|
|
156955
|
+
id: "table-delete",
|
|
156956
|
+
directCommandName: "deleteTable",
|
|
156957
|
+
state: createTableActionsStateDeriver()
|
|
156958
|
+
},
|
|
156959
|
+
"table-merge-cells": {
|
|
156960
|
+
id: "table-merge-cells",
|
|
156961
|
+
directCommandName: "mergeCells",
|
|
156962
|
+
state: createTableActionsStateDeriver()
|
|
156963
|
+
},
|
|
156964
|
+
"table-split-cell": {
|
|
156965
|
+
id: "table-split-cell",
|
|
156966
|
+
directCommandName: "splitCell",
|
|
156967
|
+
state: createTableActionsStateDeriver()
|
|
156968
|
+
},
|
|
156969
|
+
"table-remove-borders": {
|
|
156970
|
+
id: "table-remove-borders",
|
|
156971
|
+
directCommandName: "deleteCellAndTableBorders",
|
|
156972
|
+
state: createTableActionsStateDeriver()
|
|
156973
|
+
},
|
|
156974
|
+
"table-fix": {
|
|
156975
|
+
id: "table-fix",
|
|
156976
|
+
directCommandName: "fixTables",
|
|
156977
|
+
state: createTableActionsStateDeriver()
|
|
156978
|
+
}
|
|
156979
|
+
};
|
|
156980
|
+
}, executeDirectCommand = (id2, snapshot2, toolbarRegistry, payload) => {
|
|
156981
|
+
const commandName = toolbarRegistry[id2]?.directCommandName;
|
|
156982
|
+
const command = commandName ? snapshot2.context?.target?.commands?.[commandName] : null;
|
|
156983
|
+
if (typeof command !== "function")
|
|
156984
|
+
return false;
|
|
156985
|
+
const result = payload === undefined ? command() : command(payload);
|
|
156986
|
+
return typeof result === "boolean" ? result : Boolean(result);
|
|
156987
|
+
}, executeRegistryCommand = (id2, superdoc, snapshot2, toolbarRegistry, payload) => {
|
|
156988
|
+
const entry = toolbarRegistry[id2];
|
|
156989
|
+
if (!entry)
|
|
156990
|
+
return false;
|
|
156991
|
+
if (typeof entry.execute === "function")
|
|
156992
|
+
return entry.execute({
|
|
156993
|
+
context: snapshot2.context,
|
|
156994
|
+
superdoc,
|
|
156995
|
+
payload
|
|
156996
|
+
});
|
|
156997
|
+
return executeDirectCommand(id2, snapshot2, toolbarRegistry, payload);
|
|
156998
|
+
}, createHeadlessToolbar = (options) => {
|
|
156999
|
+
const listeners = /* @__PURE__ */ new Set;
|
|
157000
|
+
const toolbarRegistry = createToolbarRegistry();
|
|
157001
|
+
const buildSnapshot = () => {
|
|
157002
|
+
return createToolbarSnapshot({
|
|
157003
|
+
...options,
|
|
157004
|
+
toolbarRegistry
|
|
157005
|
+
});
|
|
157006
|
+
};
|
|
157007
|
+
let snapshot2 = buildSnapshot();
|
|
157008
|
+
let destroyed = false;
|
|
157009
|
+
let unsubscribeEvents = null;
|
|
157010
|
+
const notifyListeners = () => {
|
|
157011
|
+
listeners.forEach((listener) => listener({ snapshot: snapshot2 }));
|
|
157012
|
+
};
|
|
157013
|
+
const rebindEvents = () => {
|
|
157014
|
+
unsubscribeEvents?.();
|
|
157015
|
+
unsubscribeEvents = subscribeToolbarEvents(options, handleChange);
|
|
157016
|
+
};
|
|
157017
|
+
const rebuildSnapshot = () => {
|
|
157018
|
+
snapshot2 = buildSnapshot();
|
|
157019
|
+
};
|
|
157020
|
+
const refreshControllerState = () => {
|
|
157021
|
+
rebuildSnapshot();
|
|
157022
|
+
rebindEvents();
|
|
157023
|
+
notifyListeners();
|
|
157024
|
+
};
|
|
157025
|
+
const handleChange = () => {
|
|
157026
|
+
if (destroyed)
|
|
157027
|
+
return;
|
|
157028
|
+
refreshControllerState();
|
|
157029
|
+
};
|
|
157030
|
+
rebindEvents();
|
|
157031
|
+
return {
|
|
157032
|
+
getSnapshot() {
|
|
157033
|
+
return snapshot2;
|
|
157034
|
+
},
|
|
157035
|
+
subscribe(listener) {
|
|
157036
|
+
if (destroyed)
|
|
157037
|
+
return () => {};
|
|
157038
|
+
listeners.add(listener);
|
|
157039
|
+
listener({ snapshot: snapshot2 });
|
|
157040
|
+
return () => {
|
|
157041
|
+
listeners.delete(listener);
|
|
157042
|
+
};
|
|
157043
|
+
},
|
|
157044
|
+
execute(id2, payload) {
|
|
157045
|
+
const result = executeRegistryCommand(id2, options.superdoc, snapshot2, toolbarRegistry, payload);
|
|
157046
|
+
if (result && !destroyed)
|
|
157047
|
+
refreshControllerState();
|
|
157048
|
+
return result;
|
|
157049
|
+
},
|
|
157050
|
+
destroy() {
|
|
157051
|
+
if (destroyed)
|
|
157052
|
+
return;
|
|
157053
|
+
destroyed = true;
|
|
157054
|
+
unsubscribeEvents?.();
|
|
157055
|
+
unsubscribeEvents = null;
|
|
157056
|
+
listeners.clear();
|
|
157057
|
+
}
|
|
157058
|
+
};
|
|
156078
157059
|
};
|
|
156079
|
-
var
|
|
157060
|
+
var init_create_headless_toolbar_Dcw4Hyt2_es = __esm(() => {
|
|
156080
157061
|
init_SuperConverter_BgwP1GeS_es();
|
|
156081
157062
|
init_constants_CGhJRd87_es();
|
|
156082
157063
|
init_dist_B8HfvhaK_es();
|
|
@@ -204515,7 +205496,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
204515
205496
|
init_remark_gfm_BhnWr3yf_es();
|
|
204516
205497
|
});
|
|
204517
205498
|
|
|
204518
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
205499
|
+
// ../../packages/superdoc/dist/chunks/src-yUVuhLM1.es.js
|
|
204519
205500
|
function deleteProps(obj, propOrProps) {
|
|
204520
205501
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
204521
205502
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -205240,9 +206221,9 @@ function mapPreservedSelection(selection, tr) {
|
|
|
205240
206221
|
function applySelectionCleanup(editor, tr) {
|
|
205241
206222
|
let cleaned = tr.setMeta(CustomSelectionPluginKey, DEFAULT_SELECTION_STATE);
|
|
205242
206223
|
const sel = cleaned.selection;
|
|
205243
|
-
if (sel && sel instanceof
|
|
206224
|
+
if (sel && sel instanceof TextSelection && !sel.empty)
|
|
205244
206225
|
try {
|
|
205245
|
-
const collapsed =
|
|
206226
|
+
const collapsed = TextSelection.create(cleaned.doc, sel.head);
|
|
205246
206227
|
cleaned = cleaned.setSelection(collapsed);
|
|
205247
206228
|
} catch {}
|
|
205248
206229
|
editor.setOptions({
|
|
@@ -205355,7 +206336,7 @@ function arrow$1(axis, dir) {
|
|
|
205355
206336
|
return function(state, dispatch, view) {
|
|
205356
206337
|
let sel = state.selection;
|
|
205357
206338
|
let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
|
|
205358
|
-
if (sel instanceof
|
|
206339
|
+
if (sel instanceof TextSelection) {
|
|
205359
206340
|
if (!view.endOfTextblock(dirStr) || $start.depth == 0)
|
|
205360
206341
|
return false;
|
|
205361
206342
|
mustMove = false;
|
|
@@ -205395,7 +206376,7 @@ function beforeinput(view, event) {
|
|
|
205395
206376
|
for (let i4 = insert.length - 1;i4 >= 0; i4--)
|
|
205396
206377
|
frag = Fragment.from(insert[i4].createAndFill(null, frag));
|
|
205397
206378
|
let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
|
|
205398
|
-
tr.setSelection(
|
|
206379
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
|
|
205399
206380
|
view.dispatch(tr);
|
|
205400
206381
|
return false;
|
|
205401
206382
|
}
|
|
@@ -206282,7 +207263,7 @@ function createStructuredContentSelectPlugin(editor) {
|
|
|
206282
207263
|
for (let od = old$pos.depth;od > 0; od--)
|
|
206283
207264
|
if (old$pos.node(od).type.name === "structuredContent" && old$pos.before(od) === sdtStart)
|
|
206284
207265
|
return null;
|
|
206285
|
-
return newState.tr.setSelection(
|
|
207266
|
+
return newState.tr.setSelection(TextSelection.create(newState.doc, contentFrom, contentTo));
|
|
206286
207267
|
}
|
|
206287
207268
|
return null;
|
|
206288
207269
|
} });
|
|
@@ -206493,7 +207474,7 @@ function splitBlockPatch(state, dispatch, editor) {
|
|
|
206493
207474
|
}
|
|
206494
207475
|
}
|
|
206495
207476
|
let tr = state.tr;
|
|
206496
|
-
if (state.selection instanceof
|
|
207477
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection)
|
|
206497
207478
|
tr.deleteSelection();
|
|
206498
207479
|
let splitPos = tr.mapping.map($from.pos);
|
|
206499
207480
|
let can = canSplit(tr.doc, splitPos, types3.length, types3);
|
|
@@ -206698,7 +207679,7 @@ function splitBlockAs(splitNode) {
|
|
|
206698
207679
|
types3.unshift(null);
|
|
206699
207680
|
}
|
|
206700
207681
|
let tr = state.tr;
|
|
206701
|
-
if (state.selection instanceof
|
|
207682
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection)
|
|
206702
207683
|
tr.deleteSelection();
|
|
206703
207684
|
let splitPos = tr.mapping.map($from.pos);
|
|
206704
207685
|
let can = canSplit(tr.doc, splitPos, types3.length, types3);
|
|
@@ -206796,7 +207777,7 @@ function selectTextblockSide(side) {
|
|
|
206796
207777
|
if (!$pos.node(depth).isTextblock)
|
|
206797
207778
|
return false;
|
|
206798
207779
|
if (dispatch)
|
|
206799
|
-
dispatch(state.tr.setSelection(
|
|
207780
|
+
dispatch(state.tr.setSelection(TextSelection.create(state.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));
|
|
206800
207781
|
return true;
|
|
206801
207782
|
};
|
|
206802
207783
|
}
|
|
@@ -207124,7 +208105,7 @@ function skipTab(dir) {
|
|
|
207124
208105
|
return false;
|
|
207125
208106
|
const nextPos = dir > 0 ? Math.min($nextPos.pos + nextNode.nodeSize + 1, state.doc.nodeSize) : Math.max(0, $nextPos.pos - nextNode.nodeSize - 1);
|
|
207126
208107
|
if (dispatch)
|
|
207127
|
-
dispatch(state.tr.setSelection(
|
|
208108
|
+
dispatch(state.tr.setSelection(TextSelection.create(state.doc, nextPos)));
|
|
207128
208109
|
return true;
|
|
207129
208110
|
};
|
|
207130
208111
|
}
|
|
@@ -208844,7 +209825,7 @@ function getTableBoundaryExitSelection(state, dir) {
|
|
|
208844
209825
|
const boundaryPos = helpers.getTableBoundaryPos(context);
|
|
208845
209826
|
const targetPos = helpers.findTextPosAcrossBoundary(state, boundaryPos);
|
|
208846
209827
|
if (targetPos != null)
|
|
208847
|
-
return
|
|
209828
|
+
return TextSelection.create(state.doc, targetPos);
|
|
208848
209829
|
return findSelectionNearBoundary(state, boundaryPos, dir);
|
|
208849
209830
|
}
|
|
208850
209831
|
function getAdjacentTableEntrySelection(state, dir) {
|
|
@@ -208865,13 +209846,13 @@ function getAdjacentTableEntrySelection(state, dir) {
|
|
|
208865
209846
|
if (dir > 0) {
|
|
208866
209847
|
const targetPos$1 = findFirstTextPosInNode(adjacentNode, boundaryPos);
|
|
208867
209848
|
if (targetPos$1 != null)
|
|
208868
|
-
return
|
|
209849
|
+
return TextSelection.create(state.doc, targetPos$1);
|
|
208869
209850
|
return findSelectionNearBoundary(state, boundaryPos, 1);
|
|
208870
209851
|
}
|
|
208871
209852
|
const tablePos = boundaryPos - adjacentNode.nodeSize;
|
|
208872
209853
|
const targetPos = findLastTextPosInNode(adjacentNode, tablePos);
|
|
208873
209854
|
if (targetPos != null)
|
|
208874
|
-
return
|
|
209855
|
+
return TextSelection.create(state.doc, targetPos);
|
|
208875
209856
|
return findSelectionNearBoundary(state, tablePos + adjacentNode.nodeSize, -1);
|
|
208876
209857
|
}
|
|
208877
209858
|
function createTableBoundaryNavigationPlugin() {
|
|
@@ -209215,7 +210196,7 @@ function insertRowAtIndex({ tr, tablePos, tableNode, sourceRowIndex, insertIndex
|
|
|
209215
210196
|
if (newRow) {
|
|
209216
210197
|
tr.insert(insertPos, newRow);
|
|
209217
210198
|
const cursorPos = insertPos + ROW_START_TO_TEXT_OFFSET;
|
|
209218
|
-
tr.setSelection(
|
|
210199
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
209219
210200
|
const firstTextNode = newCells[0].firstChild?.firstChild;
|
|
209220
210201
|
if (firstTextNode?.marks?.length)
|
|
209221
210202
|
tr.setStoredMarks(firstTextNode.marks);
|
|
@@ -209224,7 +210205,7 @@ function insertRowAtIndex({ tr, tablePos, tableNode, sourceRowIndex, insertIndex
|
|
|
209224
210205
|
}
|
|
209225
210206
|
} else if (cellsToExtend.length > 0) {
|
|
209226
210207
|
const cursorPos = cellsToExtend[0].pos + CELL_TO_TEXT_OFFSET;
|
|
209227
|
-
tr.setSelection(
|
|
210208
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
209228
210209
|
}
|
|
209229
210210
|
return true;
|
|
209230
210211
|
}
|
|
@@ -212955,7 +213936,7 @@ function findCommand(wrap5, dir) {
|
|
|
212955
213936
|
let next2 = dir > 0 ? nextMatch(search$1, state, wrap5, from$1, to) : prevMatch(search$1, state, wrap5, from$1, to);
|
|
212956
213937
|
if (!next2)
|
|
212957
213938
|
return false;
|
|
212958
|
-
let selection =
|
|
213939
|
+
let selection = TextSelection.create(state.doc, next2.from, next2.to);
|
|
212959
213940
|
if (dispatch)
|
|
212960
213941
|
dispatch(state.tr.setSelection(selection).scrollIntoView());
|
|
212961
213942
|
return true;
|
|
@@ -212980,14 +213961,14 @@ function replaceCommand(wrap5, moveForward) {
|
|
|
212980
213961
|
}
|
|
212981
213962
|
let after2 = moveForward && nextMatch(search$1, state, wrap5, next2.from, next2.to);
|
|
212982
213963
|
if (after2)
|
|
212983
|
-
tr.setSelection(
|
|
213964
|
+
tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(after2.from, 1), tr.mapping.map(after2.to, -1)));
|
|
212984
213965
|
else
|
|
212985
|
-
tr.setSelection(
|
|
213966
|
+
tr.setSelection(TextSelection.create(tr.doc, next2.from, tr.mapping.map(next2.to, 1)));
|
|
212986
213967
|
dispatch(tr.scrollIntoView());
|
|
212987
213968
|
} else if (!moveForward)
|
|
212988
213969
|
return false;
|
|
212989
213970
|
else
|
|
212990
|
-
dispatch(state.tr.setSelection(
|
|
213971
|
+
dispatch(state.tr.setSelection(TextSelection.create(state.doc, next2.from, next2.to)).scrollIntoView());
|
|
212991
213972
|
return true;
|
|
212992
213973
|
};
|
|
212993
213974
|
}
|
|
@@ -213057,9 +214038,9 @@ function buildSelection(state, pos, extend) {
|
|
|
213057
214038
|
const clamped = Math.max(0, Math.min(pos, doc$12.content.size));
|
|
213058
214039
|
if (extend) {
|
|
213059
214040
|
const anchor = selection.anchor ?? selection.from;
|
|
213060
|
-
return
|
|
214041
|
+
return TextSelection.create(doc$12, anchor, clamped);
|
|
213061
214042
|
}
|
|
213062
|
-
return
|
|
214043
|
+
return TextSelection.create(doc$12, clamped);
|
|
213063
214044
|
}
|
|
213064
214045
|
function findLineElementAtPoint(doc$12, x, y$1) {
|
|
213065
214046
|
if (typeof doc$12?.elementsFromPoint !== "function")
|
|
@@ -216221,13 +217202,6 @@ function scrollToElement(targetElement, options = {
|
|
|
216221
217202
|
behavior: options.behavior
|
|
216222
217203
|
});
|
|
216223
217204
|
}
|
|
216224
|
-
function getParagraphFontFamilyFromProperties(paragraphProps, convertedXml = {}) {
|
|
216225
|
-
const fontFamilyProps = paragraphProps?.runProperties?.fontFamily;
|
|
216226
|
-
if (!fontFamilyProps)
|
|
216227
|
-
return null;
|
|
216228
|
-
const [markDef] = encodeMarksFromRPr({ fontFamily: fontFamilyProps }, convertedXml);
|
|
216229
|
-
return markDef?.attrs?.fontFamily ?? null;
|
|
216230
|
-
}
|
|
216231
217205
|
function getDefaultExportFromCjs2(x) {
|
|
216232
217206
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
216233
217207
|
}
|
|
@@ -226332,7 +227306,7 @@ function applyTextSelection(editor, from$1, to) {
|
|
|
226332
227306
|
}
|
|
226333
227307
|
if (editor.state?.tr && typeof editor.dispatch === "function")
|
|
226334
227308
|
try {
|
|
226335
|
-
const tr = editor.state.tr.setSelection(
|
|
227309
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, from$1, to)).setMeta("inputType", "programmatic");
|
|
226336
227310
|
editor.dispatch(tr);
|
|
226337
227311
|
return true;
|
|
226338
227312
|
} catch {
|
|
@@ -238785,7 +239759,7 @@ function createWrapper(editor, input2, options) {
|
|
|
238785
239759
|
if (input2.at) {
|
|
238786
239760
|
const { absFrom, absTo } = resolveSelectionTarget(editor, input2.at);
|
|
238787
239761
|
const { tr } = editor.state;
|
|
238788
|
-
tr.setSelection(
|
|
239762
|
+
tr.setSelection(TextSelection.create(tr.doc, absFrom, absTo));
|
|
238789
239763
|
dispatchTransaction(editor, tr);
|
|
238790
239764
|
}
|
|
238791
239765
|
const cmd = editor.commands?.[commandName];
|
|
@@ -254938,13 +255912,13 @@ function normalizeFieldAnnotationMetadata(attrs) {
|
|
|
254938
255912
|
displayLabel: toOptionalString(attrs.displayLabel),
|
|
254939
255913
|
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
254940
255914
|
alias: toOptionalString(attrs.alias),
|
|
254941
|
-
fieldColor:
|
|
254942
|
-
borderColor:
|
|
255915
|
+
fieldColor: normalizeColorValue2(attrs.fieldColor),
|
|
255916
|
+
borderColor: normalizeColorValue2(attrs.borderColor),
|
|
254943
255917
|
highlighted: toBoolean$2(attrs.highlighted, true),
|
|
254944
255918
|
fontFamily: toNullableString(attrs.fontFamily),
|
|
254945
255919
|
fontSize: normalizeFontSize$1(attrs.fontSize),
|
|
254946
|
-
textColor:
|
|
254947
|
-
textHighlight:
|
|
255920
|
+
textColor: normalizeColorValue2(attrs.textColor) ?? null,
|
|
255921
|
+
textHighlight: normalizeColorValue2(attrs.textHighlight) ?? null,
|
|
254948
255922
|
linkUrl: toNullableString(attrs.linkUrl),
|
|
254949
255923
|
imageSrc: toNullableString(attrs.imageSrc),
|
|
254950
255924
|
rawHtml: attrs.rawHtml ?? undefined,
|
|
@@ -255028,7 +256002,7 @@ function normalizeVisibility(value) {
|
|
|
255028
256002
|
if (normalized === "visible" || normalized === "hidden")
|
|
255029
256003
|
return normalized;
|
|
255030
256004
|
}
|
|
255031
|
-
function
|
|
256005
|
+
function normalizeColorValue2(value) {
|
|
255032
256006
|
if (typeof value !== "string")
|
|
255033
256007
|
return;
|
|
255034
256008
|
const trimmed = value.trim();
|
|
@@ -262063,7 +263037,7 @@ var Node$13 = class Node$14 {
|
|
|
262063
263037
|
const anchor = relativePositionToAbsolutePosition(binding.doc, binding.type, relSel.anchor, binding.mapping);
|
|
262064
263038
|
const head = relativePositionToAbsolutePosition(binding.doc, binding.type, relSel.head, binding.mapping);
|
|
262065
263039
|
if (anchor !== null && head !== null) {
|
|
262066
|
-
const sel =
|
|
263040
|
+
const sel = TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
|
|
262067
263041
|
tr.setSelection(sel);
|
|
262068
263042
|
}
|
|
262069
263043
|
}
|
|
@@ -262148,7 +263122,7 @@ var Node$13 = class Node$14 {
|
|
|
262148
263122
|
if (sel) {
|
|
262149
263123
|
const clampedAnchor = min$1(max$1(sel.anchor, 0), tr.doc.content.size);
|
|
262150
263124
|
const clampedHead = min$1(max$1(sel.head, 0), tr.doc.content.size);
|
|
262151
|
-
tr.setSelection(
|
|
263125
|
+
tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
|
|
262152
263126
|
}
|
|
262153
263127
|
this.prosemirrorView.dispatch(tr.setMeta(ySyncPluginKey, {
|
|
262154
263128
|
isChangeOrigin: true,
|
|
@@ -264036,19 +265010,19 @@ var Node$13 = class Node$14 {
|
|
|
264036
265010
|
const leftRun = runType.create(run2.attrs, leftFrag, run2.marks);
|
|
264037
265011
|
const rightRun = runType.create(run2.attrs, rightFrag, run2.marks);
|
|
264038
265012
|
const gapPos = runStart + leftRun.nodeSize;
|
|
264039
|
-
tr.replaceWith(runStart, runEnd, [leftRun, rightRun]).setSelection(
|
|
265013
|
+
tr.replaceWith(runStart, runEnd, [leftRun, rightRun]).setSelection(TextSelection.create(tr.doc, gapPos));
|
|
264040
265014
|
if (dispatch)
|
|
264041
265015
|
dispatch(tr);
|
|
264042
265016
|
return true;
|
|
264043
265017
|
}, cleanupEmptyRunsPlugin, preserveStoredMarks = (state, tr) => {
|
|
264044
|
-
if (!(tr.selection instanceof
|
|
265018
|
+
if (!(tr.selection instanceof TextSelection) || !tr.selection.empty)
|
|
264045
265019
|
return;
|
|
264046
265020
|
if (state.storedMarks === null)
|
|
264047
265021
|
return;
|
|
264048
265022
|
tr.setStoredMarks(state.storedMarks);
|
|
264049
265023
|
}, normalizeSelectionIntoRun = (tr, runType) => {
|
|
264050
265024
|
const selection = tr.selection;
|
|
264051
|
-
if (!(selection instanceof
|
|
265025
|
+
if (!(selection instanceof TextSelection))
|
|
264052
265026
|
return;
|
|
264053
265027
|
if (selection.from !== selection.to)
|
|
264054
265028
|
return;
|
|
@@ -264059,14 +265033,14 @@ var Node$13 = class Node$14 {
|
|
|
264059
265033
|
if (nodeAfter?.type === runType && nodeAfter.content.size > 0) {
|
|
264060
265034
|
const nextPos = selection.from + 1;
|
|
264061
265035
|
if (nextPos <= tr.doc.content.size)
|
|
264062
|
-
tr.setSelection(
|
|
265036
|
+
tr.setSelection(TextSelection.create(tr.doc, nextPos));
|
|
264063
265037
|
return;
|
|
264064
265038
|
}
|
|
264065
265039
|
const nodeBefore = $pos.nodeBefore;
|
|
264066
265040
|
if (nodeBefore?.type === runType && nodeBefore.content.size > 0) {
|
|
264067
265041
|
const prevPos = selection.from - 1;
|
|
264068
265042
|
if (prevPos >= 0)
|
|
264069
|
-
tr.setSelection(
|
|
265043
|
+
tr.setSelection(TextSelection.create(tr.doc, prevPos));
|
|
264070
265044
|
}
|
|
264071
265045
|
}, copyRunPropertiesFromParagraph = (state, pos, textNode, runType, editor) => {
|
|
264072
265046
|
let updatedTextNode = textNode;
|
|
@@ -264204,7 +265178,7 @@ var Node$13 = class Node$14 {
|
|
|
264204
265178
|
const runProperties = getSplitRunProperties(state, $from);
|
|
264205
265179
|
newAttrs = syncSplitParagraphRunProperties(newAttrs, runProperties);
|
|
264206
265180
|
}
|
|
264207
|
-
if (selection instanceof
|
|
265181
|
+
if (selection instanceof TextSelection)
|
|
264208
265182
|
tr.deleteSelection();
|
|
264209
265183
|
const deflt = $from.depth === 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
264210
265184
|
let types3 = atEnd && deflt ? [{
|
|
@@ -264276,7 +265250,7 @@ var Node$13 = class Node$14 {
|
|
|
264276
265250
|
const { from: from$1 } = tr.selection;
|
|
264277
265251
|
const tabText = state.schema.text("\t");
|
|
264278
265252
|
tr = tr.replaceSelectionWith(tabText);
|
|
264279
|
-
tr = tr.setSelection(
|
|
265253
|
+
tr = tr.setSelection(TextSelection.create(tr.doc, from$1 + 1));
|
|
264280
265254
|
if (dispatch)
|
|
264281
265255
|
dispatch(tr);
|
|
264282
265256
|
return true;
|
|
@@ -264304,7 +265278,7 @@ var Node$13 = class Node$14 {
|
|
|
264304
265278
|
newPos = tr.selection.from;
|
|
264305
265279
|
}
|
|
264306
265280
|
tr.insert(newPos, tabNode);
|
|
264307
|
-
tr = tr.setSelection(
|
|
265281
|
+
tr = tr.setSelection(TextSelection.create(tr.doc, newPos + tabNode.nodeSize));
|
|
264308
265282
|
if (dispatch)
|
|
264309
265283
|
dispatch(tr);
|
|
264310
265284
|
return true;
|
|
@@ -264473,7 +265447,7 @@ var Node$13 = class Node$14 {
|
|
|
264473
265447
|
if (dispatch) {
|
|
264474
265448
|
let side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
|
|
264475
265449
|
let tr = state.tr.insert(side, type.createAndFill());
|
|
264476
|
-
tr.setSelection(
|
|
265450
|
+
tr.setSelection(TextSelection.create(tr.doc, side + 1));
|
|
264477
265451
|
dispatch(tr.scrollIntoView());
|
|
264478
265452
|
}
|
|
264479
265453
|
return true;
|
|
@@ -265201,7 +266175,7 @@ var Node$13 = class Node$14 {
|
|
|
265201
266175
|
const paraPos = $from.before();
|
|
265202
266176
|
let tr = state.tr.deleteRange(paraPos, paraPos + para.nodeSize).scrollIntoView();
|
|
265203
266177
|
const targetPos = Math.max(1, Math.min(paraPos - 1, tr.doc.content.size));
|
|
265204
|
-
tr = tr.setSelection(
|
|
266178
|
+
tr = tr.setSelection(TextSelection.create(tr.doc, targetPos));
|
|
265205
266179
|
dispatch(tr);
|
|
265206
266180
|
}
|
|
265207
266181
|
return true;
|
|
@@ -265467,7 +266441,7 @@ var Node$13 = class Node$14 {
|
|
|
265467
266441
|
if (selection.empty && paragraphsInSelection.length === 1)
|
|
265468
266442
|
tr.setSelection(Selection.near(tr.doc.resolve(restoredSelectionRange.to), -1));
|
|
265469
266443
|
else
|
|
265470
|
-
tr.setSelection(
|
|
266444
|
+
tr.setSelection(TextSelection.create(tr.doc, restoredSelectionRange.from, restoredSelectionRange.to));
|
|
265471
266445
|
} catch {}
|
|
265472
266446
|
}
|
|
265473
266447
|
dispatch(tr);
|
|
@@ -265576,7 +266550,7 @@ var Node$13 = class Node$14 {
|
|
|
265576
266550
|
return true;
|
|
265577
266551
|
}, restoreSelection = () => ({ editor, state, tr }) => {
|
|
265578
266552
|
if (editor.options.lastSelection) {
|
|
265579
|
-
tr.setSelection(
|
|
266553
|
+
tr.setSelection(TextSelection.create(state.doc, editor.options.lastSelection.from, editor.options.lastSelection.to));
|
|
265580
266554
|
return true;
|
|
265581
266555
|
}
|
|
265582
266556
|
return false;
|
|
@@ -265588,7 +266562,7 @@ var Node$13 = class Node$14 {
|
|
|
265588
266562
|
const nextFrom = clamp$1(typeof from$1 === "number" ? from$1 : state.selection.from, 0, docSize);
|
|
265589
266563
|
const nextTo = clamp$1(typeof to === "number" ? to : nextFrom, 0, docSize);
|
|
265590
266564
|
const [head, anchor] = nextFrom <= nextTo ? [nextFrom, nextTo] : [nextTo, nextFrom];
|
|
265591
|
-
const selection =
|
|
266565
|
+
const selection = TextSelection.create(doc$12, head, anchor);
|
|
265592
266566
|
if (dispatch)
|
|
265593
266567
|
dispatch(state.tr.setSelection(selection));
|
|
265594
266568
|
if (editor?.view?.dom && typeof editor.view.dom.focus === "function")
|
|
@@ -269736,9 +270710,9 @@ var Node$13 = class Node$14 {
|
|
|
269736
270710
|
}, syncSelectionFromTransaction = ({ targetTr, sourceSelection }) => {
|
|
269737
270711
|
const boundedFrom = Math.max(0, Math.min(sourceSelection.from, targetTr.doc.content.size));
|
|
269738
270712
|
const boundedTo = Math.max(0, Math.min(sourceSelection.to, targetTr.doc.content.size));
|
|
269739
|
-
if (sourceSelection instanceof
|
|
270713
|
+
if (sourceSelection instanceof TextSelection)
|
|
269740
270714
|
try {
|
|
269741
|
-
targetTr.setSelection(
|
|
270715
|
+
targetTr.setSelection(TextSelection.create(targetTr.doc, boundedFrom, boundedTo));
|
|
269742
270716
|
return;
|
|
269743
270717
|
} catch {
|
|
269744
270718
|
targetTr.setSelection(Selection.near(targetTr.doc.resolve(boundedFrom), -1));
|
|
@@ -270449,29 +271423,29 @@ var Node$13 = class Node$14 {
|
|
|
270449
271423
|
const boundedPos = Math.max(0, Math.min(trackMeta.selectionPos, newTr.doc.content.size));
|
|
270450
271424
|
const $pos = newTr.doc.resolve(boundedPos);
|
|
270451
271425
|
if ($pos.parent.inlineContent)
|
|
270452
|
-
newTr.setSelection(
|
|
271426
|
+
newTr.setSelection(TextSelection.create(newTr.doc, boundedPos));
|
|
270453
271427
|
else
|
|
270454
|
-
newTr.setSelection(
|
|
271428
|
+
newTr.setSelection(TextSelection.near($pos, -1));
|
|
270455
271429
|
} else if (tr.selectionSet)
|
|
270456
|
-
if (tr.selection instanceof
|
|
271430
|
+
if (tr.selection instanceof TextSelection && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
|
|
270457
271431
|
const caretPos = map$12.map(tr.selection.from, -1);
|
|
270458
|
-
newTr.setSelection(new
|
|
271432
|
+
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
|
|
270459
271433
|
} else if (trackMeta?.insertedTo !== undefined) {
|
|
270460
271434
|
const boundedInsertedTo = Math.max(0, Math.min(trackMeta.insertedTo, newTr.doc.content.size));
|
|
270461
271435
|
const $insertPos = newTr.doc.resolve(boundedInsertedTo);
|
|
270462
|
-
newTr.setSelection(
|
|
271436
|
+
newTr.setSelection(TextSelection.near($insertPos, 1));
|
|
270463
271437
|
} else {
|
|
270464
271438
|
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName];
|
|
270465
271439
|
const deletionMark = findMark(state, deletionMarkSchema, false);
|
|
270466
271440
|
if (tr.selection.from > state.selection.from && deletionMark) {
|
|
270467
271441
|
const caretPos = map$12.map(deletionMark.to + 1, 1);
|
|
270468
|
-
newTr.setSelection(new
|
|
271442
|
+
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
|
|
270469
271443
|
} else
|
|
270470
271444
|
newTr.setSelection(tr.selection.map(newTr.doc, map$12));
|
|
270471
271445
|
}
|
|
270472
271446
|
else if (state.selection.from - tr.selection.from > 1 && tr.selection.$head.depth > 1) {
|
|
270473
271447
|
const caretPos = map$12.map(tr.selection.from - 2, -1);
|
|
270474
|
-
newTr.setSelection(new
|
|
271448
|
+
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
|
|
270475
271449
|
}
|
|
270476
271450
|
if (tr.storedMarksSet)
|
|
270477
271451
|
newTr.setStoredMarks(tr.storedMarks);
|
|
@@ -270942,7 +271916,7 @@ var Node$13 = class Node$14 {
|
|
|
270942
271916
|
to
|
|
270943
271917
|
});
|
|
270944
271918
|
else if (this.#editor.state) {
|
|
270945
|
-
const tr = this.#editor.state.tr.setSelection(
|
|
271919
|
+
const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, from$1, to)).scrollIntoView();
|
|
270946
271920
|
this.#editor.dispatch(tr);
|
|
270947
271921
|
}
|
|
270948
271922
|
const presentationEditor = this.#editor.presentationEditor;
|
|
@@ -272215,7 +273189,7 @@ var Node$13 = class Node$14 {
|
|
|
272215
273189
|
}, icons, getAvailableColorOptions = () => {
|
|
272216
273190
|
return icons.flat().map((item) => item.value);
|
|
272217
273191
|
}, _hoisted_1$14, _hoisted_2$10, ROW_SIZE = 5, TableGrid_default, _hoisted_1$13, _hoisted_2$9, _hoisted_3$7, _hoisted_4$5, _hoisted_5$2, TableActions_default, check_default = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
272218
|
-
`, _hoisted_1$12, _hoisted_2$8, _hoisted_3$6, SearchInput_default, TOOLBAR_FONTS, TOOLBAR_FONT_SIZES, closeDropdown = (dropdown) => {
|
|
273192
|
+
`, _hoisted_1$12, _hoisted_2$8, _hoisted_3$6, SearchInput_default, TOOLBAR_FONTS, TOOLBAR_FONT_SIZES, HEADLESS_ITEM_MAP, TABLE_ACTION_COMMAND_MAP, TABLE_ACTION_COMMAND_IDS, HEADLESS_TOOLBAR_COMMANDS, NON_HEADLESS_EXECUTE_ITEM_NAMES, HEADLESS_EXECUTE_ITEMS, closeDropdown = (dropdown) => {
|
|
272219
273193
|
dropdown.expand.value = false;
|
|
272220
273194
|
}, makeDefaultItems = ({ superToolbar, toolbarIcons: toolbarIcons$1, toolbarTexts: toolbarTexts$1, toolbarFonts, hideButtons, availableWidth, role, isDev = false } = {}) => {
|
|
272221
273195
|
const bold2 = useToolbarItem({
|
|
@@ -272854,16 +273828,6 @@ var Node$13 = class Node$14 {
|
|
|
272854
273828
|
group: "left",
|
|
272855
273829
|
attributes: { ariaLabel: "Redo" }
|
|
272856
273830
|
});
|
|
272857
|
-
const toggleTrackChanges = useToolbarItem({
|
|
272858
|
-
type: "button",
|
|
272859
|
-
disabled: false,
|
|
272860
|
-
name: "toggleTrackChanges",
|
|
272861
|
-
tooltip: toolbarTexts$1.trackChanges,
|
|
272862
|
-
command: "toggleTrackChanges",
|
|
272863
|
-
icon: toolbarIcons$1.trackChanges,
|
|
272864
|
-
group: "left",
|
|
272865
|
-
attributes: { ariaLabel: "Track changes" }
|
|
272866
|
-
});
|
|
272867
273831
|
const acceptTrackedChangeBySelection = useToolbarItem({
|
|
272868
273832
|
type: "button",
|
|
272869
273833
|
disabled: false,
|
|
@@ -272884,26 +273848,6 @@ var Node$13 = class Node$14 {
|
|
|
272884
273848
|
group: "left",
|
|
272885
273849
|
attributes: { ariaLabel: "Reject tracked changes" }
|
|
272886
273850
|
});
|
|
272887
|
-
const toggleTrackChangesOriginal = useToolbarItem({
|
|
272888
|
-
type: "button",
|
|
272889
|
-
disabled: false,
|
|
272890
|
-
name: "toggleTrackChangesShowOriginal",
|
|
272891
|
-
tooltip: toolbarTexts$1.trackChangesOriginal,
|
|
272892
|
-
command: "toggleTrackChangesShowOriginal",
|
|
272893
|
-
icon: toolbarIcons$1.trackChangesOriginal,
|
|
272894
|
-
group: "left",
|
|
272895
|
-
attributes: { ariaLabel: "Toggle tracked changes show original" }
|
|
272896
|
-
});
|
|
272897
|
-
const toggleTrackChangesFinal = useToolbarItem({
|
|
272898
|
-
type: "button",
|
|
272899
|
-
disabled: false,
|
|
272900
|
-
name: "toggleTrackChangesShowFinal",
|
|
272901
|
-
tooltip: toolbarTexts$1.trackChangesFinal,
|
|
272902
|
-
command: "toggleTrackChangesShowFinal",
|
|
272903
|
-
icon: toolbarIcons$1.trackChangesFinal,
|
|
272904
|
-
group: "left",
|
|
272905
|
-
attributes: { ariaLabel: "Toggle tracked changes show final" }
|
|
272906
|
-
});
|
|
272907
273851
|
const clearFormatting = useToolbarItem({
|
|
272908
273852
|
type: "button",
|
|
272909
273853
|
name: "clearFormatting",
|
|
@@ -273183,11 +274127,7 @@ var Node$13 = class Node$14 {
|
|
|
273183
274127
|
];
|
|
273184
274128
|
toolbarItems = toolbarItems.filter((item) => !filterItems.includes(item.name.value));
|
|
273185
274129
|
}
|
|
273186
|
-
const devItems = [
|
|
273187
|
-
toggleTrackChanges,
|
|
273188
|
-
toggleTrackChangesOriginal,
|
|
273189
|
-
toggleTrackChangesFinal
|
|
273190
|
-
];
|
|
274130
|
+
const devItems = [];
|
|
273191
274131
|
if (!isDev) {
|
|
273192
274132
|
if (role === "viewer")
|
|
273193
274133
|
devItems.push(...[acceptTrackedChangeBySelection, rejectTrackedChangeOnSelection]);
|
|
@@ -273232,7 +274172,24 @@ var Node$13 = class Node$14 {
|
|
|
273232
274172
|
defaultItems: visibleItems,
|
|
273233
274173
|
overflowItems: overflowItems.filter((item) => item.type !== "separator")
|
|
273234
274174
|
};
|
|
273235
|
-
}, _hoisted_1$11, _hoisted_2$7, ToolbarButtonIcon_default, _hoisted_1$10, _hoisted_2$6, _hoisted_3$5, _hoisted_4$4, _hoisted_5$1, _hoisted_6, _hoisted_7, _hoisted_8, ToolbarButton_default, _hoisted_1$9, ToolbarSeparator_default, _hoisted_1$8, _hoisted_2$5, _hoisted_3$4, OverflowMenu_default, _hoisted_1$7, _hoisted_2$4, _hoisted_3$3, _hoisted_4$3, ToolbarDropdown_default, SdTooltip_default, _hoisted_1$6, _hoisted_2$3, _hoisted_3$2, _hoisted_4$2, ButtonGroup_default, DEFAULT_UI_FONT_FAMILY = "Arial, Helvetica, sans-serif", Toolbar_default, toolbarTexts,
|
|
274175
|
+
}, _hoisted_1$11, _hoisted_2$7, ToolbarButtonIcon_default, _hoisted_1$10, _hoisted_2$6, _hoisted_3$5, _hoisted_4$4, _hoisted_5$1, _hoisted_6, _hoisted_7, _hoisted_8, ToolbarButton_default, _hoisted_1$9, ToolbarSeparator_default, _hoisted_1$8, _hoisted_2$5, _hoisted_3$4, OverflowMenu_default, _hoisted_1$7, _hoisted_2$4, _hoisted_3$3, _hoisted_4$3, ToolbarDropdown_default, SdTooltip_default, _hoisted_1$6, _hoisted_2$3, _hoisted_3$2, _hoisted_4$2, ButtonGroup_default, DEFAULT_UI_FONT_FAMILY = "Arial, Helvetica, sans-serif", Toolbar_default, toolbarTexts, getParagraphFontFamilyFromProperties = (paragraphProps, convertedXml = {}) => {
|
|
274176
|
+
const fontFamilyProps = paragraphProps?.runProperties?.fontFamily;
|
|
274177
|
+
if (!fontFamilyProps)
|
|
274178
|
+
return null;
|
|
274179
|
+
const [markDef] = encodeMarksFromRPr({ fontFamily: fontFamilyProps }, convertedXml);
|
|
274180
|
+
return markDef?.attrs?.fontFamily ?? null;
|
|
274181
|
+
}, findElementBySelector = (selector) => {
|
|
274182
|
+
let el = null;
|
|
274183
|
+
if (selector) {
|
|
274184
|
+
if (selector.startsWith("#") || selector.startsWith("."))
|
|
274185
|
+
el = document.querySelector(selector);
|
|
274186
|
+
else
|
|
274187
|
+
el = document.getElementById(selector);
|
|
274188
|
+
if (!el)
|
|
274189
|
+
return null;
|
|
274190
|
+
}
|
|
274191
|
+
return el;
|
|
274192
|
+
}, SuperToolbar, Schema3 = class Schema4 {
|
|
273236
274193
|
static createSchemaByExtensions(extensions, editor) {
|
|
273237
274194
|
const nodeExtensions = extensions.filter((e) => e.type === "node");
|
|
273238
274195
|
const markExtensions = extensions.filter((e) => e.type === "mark");
|
|
@@ -284645,7 +285602,7 @@ var Node$13 = class Node$14 {
|
|
|
284645
285602
|
if (isolatingDepth > 0) {
|
|
284646
285603
|
const boundary = forward ? $head.before(isolatingDepth) : $head.after(isolatingDepth);
|
|
284647
285604
|
const near = Selection.near(doc$12.resolve(boundary), forward ? -1 : 1);
|
|
284648
|
-
if (near instanceof
|
|
285605
|
+
if (near instanceof TextSelection)
|
|
284649
285606
|
return near.head;
|
|
284650
285607
|
return anchor;
|
|
284651
285608
|
}
|
|
@@ -284992,7 +285949,7 @@ var Node$13 = class Node$14 {
|
|
|
284992
285949
|
const resolved = this.#resolveStructuredContentInlineFromElement(doc$12, inlineStructuredContentLabel);
|
|
284993
285950
|
if (resolved) {
|
|
284994
285951
|
try {
|
|
284995
|
-
const tr = editor.state.tr.setSelection(
|
|
285952
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(doc$12, resolved.start, resolved.end));
|
|
284996
285953
|
editor.view?.dispatch(tr);
|
|
284997
285954
|
} catch {}
|
|
284998
285955
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
@@ -285006,7 +285963,7 @@ var Node$13 = class Node$14 {
|
|
|
285006
285963
|
if (resolved) {
|
|
285007
285964
|
try {
|
|
285008
285965
|
const contentRange = this.#findStructuredContentBlockContentRange(resolved);
|
|
285009
|
-
const selection = contentRange != null ?
|
|
285966
|
+
const selection = contentRange != null ? TextSelection.create(doc$12, contentRange.from, contentRange.to) : NodeSelection.create(editor.state.doc, resolved.pos);
|
|
285010
285967
|
const tr = editor.state.tr.setSelection(selection);
|
|
285011
285968
|
editor.view?.dispatch(tr);
|
|
285012
285969
|
} catch {}
|
|
@@ -285097,12 +286054,12 @@ var Node$13 = class Node$14 {
|
|
|
285097
286054
|
if (sdtBlock)
|
|
285098
286055
|
nextSelection = NodeSelection.create(doc$12, sdtBlock.pos);
|
|
285099
286056
|
else {
|
|
285100
|
-
nextSelection =
|
|
286057
|
+
nextSelection = TextSelection.create(doc$12, hit.pos);
|
|
285101
286058
|
if (!nextSelection.$from.parent.inlineContent)
|
|
285102
286059
|
nextSelection = Selection.near(doc$12.resolve(hit.pos), 1);
|
|
285103
286060
|
}
|
|
285104
286061
|
const tr = editor.state.tr.setSelection(nextSelection);
|
|
285105
|
-
if (nextSelection instanceof
|
|
286062
|
+
if (nextSelection instanceof TextSelection && nextSelection.empty && editor.state.storedMarks)
|
|
285106
286063
|
tr.setStoredMarks(editor.state.storedMarks);
|
|
285107
286064
|
editor.view?.dispatch(tr);
|
|
285108
286065
|
} catch {}
|
|
@@ -285532,7 +286489,7 @@ var Node$13 = class Node$14 {
|
|
|
285532
286489
|
const anchor = editor.state.selection.anchor;
|
|
285533
286490
|
const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, headPos, this.#dragExtensionMode);
|
|
285534
286491
|
try {
|
|
285535
|
-
const tr = editor.state.tr.setSelection(
|
|
286492
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
|
|
285536
286493
|
editor.view?.dispatch(tr);
|
|
285537
286494
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
285538
286495
|
} catch (error3) {
|
|
@@ -285615,7 +286572,7 @@ var Node$13 = class Node$14 {
|
|
|
285615
286572
|
head = this.#clampHeadAtIsolatingBoundary(doc$12, anchor, head);
|
|
285616
286573
|
const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
|
|
285617
286574
|
try {
|
|
285618
|
-
const tr = editor.state.tr.setSelection(
|
|
286575
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
|
|
285619
286576
|
editor.view?.dispatch(tr);
|
|
285620
286577
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
285621
286578
|
} catch (error3) {
|
|
@@ -285646,7 +286603,7 @@ var Node$13 = class Node$14 {
|
|
|
285646
286603
|
const head = hit.pos;
|
|
285647
286604
|
const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
|
|
285648
286605
|
try {
|
|
285649
|
-
const tr = editor.state.tr.setSelection(
|
|
286606
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
|
|
285650
286607
|
editor.view?.dispatch(tr);
|
|
285651
286608
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
285652
286609
|
} catch {}
|
|
@@ -285693,7 +286650,7 @@ var Node$13 = class Node$14 {
|
|
|
285693
286650
|
if (pendingMarginClick.kind === "aboveFirstLine") {
|
|
285694
286651
|
const pos = this.#getFirstTextPosition();
|
|
285695
286652
|
try {
|
|
285696
|
-
const tr = editor.state.tr.setSelection(
|
|
286653
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(doc$12, pos));
|
|
285697
286654
|
editor.view?.dispatch(tr);
|
|
285698
286655
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
285699
286656
|
} catch {}
|
|
@@ -285717,7 +286674,7 @@ var Node$13 = class Node$14 {
|
|
|
285717
286674
|
}
|
|
285718
286675
|
const caretPos = Math.max(0, Math.min(mappedEnd$1.pos, doc$12.content.size));
|
|
285719
286676
|
try {
|
|
285720
|
-
const tr = editor.state.tr.setSelection(
|
|
286677
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(doc$12, caretPos));
|
|
285721
286678
|
editor.view?.dispatch(tr);
|
|
285722
286679
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
285723
286680
|
} catch {}
|
|
@@ -285742,7 +286699,7 @@ var Node$13 = class Node$14 {
|
|
|
285742
286699
|
const selFrom = Math.max(0, Math.min(Math.min(mappedStart.pos, mappedEnd.pos), doc$12.content.size));
|
|
285743
286700
|
const selTo = Math.max(0, Math.min(Math.max(mappedStart.pos, mappedEnd.pos), doc$12.content.size));
|
|
285744
286701
|
try {
|
|
285745
|
-
const tr = editor.state.tr.setSelection(
|
|
286702
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(doc$12, selFrom, selTo));
|
|
285746
286703
|
editor.view?.dispatch(tr);
|
|
285747
286704
|
this.#callbacks.scheduleSelectionUpdate?.();
|
|
285748
286705
|
} catch {}
|
|
@@ -285780,7 +286737,7 @@ var Node$13 = class Node$14 {
|
|
|
285780
286737
|
const doc$12 = editor?.state?.doc;
|
|
285781
286738
|
if (doc$12)
|
|
285782
286739
|
try {
|
|
285783
|
-
const tr = editor.state.tr.setSelection(
|
|
286740
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(doc$12, validPos));
|
|
285784
286741
|
editor.view?.dispatch(tr);
|
|
285785
286742
|
} catch {}
|
|
285786
286743
|
editorDom.focus();
|
|
@@ -286278,10 +287235,10 @@ var Node$13 = class Node$14 {
|
|
|
286278
287235
|
return;
|
|
286279
287236
|
const pos = Math.min(Math.max(hit.pos, 1), doc$12.content.size);
|
|
286280
287237
|
const currentSelection = activeEditor.state.selection;
|
|
286281
|
-
if (currentSelection instanceof
|
|
287238
|
+
if (currentSelection instanceof TextSelection && currentSelection.from === pos && currentSelection.to === pos)
|
|
286282
287239
|
return;
|
|
286283
287240
|
try {
|
|
286284
|
-
const tr = activeEditor.state.tr.setSelection(
|
|
287241
|
+
const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc$12, pos)).setMeta("addToHistory", false);
|
|
286285
287242
|
activeEditor.view?.dispatch(tr);
|
|
286286
287243
|
this.#deps.scheduleSelectionUpdate();
|
|
286287
287244
|
} catch {}
|
|
@@ -286335,7 +287292,7 @@ var Node$13 = class Node$14 {
|
|
|
286335
287292
|
return;
|
|
286336
287293
|
const clampedPos = Math.min(Math.max(pos, 1), doc$12.content.size);
|
|
286337
287294
|
try {
|
|
286338
|
-
const tr = activeEditor.state.tr.setSelection(
|
|
287295
|
+
const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc$12, clampedPos)).setMeta("addToHistory", false);
|
|
286339
287296
|
activeEditor.view?.dispatch(tr);
|
|
286340
287297
|
} catch {}
|
|
286341
287298
|
}
|
|
@@ -286416,7 +287373,7 @@ var Node$13 = class Node$14 {
|
|
|
286416
287373
|
if (attributes && isValidFieldAnnotationAttributes(attributes)) {
|
|
286417
287374
|
activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
|
|
286418
287375
|
const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
|
|
286419
|
-
const tr = activeEditor.state?.tr.setSelection(
|
|
287376
|
+
const tr = activeEditor.state?.tr.setSelection(TextSelection.create(activeEditor.state.doc, posAfter));
|
|
286420
287377
|
if (tr)
|
|
286421
287378
|
activeEditor.view?.dispatch(tr);
|
|
286422
287379
|
this.#deps.scheduleSelectionUpdate();
|
|
@@ -288158,12 +289115,12 @@ var Node$13 = class Node$14 {
|
|
|
288158
289115
|
return;
|
|
288159
289116
|
console.log(...args$1);
|
|
288160
289117
|
}, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
|
|
288161
|
-
var
|
|
289118
|
+
var init_src_yUVuhLM1_es = __esm(() => {
|
|
288162
289119
|
init_rolldown_runtime_Bg48TavK_es();
|
|
288163
289120
|
init_SuperConverter_BgwP1GeS_es();
|
|
288164
289121
|
init_jszip_C49i9kUs_es();
|
|
288165
289122
|
init_uuid_qzgm05fK_es();
|
|
288166
|
-
|
|
289123
|
+
init_create_headless_toolbar_Dcw4Hyt2_es();
|
|
288167
289124
|
init_constants_CGhJRd87_es();
|
|
288168
289125
|
init_dist_B8HfvhaK_es();
|
|
288169
289126
|
init_unified_Dsuw2be5_es();
|
|
@@ -288835,7 +289792,7 @@ ${err.toString()}`);
|
|
|
288835
289792
|
}));
|
|
288836
289793
|
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
288837
289794
|
this.editor.setOptions({ lastSelection: selection });
|
|
288838
|
-
const clearSelectionTr = view.state.tr.setSelection(
|
|
289795
|
+
const clearSelectionTr = view.state.tr.setSelection(TextSelection.create(view.state.doc, 0));
|
|
288839
289796
|
view.dispatch(clearSelectionTr);
|
|
288840
289797
|
}
|
|
288841
289798
|
}
|
|
@@ -290206,7 +291163,7 @@ ${err.toString()}`);
|
|
|
290206
291163
|
fragments.push(runType.create(parentRun.attrs, rightContent, parentRun.marks));
|
|
290207
291164
|
tr.replaceWith(runStart, runEnd, fragments);
|
|
290208
291165
|
const cursorPos = runStart + (leftContent.size > 0 ? leftContent.size + 2 : 0) + node3.nodeSize;
|
|
290209
|
-
tr.setSelection(
|
|
291166
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
290210
291167
|
} else
|
|
290211
291168
|
tr.replaceWith(from$1, to, node3);
|
|
290212
291169
|
}
|
|
@@ -290785,7 +291742,7 @@ ${err.toString()}`);
|
|
|
290785
291742
|
return null;
|
|
290786
291743
|
const tr = newState.tr;
|
|
290787
291744
|
toDelete.sort((a2, b$1) => b$1.from - a2.from).forEach(({ from: from$1, to }) => tr.deleteRange(from$1, to));
|
|
290788
|
-
if (tr.selection instanceof
|
|
291745
|
+
if (tr.selection instanceof TextSelection && tr.selection.empty && newState.storedMarks !== null)
|
|
290789
291746
|
tr.setStoredMarks(newState.storedMarks);
|
|
290790
291747
|
return tr.docChanged ? tr : null;
|
|
290791
291748
|
} });
|
|
@@ -291147,7 +292104,7 @@ ${err.toString()}`);
|
|
|
291147
292104
|
if (findParentNode(isList)(state.selection))
|
|
291148
292105
|
return null;
|
|
291149
292106
|
const { tr } = state;
|
|
291150
|
-
tr.delete(range.from, range.to).setSelection(
|
|
292107
|
+
tr.delete(range.from, range.to).setSelection(TextSelection.create(tr.doc, range.from));
|
|
291151
292108
|
ListHelpers.createNewList({
|
|
291152
292109
|
listType: type,
|
|
291153
292110
|
tr,
|
|
@@ -291604,7 +292561,7 @@ ${err.toString()}`);
|
|
|
291604
292561
|
const { from: from$1 } = findRangeById(state.doc, id2) || {};
|
|
291605
292562
|
if (from$1 != null) {
|
|
291606
292563
|
const tr = state.tr;
|
|
291607
|
-
tr.setSelection(
|
|
292564
|
+
tr.setSelection(TextSelection.create(state.doc, from$1));
|
|
291608
292565
|
if (options.activeCommentId)
|
|
291609
292566
|
tr.setMeta(CommentsPluginKey, {
|
|
291610
292567
|
type: "setActiveComment",
|
|
@@ -292299,7 +293256,7 @@ ${err.toString()}`);
|
|
|
292299
293256
|
const { from: from$1, to, tablePos } = structuredContentInsertion;
|
|
292300
293257
|
tr.replaceWith(from$1, to, node3);
|
|
292301
293258
|
const selectionPos$1 = getFirstTableCellTextPos(tablePos, node3);
|
|
292302
|
-
tr.scrollIntoView().setSelection(
|
|
293259
|
+
tr.scrollIntoView().setSelection(TextSelection.near(tr.doc.resolve(selectionPos$1)));
|
|
292303
293260
|
return true;
|
|
292304
293261
|
}
|
|
292305
293262
|
let offset$1;
|
|
@@ -292329,7 +293286,7 @@ ${err.toString()}`);
|
|
|
292329
293286
|
if (!inserted)
|
|
292330
293287
|
return false;
|
|
292331
293288
|
const selectionPos = getFirstTableCellTextPos(offset$1, node3);
|
|
292332
|
-
tr.scrollIntoView().setSelection(
|
|
293289
|
+
tr.scrollIntoView().setSelection(TextSelection.near(tr.doc.resolve(selectionPos)));
|
|
292333
293290
|
}
|
|
292334
293291
|
return true;
|
|
292335
293292
|
},
|
|
@@ -305812,7 +306769,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
305812
306769
|
if (typeof from$1 !== "number" || typeof to !== "number")
|
|
305813
306770
|
return false;
|
|
305814
306771
|
editor.view.focus();
|
|
305815
|
-
const tr$1 = state.tr.setSelection(
|
|
306772
|
+
const tr$1 = state.tr.setSelection(TextSelection.create(state.doc, from$1, to)).scrollIntoView();
|
|
305816
306773
|
if (dispatch)
|
|
305817
306774
|
dispatch(tr$1);
|
|
305818
306775
|
const presentationEditor$1 = editor.presentationEditor;
|
|
@@ -305835,7 +306792,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
305835
306792
|
return false;
|
|
305836
306793
|
const firstDeco = decorations[0];
|
|
305837
306794
|
editor.view.focus();
|
|
305838
|
-
const tr = state.tr.setSelection(
|
|
306795
|
+
const tr = state.tr.setSelection(TextSelection.create(state.doc, firstDeco.from, firstDeco.to)).scrollIntoView();
|
|
305839
306796
|
if (dispatch)
|
|
305840
306797
|
dispatch(tr);
|
|
305841
306798
|
const presentationEditor = editor.presentationEditor;
|
|
@@ -305902,7 +306859,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
305902
306859
|
from$1 = normalized.from;
|
|
305903
306860
|
to = normalized.to;
|
|
305904
306861
|
editor.view.focus();
|
|
305905
|
-
const tr = state.tr.setSelection(
|
|
306862
|
+
const tr = state.tr.setSelection(TextSelection.create(state.doc, from$1, to)).scrollIntoView();
|
|
305906
306863
|
if (dispatch)
|
|
305907
306864
|
dispatch(tr);
|
|
305908
306865
|
const presentationEditor = editor.presentationEditor;
|
|
@@ -306633,7 +307590,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
306633
307590
|
if (selectionState.value) {
|
|
306634
307591
|
const { state } = props.editor;
|
|
306635
307592
|
const { from: from$1, to } = selectionState.value;
|
|
306636
|
-
const tr = state.tr.setSelection(
|
|
307593
|
+
const tr = state.tr.setSelection(TextSelection.create(state.doc, from$1, to));
|
|
306637
307594
|
props.editor.view.dispatch(tr);
|
|
306638
307595
|
} else
|
|
306639
307596
|
console.warn("[AIWriter] No stored selection to restore");
|
|
@@ -307271,7 +308228,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
307271
308228
|
text: finalText
|
|
307272
308229
|
});
|
|
307273
308230
|
const endPos = editor.view.state.selection.$to.pos;
|
|
307274
|
-
editor.view.dispatch(editor.view.state.tr.setSelection(new
|
|
308231
|
+
editor.view.dispatch(editor.view.state.tr.setSelection(new TextSelection(editor.view.state.doc.resolve(endPos))));
|
|
307275
308232
|
setTimeout(() => editor.view.focus(), 100);
|
|
307276
308233
|
props.closePopover();
|
|
307277
308234
|
};
|
|
@@ -307898,6 +308855,52 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
307898
308855
|
props: { "data-item": "btn-fontSize-option" }
|
|
307899
308856
|
}
|
|
307900
308857
|
];
|
|
308858
|
+
HEADLESS_ITEM_MAP = {
|
|
308859
|
+
undo: "undo",
|
|
308860
|
+
redo: "redo",
|
|
308861
|
+
bold: "bold",
|
|
308862
|
+
italic: "italic",
|
|
308863
|
+
underline: "underline",
|
|
308864
|
+
strike: "strikethrough",
|
|
308865
|
+
acceptTrackedChangeBySelection: "track-changes-accept-selection",
|
|
308866
|
+
rejectTrackedChangeOnSelection: "track-changes-reject-selection",
|
|
308867
|
+
ruler: "ruler",
|
|
308868
|
+
zoom: "zoom",
|
|
308869
|
+
documentMode: "document-mode",
|
|
308870
|
+
link: "link",
|
|
308871
|
+
fontFamily: "font-family",
|
|
308872
|
+
fontSize: "font-size",
|
|
308873
|
+
list: "bullet-list",
|
|
308874
|
+
numberedlist: "numbered-list",
|
|
308875
|
+
table: "table-insert",
|
|
308876
|
+
image: "image",
|
|
308877
|
+
color: "text-color",
|
|
308878
|
+
highlight: "highlight-color",
|
|
308879
|
+
textAlign: "text-align",
|
|
308880
|
+
lineHeight: "line-height",
|
|
308881
|
+
linkedStyles: "linked-style",
|
|
308882
|
+
indentleft: "indent-decrease",
|
|
308883
|
+
indentright: "indent-increase",
|
|
308884
|
+
clearFormatting: "clear-formatting",
|
|
308885
|
+
copyFormat: "copy-format"
|
|
308886
|
+
};
|
|
308887
|
+
TABLE_ACTION_COMMAND_MAP = {
|
|
308888
|
+
addRowBefore: "table-add-row-before",
|
|
308889
|
+
addRowAfter: "table-add-row-after",
|
|
308890
|
+
deleteRow: "table-delete-row",
|
|
308891
|
+
addColumnBefore: "table-add-column-before",
|
|
308892
|
+
addColumnAfter: "table-add-column-after",
|
|
308893
|
+
deleteColumn: "table-delete-column",
|
|
308894
|
+
deleteTable: "table-delete",
|
|
308895
|
+
deleteCellAndTableBorders: "table-remove-borders",
|
|
308896
|
+
mergeCells: "table-merge-cells",
|
|
308897
|
+
splitCell: "table-split-cell",
|
|
308898
|
+
fixTables: "table-fix"
|
|
308899
|
+
};
|
|
308900
|
+
TABLE_ACTION_COMMAND_IDS = Object.values(TABLE_ACTION_COMMAND_MAP);
|
|
308901
|
+
HEADLESS_TOOLBAR_COMMANDS = [...new Set([...Object.values(HEADLESS_ITEM_MAP), ...TABLE_ACTION_COMMAND_IDS])];
|
|
308902
|
+
NON_HEADLESS_EXECUTE_ITEM_NAMES = new Set(["link"]);
|
|
308903
|
+
HEADLESS_EXECUTE_ITEMS = new Set(Object.keys(HEADLESS_ITEM_MAP).filter((itemName) => !NON_HEADLESS_EXECUTE_ITEM_NAMES.has(itemName)));
|
|
307901
308904
|
_hoisted_1$11 = { class: "toolbar-icon" };
|
|
307902
308905
|
_hoisted_2$7 = ["innerHTML"];
|
|
307903
308906
|
ToolbarButtonIcon_default = /* @__PURE__ */ __plugin_vue_export_helper_default({
|
|
@@ -309281,11 +310284,13 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309281
310284
|
};
|
|
309282
310285
|
this.toolbarItems = [];
|
|
309283
310286
|
this.overflowItems = [];
|
|
309284
|
-
this.documentMode = config2.documentMode || "editing";
|
|
309285
310287
|
this.isDev = config2.isDev || false;
|
|
309286
310288
|
this.superdoc = config2.superdoc;
|
|
309287
310289
|
this.role = config2.role || "editor";
|
|
309288
310290
|
this.toolbarContainer = null;
|
|
310291
|
+
this.controller = null;
|
|
310292
|
+
this.snapshot = null;
|
|
310293
|
+
this._unsubscribeController = null;
|
|
309289
310294
|
if (this.config.editor)
|
|
309290
310295
|
this.config.mode = this.config.editor.options.mode;
|
|
309291
310296
|
this.config.icons = {
|
|
@@ -309308,7 +310313,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309308
310313
|
this._restoreFocusTimeoutId = null;
|
|
309309
310314
|
if (!this.config.selector && this.config.element)
|
|
309310
310315
|
this.config.selector = this.config.element;
|
|
309311
|
-
this.toolbarContainer =
|
|
310316
|
+
this.toolbarContainer = findElementBySelector(this.config.selector);
|
|
309312
310317
|
if (this.toolbarContainer) {
|
|
309313
310318
|
const uiFontFamily = (this.config?.uiDisplayFallbackFont || "").toString().trim() || "Arial, Helvetica, sans-serif";
|
|
309314
310319
|
this.toolbarContainer.style.setProperty("--sd-ui-font-family", uiFontFamily);
|
|
@@ -309330,215 +310335,39 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309330
310335
|
if (this.toolbarContainer)
|
|
309331
310336
|
this.toolbar = this.app.mount(this.toolbarContainer);
|
|
309332
310337
|
this.activeEditor = config2.editor || null;
|
|
310338
|
+
this.initHeadlessToolbar();
|
|
309333
310339
|
this.updateToolbarState();
|
|
309334
310340
|
}
|
|
309335
|
-
|
|
309336
|
-
|
|
309337
|
-
|
|
309338
|
-
|
|
309339
|
-
|
|
309340
|
-
|
|
309341
|
-
|
|
309342
|
-
|
|
309343
|
-
|
|
309344
|
-
|
|
309345
|
-
|
|
310341
|
+
createHeadlessToolbar() {
|
|
310342
|
+
if (!this.superdoc)
|
|
310343
|
+
return null;
|
|
310344
|
+
return createHeadlessToolbar({
|
|
310345
|
+
superdoc: this.superdoc,
|
|
310346
|
+
commands: HEADLESS_TOOLBAR_COMMANDS
|
|
310347
|
+
});
|
|
310348
|
+
}
|
|
310349
|
+
initHeadlessToolbar() {
|
|
310350
|
+
if (!this.superdoc)
|
|
310351
|
+
return;
|
|
310352
|
+
this.destroyHeadlessToolbar();
|
|
310353
|
+
this.controller = this.createHeadlessToolbar();
|
|
310354
|
+
this.snapshot = this.controller.getSnapshot();
|
|
310355
|
+
this._unsubscribeController = this.controller.subscribe(({ snapshot: snapshot2 }) => {
|
|
310356
|
+
this.snapshot = snapshot2;
|
|
310357
|
+
this.updateToolbarState();
|
|
310358
|
+
});
|
|
310359
|
+
}
|
|
310360
|
+
destroyHeadlessToolbar() {
|
|
310361
|
+
this._unsubscribeController?.();
|
|
310362
|
+
this.controller?.destroy();
|
|
310363
|
+
this.controller = null;
|
|
310364
|
+
this.snapshot = null;
|
|
310365
|
+
this._unsubscribeController = null;
|
|
309346
310366
|
}
|
|
309347
310367
|
#initToolbarGroups() {
|
|
309348
310368
|
if (this.config.groups && !Array.isArray(this.config.groups) && Object.keys(this.config.groups).length)
|
|
309349
310369
|
this.config.toolbarGroups = Object.keys(this.config.groups);
|
|
309350
310370
|
}
|
|
309351
|
-
#interceptedCommands = {
|
|
309352
|
-
setZoom: ({ item, argument }) => {
|
|
309353
|
-
if (!argument)
|
|
309354
|
-
return;
|
|
309355
|
-
item.onActivate({ zoom: argument });
|
|
309356
|
-
this.emit("superdoc-command", {
|
|
309357
|
-
item,
|
|
309358
|
-
argument
|
|
309359
|
-
});
|
|
309360
|
-
this.superdoc.superdocStore.activeZoom = parseInt(argument, 10);
|
|
309361
|
-
},
|
|
309362
|
-
setDocumentMode: ({ item, argument }) => {
|
|
309363
|
-
if (!argument)
|
|
309364
|
-
return;
|
|
309365
|
-
this.emit("superdoc-command", {
|
|
309366
|
-
item,
|
|
309367
|
-
argument
|
|
309368
|
-
});
|
|
309369
|
-
},
|
|
309370
|
-
setFontSize: ({ item, argument }) => {
|
|
309371
|
-
if (this.#isFieldAnnotationSelection() && argument) {
|
|
309372
|
-
this.activeEditor?.commands.setFieldAnnotationsFontSize(argument, true);
|
|
309373
|
-
this.updateToolbarState();
|
|
309374
|
-
return;
|
|
309375
|
-
}
|
|
309376
|
-
this.#runCommandWithArgumentOnly({
|
|
309377
|
-
item,
|
|
309378
|
-
argument
|
|
309379
|
-
}, () => {
|
|
309380
|
-
this.activeEditor?.commands.setFieldAnnotationsFontSize(argument, true);
|
|
309381
|
-
});
|
|
309382
|
-
},
|
|
309383
|
-
setFontFamily: ({ item, argument }) => {
|
|
309384
|
-
if (this.#isFieldAnnotationSelection() && argument) {
|
|
309385
|
-
this.activeEditor?.commands.setFieldAnnotationsFontFamily(argument, true);
|
|
309386
|
-
this.updateToolbarState();
|
|
309387
|
-
return;
|
|
309388
|
-
}
|
|
309389
|
-
this.#runCommandWithArgumentOnly({
|
|
309390
|
-
item,
|
|
309391
|
-
argument
|
|
309392
|
-
}, () => {
|
|
309393
|
-
this.activeEditor?.commands.setFieldAnnotationsFontFamily(argument, true);
|
|
309394
|
-
});
|
|
309395
|
-
},
|
|
309396
|
-
setColor: ({ argument }) => {
|
|
309397
|
-
if (!argument || !this.activeEditor)
|
|
309398
|
-
return;
|
|
309399
|
-
const isNone = argument === "none";
|
|
309400
|
-
const value = isNone ? "inherit" : argument;
|
|
309401
|
-
if (this.activeEditor?.commands?.setColor)
|
|
309402
|
-
this.activeEditor.commands.setColor(value);
|
|
309403
|
-
const argValue = isNone ? null : argument;
|
|
309404
|
-
this.activeEditor?.commands.setFieldAnnotationsTextColor(argValue, true);
|
|
309405
|
-
this.updateToolbarState();
|
|
309406
|
-
},
|
|
309407
|
-
setHighlight: ({ argument }) => {
|
|
309408
|
-
if (!argument || !this.activeEditor)
|
|
309409
|
-
return;
|
|
309410
|
-
const inlineColor = argument !== "none" ? argument : "transparent";
|
|
309411
|
-
if (this.activeEditor?.commands?.setHighlight)
|
|
309412
|
-
this.activeEditor.commands.setHighlight(inlineColor);
|
|
309413
|
-
const argValue = argument !== "none" ? argument : null;
|
|
309414
|
-
this.activeEditor?.commands.setFieldAnnotationsTextHighlight(argValue, true);
|
|
309415
|
-
this.activeEditor?.commands.setCellBackground(argValue);
|
|
309416
|
-
this.updateToolbarState();
|
|
309417
|
-
},
|
|
309418
|
-
toggleRuler: () => {
|
|
309419
|
-
this.superdoc.toggleRuler();
|
|
309420
|
-
this.updateToolbarState();
|
|
309421
|
-
},
|
|
309422
|
-
startImageUpload: async () => {
|
|
309423
|
-
try {
|
|
309424
|
-
let result = await getFileOpener()();
|
|
309425
|
-
if (!result?.file)
|
|
309426
|
-
return;
|
|
309427
|
-
await processAndInsertImageFile({
|
|
309428
|
-
file: result.file,
|
|
309429
|
-
editor: this.activeEditor,
|
|
309430
|
-
view: this.activeEditor.view,
|
|
309431
|
-
editorOptions: this.activeEditor.options,
|
|
309432
|
-
getMaxContentSize: () => this.activeEditor.getMaxContentSize()
|
|
309433
|
-
});
|
|
309434
|
-
} catch (error3) {
|
|
309435
|
-
const err = /* @__PURE__ */ new Error("[super-toolbar \uD83C\uDFA8] Image upload failed");
|
|
309436
|
-
this.emit("exception", {
|
|
309437
|
-
error: err,
|
|
309438
|
-
editor: this.activeEditor,
|
|
309439
|
-
originalError: error3
|
|
309440
|
-
});
|
|
309441
|
-
console.error(err, error3);
|
|
309442
|
-
}
|
|
309443
|
-
},
|
|
309444
|
-
increaseTextIndent: ({ item, argument }) => {
|
|
309445
|
-
let command$1 = item.command;
|
|
309446
|
-
if (this.activeEditor.commands.increaseListIndent?.())
|
|
309447
|
-
return true;
|
|
309448
|
-
if (command$1 in this.activeEditor.commands)
|
|
309449
|
-
this.activeEditor.commands[command$1](argument);
|
|
309450
|
-
},
|
|
309451
|
-
decreaseTextIndent: ({ item, argument }) => {
|
|
309452
|
-
let command$1 = item.command;
|
|
309453
|
-
if (this.activeEditor.commands.decreaseListIndent?.())
|
|
309454
|
-
return true;
|
|
309455
|
-
if (command$1 in this.activeEditor.commands)
|
|
309456
|
-
this.activeEditor.commands[command$1](argument);
|
|
309457
|
-
},
|
|
309458
|
-
toggleBold: ({ item, argument }) => {
|
|
309459
|
-
if (this.#isFieldAnnotationSelection()) {
|
|
309460
|
-
this.activeEditor?.commands.toggleFieldAnnotationsFormat("bold", true);
|
|
309461
|
-
this.updateToolbarState();
|
|
309462
|
-
return;
|
|
309463
|
-
}
|
|
309464
|
-
let command$1 = item.command;
|
|
309465
|
-
if (command$1 in this.activeEditor.commands) {
|
|
309466
|
-
this.activeEditor.commands[command$1](argument);
|
|
309467
|
-
this.activeEditor.commands.toggleFieldAnnotationsFormat("bold", true);
|
|
309468
|
-
}
|
|
309469
|
-
this.updateToolbarState();
|
|
309470
|
-
},
|
|
309471
|
-
toggleItalic: ({ item, argument }) => {
|
|
309472
|
-
if (this.#isFieldAnnotationSelection()) {
|
|
309473
|
-
this.activeEditor?.commands.toggleFieldAnnotationsFormat("italic", true);
|
|
309474
|
-
this.updateToolbarState();
|
|
309475
|
-
return;
|
|
309476
|
-
}
|
|
309477
|
-
let command$1 = item.command;
|
|
309478
|
-
if (command$1 in this.activeEditor.commands) {
|
|
309479
|
-
this.activeEditor.commands[command$1](argument);
|
|
309480
|
-
this.activeEditor.commands.toggleFieldAnnotationsFormat("italic", true);
|
|
309481
|
-
}
|
|
309482
|
-
this.updateToolbarState();
|
|
309483
|
-
},
|
|
309484
|
-
toggleUnderline: ({ item, argument }) => {
|
|
309485
|
-
if (this.#isFieldAnnotationSelection()) {
|
|
309486
|
-
this.activeEditor?.commands.toggleFieldAnnotationsFormat("underline", true);
|
|
309487
|
-
this.updateToolbarState();
|
|
309488
|
-
return;
|
|
309489
|
-
}
|
|
309490
|
-
let command$1 = item.command;
|
|
309491
|
-
if (command$1 in this.activeEditor.commands) {
|
|
309492
|
-
this.activeEditor.commands[command$1](argument);
|
|
309493
|
-
this.activeEditor.commands.toggleFieldAnnotationsFormat("underline", true);
|
|
309494
|
-
}
|
|
309495
|
-
this.updateToolbarState();
|
|
309496
|
-
},
|
|
309497
|
-
toggleLink: ({ item, argument }) => {
|
|
309498
|
-
let command$1 = item.command;
|
|
309499
|
-
if (command$1 in this.activeEditor.commands) {
|
|
309500
|
-
this.activeEditor.commands[command$1](argument);
|
|
309501
|
-
const { view } = this.activeEditor;
|
|
309502
|
-
let { selection } = view.state;
|
|
309503
|
-
if (this.activeEditor.options.isHeaderOrFooter)
|
|
309504
|
-
selection = this.activeEditor.options.lastSelection;
|
|
309505
|
-
const endPos = selection.$to.pos;
|
|
309506
|
-
const newSelection = new TextSelection(view.state.doc.resolve(endPos));
|
|
309507
|
-
const tr = view.state.tr.setSelection(newSelection);
|
|
309508
|
-
const state = view.state.apply(tr);
|
|
309509
|
-
view.updateState(state);
|
|
309510
|
-
if (!this.activeEditor.options.isHeaderOrFooter)
|
|
309511
|
-
setTimeout(() => {
|
|
309512
|
-
view.focus();
|
|
309513
|
-
}, 100);
|
|
309514
|
-
}
|
|
309515
|
-
this.updateToolbarState();
|
|
309516
|
-
},
|
|
309517
|
-
insertTable: ({ item, argument }) => {
|
|
309518
|
-
this.#runCommandWithArgumentOnly({
|
|
309519
|
-
item,
|
|
309520
|
-
argument
|
|
309521
|
-
});
|
|
309522
|
-
},
|
|
309523
|
-
executeTableCommand: ({ argument }) => {
|
|
309524
|
-
if (!argument)
|
|
309525
|
-
return;
|
|
309526
|
-
let command$1 = argument.command;
|
|
309527
|
-
if (command$1 in this.activeEditor.commands)
|
|
309528
|
-
this.activeEditor.commands[command$1](argument);
|
|
309529
|
-
this.updateToolbarState();
|
|
309530
|
-
}
|
|
309531
|
-
};
|
|
309532
|
-
log(...args$1) {
|
|
309533
|
-
console.debug("[\uD83C\uDFA8 super-toolbar]", ...args$1);
|
|
309534
|
-
}
|
|
309535
|
-
setZoom(percent_int) {
|
|
309536
|
-
const item = [...this.toolbarItems, ...this.overflowItems].find((item$1) => item$1.name.value === "zoom");
|
|
309537
|
-
this.#interceptedCommands.setZoom({
|
|
309538
|
-
item,
|
|
309539
|
-
argument: percent_int
|
|
309540
|
-
});
|
|
309541
|
-
}
|
|
309542
310371
|
setActiveEditor(editor) {
|
|
309543
310372
|
if (this.activeEditor && this._boundEditorHandlers.transaction) {
|
|
309544
310373
|
this.activeEditor.off("transaction", this._boundEditorHandlers.transaction);
|
|
@@ -309626,7 +310455,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309626
310455
|
const documentModeItem = this.getToolbarItemByName("documentMode");
|
|
309627
310456
|
if (!documentModeItem)
|
|
309628
310457
|
return;
|
|
309629
|
-
const mode = (this.
|
|
310458
|
+
const mode = (this.snapshot?.commands?.["document-mode"]?.value || "editing").toLowerCase();
|
|
309630
310459
|
const texts = this.config.texts || {};
|
|
309631
310460
|
const icons$1 = this.config.icons || {};
|
|
309632
310461
|
const map$12 = {
|
|
@@ -309651,12 +310480,127 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309651
310480
|
if (documentModeItem.icon?.value !== undefined && next2.icon)
|
|
309652
310481
|
documentModeItem.icon.value = next2.icon;
|
|
309653
310482
|
}
|
|
310483
|
+
#getFontFamilyFallbackValue() {
|
|
310484
|
+
if (!this.activeEditor?.state)
|
|
310485
|
+
return null;
|
|
310486
|
+
const { state } = this.activeEditor;
|
|
310487
|
+
const selection = state.selection;
|
|
310488
|
+
if (!selection?.empty)
|
|
310489
|
+
return null;
|
|
310490
|
+
const paragraphParent = findParentNode((n) => n.type.name === "paragraph")(selection);
|
|
310491
|
+
if (!paragraphParent || paragraphParent.node?.content?.size !== 0)
|
|
310492
|
+
return null;
|
|
310493
|
+
return getParagraphFontFamilyFromProperties(calculateResolvedParagraphProperties(this.activeEditor, paragraphParent.node, state.doc.resolve(paragraphParent.pos)), this.activeEditor?.converter?.convertedXml ?? {}) || null;
|
|
310494
|
+
}
|
|
310495
|
+
#isFontSizeMixedState(commandState) {
|
|
310496
|
+
return Boolean(commandState?.active) && commandState?.value == null;
|
|
310497
|
+
}
|
|
310498
|
+
#applyHeadlessState(item) {
|
|
310499
|
+
if (item.name.value === "tableActions") {
|
|
310500
|
+
const hasAnyEnabled = TABLE_ACTION_COMMAND_IDS.map((commandId$1) => this.snapshot?.commands?.[commandId$1]).some((state) => state && !state.disabled);
|
|
310501
|
+
item.setDisabled(!hasAnyEnabled);
|
|
310502
|
+
return true;
|
|
310503
|
+
}
|
|
310504
|
+
const commandId = HEADLESS_ITEM_MAP[item.name.value];
|
|
310505
|
+
if (!commandId)
|
|
310506
|
+
return false;
|
|
310507
|
+
const commandState = this.snapshot?.commands?.[commandId];
|
|
310508
|
+
const setDisabled = () => {
|
|
310509
|
+
item.setDisabled(Boolean(commandState?.disabled));
|
|
310510
|
+
};
|
|
310511
|
+
const handlers3 = {
|
|
310512
|
+
textAlign: () => {
|
|
310513
|
+
if (commandState?.value)
|
|
310514
|
+
item.activate({ textAlign: commandState.value });
|
|
310515
|
+
else
|
|
310516
|
+
item.deactivate();
|
|
310517
|
+
},
|
|
310518
|
+
lineHeight: () => {
|
|
310519
|
+
item.selectedValue.value = commandState?.value != null ? commandState.value : "";
|
|
310520
|
+
},
|
|
310521
|
+
zoom: () => {
|
|
310522
|
+
if (commandState?.value != null) {
|
|
310523
|
+
const value = typeof commandState.value === "number" ? `${commandState.value}%` : String(commandState.value);
|
|
310524
|
+
item.onActivate({ zoom: value });
|
|
310525
|
+
}
|
|
310526
|
+
},
|
|
310527
|
+
documentMode: () => {
|
|
310528
|
+
this.#syncDocumentModeUi();
|
|
310529
|
+
},
|
|
310530
|
+
link: () => {
|
|
310531
|
+
item.active.value = Boolean(commandState?.active);
|
|
310532
|
+
item.attributes.value = commandState?.value ? { href: commandState.value } : {};
|
|
310533
|
+
},
|
|
310534
|
+
fontFamily: () => {
|
|
310535
|
+
if (commandState?.value != null) {
|
|
310536
|
+
item.activate({ fontFamily: commandState.value });
|
|
310537
|
+
return;
|
|
310538
|
+
}
|
|
310539
|
+
const fallbackFontFamily = this.#getFontFamilyFallbackValue();
|
|
310540
|
+
if (fallbackFontFamily) {
|
|
310541
|
+
item.activate({ fontFamily: fallbackFontFamily });
|
|
310542
|
+
return;
|
|
310543
|
+
}
|
|
310544
|
+
item.deactivate();
|
|
310545
|
+
},
|
|
310546
|
+
fontSize: () => {
|
|
310547
|
+
if (commandState?.value != null) {
|
|
310548
|
+
item.activate({ fontSize: commandState.value });
|
|
310549
|
+
return;
|
|
310550
|
+
}
|
|
310551
|
+
if (this.#isFontSizeMixedState(commandState)) {
|
|
310552
|
+
item.activate({}, true);
|
|
310553
|
+
return;
|
|
310554
|
+
}
|
|
310555
|
+
item.deactivate();
|
|
310556
|
+
},
|
|
310557
|
+
color: () => {
|
|
310558
|
+
if (commandState?.value != null)
|
|
310559
|
+
item.activate({ color: commandState.value });
|
|
310560
|
+
else
|
|
310561
|
+
item.deactivate();
|
|
310562
|
+
},
|
|
310563
|
+
highlight: () => {
|
|
310564
|
+
if (commandState?.value != null)
|
|
310565
|
+
item.activate({ color: commandState.value });
|
|
310566
|
+
else
|
|
310567
|
+
item.deactivate();
|
|
310568
|
+
},
|
|
310569
|
+
linkedStyles: () => {
|
|
310570
|
+
if (commandState?.value != null)
|
|
310571
|
+
item.activate({ styleId: commandState.value });
|
|
310572
|
+
else
|
|
310573
|
+
item.label.value = this.config.texts?.formatText || "Format text";
|
|
310574
|
+
},
|
|
310575
|
+
default: () => {
|
|
310576
|
+
if (commandState?.active)
|
|
310577
|
+
item.activate();
|
|
310578
|
+
else
|
|
310579
|
+
item.deactivate();
|
|
310580
|
+
}
|
|
310581
|
+
};
|
|
310582
|
+
const handler2 = handlers3[item.name.value] ?? handlers3.default;
|
|
310583
|
+
setDisabled();
|
|
310584
|
+
handler2();
|
|
310585
|
+
return true;
|
|
310586
|
+
}
|
|
310587
|
+
#executeHeadlessCommand(item, argument) {
|
|
310588
|
+
const isTableActions = item?.name?.value === "tableActions";
|
|
310589
|
+
const commandId = isTableActions ? TABLE_ACTION_COMMAND_MAP[argument?.command] : HEADLESS_ITEM_MAP[item?.name?.value];
|
|
310590
|
+
if (!commandId || !this.controller?.execute)
|
|
310591
|
+
return false;
|
|
310592
|
+
if (isTableActions)
|
|
310593
|
+
this.controller.execute(commandId);
|
|
310594
|
+
else
|
|
310595
|
+
this.controller.execute(commandId, argument);
|
|
310596
|
+
return true;
|
|
310597
|
+
}
|
|
309654
310598
|
updateToolbarState() {
|
|
309655
310599
|
this.#syncDocumentModeUi();
|
|
309656
|
-
this.#updateToolbarHistory();
|
|
309657
310600
|
this.#initDefaultFonts();
|
|
309658
310601
|
this.#updateHighlightColors();
|
|
309659
|
-
|
|
310602
|
+
const currentMode = this.snapshot?.commands?.["document-mode"]?.value || "editing";
|
|
310603
|
+
if (!this.activeEditor || currentMode === "viewing") {
|
|
309660
310604
|
this.#deactivateAll();
|
|
309661
310605
|
return;
|
|
309662
310606
|
}
|
|
@@ -309665,96 +310609,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309665
310609
|
this.#deactivateAll();
|
|
309666
310610
|
return;
|
|
309667
310611
|
}
|
|
309668
|
-
const selection = state.selection;
|
|
309669
|
-
const selectionTrackedChanges = this.#enrichTrackedChanges(collectTrackedChanges({
|
|
309670
|
-
state,
|
|
309671
|
-
from: selection.from,
|
|
309672
|
-
to: selection.to
|
|
309673
|
-
}));
|
|
309674
|
-
const hasValidSelection = selectionTrackedChanges.length > 0;
|
|
309675
|
-
const canAcceptTrackedChanges = hasValidSelection && isTrackedChangeActionAllowed({
|
|
309676
|
-
editor: this.activeEditor,
|
|
309677
|
-
action: "accept",
|
|
309678
|
-
trackedChanges: selectionTrackedChanges
|
|
309679
|
-
});
|
|
309680
|
-
const canRejectTrackedChanges = hasValidSelection && isTrackedChangeActionAllowed({
|
|
309681
|
-
editor: this.activeEditor,
|
|
309682
|
-
action: "reject",
|
|
309683
|
-
trackedChanges: selectionTrackedChanges
|
|
309684
|
-
});
|
|
309685
|
-
const marks = getActiveFormatting(this.activeEditor);
|
|
309686
|
-
const inTable = isInTable(this.activeEditor.state);
|
|
309687
|
-
const paragraphParent = findParentNode((n) => n.type.name === "paragraph")(selection);
|
|
309688
|
-
const paragraphProps = paragraphParent ? calculateResolvedParagraphProperties(this.activeEditor, paragraphParent.node, state.doc.resolve(paragraphParent.pos)) : null;
|
|
309689
|
-
const selectionIsCollapsed = selection.empty;
|
|
309690
|
-
const paragraphIsEmpty = paragraphParent?.node?.content?.size === 0;
|
|
309691
|
-
const paragraphFontFamily = getParagraphFontFamilyFromProperties(paragraphProps, this.activeEditor?.converter?.convertedXml ?? {});
|
|
309692
310612
|
this.toolbarItems.forEach((item) => {
|
|
309693
310613
|
item.resetDisabled();
|
|
309694
|
-
|
|
309695
|
-
if (item.name.value === "undo")
|
|
309696
|
-
item.setDisabled(this.undoDepth === 0);
|
|
309697
|
-
if (item.name.value === "redo")
|
|
309698
|
-
item.setDisabled(this.redoDepth === 0);
|
|
309699
|
-
if (item.name.value === "acceptTrackedChangeBySelection")
|
|
309700
|
-
item.setDisabled(!canAcceptTrackedChanges);
|
|
309701
|
-
if (item.name.value === "rejectTrackedChangeOnSelection")
|
|
309702
|
-
item.setDisabled(!canRejectTrackedChanges);
|
|
309703
|
-
if (item.name.value === "linkedStyles")
|
|
309704
|
-
if (this.activeEditor && !getQuickFormatList(this.activeEditor).length)
|
|
309705
|
-
return item.deactivate();
|
|
309706
|
-
else
|
|
309707
|
-
return item.activate({ styleId: paragraphProps?.styleId || null });
|
|
309708
|
-
const rawActiveMark = marks.find((mark2) => mark2.name === item.name.value);
|
|
309709
|
-
const markNegated = rawActiveMark ? isNegatedMark(rawActiveMark.name, rawActiveMark.attrs) : false;
|
|
309710
|
-
const activeMark = markNegated ? null : rawActiveMark;
|
|
309711
|
-
if (activeMark)
|
|
309712
|
-
if (activeMark.name === "fontSize") {
|
|
309713
|
-
const fontSizes = marks.filter((i4) => i4.name === "fontSize").map((i4) => i4.attrs.fontSize);
|
|
309714
|
-
const isMultiple = [...new Set(fontSizes)].length > 1;
|
|
309715
|
-
item.activate(activeMark.attrs, isMultiple);
|
|
309716
|
-
} else
|
|
309717
|
-
item.activate(activeMark.attrs);
|
|
309718
|
-
else
|
|
309719
|
-
item.deactivate();
|
|
309720
|
-
if (!activeMark && !markNegated && paragraphParent && paragraphProps?.styleId) {
|
|
309721
|
-
const markToStyleMap = {
|
|
309722
|
-
fontSize: "font-size",
|
|
309723
|
-
fontFamily: "font-family",
|
|
309724
|
-
bold: "bold"
|
|
309725
|
-
};
|
|
309726
|
-
const linkedStyles = this.activeEditor.converter?.linkedStyles.find((style2) => style2.id === paragraphProps.styleId);
|
|
309727
|
-
if (linkedStyles && linkedStyles.definition && linkedStyles.definition.styles && markToStyleMap[item.name.value] in linkedStyles.definition.styles) {
|
|
309728
|
-
const linkedStylesItem = linkedStyles.definition.styles[markToStyleMap[item.name.value]];
|
|
309729
|
-
const value = { [item.name.value]: linkedStylesItem };
|
|
309730
|
-
item.activate(value);
|
|
309731
|
-
activatedFromLinkedStyle = true;
|
|
309732
|
-
}
|
|
309733
|
-
}
|
|
309734
|
-
if (item.name.value === "textAlign" && paragraphProps?.justification)
|
|
309735
|
-
item.activate({ textAlign: paragraphProps.justification });
|
|
309736
|
-
if (item.name.value === "fontFamily" && selectionIsCollapsed && paragraphIsEmpty && !activeMark && !markNegated && !activatedFromLinkedStyle && paragraphFontFamily)
|
|
309737
|
-
item.activate({ fontFamily: paragraphFontFamily });
|
|
309738
|
-
if (item.name.value === "lineHeight")
|
|
309739
|
-
if (paragraphProps?.spacing)
|
|
309740
|
-
item.selectedValue.value = twipsToLines(paragraphProps.spacing.line);
|
|
309741
|
-
else
|
|
309742
|
-
item.selectedValue.value = "";
|
|
309743
|
-
if (item.name.value === "tableActions")
|
|
309744
|
-
item.disabled.value = !inTable;
|
|
309745
|
-
const listParent = isList(paragraphParent?.node) ? paragraphParent.node : null;
|
|
309746
|
-
if (listParent) {
|
|
309747
|
-
const numberingType = listParent.attrs.listRendering.numberingType;
|
|
309748
|
-
if (item.name.value === "list" && numberingType === "bullet")
|
|
309749
|
-
item.activate();
|
|
309750
|
-
else if (item.name.value === "numberedlist" && numberingType !== "bullet")
|
|
309751
|
-
item.activate();
|
|
309752
|
-
}
|
|
309753
|
-
if (item.name.value === "ruler")
|
|
309754
|
-
if (this.superdoc?.config?.rulers)
|
|
309755
|
-
item.activate();
|
|
309756
|
-
else
|
|
309757
|
-
item.deactivate();
|
|
310614
|
+
this.#applyHeadlessState(item);
|
|
309758
310615
|
});
|
|
309759
310616
|
}
|
|
309760
310617
|
onToolbarResize = () => {
|
|
@@ -309779,48 +310636,22 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309779
310636
|
item.setDisabled(true);
|
|
309780
310637
|
});
|
|
309781
310638
|
}
|
|
309782
|
-
#updateToolbarHistory() {
|
|
309783
|
-
if (!this.activeEditor?.state)
|
|
309784
|
-
return;
|
|
309785
|
-
try {
|
|
309786
|
-
if (this.activeEditor.options.ydoc) {
|
|
309787
|
-
const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
|
|
309788
|
-
this.undoDepth = undoManager?.undoStack.length || 0;
|
|
309789
|
-
this.redoDepth = undoManager?.redoStack.length || 0;
|
|
309790
|
-
} else {
|
|
309791
|
-
this.undoDepth = undoDepth(this.activeEditor.state);
|
|
309792
|
-
this.redoDepth = redoDepth(this.activeEditor.state);
|
|
309793
|
-
}
|
|
309794
|
-
} catch {
|
|
309795
|
-
this.undoDepth = 0;
|
|
309796
|
-
this.redoDepth = 0;
|
|
309797
|
-
}
|
|
309798
|
-
}
|
|
309799
|
-
#enrichTrackedChanges(trackedChanges = []) {
|
|
309800
|
-
if (!trackedChanges?.length)
|
|
309801
|
-
return trackedChanges;
|
|
309802
|
-
const store = this.superdoc?.commentsStore;
|
|
309803
|
-
if (!store?.getComment)
|
|
309804
|
-
return trackedChanges;
|
|
309805
|
-
return trackedChanges.map((change) => {
|
|
309806
|
-
const commentId = change.id;
|
|
309807
|
-
if (!commentId)
|
|
309808
|
-
return change;
|
|
309809
|
-
const storeComment = store.getComment(commentId);
|
|
309810
|
-
if (!storeComment)
|
|
309811
|
-
return change;
|
|
309812
|
-
const comment2 = typeof storeComment.getValues === "function" ? storeComment.getValues() : storeComment;
|
|
309813
|
-
return {
|
|
309814
|
-
...change,
|
|
309815
|
-
comment: comment2
|
|
309816
|
-
};
|
|
309817
|
-
});
|
|
309818
|
-
}
|
|
309819
310639
|
onEditorTransaction({ transaction }) {
|
|
309820
310640
|
if (!transaction.docChanged && !transaction.selectionSet)
|
|
309821
310641
|
return;
|
|
309822
310642
|
this.updateToolbarState();
|
|
309823
310643
|
}
|
|
310644
|
+
#scheduleRestoreEditorFocus() {
|
|
310645
|
+
if (!this.activeEditor || this.activeEditor.options.isHeaderOrFooter)
|
|
310646
|
+
return;
|
|
310647
|
+
clearTimeout(this._restoreFocusTimeoutId);
|
|
310648
|
+
this._restoreFocusTimeoutId = setTimeout(() => {
|
|
310649
|
+
this._restoreFocusTimeoutId = null;
|
|
310650
|
+
if (!this.activeEditor || this.activeEditor.options.isHeaderOrFooter)
|
|
310651
|
+
return;
|
|
310652
|
+
this.activeEditor.focus();
|
|
310653
|
+
}, 0);
|
|
310654
|
+
}
|
|
309824
310655
|
emitCommand({ item, argument, option }) {
|
|
309825
310656
|
const hasFocusFn = this.activeEditor?.view?.hasFocus;
|
|
309826
310657
|
const wasFocused = Boolean(typeof hasFocusFn === "function" && hasFocusFn.call(this.activeEditor.view));
|
|
@@ -309851,14 +310682,21 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309851
310682
|
this.activeEditor.focus();
|
|
309852
310683
|
if (!command$1)
|
|
309853
310684
|
return;
|
|
309854
|
-
if (
|
|
309855
|
-
|
|
309856
|
-
|
|
309857
|
-
|
|
309858
|
-
}
|
|
309859
|
-
|
|
309860
|
-
|
|
309861
|
-
|
|
310685
|
+
if (item?.name?.value === "tableActions") {
|
|
310686
|
+
if (this.#executeHeadlessCommand(item, argument)) {
|
|
310687
|
+
this.updateToolbarState();
|
|
310688
|
+
return;
|
|
310689
|
+
}
|
|
310690
|
+
}
|
|
310691
|
+
if (HEADLESS_EXECUTE_ITEMS.has(item?.name?.value)) {
|
|
310692
|
+
if (this.#executeHeadlessCommand(item, argument)) {
|
|
310693
|
+
if (isMarkToggle)
|
|
310694
|
+
this.#syncStickyMarksFromState();
|
|
310695
|
+
this.updateToolbarState();
|
|
310696
|
+
if (shouldRestoreFocus)
|
|
310697
|
+
this.#scheduleRestoreEditorFocus();
|
|
310698
|
+
return;
|
|
310699
|
+
}
|
|
309862
310700
|
}
|
|
309863
310701
|
if (this.activeEditor && this.activeEditor.commands && command$1 in this.activeEditor.commands)
|
|
309864
310702
|
this.activeEditor.commands[command$1](argument);
|
|
@@ -309879,13 +310717,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309879
310717
|
if (isMarkToggle)
|
|
309880
310718
|
this.#syncStickyMarksFromState();
|
|
309881
310719
|
this.updateToolbarState();
|
|
309882
|
-
if (shouldRestoreFocus
|
|
309883
|
-
this
|
|
309884
|
-
this._restoreFocusTimeoutId = null;
|
|
309885
|
-
if (!this.activeEditor || this.activeEditor.options.isHeaderOrFooter)
|
|
309886
|
-
return;
|
|
309887
|
-
this.activeEditor.focus();
|
|
309888
|
-
}, 0);
|
|
310720
|
+
if (shouldRestoreFocus)
|
|
310721
|
+
this.#scheduleRestoreEditorFocus();
|
|
309889
310722
|
}
|
|
309890
310723
|
onEditorSelectionUpdate() {
|
|
309891
310724
|
if (!this.activeEditor)
|
|
@@ -309897,12 +310730,16 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309897
310730
|
if (!command$1)
|
|
309898
310731
|
return;
|
|
309899
310732
|
try {
|
|
309900
|
-
if (
|
|
309901
|
-
this.#
|
|
309902
|
-
|
|
309903
|
-
|
|
309904
|
-
|
|
309905
|
-
|
|
310733
|
+
if (HEADLESS_EXECUTE_ITEMS.has(item?.name?.value)) {
|
|
310734
|
+
if (this.#executeHeadlessCommand(item, argument)) {
|
|
310735
|
+
this.#ensureStoredMarksForMarkToggle({
|
|
310736
|
+
command: command$1,
|
|
310737
|
+
argument
|
|
310738
|
+
});
|
|
310739
|
+
return;
|
|
310740
|
+
}
|
|
310741
|
+
}
|
|
310742
|
+
if (this.activeEditor.commands && command$1 in this.activeEditor.commands)
|
|
309906
310743
|
this.activeEditor.commands[command$1](argument);
|
|
309907
310744
|
this.#ensureStoredMarksForMarkToggle({
|
|
309908
310745
|
command: command$1,
|
|
@@ -309937,25 +310774,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
309937
310774
|
const name = item?.name?.value;
|
|
309938
310775
|
return SuperToolbar2.#MARK_TOGGLE_NAMES.has(name);
|
|
309939
310776
|
}
|
|
309940
|
-
#runCommandWithArgumentOnly({ item, argument, noArgumentCallback = false }, callback) {
|
|
309941
|
-
if (!argument || !this.activeEditor)
|
|
309942
|
-
return;
|
|
309943
|
-
let command$1 = item.command;
|
|
309944
|
-
const noArgumentCommand = item.noArgumentCommand;
|
|
309945
|
-
if (argument === "none" && this.activeEditor && this.activeEditor.commands && noArgumentCommand in this.activeEditor.commands) {
|
|
309946
|
-
this.activeEditor.commands[noArgumentCommand]();
|
|
309947
|
-
if (typeof callback === "function" && noArgumentCallback)
|
|
309948
|
-
callback(argument);
|
|
309949
|
-
this.updateToolbarState();
|
|
309950
|
-
return;
|
|
309951
|
-
}
|
|
309952
|
-
if (this.activeEditor && this.activeEditor.commands && command$1 in this.activeEditor.commands) {
|
|
309953
|
-
this.activeEditor.commands[command$1](argument);
|
|
309954
|
-
if (typeof callback === "function")
|
|
309955
|
-
callback(argument);
|
|
309956
|
-
this.updateToolbarState();
|
|
309957
|
-
}
|
|
309958
|
-
}
|
|
309959
310777
|
#syncStickyMarksFromState() {
|
|
309960
310778
|
if (!this.activeEditor)
|
|
309961
310779
|
return;
|
|
@@ -310005,15 +310823,12 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
310005
310823
|
const tr = state.tr.setStoredMarks([mark2]);
|
|
310006
310824
|
view.dispatch(tr);
|
|
310007
310825
|
}
|
|
310008
|
-
#isFieldAnnotationSelection() {
|
|
310009
|
-
const selection = this.activeEditor?.state?.selection;
|
|
310010
|
-
return selection instanceof NodeSelection && selection?.node?.type?.name === "fieldAnnotation";
|
|
310011
|
-
}
|
|
310012
310826
|
destroy() {
|
|
310013
310827
|
if (this._restoreFocusTimeoutId !== null) {
|
|
310014
310828
|
clearTimeout(this._restoreFocusTimeoutId);
|
|
310015
310829
|
this._restoreFocusTimeoutId = null;
|
|
310016
310830
|
}
|
|
310831
|
+
this.destroyHeadlessToolbar();
|
|
310017
310832
|
}
|
|
310018
310833
|
};
|
|
310019
310834
|
Commands = Extension.create({
|
|
@@ -320832,7 +321647,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
320832
321647
|
const range = computeWordSelectionRangeAt(state, pos);
|
|
320833
321648
|
if (!range)
|
|
320834
321649
|
return false;
|
|
320835
|
-
const tr = state.tr.setSelection(
|
|
321650
|
+
const tr = state.tr.setSelection(TextSelection.create(state.doc, range.from, range.to));
|
|
320836
321651
|
try {
|
|
320837
321652
|
this.#editor.view?.dispatch(tr);
|
|
320838
321653
|
return true;
|
|
@@ -320849,7 +321664,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
320849
321664
|
const range = computeParagraphSelectionRangeAt(state, pos);
|
|
320850
321665
|
if (!range)
|
|
320851
321666
|
return false;
|
|
320852
|
-
const tr = state.tr.setSelection(
|
|
321667
|
+
const tr = state.tr.setSelection(TextSelection.create(state.doc, range.from, range.to));
|
|
320853
321668
|
try {
|
|
320854
321669
|
this.#editor.view?.dispatch(tr);
|
|
320855
321670
|
return true;
|
|
@@ -321672,8 +322487,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
321672
322487
|
}
|
|
321673
322488
|
try {
|
|
321674
322489
|
this.#localSelectionLayer.innerHTML = "";
|
|
321675
|
-
const
|
|
321676
|
-
if (domRects.length > 0 && !
|
|
322490
|
+
const isFieldAnnotationSelection2 = selection instanceof NodeSelection && selection.node?.type?.name === "fieldAnnotation";
|
|
322491
|
+
if (domRects.length > 0 && !isFieldAnnotationSelection2)
|
|
321677
322492
|
renderSelectionRects({
|
|
321678
322493
|
localSelectionLayer: this.#localSelectionLayer,
|
|
321679
322494
|
rects: domRects,
|
|
@@ -322104,7 +322919,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
322104
322919
|
if (current.from === desiredFrom && current.to === desiredTo)
|
|
322105
322920
|
return;
|
|
322106
322921
|
try {
|
|
322107
|
-
const tr = this.#editor.state.tr.setSelection(
|
|
322922
|
+
const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, selAnchor, selHead));
|
|
322108
322923
|
this.#editor.view?.dispatch(tr);
|
|
322109
322924
|
this.#scheduleSelectionUpdate();
|
|
322110
322925
|
} catch {}
|
|
@@ -322918,11 +323733,11 @@ var init_zipper_DbkgrypV_es = __esm(() => {
|
|
|
322918
323733
|
|
|
322919
323734
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
322920
323735
|
var init_super_editor_es = __esm(() => {
|
|
322921
|
-
|
|
323736
|
+
init_src_yUVuhLM1_es();
|
|
322922
323737
|
init_SuperConverter_BgwP1GeS_es();
|
|
322923
323738
|
init_jszip_C49i9kUs_es();
|
|
322924
323739
|
init_xml_js_CqGKpaft_es();
|
|
322925
|
-
|
|
323740
|
+
init_create_headless_toolbar_Dcw4Hyt2_es();
|
|
322926
323741
|
init_constants_CGhJRd87_es();
|
|
322927
323742
|
init_dist_B8HfvhaK_es();
|
|
322928
323743
|
init_unified_Dsuw2be5_es();
|