@harbour-enterprises/superdoc 0.13.0-next.6 → 0.13.2-rev10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{eventemitter3-DfVviFzP.cjs → eventemitter3-CHxWXmuK.cjs} +1 -1
- package/dist/chunks/{eventemitter3-BrspJk8q.es.js → eventemitter3-KKY27oz-.es.js} +1 -1
- package/dist/chunks/{index-Hr3Um-Bg.es.js → index-BqLFjUHn.es.js} +2 -2
- package/dist/chunks/{index-B4J7wgs6.cjs → index-CweAXNfB.cjs} +2 -2
- package/dist/chunks/{index-Diu6UKHt.es.js → index-DS3W0eVB.es.js} +4 -4
- package/dist/chunks/{index-Cdsq63Xq.cjs → index-kOMfCfBT.cjs} +4 -4
- package/dist/chunks/{jszip-BTAcmbVg.cjs → jszip-9bCX1h2W.cjs} +1 -1
- package/dist/chunks/{jszip-DckFs3A7.es.js → jszip-Cl3s9njw.es.js} +1 -1
- package/dist/chunks/{super-editor.es-BSS_LTA0.cjs → super-editor.es-Bdu65rjC.cjs} +1096 -819
- package/dist/chunks/{super-editor.es-CU8V5_XY.es.js → super-editor.es-BwWbNxcS.es.js} +1096 -819
- package/dist/chunks/{url-BIzg4y2i.cjs → url-B8LY3nwf.cjs} +2 -2
- package/dist/chunks/{url-CHayXMZH.es.js → url-Bq00tGvm.es.js} +2 -2
- package/dist/chunks/{vue-Bi1uWinj.es.js → vue-BBJVqxjL.es.js} +10 -3
- package/dist/chunks/{vue-HIY1g7dm.cjs → vue-BBjMeYfo.cjs} +10 -3
- package/dist/chunks/{xml-js-CfClL-1b.es.js → xml-js-1F0lia4t.es.js} +81 -102
- package/dist/chunks/{xml-js-BjqmFOSP.cjs → xml-js-BuAdLsHD.cjs} +81 -102
- package/dist/style.css +4 -3
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-Bns3BtmW.js → converter-lPrQA7b1.js} +637 -55
- package/dist/super-editor/chunks/{docx-zipper-qf0kgh0l.js → docx-zipper-HvG9XskR.js} +1 -1
- package/dist/super-editor/chunks/{editor-hIfvfc-Y.js → editor-DbkiH8Up.js} +387 -685
- package/dist/super-editor/chunks/{toolbar-BC9mPZ43.js → toolbar-JdrfUR1G.js} +2 -3
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/core/Editor.d.ts +7 -0
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/InputRule.d.ts +7 -0
- package/dist/super-editor/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/annotator.d.ts +4 -0
- package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts +2 -0
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts.map +1 -0
- package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
- package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.d.ts.map +1 -1
- package/dist/super-editor/extensions/image/imageHelpers/startImageUpload.d.ts.map +1 -1
- package/dist/super-editor/extensions/line-break/line-break.d.ts.map +1 -1
- package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +6 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +4 -3
- package/dist/super-editor/super-editor.es.js +7 -7
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +3 -0
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +1 -0
- package/dist/super-editor/tests/e2e/test-app/vite.config.d.ts +1 -1
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +8 -9
- package/dist/superdoc.es.js +9 -10
- package/dist/superdoc.umd.js +1107 -824
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const vue = require("./vue-
|
|
2
|
+
const vue = require("./vue-BBjMeYfo.cjs");
|
|
3
3
|
const Y = require("yjs");
|
|
4
4
|
function _interopNamespaceDefault(e) {
|
|
5
5
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -10958,7 +10958,7 @@ class NodeRange {
|
|
|
10958
10958
|
}
|
|
10959
10959
|
}
|
|
10960
10960
|
const emptyAttrs = /* @__PURE__ */ Object.create(null);
|
|
10961
|
-
let Node$
|
|
10961
|
+
let Node$1$1 = class Node2 {
|
|
10962
10962
|
/**
|
|
10963
10963
|
@internal
|
|
10964
10964
|
*/
|
|
@@ -11359,8 +11359,8 @@ let Node$2 = class Node2 {
|
|
|
11359
11359
|
return node2;
|
|
11360
11360
|
}
|
|
11361
11361
|
};
|
|
11362
|
-
Node$
|
|
11363
|
-
class TextNode extends Node$
|
|
11362
|
+
Node$1$1.prototype.text = void 0;
|
|
11363
|
+
class TextNode extends Node$1$1 {
|
|
11364
11364
|
/**
|
|
11365
11365
|
@internal
|
|
11366
11366
|
*/
|
|
@@ -11947,7 +11947,7 @@ let NodeType$1 = class NodeType {
|
|
|
11947
11947
|
create(attrs = null, content, marks) {
|
|
11948
11948
|
if (this.isText)
|
|
11949
11949
|
throw new Error("NodeType.create can't construct text nodes");
|
|
11950
|
-
return new Node$
|
|
11950
|
+
return new Node$1$1(this, this.computeAttrs(attrs), Fragment.from(content), Mark$1.setFrom(marks));
|
|
11951
11951
|
}
|
|
11952
11952
|
/**
|
|
11953
11953
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
@@ -11957,7 +11957,7 @@ let NodeType$1 = class NodeType {
|
|
|
11957
11957
|
createChecked(attrs = null, content, marks) {
|
|
11958
11958
|
content = Fragment.from(content);
|
|
11959
11959
|
this.checkContent(content);
|
|
11960
|
-
return new Node$
|
|
11960
|
+
return new Node$1$1(this, this.computeAttrs(attrs), content, Mark$1.setFrom(marks));
|
|
11961
11961
|
}
|
|
11962
11962
|
/**
|
|
11963
11963
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
@@ -11980,7 +11980,7 @@ let NodeType$1 = class NodeType {
|
|
|
11980
11980
|
let after = matched && matched.fillBefore(Fragment.empty, true);
|
|
11981
11981
|
if (!after)
|
|
11982
11982
|
return null;
|
|
11983
|
-
return new Node$
|
|
11983
|
+
return new Node$1$1(this, attrs, content.append(after), Mark$1.setFrom(marks));
|
|
11984
11984
|
}
|
|
11985
11985
|
/**
|
|
11986
11986
|
Returns true if the given fragment is valid content for this node
|
|
@@ -12217,7 +12217,7 @@ let Schema$1 = class Schema {
|
|
|
12217
12217
|
bound.
|
|
12218
12218
|
*/
|
|
12219
12219
|
nodeFromJSON(json) {
|
|
12220
|
-
return Node$
|
|
12220
|
+
return Node$1$1.fromJSON(this, json);
|
|
12221
12221
|
}
|
|
12222
12222
|
/**
|
|
12223
12223
|
Deserialize a mark from its JSON representation. This method is
|
|
@@ -13743,7 +13743,7 @@ class ReplaceStep extends Step {
|
|
|
13743
13743
|
}
|
|
13744
13744
|
}
|
|
13745
13745
|
Step.jsonID("replace", ReplaceStep);
|
|
13746
|
-
|
|
13746
|
+
let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
13747
13747
|
/**
|
|
13748
13748
|
Create a replace-around step with the given range and gap.
|
|
13749
13749
|
`insert` should be the point in the slice into which the content
|
|
@@ -13783,7 +13783,7 @@ class ReplaceAroundStep extends Step {
|
|
|
13783
13783
|
}
|
|
13784
13784
|
invert(doc2) {
|
|
13785
13785
|
let gap = this.gapTo - this.gapFrom;
|
|
13786
|
-
return new
|
|
13786
|
+
return new ReplaceAroundStep2(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc2.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
13787
13787
|
}
|
|
13788
13788
|
map(mapping) {
|
|
13789
13789
|
let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
@@ -13791,7 +13791,7 @@ class ReplaceAroundStep extends Step {
|
|
|
13791
13791
|
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
13792
13792
|
if (from2.deletedAcross && to.deletedAcross || gapFrom < from2.pos || gapTo > to.pos)
|
|
13793
13793
|
return null;
|
|
13794
|
-
return new
|
|
13794
|
+
return new ReplaceAroundStep2(from2.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
13795
13795
|
}
|
|
13796
13796
|
toJSON() {
|
|
13797
13797
|
let json = {
|
|
@@ -13814,10 +13814,10 @@ class ReplaceAroundStep extends Step {
|
|
|
13814
13814
|
static fromJSON(schema, json) {
|
|
13815
13815
|
if (typeof json.from != "number" || typeof json.to != "number" || typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
13816
13816
|
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
13817
|
-
return new
|
|
13817
|
+
return new ReplaceAroundStep2(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
13818
13818
|
}
|
|
13819
|
-
}
|
|
13820
|
-
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
13819
|
+
};
|
|
13820
|
+
Step.jsonID("replaceAround", ReplaceAroundStep$1);
|
|
13821
13821
|
function contentBetween(doc2, from2, to) {
|
|
13822
13822
|
let $from = doc2.resolve(from2), dist2 = to - from2, depth = $from.depth;
|
|
13823
13823
|
while (dist2 > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
@@ -13970,7 +13970,7 @@ function lift(tr, range2, target) {
|
|
|
13970
13970
|
} else {
|
|
13971
13971
|
end2++;
|
|
13972
13972
|
}
|
|
13973
|
-
tr.step(new ReplaceAroundStep(start2, end2, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
13973
|
+
tr.step(new ReplaceAroundStep$1(start2, end2, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
13974
13974
|
}
|
|
13975
13975
|
function findWrapping(range2, nodeType, attrs = null, innerRange = range2) {
|
|
13976
13976
|
let around = findWrappingOutside(range2, nodeType);
|
|
@@ -14015,7 +14015,7 @@ function wrap(tr, range2, wrappers) {
|
|
|
14015
14015
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
14016
14016
|
}
|
|
14017
14017
|
let start2 = range2.start, end2 = range2.end;
|
|
14018
|
-
tr.step(new ReplaceAroundStep(start2, end2, start2, end2, new Slice(content, 0, 0), wrappers.length, true));
|
|
14018
|
+
tr.step(new ReplaceAroundStep$1(start2, end2, start2, end2, new Slice(content, 0, 0), wrappers.length, true));
|
|
14019
14019
|
}
|
|
14020
14020
|
function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
14021
14021
|
if (!type2.isTextblock)
|
|
@@ -14037,7 +14037,7 @@ function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
|
14037
14037
|
clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type2, void 0, convertNewlines === null);
|
|
14038
14038
|
let mapping = tr.mapping.slice(mapFrom);
|
|
14039
14039
|
let startM = mapping.map(pos, 1), endM = mapping.map(pos + node2.nodeSize, 1);
|
|
14040
|
-
tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
14040
|
+
tr.step(new ReplaceAroundStep$1(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
14041
14041
|
if (convertNewlines === true)
|
|
14042
14042
|
replaceNewlines(tr, node2, pos, mapFrom);
|
|
14043
14043
|
return false;
|
|
@@ -14078,7 +14078,7 @@ function setNodeMarkup(tr, pos, type2, attrs, marks) {
|
|
|
14078
14078
|
return tr.replaceWith(pos, pos + node2.nodeSize, newNode);
|
|
14079
14079
|
if (!type2.validContent(node2.content))
|
|
14080
14080
|
throw new RangeError("Invalid content for node type " + type2.name);
|
|
14081
|
-
tr.step(new ReplaceAroundStep(pos, pos + node2.nodeSize, pos + 1, pos + node2.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
14081
|
+
tr.step(new ReplaceAroundStep$1(pos, pos + node2.nodeSize, pos + 1, pos + node2.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
14082
14082
|
}
|
|
14083
14083
|
function canSplit(doc2, pos, depth = 1, typesAfter) {
|
|
14084
14084
|
let $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
|
|
@@ -14279,7 +14279,7 @@ class Fitter {
|
|
|
14279
14279
|
}
|
|
14280
14280
|
let slice2 = new Slice(content, openStart, openEnd);
|
|
14281
14281
|
if (moveInline > -1)
|
|
14282
|
-
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice2, placedSize);
|
|
14282
|
+
return new ReplaceAroundStep$1($from.pos, moveInline, this.$to.pos, this.$to.end(), slice2, placedSize);
|
|
14283
14283
|
if (slice2.size || $from.pos != this.$to.pos)
|
|
14284
14284
|
return new ReplaceStep($from.pos, $to.pos, slice2);
|
|
14285
14285
|
return null;
|
|
@@ -15362,7 +15362,7 @@ function selectionToInsertionEnd$1(tr, startLen, bias) {
|
|
|
15362
15362
|
if (last < startLen)
|
|
15363
15363
|
return;
|
|
15364
15364
|
let step = tr.steps[last];
|
|
15365
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))
|
|
15365
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1))
|
|
15366
15366
|
return;
|
|
15367
15367
|
let map3 = tr.mapping.maps[last], end2;
|
|
15368
15368
|
map3.forEach((_from, _to, _newFrom, newTo) => {
|
|
@@ -15777,7 +15777,7 @@ class EditorState {
|
|
|
15777
15777
|
let instance = new EditorState($config);
|
|
15778
15778
|
$config.fields.forEach((field) => {
|
|
15779
15779
|
if (field.name == "doc") {
|
|
15780
|
-
instance.doc = Node$
|
|
15780
|
+
instance.doc = Node$1$1.fromJSON(config.schema, json.doc);
|
|
15781
15781
|
} else if (field.name == "selection") {
|
|
15782
15782
|
instance.selection = Selection.fromJSON(instance.doc, json.selection);
|
|
15783
15783
|
} else if (field.name == "storedMarks") {
|
|
@@ -18838,6 +18838,583 @@ const createColGroup = (node2, cellMinWidth, overrideCol, overrideValue) => {
|
|
|
18838
18838
|
colgroupValues
|
|
18839
18839
|
};
|
|
18840
18840
|
};
|
|
18841
|
+
function chainableEditorState(transaction, state2) {
|
|
18842
|
+
let { selection, doc: doc2, storedMarks } = transaction;
|
|
18843
|
+
return {
|
|
18844
|
+
...state2,
|
|
18845
|
+
apply: state2.apply.bind(state2),
|
|
18846
|
+
applyTransaction: state2.applyTransaction.bind(state2),
|
|
18847
|
+
plugins: state2.plugins,
|
|
18848
|
+
schema: state2.schema,
|
|
18849
|
+
reconfigure: state2.reconfigure.bind(state2),
|
|
18850
|
+
toJSON: state2.toJSON.bind(state2),
|
|
18851
|
+
get storedMarks() {
|
|
18852
|
+
return storedMarks;
|
|
18853
|
+
},
|
|
18854
|
+
get selection() {
|
|
18855
|
+
return selection;
|
|
18856
|
+
},
|
|
18857
|
+
get doc() {
|
|
18858
|
+
return doc2;
|
|
18859
|
+
},
|
|
18860
|
+
get tr() {
|
|
18861
|
+
selection = transaction.selection;
|
|
18862
|
+
doc2 = transaction.doc;
|
|
18863
|
+
storedMarks = transaction.storedMarks;
|
|
18864
|
+
return transaction;
|
|
18865
|
+
}
|
|
18866
|
+
};
|
|
18867
|
+
}
|
|
18868
|
+
class CommandService {
|
|
18869
|
+
constructor(props) {
|
|
18870
|
+
__publicField$2(this, "editor");
|
|
18871
|
+
__publicField$2(this, "rawCommands");
|
|
18872
|
+
this.editor = props.editor;
|
|
18873
|
+
this.rawCommands = this.editor.extensionService.commands;
|
|
18874
|
+
}
|
|
18875
|
+
/**
|
|
18876
|
+
* Static method for creating a service.
|
|
18877
|
+
* @param args Arguments for the constructor.
|
|
18878
|
+
*/
|
|
18879
|
+
static create(...args) {
|
|
18880
|
+
return new CommandService(...args);
|
|
18881
|
+
}
|
|
18882
|
+
/**
|
|
18883
|
+
* Get editor state.
|
|
18884
|
+
*/
|
|
18885
|
+
get state() {
|
|
18886
|
+
return this.editor.state;
|
|
18887
|
+
}
|
|
18888
|
+
/**
|
|
18889
|
+
* Get all commands with wrapped command method.
|
|
18890
|
+
*/
|
|
18891
|
+
get commands() {
|
|
18892
|
+
const { editor, state: state2 } = this;
|
|
18893
|
+
const { view } = editor;
|
|
18894
|
+
const { tr } = state2;
|
|
18895
|
+
const props = this.createProps(tr);
|
|
18896
|
+
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
18897
|
+
const method = (...args) => {
|
|
18898
|
+
const fn2 = command2(...args)(props);
|
|
18899
|
+
if (!tr.getMeta("preventDispatch")) {
|
|
18900
|
+
view.dispatch(tr);
|
|
18901
|
+
}
|
|
18902
|
+
return fn2;
|
|
18903
|
+
};
|
|
18904
|
+
return [name, method];
|
|
18905
|
+
});
|
|
18906
|
+
return Object.fromEntries(entries);
|
|
18907
|
+
}
|
|
18908
|
+
/**
|
|
18909
|
+
* Create a chain of commands to call multiple commands at once.
|
|
18910
|
+
*/
|
|
18911
|
+
get chain() {
|
|
18912
|
+
return () => this.createChain();
|
|
18913
|
+
}
|
|
18914
|
+
/**
|
|
18915
|
+
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
18916
|
+
*/
|
|
18917
|
+
get can() {
|
|
18918
|
+
return () => this.createCan();
|
|
18919
|
+
}
|
|
18920
|
+
/**
|
|
18921
|
+
* Creates a chain of commands.
|
|
18922
|
+
* @param startTr Start transaction.
|
|
18923
|
+
* @param shouldDispatch Should dispatch or not.
|
|
18924
|
+
*/
|
|
18925
|
+
createChain(startTr, shouldDispatch = true) {
|
|
18926
|
+
const { editor, state: state2, rawCommands } = this;
|
|
18927
|
+
const { view } = editor;
|
|
18928
|
+
const callbacks2 = [];
|
|
18929
|
+
const hasStartTr = !!startTr;
|
|
18930
|
+
const tr = startTr || state2.tr;
|
|
18931
|
+
const run2 = () => {
|
|
18932
|
+
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
18933
|
+
view.dispatch(tr);
|
|
18934
|
+
}
|
|
18935
|
+
return callbacks2.every((cb) => cb === true);
|
|
18936
|
+
};
|
|
18937
|
+
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
18938
|
+
const chainedCommand = (...args) => {
|
|
18939
|
+
const props = this.createProps(tr, shouldDispatch);
|
|
18940
|
+
const callback = command2(...args)(props);
|
|
18941
|
+
callbacks2.push(callback);
|
|
18942
|
+
return chain;
|
|
18943
|
+
};
|
|
18944
|
+
return [name, chainedCommand];
|
|
18945
|
+
});
|
|
18946
|
+
const chain = {
|
|
18947
|
+
...Object.fromEntries(entries),
|
|
18948
|
+
run: run2
|
|
18949
|
+
};
|
|
18950
|
+
return chain;
|
|
18951
|
+
}
|
|
18952
|
+
/**
|
|
18953
|
+
* Creates a can check for commands.
|
|
18954
|
+
* @param startTr Start transaction.
|
|
18955
|
+
*/
|
|
18956
|
+
createCan(startTr) {
|
|
18957
|
+
const { rawCommands, state: state2 } = this;
|
|
18958
|
+
const dispatch = false;
|
|
18959
|
+
const tr = startTr || state2.tr;
|
|
18960
|
+
const props = this.createProps(tr, dispatch);
|
|
18961
|
+
const commands2 = Object.fromEntries(
|
|
18962
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
18963
|
+
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
18964
|
+
})
|
|
18965
|
+
);
|
|
18966
|
+
return {
|
|
18967
|
+
...commands2,
|
|
18968
|
+
chain: () => this.createChain(tr, dispatch)
|
|
18969
|
+
};
|
|
18970
|
+
}
|
|
18971
|
+
/**
|
|
18972
|
+
* Creates default props for the command method.
|
|
18973
|
+
* @param {*} tr Transaction.
|
|
18974
|
+
* @param {*} shouldDispatch Check if should dispatch.
|
|
18975
|
+
* @returns Object with props.
|
|
18976
|
+
*/
|
|
18977
|
+
createProps(tr, shouldDispatch = true) {
|
|
18978
|
+
const { editor, state: state2, rawCommands } = this;
|
|
18979
|
+
const { view } = editor;
|
|
18980
|
+
const props = {
|
|
18981
|
+
tr,
|
|
18982
|
+
editor,
|
|
18983
|
+
view,
|
|
18984
|
+
state: chainableEditorState(tr, state2),
|
|
18985
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
18986
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
18987
|
+
can: () => this.createCan(tr),
|
|
18988
|
+
get commands() {
|
|
18989
|
+
return Object.fromEntries(
|
|
18990
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
18991
|
+
return [name, (...args) => command2(...args)(props)];
|
|
18992
|
+
})
|
|
18993
|
+
);
|
|
18994
|
+
}
|
|
18995
|
+
};
|
|
18996
|
+
return props;
|
|
18997
|
+
}
|
|
18998
|
+
}
|
|
18999
|
+
function getHTMLFromFragment(fragment, schema) {
|
|
19000
|
+
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
19001
|
+
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
19002
|
+
const container = temporaryDocument.createElement("div");
|
|
19003
|
+
container.appendChild(documentFragment);
|
|
19004
|
+
return container.innerHTML;
|
|
19005
|
+
}
|
|
19006
|
+
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
19007
|
+
let textBefore = "";
|
|
19008
|
+
const sliceEndPos = $from.parentOffset;
|
|
19009
|
+
$from.parent.nodesBetween(
|
|
19010
|
+
Math.max(0, sliceEndPos - maxMatch),
|
|
19011
|
+
sliceEndPos,
|
|
19012
|
+
(node2, pos, parent, index2) => {
|
|
19013
|
+
const chunk = node2.type.spec.toText?.({
|
|
19014
|
+
node: node2,
|
|
19015
|
+
pos,
|
|
19016
|
+
parent,
|
|
19017
|
+
index: index2
|
|
19018
|
+
}) || node2.textContent || "%leaf%";
|
|
19019
|
+
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
19020
|
+
}
|
|
19021
|
+
);
|
|
19022
|
+
return textBefore;
|
|
19023
|
+
};
|
|
19024
|
+
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
19025
|
+
const { converter } = editor;
|
|
19026
|
+
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
19027
|
+
let cleanedHtml = convertEmToPt(html);
|
|
19028
|
+
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
19029
|
+
const tempDiv = document.createElement("div");
|
|
19030
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
19031
|
+
const paragraphs = tempDiv.querySelectorAll("p");
|
|
19032
|
+
paragraphs.forEach((p) => {
|
|
19033
|
+
const innerHTML3 = p.innerHTML;
|
|
19034
|
+
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
19035
|
+
const styleAttr = p.getAttribute("style") || "";
|
|
19036
|
+
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
19037
|
+
if (msoListMatch) {
|
|
19038
|
+
const [, abstractId, level] = msoListMatch;
|
|
19039
|
+
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
19040
|
+
if (!listNumId) return;
|
|
19041
|
+
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
19042
|
+
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
19043
|
+
p.setAttribute("data-num-id", listNumId);
|
|
19044
|
+
p.setAttribute("data-list-level", level - 1);
|
|
19045
|
+
p.setAttribute("data-start", start2);
|
|
19046
|
+
p.setAttribute("data-lvl-text", lvlText);
|
|
19047
|
+
p.setAttribute("data-num-fmt", numFmt);
|
|
19048
|
+
}
|
|
19049
|
+
extractAndRemoveConditionalPrefix(p);
|
|
19050
|
+
});
|
|
19051
|
+
transformWordLists(tempDiv);
|
|
19052
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
19053
|
+
tempDiv.remove();
|
|
19054
|
+
const { dispatch } = editor.view;
|
|
19055
|
+
if (!dispatch) return false;
|
|
19056
|
+
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
19057
|
+
return true;
|
|
19058
|
+
};
|
|
19059
|
+
const getLevelDefinition = (abstractDefinition, level) => {
|
|
19060
|
+
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
19061
|
+
const levelElement = abstractDefinition.elements.find((el) => {
|
|
19062
|
+
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
19063
|
+
});
|
|
19064
|
+
if (!levelElement) return null;
|
|
19065
|
+
const { elements } = levelElement;
|
|
19066
|
+
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
19067
|
+
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
19068
|
+
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
19069
|
+
return { lvlText, start: start2, numFmt, elements };
|
|
19070
|
+
};
|
|
19071
|
+
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
19072
|
+
const { definitions } = editor?.converter?.numbering;
|
|
19073
|
+
if (!definitions) return null;
|
|
19074
|
+
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
19075
|
+
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
19076
|
+
});
|
|
19077
|
+
return matchedDefinition?.attributes?.["w:numId"];
|
|
19078
|
+
};
|
|
19079
|
+
const getListAbstractDefinition = (abstractId, editor) => {
|
|
19080
|
+
const { abstracts = {} } = editor?.converter?.numbering;
|
|
19081
|
+
return abstracts[abstractId] || null;
|
|
19082
|
+
};
|
|
19083
|
+
const transformWordLists = (container) => {
|
|
19084
|
+
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
19085
|
+
const listMap = /* @__PURE__ */ new Map();
|
|
19086
|
+
const listLevels = {};
|
|
19087
|
+
for (const p of paragraphs) {
|
|
19088
|
+
const listId = p.getAttribute("data-num-id");
|
|
19089
|
+
const level = parseInt(p.getAttribute("data-list-level"));
|
|
19090
|
+
const numFmt = p.getAttribute("data-num-fmt");
|
|
19091
|
+
const start2 = p.getAttribute("data-start");
|
|
19092
|
+
const lvlText = p.getAttribute("data-lvl-text");
|
|
19093
|
+
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
19094
|
+
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
19095
|
+
}
|
|
19096
|
+
for (const [id, items] of listMap.entries()) {
|
|
19097
|
+
if (!listLevels[id]) {
|
|
19098
|
+
listLevels[id] = {
|
|
19099
|
+
stack: [],
|
|
19100
|
+
counts: {},
|
|
19101
|
+
prevLevel: null
|
|
19102
|
+
};
|
|
19103
|
+
}
|
|
19104
|
+
const parentStack = [];
|
|
19105
|
+
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
19106
|
+
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
19107
|
+
const li = document.createElement("li");
|
|
19108
|
+
li.innerHTML = p.innerHTML;
|
|
19109
|
+
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
19110
|
+
li.setAttribute("data-num-id", id);
|
|
19111
|
+
li.setAttribute("data-lvl-text", lvlText);
|
|
19112
|
+
li.setAttribute("data-num-fmt", numFmt);
|
|
19113
|
+
if (p.hasAttribute("data-font-family")) {
|
|
19114
|
+
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
19115
|
+
}
|
|
19116
|
+
if (p.hasAttribute("data-font-size")) {
|
|
19117
|
+
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
19118
|
+
}
|
|
19119
|
+
const parentNode2 = p.parentNode;
|
|
19120
|
+
let listForLevel = parentStack[level];
|
|
19121
|
+
if (!listForLevel) {
|
|
19122
|
+
const newList = document.createElement("ol");
|
|
19123
|
+
newList.setAttribute("data-list-id", id);
|
|
19124
|
+
newList.level = level;
|
|
19125
|
+
if (level > 0) {
|
|
19126
|
+
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
19127
|
+
if (parentLi) parentLi.appendChild(newList);
|
|
19128
|
+
} else {
|
|
19129
|
+
parentNode2.insertBefore(newList, p);
|
|
19130
|
+
}
|
|
19131
|
+
parentStack[level] = newList;
|
|
19132
|
+
parentStack.length = level + 1;
|
|
19133
|
+
listForLevel = newList;
|
|
19134
|
+
}
|
|
19135
|
+
listForLevel.appendChild(li);
|
|
19136
|
+
p.remove();
|
|
19137
|
+
});
|
|
19138
|
+
}
|
|
19139
|
+
};
|
|
19140
|
+
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
19141
|
+
const levelState = listLevels[listId];
|
|
19142
|
+
if (!levelState.stack) levelState.stack = [];
|
|
19143
|
+
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
19144
|
+
if (levelState.prevLevel === null) {
|
|
19145
|
+
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
19146
|
+
} else {
|
|
19147
|
+
if (currentLevel > levelState.prevLevel) {
|
|
19148
|
+
levelState.stack.push(1);
|
|
19149
|
+
} else if (currentLevel === levelState.prevLevel) {
|
|
19150
|
+
levelState.stack[levelState.stack.length - 1]++;
|
|
19151
|
+
} else {
|
|
19152
|
+
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
19153
|
+
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
19154
|
+
}
|
|
19155
|
+
}
|
|
19156
|
+
levelState.prevLevel = currentLevel;
|
|
19157
|
+
return [...levelState.stack];
|
|
19158
|
+
}
|
|
19159
|
+
function extractAndRemoveConditionalPrefix(p) {
|
|
19160
|
+
const nodes = Array.from(p.childNodes);
|
|
19161
|
+
let fontFamily2 = null;
|
|
19162
|
+
let fontSize2 = null;
|
|
19163
|
+
let start2 = -1, end2 = -1;
|
|
19164
|
+
nodes.forEach((node2, index2) => {
|
|
19165
|
+
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
19166
|
+
start2 = index2;
|
|
19167
|
+
}
|
|
19168
|
+
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
19169
|
+
end2 = index2;
|
|
19170
|
+
}
|
|
19171
|
+
});
|
|
19172
|
+
if (start2 !== -1 && end2 !== -1) {
|
|
19173
|
+
for (let i = start2 + 1; i < end2; i++) {
|
|
19174
|
+
const node2 = nodes[i];
|
|
19175
|
+
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
19176
|
+
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
19177
|
+
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
19178
|
+
}
|
|
19179
|
+
}
|
|
19180
|
+
for (let i = end2; i >= start2; i--) {
|
|
19181
|
+
p.removeChild(p.childNodes[i]);
|
|
19182
|
+
}
|
|
19183
|
+
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
19184
|
+
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
19185
|
+
}
|
|
19186
|
+
}
|
|
19187
|
+
class InputRule {
|
|
19188
|
+
constructor(config) {
|
|
19189
|
+
__publicField$2(this, "match");
|
|
19190
|
+
__publicField$2(this, "handler");
|
|
19191
|
+
this.match = config.match;
|
|
19192
|
+
this.handler = config.handler;
|
|
19193
|
+
}
|
|
19194
|
+
}
|
|
19195
|
+
const inputRuleMatcherHandler = (text, match) => {
|
|
19196
|
+
if (isRegExp(match)) {
|
|
19197
|
+
return match.exec(text);
|
|
19198
|
+
}
|
|
19199
|
+
const inputRuleMatch = match(text);
|
|
19200
|
+
if (!inputRuleMatch) {
|
|
19201
|
+
return null;
|
|
19202
|
+
}
|
|
19203
|
+
const result = [inputRuleMatch.text];
|
|
19204
|
+
result.index = inputRuleMatch.index;
|
|
19205
|
+
result.input = text;
|
|
19206
|
+
result.data = inputRuleMatch.data;
|
|
19207
|
+
if (inputRuleMatch.replaceWith) {
|
|
19208
|
+
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
19209
|
+
console.warn(
|
|
19210
|
+
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
19211
|
+
);
|
|
19212
|
+
}
|
|
19213
|
+
result.push(inputRuleMatch.replaceWith);
|
|
19214
|
+
}
|
|
19215
|
+
return result;
|
|
19216
|
+
};
|
|
19217
|
+
const run = (config) => {
|
|
19218
|
+
const {
|
|
19219
|
+
editor,
|
|
19220
|
+
from: from2,
|
|
19221
|
+
to,
|
|
19222
|
+
text,
|
|
19223
|
+
rules,
|
|
19224
|
+
plugin: plugin2
|
|
19225
|
+
} = config;
|
|
19226
|
+
const { view } = editor;
|
|
19227
|
+
if (view.composing) {
|
|
19228
|
+
return false;
|
|
19229
|
+
}
|
|
19230
|
+
const $from = view.state.doc.resolve(from2);
|
|
19231
|
+
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
19232
|
+
return false;
|
|
19233
|
+
}
|
|
19234
|
+
let matched = false;
|
|
19235
|
+
const textBefore = getTextContentFromNodes($from) + text;
|
|
19236
|
+
rules.forEach((rule) => {
|
|
19237
|
+
if (matched) {
|
|
19238
|
+
return;
|
|
19239
|
+
}
|
|
19240
|
+
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
19241
|
+
if (!match) {
|
|
19242
|
+
return;
|
|
19243
|
+
}
|
|
19244
|
+
const tr = view.state.tr;
|
|
19245
|
+
const state2 = chainableEditorState(tr, view.state);
|
|
19246
|
+
const range2 = {
|
|
19247
|
+
from: from2 - (match[0].length - text.length),
|
|
19248
|
+
to
|
|
19249
|
+
};
|
|
19250
|
+
const { commands: commands2, chain, can } = new CommandService({
|
|
19251
|
+
editor,
|
|
19252
|
+
state: state2
|
|
19253
|
+
});
|
|
19254
|
+
const handler = rule.handler({
|
|
19255
|
+
state: state2,
|
|
19256
|
+
range: range2,
|
|
19257
|
+
match,
|
|
19258
|
+
commands: commands2,
|
|
19259
|
+
chain,
|
|
19260
|
+
can
|
|
19261
|
+
});
|
|
19262
|
+
if (handler === null || !tr.steps.length) {
|
|
19263
|
+
return;
|
|
19264
|
+
}
|
|
19265
|
+
tr.setMeta(plugin2, {
|
|
19266
|
+
transform: tr,
|
|
19267
|
+
from: from2,
|
|
19268
|
+
to,
|
|
19269
|
+
text
|
|
19270
|
+
});
|
|
19271
|
+
view.dispatch(tr);
|
|
19272
|
+
matched = true;
|
|
19273
|
+
});
|
|
19274
|
+
return matched;
|
|
19275
|
+
};
|
|
19276
|
+
const inputRulesPlugin = ({ editor, rules }) => {
|
|
19277
|
+
const plugin2 = new Plugin({
|
|
19278
|
+
key: new PluginKey("inputRulesPlugin"),
|
|
19279
|
+
state: {
|
|
19280
|
+
init() {
|
|
19281
|
+
return null;
|
|
19282
|
+
},
|
|
19283
|
+
apply(tr, prev, state2) {
|
|
19284
|
+
const stored = tr.getMeta(plugin2);
|
|
19285
|
+
if (stored) {
|
|
19286
|
+
return stored;
|
|
19287
|
+
}
|
|
19288
|
+
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
19289
|
+
const isSimulatedInput = !!simulatedInputMeta;
|
|
19290
|
+
if (isSimulatedInput) {
|
|
19291
|
+
setTimeout(() => {
|
|
19292
|
+
let { text } = simulatedInputMeta;
|
|
19293
|
+
if (typeof text !== "string") {
|
|
19294
|
+
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
19295
|
+
}
|
|
19296
|
+
const { from: from2 } = simulatedInputMeta;
|
|
19297
|
+
const to = from2 + text.length;
|
|
19298
|
+
run({
|
|
19299
|
+
editor,
|
|
19300
|
+
from: from2,
|
|
19301
|
+
to,
|
|
19302
|
+
text,
|
|
19303
|
+
rules,
|
|
19304
|
+
plugin: plugin2
|
|
19305
|
+
});
|
|
19306
|
+
});
|
|
19307
|
+
}
|
|
19308
|
+
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
19309
|
+
}
|
|
19310
|
+
},
|
|
19311
|
+
props: {
|
|
19312
|
+
handleTextInput(view, from2, to, text) {
|
|
19313
|
+
return run({
|
|
19314
|
+
editor,
|
|
19315
|
+
from: from2,
|
|
19316
|
+
to,
|
|
19317
|
+
text,
|
|
19318
|
+
rules,
|
|
19319
|
+
plugin: plugin2
|
|
19320
|
+
});
|
|
19321
|
+
},
|
|
19322
|
+
// add support for input rules to trigger on enter
|
|
19323
|
+
// this is useful for example for code blocks
|
|
19324
|
+
handleKeyDown(view, event) {
|
|
19325
|
+
if (event.key !== "Enter") {
|
|
19326
|
+
return false;
|
|
19327
|
+
}
|
|
19328
|
+
const { $cursor } = view.state.selection;
|
|
19329
|
+
if ($cursor) {
|
|
19330
|
+
return run({
|
|
19331
|
+
editor,
|
|
19332
|
+
from: $cursor.pos,
|
|
19333
|
+
to: $cursor.pos,
|
|
19334
|
+
text: "\n",
|
|
19335
|
+
rules,
|
|
19336
|
+
plugin: plugin2
|
|
19337
|
+
});
|
|
19338
|
+
}
|
|
19339
|
+
return false;
|
|
19340
|
+
},
|
|
19341
|
+
// Paste handler
|
|
19342
|
+
handlePaste(view, event, slice2) {
|
|
19343
|
+
const clipboard = event.clipboardData;
|
|
19344
|
+
const html = clipboard.getData("text/html");
|
|
19345
|
+
clipboard.getData("text/plain");
|
|
19346
|
+
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
19347
|
+
if (fieldAnnotationContent.length) {
|
|
19348
|
+
return false;
|
|
19349
|
+
}
|
|
19350
|
+
let source;
|
|
19351
|
+
if (!html) {
|
|
19352
|
+
source = "plain-text";
|
|
19353
|
+
} else if (isWordHtml(html)) {
|
|
19354
|
+
source = "word-html";
|
|
19355
|
+
} else {
|
|
19356
|
+
source = "browser-html";
|
|
19357
|
+
}
|
|
19358
|
+
switch (source) {
|
|
19359
|
+
case "plain-text":
|
|
19360
|
+
break;
|
|
19361
|
+
case "word-html":
|
|
19362
|
+
if (editor.options.mode === "docx") {
|
|
19363
|
+
return handleDocxPaste(html, editor, view, plugin2);
|
|
19364
|
+
}
|
|
19365
|
+
case "browser-html":
|
|
19366
|
+
return handleHtmlPaste$1(html, editor);
|
|
19367
|
+
}
|
|
19368
|
+
return false;
|
|
19369
|
+
}
|
|
19370
|
+
},
|
|
19371
|
+
isInputRules: true
|
|
19372
|
+
});
|
|
19373
|
+
return plugin2;
|
|
19374
|
+
};
|
|
19375
|
+
function isWordHtml(html) {
|
|
19376
|
+
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
19377
|
+
}
|
|
19378
|
+
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
19379
|
+
const htmlWithPtSizing = convertEmToPt(html);
|
|
19380
|
+
const cleanedHtml = sanitizeHtml(htmlWithPtSizing);
|
|
19381
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
19382
|
+
const { dispatch } = editor.view;
|
|
19383
|
+
if (!dispatch) return false;
|
|
19384
|
+
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
19385
|
+
return true;
|
|
19386
|
+
};
|
|
19387
|
+
const convertEmToPt = (html) => {
|
|
19388
|
+
return html.replace(
|
|
19389
|
+
/font-size\s*:\s*([\d.]+)em/gi,
|
|
19390
|
+
(_, emValue) => {
|
|
19391
|
+
const em = parseFloat(emValue);
|
|
19392
|
+
const pt = Math.round(em * 12 * 100) / 100;
|
|
19393
|
+
return `font-size: ${pt}pt`;
|
|
19394
|
+
}
|
|
19395
|
+
);
|
|
19396
|
+
};
|
|
19397
|
+
function cleanHtmlUnnecessaryTags(html) {
|
|
19398
|
+
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
19399
|
+
}
|
|
19400
|
+
function sanitizeHtml(html, forbiddenTags = ["meta", "svg", "script", "style", "button"]) {
|
|
19401
|
+
const container = document.createElement("div");
|
|
19402
|
+
container.innerHTML = html;
|
|
19403
|
+
const walkAndClean = (node2) => {
|
|
19404
|
+
for (const child of [...node2.children]) {
|
|
19405
|
+
if (forbiddenTags.includes(child.tagName.toLowerCase())) {
|
|
19406
|
+
child.remove();
|
|
19407
|
+
continue;
|
|
19408
|
+
}
|
|
19409
|
+
if (child.hasAttribute("linebreaktype")) {
|
|
19410
|
+
child.removeAttribute("linebreaktype");
|
|
19411
|
+
}
|
|
19412
|
+
walkAndClean(child);
|
|
19413
|
+
}
|
|
19414
|
+
};
|
|
19415
|
+
walkAndClean(container);
|
|
19416
|
+
return container;
|
|
19417
|
+
}
|
|
18841
19418
|
function exportSchemaToJson(params2) {
|
|
18842
19419
|
const { type: type2 } = params2.node || {};
|
|
18843
19420
|
const router = {
|
|
@@ -18875,13 +19452,13 @@ function exportSchemaToJson(params2) {
|
|
|
18875
19452
|
function translateBodyNode(params2) {
|
|
18876
19453
|
let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
|
|
18877
19454
|
if (params2.converter) {
|
|
18878
|
-
const hasHeader = sectPr
|
|
19455
|
+
const hasHeader = sectPr?.elements?.some((n) => n.name === "w:headerReference");
|
|
18879
19456
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
18880
19457
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
18881
19458
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
18882
19459
|
sectPr.elements.push(defaultHeader);
|
|
18883
19460
|
}
|
|
18884
|
-
const hasFooter = sectPr
|
|
19461
|
+
const hasFooter = sectPr?.elements?.some((n) => n.name === "w:footerReference");
|
|
18885
19462
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
18886
19463
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
18887
19464
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
@@ -20181,12 +20758,11 @@ function prepareHtmlAnnotation(params2) {
|
|
|
20181
20758
|
node: { attrs = {}, marks = [] },
|
|
20182
20759
|
editorSchema
|
|
20183
20760
|
} = params2;
|
|
20184
|
-
const
|
|
20185
|
-
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, "text/html");
|
|
20761
|
+
const paragraphHtmlContainer = sanitizeHtml(attrs.rawHtml);
|
|
20186
20762
|
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
20187
20763
|
const allMarks = [...marks, ...marksFromAttrs];
|
|
20188
20764
|
let state2 = EditorState.create({
|
|
20189
|
-
doc: DOMParser$1.fromSchema(editorSchema).parse(
|
|
20765
|
+
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtmlContainer)
|
|
20190
20766
|
});
|
|
20191
20767
|
if (allMarks.length) {
|
|
20192
20768
|
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
@@ -23241,7 +23817,7 @@ function addDefaultStylesIfMissing(styles) {
|
|
|
23241
23817
|
});
|
|
23242
23818
|
return updatedStyles;
|
|
23243
23819
|
}
|
|
23244
|
-
const importHeadersFooters = (docx, converter,
|
|
23820
|
+
const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
23245
23821
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
23246
23822
|
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
23247
23823
|
const { elements } = relationships;
|
|
@@ -23251,6 +23827,9 @@ const importHeadersFooters = (docx, converter, editor) => {
|
|
|
23251
23827
|
const footers = elements.filter((el) => el.attributes["Type"] === footerType);
|
|
23252
23828
|
const sectPr = findSectPr(docx["word/document.xml"]) || [];
|
|
23253
23829
|
const allSectPrElements = sectPr.flatMap((el) => el.elements);
|
|
23830
|
+
if (!mainEditor) return;
|
|
23831
|
+
const editor = { ...mainEditor };
|
|
23832
|
+
editor.options.annotations = true;
|
|
23254
23833
|
headers.forEach((header) => {
|
|
23255
23834
|
const { rId, referenceFile, currentFileName } = getHeaderFooterSectionData(header, docx);
|
|
23256
23835
|
const sectPrHeader = allSectPrElements.find((el) => el.name === "w:headerReference" && el.attributes["r:id"] === rId);
|
|
@@ -23410,7 +23989,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
23410
23989
|
return;
|
|
23411
23990
|
}
|
|
23412
23991
|
}
|
|
23413
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.
|
|
23992
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2-rev10") {
|
|
23414
23993
|
const customLocation = "docProps/custom.xml";
|
|
23415
23994
|
if (!docx[customLocation]) {
|
|
23416
23995
|
docx[customLocation] = generateCustomXml();
|
|
@@ -23877,7 +24456,7 @@ function storeSuperdocVersion(docx) {
|
|
|
23877
24456
|
function generateCustomXml() {
|
|
23878
24457
|
return DEFAULT_CUSTOM_XML;
|
|
23879
24458
|
}
|
|
23880
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.13.
|
|
24459
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.13.2-rev10") {
|
|
23881
24460
|
return {
|
|
23882
24461
|
type: "element",
|
|
23883
24462
|
name: "property",
|
|
@@ -26410,7 +26989,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
26410
26989
|
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
26411
26990
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
26412
26991
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
26413
|
-
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
26992
|
+
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
26414
26993
|
function getMarksFromSelection(state2) {
|
|
26415
26994
|
const { from: from2, to, empty: empty2 } = state2.selection;
|
|
26416
26995
|
const marks = [];
|
|
@@ -27599,164 +28178,6 @@ createMarksSchema_fn = function(markExtensions, attributes, editor) {
|
|
|
27599
28178
|
};
|
|
27600
28179
|
__privateAdd$1(_Schema, _Schema_static);
|
|
27601
28180
|
let Schema2 = _Schema;
|
|
27602
|
-
function chainableEditorState(transaction, state2) {
|
|
27603
|
-
let { selection, doc: doc2, storedMarks } = transaction;
|
|
27604
|
-
return {
|
|
27605
|
-
...state2,
|
|
27606
|
-
apply: state2.apply.bind(state2),
|
|
27607
|
-
applyTransaction: state2.applyTransaction.bind(state2),
|
|
27608
|
-
plugins: state2.plugins,
|
|
27609
|
-
schema: state2.schema,
|
|
27610
|
-
reconfigure: state2.reconfigure.bind(state2),
|
|
27611
|
-
toJSON: state2.toJSON.bind(state2),
|
|
27612
|
-
get storedMarks() {
|
|
27613
|
-
return storedMarks;
|
|
27614
|
-
},
|
|
27615
|
-
get selection() {
|
|
27616
|
-
return selection;
|
|
27617
|
-
},
|
|
27618
|
-
get doc() {
|
|
27619
|
-
return doc2;
|
|
27620
|
-
},
|
|
27621
|
-
get tr() {
|
|
27622
|
-
selection = transaction.selection;
|
|
27623
|
-
doc2 = transaction.doc;
|
|
27624
|
-
storedMarks = transaction.storedMarks;
|
|
27625
|
-
return transaction;
|
|
27626
|
-
}
|
|
27627
|
-
};
|
|
27628
|
-
}
|
|
27629
|
-
class CommandService {
|
|
27630
|
-
constructor(props) {
|
|
27631
|
-
__publicField$1(this, "editor");
|
|
27632
|
-
__publicField$1(this, "rawCommands");
|
|
27633
|
-
this.editor = props.editor;
|
|
27634
|
-
this.rawCommands = this.editor.extensionService.commands;
|
|
27635
|
-
}
|
|
27636
|
-
/**
|
|
27637
|
-
* Static method for creating a service.
|
|
27638
|
-
* @param args Arguments for the constructor.
|
|
27639
|
-
*/
|
|
27640
|
-
static create(...args) {
|
|
27641
|
-
return new CommandService(...args);
|
|
27642
|
-
}
|
|
27643
|
-
/**
|
|
27644
|
-
* Get editor state.
|
|
27645
|
-
*/
|
|
27646
|
-
get state() {
|
|
27647
|
-
return this.editor.state;
|
|
27648
|
-
}
|
|
27649
|
-
/**
|
|
27650
|
-
* Get all commands with wrapped command method.
|
|
27651
|
-
*/
|
|
27652
|
-
get commands() {
|
|
27653
|
-
const { editor, state: state2 } = this;
|
|
27654
|
-
const { view } = editor;
|
|
27655
|
-
const { tr } = state2;
|
|
27656
|
-
const props = this.createProps(tr);
|
|
27657
|
-
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
27658
|
-
const method = (...args) => {
|
|
27659
|
-
const fn2 = command2(...args)(props);
|
|
27660
|
-
if (!tr.getMeta("preventDispatch")) {
|
|
27661
|
-
view.dispatch(tr);
|
|
27662
|
-
}
|
|
27663
|
-
return fn2;
|
|
27664
|
-
};
|
|
27665
|
-
return [name, method];
|
|
27666
|
-
});
|
|
27667
|
-
return Object.fromEntries(entries);
|
|
27668
|
-
}
|
|
27669
|
-
/**
|
|
27670
|
-
* Create a chain of commands to call multiple commands at once.
|
|
27671
|
-
*/
|
|
27672
|
-
get chain() {
|
|
27673
|
-
return () => this.createChain();
|
|
27674
|
-
}
|
|
27675
|
-
/**
|
|
27676
|
-
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
27677
|
-
*/
|
|
27678
|
-
get can() {
|
|
27679
|
-
return () => this.createCan();
|
|
27680
|
-
}
|
|
27681
|
-
/**
|
|
27682
|
-
* Creates a chain of commands.
|
|
27683
|
-
* @param startTr Start transaction.
|
|
27684
|
-
* @param shouldDispatch Should dispatch or not.
|
|
27685
|
-
*/
|
|
27686
|
-
createChain(startTr, shouldDispatch = true) {
|
|
27687
|
-
const { editor, state: state2, rawCommands } = this;
|
|
27688
|
-
const { view } = editor;
|
|
27689
|
-
const callbacks2 = [];
|
|
27690
|
-
const hasStartTr = !!startTr;
|
|
27691
|
-
const tr = startTr || state2.tr;
|
|
27692
|
-
const run2 = () => {
|
|
27693
|
-
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
27694
|
-
view.dispatch(tr);
|
|
27695
|
-
}
|
|
27696
|
-
return callbacks2.every((cb) => cb === true);
|
|
27697
|
-
};
|
|
27698
|
-
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
27699
|
-
const chainedCommand = (...args) => {
|
|
27700
|
-
const props = this.createProps(tr, shouldDispatch);
|
|
27701
|
-
const callback = command2(...args)(props);
|
|
27702
|
-
callbacks2.push(callback);
|
|
27703
|
-
return chain;
|
|
27704
|
-
};
|
|
27705
|
-
return [name, chainedCommand];
|
|
27706
|
-
});
|
|
27707
|
-
const chain = {
|
|
27708
|
-
...Object.fromEntries(entries),
|
|
27709
|
-
run: run2
|
|
27710
|
-
};
|
|
27711
|
-
return chain;
|
|
27712
|
-
}
|
|
27713
|
-
/**
|
|
27714
|
-
* Creates a can check for commands.
|
|
27715
|
-
* @param startTr Start transaction.
|
|
27716
|
-
*/
|
|
27717
|
-
createCan(startTr) {
|
|
27718
|
-
const { rawCommands, state: state2 } = this;
|
|
27719
|
-
const dispatch = false;
|
|
27720
|
-
const tr = startTr || state2.tr;
|
|
27721
|
-
const props = this.createProps(tr, dispatch);
|
|
27722
|
-
const commands2 = Object.fromEntries(
|
|
27723
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27724
|
-
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
27725
|
-
})
|
|
27726
|
-
);
|
|
27727
|
-
return {
|
|
27728
|
-
...commands2,
|
|
27729
|
-
chain: () => this.createChain(tr, dispatch)
|
|
27730
|
-
};
|
|
27731
|
-
}
|
|
27732
|
-
/**
|
|
27733
|
-
* Creates default props for the command method.
|
|
27734
|
-
* @param {*} tr Transaction.
|
|
27735
|
-
* @param {*} shouldDispatch Check if should dispatch.
|
|
27736
|
-
* @returns Object with props.
|
|
27737
|
-
*/
|
|
27738
|
-
createProps(tr, shouldDispatch = true) {
|
|
27739
|
-
const { editor, state: state2, rawCommands } = this;
|
|
27740
|
-
const { view } = editor;
|
|
27741
|
-
const props = {
|
|
27742
|
-
tr,
|
|
27743
|
-
editor,
|
|
27744
|
-
view,
|
|
27745
|
-
state: chainableEditorState(tr, state2),
|
|
27746
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
27747
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
27748
|
-
can: () => this.createCan(tr),
|
|
27749
|
-
get commands() {
|
|
27750
|
-
return Object.fromEntries(
|
|
27751
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27752
|
-
return [name, (...args) => command2(...args)(props)];
|
|
27753
|
-
})
|
|
27754
|
-
);
|
|
27755
|
-
}
|
|
27756
|
-
};
|
|
27757
|
-
return props;
|
|
27758
|
-
}
|
|
27759
|
-
}
|
|
27760
28181
|
const first = (commands2) => (props) => {
|
|
27761
28182
|
const items = typeof commands2 === "function" ? commands2(props) : commands2;
|
|
27762
28183
|
for (let i = 0; i < items.length; i += 1) {
|
|
@@ -28118,7 +28539,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28118
28539
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
28119
28540
|
wrap2 = Fragment.from(conn[i].create(null, wrap2));
|
|
28120
28541
|
wrap2 = Fragment.from(before.copy(wrap2));
|
|
28121
|
-
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
28542
|
+
let tr = state2.tr.step(new ReplaceAroundStep$1($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
28122
28543
|
let $joinAt = tr.doc.resolve(end2 + 2 * conn.length);
|
|
28123
28544
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
|
|
28124
28545
|
tr.join($joinAt.pos);
|
|
@@ -28149,7 +28570,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28149
28570
|
let end2 = Fragment.empty;
|
|
28150
28571
|
for (let i = wrap2.length - 1; i >= 0; i--)
|
|
28151
28572
|
end2 = Fragment.from(wrap2[i].copy(end2));
|
|
28152
|
-
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end2, wrap2.length, 0), 0, true));
|
|
28573
|
+
let tr = state2.tr.step(new ReplaceAroundStep$1($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end2, wrap2.length, 0), 0, true));
|
|
28153
28574
|
dispatch(tr.scrollIntoView());
|
|
28154
28575
|
}
|
|
28155
28576
|
return true;
|
|
@@ -28722,7 +29143,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
28722
29143
|
return;
|
|
28723
29144
|
}
|
|
28724
29145
|
const step = tr.steps[last];
|
|
28725
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
29146
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1)) {
|
|
28726
29147
|
return;
|
|
28727
29148
|
}
|
|
28728
29149
|
const map22 = tr.mapping.maps[last];
|
|
@@ -28868,7 +29289,7 @@ function doWrapInList(tr, range2, wrappers, joinBefore, listType) {
|
|
|
28868
29289
|
let content = Fragment.empty;
|
|
28869
29290
|
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
28870
29291
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
28871
|
-
tr.step(new ReplaceAroundStep(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
29292
|
+
tr.step(new ReplaceAroundStep$1(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
28872
29293
|
let found2 = 0;
|
|
28873
29294
|
for (let i = 0; i < wrappers.length; i++)
|
|
28874
29295
|
if (wrappers[i].type == listType)
|
|
@@ -28901,7 +29322,7 @@ function liftListItem$1(itemType) {
|
|
|
28901
29322
|
function liftToOuterList(state2, dispatch, itemType, range2) {
|
|
28902
29323
|
let tr = state2.tr, end2 = range2.end, endOfList = range2.$to.end(range2.depth);
|
|
28903
29324
|
if (end2 < endOfList) {
|
|
28904
|
-
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
29325
|
+
tr.step(new ReplaceAroundStep$1(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
28905
29326
|
range2 = new NodeRange(tr.doc.resolve(range2.$from.pos), tr.doc.resolve(endOfList), range2.depth);
|
|
28906
29327
|
}
|
|
28907
29328
|
const target = liftTarget(range2);
|
|
@@ -28928,7 +29349,7 @@ function liftOutOfList(state2, dispatch, range2) {
|
|
|
28928
29349
|
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))
|
|
28929
29350
|
return false;
|
|
28930
29351
|
let start2 = $start.pos, end2 = start2 + item.nodeSize;
|
|
28931
|
-
tr.step(new ReplaceAroundStep(start2 - (atStart ? 1 : 0), end2 + (atEnd ? 1 : 0), start2 + 1, end2 - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
29352
|
+
tr.step(new ReplaceAroundStep$1(start2 - (atStart ? 1 : 0), end2 + (atEnd ? 1 : 0), start2 + 1, end2 - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
28932
29353
|
dispatch(tr.scrollIntoView());
|
|
28933
29354
|
return true;
|
|
28934
29355
|
}
|
|
@@ -28949,7 +29370,7 @@ function sinkListItem$1(itemType) {
|
|
|
28949
29370
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
28950
29371
|
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
28951
29372
|
let before = range2.start, after = range2.end;
|
|
28952
|
-
dispatch(state2.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
29373
|
+
dispatch(state2.tr.step(new ReplaceAroundStep$1(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
28953
29374
|
}
|
|
28954
29375
|
return true;
|
|
28955
29376
|
};
|
|
@@ -36542,7 +36963,8 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
|
|
|
36542
36963
|
binding.mapping
|
|
36543
36964
|
);
|
|
36544
36965
|
if (anchor !== null && head !== null) {
|
|
36545
|
-
|
|
36966
|
+
const sel = TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
|
|
36967
|
+
tr.setSelection(sel);
|
|
36546
36968
|
}
|
|
36547
36969
|
}
|
|
36548
36970
|
}
|
|
@@ -37323,7 +37745,7 @@ const setMeta = (view, key, value) => {
|
|
|
37323
37745
|
};
|
|
37324
37746
|
const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
37325
37747
|
if (pos === 0) {
|
|
37326
|
-
return Y__namespace.createRelativePositionFromTypeIndex(type2, 0, -1);
|
|
37748
|
+
return Y__namespace.createRelativePositionFromTypeIndex(type2, 0, type2.length === 0 ? -1 : 0);
|
|
37327
37749
|
}
|
|
37328
37750
|
let n = type2._first === null ? null : (
|
|
37329
37751
|
/** @type {Y.ContentType} */
|
|
@@ -37332,7 +37754,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37332
37754
|
while (n !== null && type2 !== n) {
|
|
37333
37755
|
if (n instanceof Y__namespace.XmlText) {
|
|
37334
37756
|
if (n._length >= pos) {
|
|
37335
|
-
return Y__namespace.createRelativePositionFromTypeIndex(n, pos, -1);
|
|
37757
|
+
return Y__namespace.createRelativePositionFromTypeIndex(n, pos, type2.length === 0 ? -1 : 0);
|
|
37336
37758
|
} else {
|
|
37337
37759
|
pos -= n._length;
|
|
37338
37760
|
}
|
|
@@ -37396,7 +37818,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37396
37818
|
return createRelativePosition(n._item.parent, n._item);
|
|
37397
37819
|
}
|
|
37398
37820
|
}
|
|
37399
|
-
return Y__namespace.createRelativePositionFromTypeIndex(type2, type2._length, -1);
|
|
37821
|
+
return Y__namespace.createRelativePositionFromTypeIndex(type2, type2._length, type2.length === 0 ? -1 : 0);
|
|
37400
37822
|
};
|
|
37401
37823
|
const createRelativePosition = (type2, item) => {
|
|
37402
37824
|
let typeid = null;
|
|
@@ -37878,523 +38300,120 @@ var shift = {
|
|
|
37878
38300
|
186: ":",
|
|
37879
38301
|
187: "+",
|
|
37880
38302
|
188: "<",
|
|
37881
|
-
189: "_",
|
|
37882
|
-
190: ">",
|
|
37883
|
-
191: "?",
|
|
37884
|
-
192: "~",
|
|
37885
|
-
219: "{",
|
|
37886
|
-
220: "|",
|
|
37887
|
-
221: "}",
|
|
37888
|
-
222: '"'
|
|
37889
|
-
};
|
|
37890
|
-
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
37891
|
-
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
37892
|
-
for (var i = 0; i < 10; i++) base$1[48 + i] = base$1[96 + i] = String(i);
|
|
37893
|
-
for (var i = 1; i <= 24; i++) base$1[i + 111] = "F" + i;
|
|
37894
|
-
for (var i = 65; i <= 90; i++) {
|
|
37895
|
-
base$1[i] = String.fromCharCode(i + 32);
|
|
37896
|
-
shift[i] = String.fromCharCode(i);
|
|
37897
|
-
}
|
|
37898
|
-
for (var code in base$1) if (!shift.hasOwnProperty(code)) shift[code] = base$1[code];
|
|
37899
|
-
function keyName(event) {
|
|
37900
|
-
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
37901
|
-
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$1)[event.keyCode] || event.key || "Unidentified";
|
|
37902
|
-
if (name == "Esc") name = "Escape";
|
|
37903
|
-
if (name == "Del") name = "Delete";
|
|
37904
|
-
if (name == "Left") name = "ArrowLeft";
|
|
37905
|
-
if (name == "Up") name = "ArrowUp";
|
|
37906
|
-
if (name == "Right") name = "ArrowRight";
|
|
37907
|
-
if (name == "Down") name = "ArrowDown";
|
|
37908
|
-
return name;
|
|
37909
|
-
}
|
|
37910
|
-
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
37911
|
-
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
37912
|
-
function normalizeKeyName(name) {
|
|
37913
|
-
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
37914
|
-
if (result == "Space")
|
|
37915
|
-
result = " ";
|
|
37916
|
-
let alt, ctrl, shift2, meta;
|
|
37917
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
37918
|
-
let mod = parts[i];
|
|
37919
|
-
if (/^(cmd|meta|m)$/i.test(mod))
|
|
37920
|
-
meta = true;
|
|
37921
|
-
else if (/^a(lt)?$/i.test(mod))
|
|
37922
|
-
alt = true;
|
|
37923
|
-
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
37924
|
-
ctrl = true;
|
|
37925
|
-
else if (/^s(hift)?$/i.test(mod))
|
|
37926
|
-
shift2 = true;
|
|
37927
|
-
else if (/^mod$/i.test(mod)) {
|
|
37928
|
-
if (mac)
|
|
37929
|
-
meta = true;
|
|
37930
|
-
else
|
|
37931
|
-
ctrl = true;
|
|
37932
|
-
} else
|
|
37933
|
-
throw new Error("Unrecognized modifier name: " + mod);
|
|
37934
|
-
}
|
|
37935
|
-
if (alt)
|
|
37936
|
-
result = "Alt-" + result;
|
|
37937
|
-
if (ctrl)
|
|
37938
|
-
result = "Ctrl-" + result;
|
|
37939
|
-
if (meta)
|
|
37940
|
-
result = "Meta-" + result;
|
|
37941
|
-
if (shift2)
|
|
37942
|
-
result = "Shift-" + result;
|
|
37943
|
-
return result;
|
|
37944
|
-
}
|
|
37945
|
-
function normalize(map22) {
|
|
37946
|
-
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
37947
|
-
for (let prop in map22)
|
|
37948
|
-
copy2[normalizeKeyName(prop)] = map22[prop];
|
|
37949
|
-
return copy2;
|
|
37950
|
-
}
|
|
37951
|
-
function modifiers(name, event, shift2 = true) {
|
|
37952
|
-
if (event.altKey)
|
|
37953
|
-
name = "Alt-" + name;
|
|
37954
|
-
if (event.ctrlKey)
|
|
37955
|
-
name = "Ctrl-" + name;
|
|
37956
|
-
if (event.metaKey)
|
|
37957
|
-
name = "Meta-" + name;
|
|
37958
|
-
if (shift2 && event.shiftKey)
|
|
37959
|
-
name = "Shift-" + name;
|
|
37960
|
-
return name;
|
|
37961
|
-
}
|
|
37962
|
-
function keymap(bindings) {
|
|
37963
|
-
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
37964
|
-
}
|
|
37965
|
-
function keydownHandler(bindings) {
|
|
37966
|
-
let map22 = normalize(bindings);
|
|
37967
|
-
return function(view, event) {
|
|
37968
|
-
let name = keyName(event), baseName, direct = map22[modifiers(name, event)];
|
|
37969
|
-
if (direct && direct(view.state, view.dispatch, view))
|
|
37970
|
-
return true;
|
|
37971
|
-
if (name.length == 1 && name != " ") {
|
|
37972
|
-
if (event.shiftKey) {
|
|
37973
|
-
let noShift = map22[modifiers(name, event, false)];
|
|
37974
|
-
if (noShift && noShift(view.state, view.dispatch, view))
|
|
37975
|
-
return true;
|
|
37976
|
-
}
|
|
37977
|
-
if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
37978
|
-
!(windows && event.ctrlKey && event.altKey) && (baseName = base$1[event.keyCode]) && baseName != name) {
|
|
37979
|
-
let fromCode = map22[modifiers(baseName, event)];
|
|
37980
|
-
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
37981
|
-
return true;
|
|
37982
|
-
}
|
|
37983
|
-
}
|
|
37984
|
-
return false;
|
|
37985
|
-
};
|
|
37986
|
-
}
|
|
37987
|
-
function isExtensionRulesEnabled(extension, enabled) {
|
|
37988
|
-
if (Array.isArray(enabled)) {
|
|
37989
|
-
return enabled.some((enabledExtension) => {
|
|
37990
|
-
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
37991
|
-
return name === extension.name;
|
|
37992
|
-
});
|
|
37993
|
-
}
|
|
37994
|
-
return enabled;
|
|
37995
|
-
}
|
|
37996
|
-
function getHTMLFromFragment(fragment, schema) {
|
|
37997
|
-
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
37998
|
-
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
37999
|
-
const container = temporaryDocument.createElement("div");
|
|
38000
|
-
container.appendChild(documentFragment);
|
|
38001
|
-
return container.innerHTML;
|
|
38002
|
-
}
|
|
38003
|
-
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
38004
|
-
let textBefore = "";
|
|
38005
|
-
const sliceEndPos = $from.parentOffset;
|
|
38006
|
-
$from.parent.nodesBetween(
|
|
38007
|
-
Math.max(0, sliceEndPos - maxMatch),
|
|
38008
|
-
sliceEndPos,
|
|
38009
|
-
(node2, pos, parent, index2) => {
|
|
38010
|
-
const chunk = node2.type.spec.toText?.({
|
|
38011
|
-
node: node2,
|
|
38012
|
-
pos,
|
|
38013
|
-
parent,
|
|
38014
|
-
index: index2
|
|
38015
|
-
}) || node2.textContent || "%leaf%";
|
|
38016
|
-
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
38017
|
-
}
|
|
38018
|
-
);
|
|
38019
|
-
return textBefore;
|
|
38020
|
-
};
|
|
38021
|
-
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
38022
|
-
const { converter } = editor;
|
|
38023
|
-
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
38024
|
-
let cleanedHtml = convertEmToPt(html);
|
|
38025
|
-
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
38026
|
-
const tempDiv = document.createElement("div");
|
|
38027
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
38028
|
-
const paragraphs = tempDiv.querySelectorAll("p");
|
|
38029
|
-
paragraphs.forEach((p) => {
|
|
38030
|
-
const innerHTML3 = p.innerHTML;
|
|
38031
|
-
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
38032
|
-
const styleAttr = p.getAttribute("style") || "";
|
|
38033
|
-
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
38034
|
-
if (msoListMatch) {
|
|
38035
|
-
const [, abstractId, level] = msoListMatch;
|
|
38036
|
-
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
38037
|
-
if (!listNumId) return;
|
|
38038
|
-
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
38039
|
-
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
38040
|
-
p.setAttribute("data-num-id", listNumId);
|
|
38041
|
-
p.setAttribute("data-list-level", level - 1);
|
|
38042
|
-
p.setAttribute("data-start", start2);
|
|
38043
|
-
p.setAttribute("data-lvl-text", lvlText);
|
|
38044
|
-
p.setAttribute("data-num-fmt", numFmt);
|
|
38045
|
-
}
|
|
38046
|
-
extractAndRemoveConditionalPrefix(p);
|
|
38047
|
-
});
|
|
38048
|
-
transformWordLists(tempDiv);
|
|
38049
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38050
|
-
tempDiv.remove();
|
|
38051
|
-
const { dispatch } = editor.view;
|
|
38052
|
-
if (!dispatch) return false;
|
|
38053
|
-
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
38054
|
-
return true;
|
|
38055
|
-
};
|
|
38056
|
-
const getLevelDefinition = (abstractDefinition, level) => {
|
|
38057
|
-
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
38058
|
-
const levelElement = abstractDefinition.elements.find((el) => {
|
|
38059
|
-
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
38060
|
-
});
|
|
38061
|
-
if (!levelElement) return null;
|
|
38062
|
-
const { elements } = levelElement;
|
|
38063
|
-
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
38064
|
-
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
38065
|
-
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
38066
|
-
return { lvlText, start: start2, numFmt, elements };
|
|
38067
|
-
};
|
|
38068
|
-
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
38069
|
-
const { definitions } = editor?.converter?.numbering;
|
|
38070
|
-
if (!definitions) return null;
|
|
38071
|
-
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
38072
|
-
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
38073
|
-
});
|
|
38074
|
-
return matchedDefinition?.attributes?.["w:numId"];
|
|
38075
|
-
};
|
|
38076
|
-
const getListAbstractDefinition = (abstractId, editor) => {
|
|
38077
|
-
const { abstracts = {} } = editor?.converter?.numbering;
|
|
38078
|
-
return abstracts[abstractId] || null;
|
|
38079
|
-
};
|
|
38080
|
-
const transformWordLists = (container) => {
|
|
38081
|
-
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
38082
|
-
const listMap = /* @__PURE__ */ new Map();
|
|
38083
|
-
const listLevels = {};
|
|
38084
|
-
for (const p of paragraphs) {
|
|
38085
|
-
const listId = p.getAttribute("data-num-id");
|
|
38086
|
-
const level = parseInt(p.getAttribute("data-list-level"));
|
|
38087
|
-
const numFmt = p.getAttribute("data-num-fmt");
|
|
38088
|
-
const start2 = p.getAttribute("data-start");
|
|
38089
|
-
const lvlText = p.getAttribute("data-lvl-text");
|
|
38090
|
-
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
38091
|
-
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
38092
|
-
}
|
|
38093
|
-
for (const [id, items] of listMap.entries()) {
|
|
38094
|
-
if (!listLevels[id]) {
|
|
38095
|
-
listLevels[id] = {
|
|
38096
|
-
stack: [],
|
|
38097
|
-
counts: {},
|
|
38098
|
-
prevLevel: null
|
|
38099
|
-
};
|
|
38100
|
-
}
|
|
38101
|
-
const parentStack = [];
|
|
38102
|
-
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
38103
|
-
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
38104
|
-
const li = document.createElement("li");
|
|
38105
|
-
li.innerHTML = p.innerHTML;
|
|
38106
|
-
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
38107
|
-
li.setAttribute("data-num-id", id);
|
|
38108
|
-
li.setAttribute("data-lvl-text", lvlText);
|
|
38109
|
-
li.setAttribute("data-num-fmt", numFmt);
|
|
38110
|
-
if (p.hasAttribute("data-font-family")) {
|
|
38111
|
-
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
38112
|
-
}
|
|
38113
|
-
if (p.hasAttribute("data-font-size")) {
|
|
38114
|
-
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
38115
|
-
}
|
|
38116
|
-
const parentNode2 = p.parentNode;
|
|
38117
|
-
let listForLevel = parentStack[level];
|
|
38118
|
-
if (!listForLevel) {
|
|
38119
|
-
const newList = document.createElement("ol");
|
|
38120
|
-
newList.setAttribute("data-list-id", id);
|
|
38121
|
-
newList.level = level;
|
|
38122
|
-
if (level > 0) {
|
|
38123
|
-
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
38124
|
-
if (parentLi) parentLi.appendChild(newList);
|
|
38125
|
-
} else {
|
|
38126
|
-
parentNode2.insertBefore(newList, p);
|
|
38127
|
-
}
|
|
38128
|
-
parentStack[level] = newList;
|
|
38129
|
-
parentStack.length = level + 1;
|
|
38130
|
-
listForLevel = newList;
|
|
38131
|
-
}
|
|
38132
|
-
listForLevel.appendChild(li);
|
|
38133
|
-
p.remove();
|
|
38134
|
-
});
|
|
38135
|
-
}
|
|
38303
|
+
189: "_",
|
|
38304
|
+
190: ">",
|
|
38305
|
+
191: "?",
|
|
38306
|
+
192: "~",
|
|
38307
|
+
219: "{",
|
|
38308
|
+
220: "|",
|
|
38309
|
+
221: "}",
|
|
38310
|
+
222: '"'
|
|
38136
38311
|
};
|
|
38137
|
-
|
|
38138
|
-
|
|
38139
|
-
|
|
38140
|
-
|
|
38141
|
-
|
|
38142
|
-
|
|
38143
|
-
|
|
38144
|
-
if (currentLevel > levelState.prevLevel) {
|
|
38145
|
-
levelState.stack.push(1);
|
|
38146
|
-
} else if (currentLevel === levelState.prevLevel) {
|
|
38147
|
-
levelState.stack[levelState.stack.length - 1]++;
|
|
38148
|
-
} else {
|
|
38149
|
-
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
38150
|
-
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
38151
|
-
}
|
|
38152
|
-
}
|
|
38153
|
-
levelState.prevLevel = currentLevel;
|
|
38154
|
-
return [...levelState.stack];
|
|
38155
|
-
}
|
|
38156
|
-
function extractAndRemoveConditionalPrefix(p) {
|
|
38157
|
-
const nodes = Array.from(p.childNodes);
|
|
38158
|
-
let fontFamily2 = null;
|
|
38159
|
-
let fontSize2 = null;
|
|
38160
|
-
let start2 = -1, end2 = -1;
|
|
38161
|
-
nodes.forEach((node2, index2) => {
|
|
38162
|
-
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
38163
|
-
start2 = index2;
|
|
38164
|
-
}
|
|
38165
|
-
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
38166
|
-
end2 = index2;
|
|
38167
|
-
}
|
|
38168
|
-
});
|
|
38169
|
-
if (start2 !== -1 && end2 !== -1) {
|
|
38170
|
-
for (let i = start2 + 1; i < end2; i++) {
|
|
38171
|
-
const node2 = nodes[i];
|
|
38172
|
-
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
38173
|
-
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
38174
|
-
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
38175
|
-
}
|
|
38176
|
-
}
|
|
38177
|
-
for (let i = end2; i >= start2; i--) {
|
|
38178
|
-
p.removeChild(p.childNodes[i]);
|
|
38179
|
-
}
|
|
38180
|
-
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
38181
|
-
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
38182
|
-
}
|
|
38312
|
+
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
38313
|
+
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
38314
|
+
for (var i = 0; i < 10; i++) base$1[48 + i] = base$1[96 + i] = String(i);
|
|
38315
|
+
for (var i = 1; i <= 24; i++) base$1[i + 111] = "F" + i;
|
|
38316
|
+
for (var i = 65; i <= 90; i++) {
|
|
38317
|
+
base$1[i] = String.fromCharCode(i + 32);
|
|
38318
|
+
shift[i] = String.fromCharCode(i);
|
|
38183
38319
|
}
|
|
38184
|
-
|
|
38185
|
-
|
|
38186
|
-
|
|
38187
|
-
|
|
38188
|
-
|
|
38189
|
-
|
|
38190
|
-
|
|
38320
|
+
for (var code in base$1) if (!shift.hasOwnProperty(code)) shift[code] = base$1[code];
|
|
38321
|
+
function keyName(event) {
|
|
38322
|
+
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
38323
|
+
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$1)[event.keyCode] || event.key || "Unidentified";
|
|
38324
|
+
if (name == "Esc") name = "Escape";
|
|
38325
|
+
if (name == "Del") name = "Delete";
|
|
38326
|
+
if (name == "Left") name = "ArrowLeft";
|
|
38327
|
+
if (name == "Up") name = "ArrowUp";
|
|
38328
|
+
if (name == "Right") name = "ArrowRight";
|
|
38329
|
+
if (name == "Down") name = "ArrowDown";
|
|
38330
|
+
return name;
|
|
38191
38331
|
}
|
|
38192
|
-
const
|
|
38193
|
-
|
|
38194
|
-
|
|
38195
|
-
|
|
38196
|
-
|
|
38197
|
-
|
|
38198
|
-
|
|
38199
|
-
|
|
38200
|
-
|
|
38201
|
-
|
|
38202
|
-
|
|
38203
|
-
|
|
38204
|
-
|
|
38205
|
-
if (
|
|
38206
|
-
|
|
38207
|
-
|
|
38208
|
-
|
|
38209
|
-
|
|
38210
|
-
|
|
38332
|
+
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
38333
|
+
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
38334
|
+
function normalizeKeyName(name) {
|
|
38335
|
+
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
38336
|
+
if (result == "Space")
|
|
38337
|
+
result = " ";
|
|
38338
|
+
let alt, ctrl, shift2, meta;
|
|
38339
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
38340
|
+
let mod = parts[i];
|
|
38341
|
+
if (/^(cmd|meta|m)$/i.test(mod))
|
|
38342
|
+
meta = true;
|
|
38343
|
+
else if (/^a(lt)?$/i.test(mod))
|
|
38344
|
+
alt = true;
|
|
38345
|
+
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
38346
|
+
ctrl = true;
|
|
38347
|
+
else if (/^s(hift)?$/i.test(mod))
|
|
38348
|
+
shift2 = true;
|
|
38349
|
+
else if (/^mod$/i.test(mod)) {
|
|
38350
|
+
if (mac)
|
|
38351
|
+
meta = true;
|
|
38352
|
+
else
|
|
38353
|
+
ctrl = true;
|
|
38354
|
+
} else
|
|
38355
|
+
throw new Error("Unrecognized modifier name: " + mod);
|
|
38211
38356
|
}
|
|
38357
|
+
if (alt)
|
|
38358
|
+
result = "Alt-" + result;
|
|
38359
|
+
if (ctrl)
|
|
38360
|
+
result = "Ctrl-" + result;
|
|
38361
|
+
if (meta)
|
|
38362
|
+
result = "Meta-" + result;
|
|
38363
|
+
if (shift2)
|
|
38364
|
+
result = "Shift-" + result;
|
|
38212
38365
|
return result;
|
|
38213
|
-
}
|
|
38214
|
-
|
|
38215
|
-
|
|
38216
|
-
|
|
38217
|
-
|
|
38218
|
-
|
|
38219
|
-
|
|
38220
|
-
|
|
38221
|
-
|
|
38222
|
-
|
|
38223
|
-
|
|
38224
|
-
|
|
38225
|
-
|
|
38226
|
-
|
|
38227
|
-
|
|
38228
|
-
|
|
38229
|
-
|
|
38230
|
-
|
|
38231
|
-
|
|
38232
|
-
|
|
38233
|
-
|
|
38234
|
-
|
|
38235
|
-
|
|
38236
|
-
|
|
38237
|
-
|
|
38238
|
-
if (
|
|
38239
|
-
return;
|
|
38240
|
-
|
|
38241
|
-
|
|
38242
|
-
|
|
38243
|
-
|
|
38244
|
-
|
|
38245
|
-
to
|
|
38246
|
-
};
|
|
38247
|
-
const { commands: commands2, chain, can } = new CommandService({
|
|
38248
|
-
editor,
|
|
38249
|
-
state: state2
|
|
38250
|
-
});
|
|
38251
|
-
const handler = rule.handler({
|
|
38252
|
-
state: state2,
|
|
38253
|
-
range: range2,
|
|
38254
|
-
match,
|
|
38255
|
-
commands: commands2,
|
|
38256
|
-
chain,
|
|
38257
|
-
can
|
|
38258
|
-
});
|
|
38259
|
-
if (handler === null || !tr.steps.length) {
|
|
38260
|
-
return;
|
|
38261
|
-
}
|
|
38262
|
-
tr.setMeta(plugin2, {
|
|
38263
|
-
transform: tr,
|
|
38264
|
-
from: from2,
|
|
38265
|
-
to,
|
|
38266
|
-
text
|
|
38267
|
-
});
|
|
38268
|
-
view.dispatch(tr);
|
|
38269
|
-
matched = true;
|
|
38270
|
-
});
|
|
38271
|
-
return matched;
|
|
38272
|
-
};
|
|
38273
|
-
const inputRulesPlugin = ({ editor, rules }) => {
|
|
38274
|
-
const plugin2 = new Plugin({
|
|
38275
|
-
key: new PluginKey("inputRulesPlugin"),
|
|
38276
|
-
state: {
|
|
38277
|
-
init() {
|
|
38278
|
-
return null;
|
|
38279
|
-
},
|
|
38280
|
-
apply(tr, prev, state2) {
|
|
38281
|
-
const stored = tr.getMeta(plugin2);
|
|
38282
|
-
if (stored) {
|
|
38283
|
-
return stored;
|
|
38284
|
-
}
|
|
38285
|
-
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
38286
|
-
const isSimulatedInput = !!simulatedInputMeta;
|
|
38287
|
-
if (isSimulatedInput) {
|
|
38288
|
-
setTimeout(() => {
|
|
38289
|
-
let { text } = simulatedInputMeta;
|
|
38290
|
-
if (typeof text !== "string") {
|
|
38291
|
-
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
38292
|
-
}
|
|
38293
|
-
const { from: from2 } = simulatedInputMeta;
|
|
38294
|
-
const to = from2 + text.length;
|
|
38295
|
-
run({
|
|
38296
|
-
editor,
|
|
38297
|
-
from: from2,
|
|
38298
|
-
to,
|
|
38299
|
-
text,
|
|
38300
|
-
rules,
|
|
38301
|
-
plugin: plugin2
|
|
38302
|
-
});
|
|
38303
|
-
});
|
|
38304
|
-
}
|
|
38305
|
-
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
38366
|
+
}
|
|
38367
|
+
function normalize(map22) {
|
|
38368
|
+
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
38369
|
+
for (let prop in map22)
|
|
38370
|
+
copy2[normalizeKeyName(prop)] = map22[prop];
|
|
38371
|
+
return copy2;
|
|
38372
|
+
}
|
|
38373
|
+
function modifiers(name, event, shift2 = true) {
|
|
38374
|
+
if (event.altKey)
|
|
38375
|
+
name = "Alt-" + name;
|
|
38376
|
+
if (event.ctrlKey)
|
|
38377
|
+
name = "Ctrl-" + name;
|
|
38378
|
+
if (event.metaKey)
|
|
38379
|
+
name = "Meta-" + name;
|
|
38380
|
+
if (shift2 && event.shiftKey)
|
|
38381
|
+
name = "Shift-" + name;
|
|
38382
|
+
return name;
|
|
38383
|
+
}
|
|
38384
|
+
function keymap(bindings) {
|
|
38385
|
+
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
38386
|
+
}
|
|
38387
|
+
function keydownHandler(bindings) {
|
|
38388
|
+
let map22 = normalize(bindings);
|
|
38389
|
+
return function(view, event) {
|
|
38390
|
+
let name = keyName(event), baseName, direct = map22[modifiers(name, event)];
|
|
38391
|
+
if (direct && direct(view.state, view.dispatch, view))
|
|
38392
|
+
return true;
|
|
38393
|
+
if (name.length == 1 && name != " ") {
|
|
38394
|
+
if (event.shiftKey) {
|
|
38395
|
+
let noShift = map22[modifiers(name, event, false)];
|
|
38396
|
+
if (noShift && noShift(view.state, view.dispatch, view))
|
|
38397
|
+
return true;
|
|
38306
38398
|
}
|
|
38307
|
-
|
|
38308
|
-
|
|
38309
|
-
|
|
38310
|
-
|
|
38311
|
-
|
|
38312
|
-
from: from2,
|
|
38313
|
-
to,
|
|
38314
|
-
text,
|
|
38315
|
-
rules,
|
|
38316
|
-
plugin: plugin2
|
|
38317
|
-
});
|
|
38318
|
-
},
|
|
38319
|
-
// add support for input rules to trigger on enter
|
|
38320
|
-
// this is useful for example for code blocks
|
|
38321
|
-
handleKeyDown(view, event) {
|
|
38322
|
-
if (event.key !== "Enter") {
|
|
38323
|
-
return false;
|
|
38324
|
-
}
|
|
38325
|
-
const { $cursor } = view.state.selection;
|
|
38326
|
-
if ($cursor) {
|
|
38327
|
-
return run({
|
|
38328
|
-
editor,
|
|
38329
|
-
from: $cursor.pos,
|
|
38330
|
-
to: $cursor.pos,
|
|
38331
|
-
text: "\n",
|
|
38332
|
-
rules,
|
|
38333
|
-
plugin: plugin2
|
|
38334
|
-
});
|
|
38335
|
-
}
|
|
38336
|
-
return false;
|
|
38337
|
-
},
|
|
38338
|
-
// Paste handler
|
|
38339
|
-
handlePaste(view, event, slice2) {
|
|
38340
|
-
const clipboard = event.clipboardData;
|
|
38341
|
-
const html = clipboard.getData("text/html");
|
|
38342
|
-
clipboard.getData("text/plain");
|
|
38343
|
-
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
38344
|
-
if (fieldAnnotationContent.length) {
|
|
38345
|
-
return false;
|
|
38346
|
-
}
|
|
38347
|
-
let source;
|
|
38348
|
-
if (!html) {
|
|
38349
|
-
source = "plain-text";
|
|
38350
|
-
} else if (isWordHtml(html)) {
|
|
38351
|
-
source = "word-html";
|
|
38352
|
-
} else {
|
|
38353
|
-
source = "browser-html";
|
|
38354
|
-
}
|
|
38355
|
-
switch (source) {
|
|
38356
|
-
case "plain-text":
|
|
38357
|
-
break;
|
|
38358
|
-
case "word-html":
|
|
38359
|
-
if (editor.options.mode === "docx") {
|
|
38360
|
-
return handleDocxPaste(html, editor, view, plugin2);
|
|
38361
|
-
}
|
|
38362
|
-
case "browser-html":
|
|
38363
|
-
return handleHtmlPaste$1(html, editor);
|
|
38364
|
-
}
|
|
38365
|
-
return false;
|
|
38399
|
+
if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
38400
|
+
!(windows && event.ctrlKey && event.altKey) && (baseName = base$1[event.keyCode]) && baseName != name) {
|
|
38401
|
+
let fromCode = map22[modifiers(baseName, event)];
|
|
38402
|
+
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
38403
|
+
return true;
|
|
38366
38404
|
}
|
|
38367
|
-
},
|
|
38368
|
-
isInputRules: true
|
|
38369
|
-
});
|
|
38370
|
-
return plugin2;
|
|
38371
|
-
};
|
|
38372
|
-
function isWordHtml(html) {
|
|
38373
|
-
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
38374
|
-
}
|
|
38375
|
-
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
38376
|
-
const cleanedHtml = convertEmToPt(html);
|
|
38377
|
-
const tempDiv = document.createElement("div");
|
|
38378
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
38379
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38380
|
-
tempDiv.remove();
|
|
38381
|
-
const { dispatch } = editor.view;
|
|
38382
|
-
if (!dispatch) return false;
|
|
38383
|
-
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
38384
|
-
return true;
|
|
38385
|
-
};
|
|
38386
|
-
const convertEmToPt = (html) => {
|
|
38387
|
-
return html.replace(
|
|
38388
|
-
/font-size\s*:\s*([\d.]+)em/gi,
|
|
38389
|
-
(_, emValue) => {
|
|
38390
|
-
const em = parseFloat(emValue);
|
|
38391
|
-
const pt = Math.round(em * 12 * 100) / 100;
|
|
38392
|
-
return `font-size: ${pt}pt`;
|
|
38393
38405
|
}
|
|
38394
|
-
|
|
38395
|
-
};
|
|
38396
|
-
|
|
38397
|
-
|
|
38406
|
+
return false;
|
|
38407
|
+
};
|
|
38408
|
+
}
|
|
38409
|
+
function isExtensionRulesEnabled(extension, enabled) {
|
|
38410
|
+
if (Array.isArray(enabled)) {
|
|
38411
|
+
return enabled.some((enabledExtension) => {
|
|
38412
|
+
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
38413
|
+
return name === extension.name;
|
|
38414
|
+
});
|
|
38415
|
+
}
|
|
38416
|
+
return enabled;
|
|
38398
38417
|
}
|
|
38399
38418
|
const _ExtensionService = class _ExtensionService2 {
|
|
38400
38419
|
constructor(extensions, userExtensions, editor) {
|
|
@@ -39234,6 +39253,7 @@ const createHeaderFooterEditor = ({
|
|
|
39234
39253
|
mediaFiles: editor.storage.image.media,
|
|
39235
39254
|
fonts: editor.options.fonts,
|
|
39236
39255
|
isHeaderOrFooter: true,
|
|
39256
|
+
isHeadless: editor.options.isHeadless,
|
|
39237
39257
|
annotations: true,
|
|
39238
39258
|
currentPageNumber,
|
|
39239
39259
|
parentEditor: editor,
|
|
@@ -39241,13 +39261,15 @@ const createHeaderFooterEditor = ({
|
|
|
39241
39261
|
onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
|
|
39242
39262
|
});
|
|
39243
39263
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
39244
|
-
pm
|
|
39245
|
-
|
|
39246
|
-
|
|
39247
|
-
|
|
39248
|
-
|
|
39249
|
-
|
|
39250
|
-
|
|
39264
|
+
if (pm) {
|
|
39265
|
+
pm.style.maxHeight = "100%";
|
|
39266
|
+
pm.style.minHeight = "100%";
|
|
39267
|
+
pm.style.outline = "none";
|
|
39268
|
+
pm.style.border = "none";
|
|
39269
|
+
pm.setAttribute("role", "textbox");
|
|
39270
|
+
pm.setAttribute("aria-multiline", true);
|
|
39271
|
+
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
39272
|
+
}
|
|
39251
39273
|
return headerFooterEditor;
|
|
39252
39274
|
};
|
|
39253
39275
|
const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
@@ -39266,14 +39288,16 @@ const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
|
39266
39288
|
});
|
|
39267
39289
|
});
|
|
39268
39290
|
};
|
|
39269
|
-
const toggleHeaderFooterEditMode = (editor, focusedSectionEditor, isEditMode) => {
|
|
39291
|
+
const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode, documentMode }) => {
|
|
39270
39292
|
editor.converter.headerEditors.forEach((item) => {
|
|
39271
39293
|
item.editor.setEditable(isEditMode, false);
|
|
39272
39294
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39295
|
+
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39273
39296
|
});
|
|
39274
39297
|
editor.converter.footerEditors.forEach((item) => {
|
|
39275
39298
|
item.editor.setEditable(isEditMode, false);
|
|
39276
39299
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39300
|
+
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39277
39301
|
});
|
|
39278
39302
|
if (isEditMode) {
|
|
39279
39303
|
const pm = document.querySelector(".ProseMirror");
|
|
@@ -40354,6 +40378,19 @@ const deleteHeaderFooterFieldAnnotations = ({ editor, fieldIdOrArray }) => {
|
|
|
40354
40378
|
);
|
|
40355
40379
|
});
|
|
40356
40380
|
};
|
|
40381
|
+
const resetHeaderFooterFieldAnnotations = ({ editor }) => {
|
|
40382
|
+
if (!editor) return;
|
|
40383
|
+
const sectionEditors = getAllHeaderFooterEditors(editor);
|
|
40384
|
+
sectionEditors.forEach(({ editor: sectionEditor, sectionId, type: type2 }) => {
|
|
40385
|
+
sectionEditor.commands.resetFieldAnnotations();
|
|
40386
|
+
onHeaderFooterDataUpdate(
|
|
40387
|
+
{ editor: sectionEditor },
|
|
40388
|
+
editor,
|
|
40389
|
+
sectionId,
|
|
40390
|
+
type2
|
|
40391
|
+
);
|
|
40392
|
+
});
|
|
40393
|
+
};
|
|
40357
40394
|
const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
|
|
40358
40395
|
if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
|
|
40359
40396
|
const { doc: doc2 } = editor.state;
|
|
@@ -40424,6 +40461,7 @@ const AnnotatorHelpers = {
|
|
|
40424
40461
|
getAllHeaderFooterEditors,
|
|
40425
40462
|
updateHeaderFooterFieldAnnotations,
|
|
40426
40463
|
deleteHeaderFooterFieldAnnotations,
|
|
40464
|
+
resetHeaderFooterFieldAnnotations,
|
|
40427
40465
|
cleanUpListsWithAnnotations
|
|
40428
40466
|
};
|
|
40429
40467
|
const CollaborationPluginKey = new PluginKey("collaboration");
|
|
@@ -40603,6 +40641,16 @@ const setWordSelection = (view, pos) => {
|
|
|
40603
40641
|
const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
|
|
40604
40642
|
dispatch(tr);
|
|
40605
40643
|
};
|
|
40644
|
+
const setImageNodeSelection = (view, pos) => {
|
|
40645
|
+
const { doc: doc2 } = view.state;
|
|
40646
|
+
const node2 = doc2.nodeAt(pos);
|
|
40647
|
+
if (node2 && node2.type.name === "image") {
|
|
40648
|
+
const tr = view.state.tr.setSelection(NodeSelection.create(doc2, pos));
|
|
40649
|
+
view.dispatch(tr);
|
|
40650
|
+
return true;
|
|
40651
|
+
}
|
|
40652
|
+
return false;
|
|
40653
|
+
};
|
|
40606
40654
|
const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
40607
40655
|
/**
|
|
40608
40656
|
* Create a new Editor instance
|
|
@@ -40701,6 +40749,19 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40701
40749
|
this.setHighContrastMode = setHighContrastMode;
|
|
40702
40750
|
initMode();
|
|
40703
40751
|
}
|
|
40752
|
+
mount(el) {
|
|
40753
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
40754
|
+
window.setTimeout(() => {
|
|
40755
|
+
if (this.isDestroyed) return;
|
|
40756
|
+
this.emit("create", { editor: this });
|
|
40757
|
+
}, 0);
|
|
40758
|
+
}
|
|
40759
|
+
unmount() {
|
|
40760
|
+
if (this.view) {
|
|
40761
|
+
this.view.destroy();
|
|
40762
|
+
}
|
|
40763
|
+
this.view = null;
|
|
40764
|
+
}
|
|
40704
40765
|
/**
|
|
40705
40766
|
* Set the toolbar for this editor
|
|
40706
40767
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -40749,7 +40810,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40749
40810
|
* @returns {boolean}
|
|
40750
40811
|
*/
|
|
40751
40812
|
get isDestroyed() {
|
|
40752
|
-
return this.view
|
|
40813
|
+
return this.view?.isDestroyed ?? true;
|
|
40753
40814
|
}
|
|
40754
40815
|
/**
|
|
40755
40816
|
* Get the editor element
|
|
@@ -40792,7 +40853,12 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40792
40853
|
this.commands.toggleTrackChangesShowOriginal();
|
|
40793
40854
|
this.setEditable(false, false);
|
|
40794
40855
|
this.setOptions({ documentMode: "viewing" });
|
|
40795
|
-
toggleHeaderFooterEditMode(
|
|
40856
|
+
toggleHeaderFooterEditMode({
|
|
40857
|
+
editor: this,
|
|
40858
|
+
focusedSectionEditor: null,
|
|
40859
|
+
isEditMode: false,
|
|
40860
|
+
documentMode: cleanedMode
|
|
40861
|
+
});
|
|
40796
40862
|
} else if (cleanedMode === "suggesting") {
|
|
40797
40863
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
40798
40864
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -40805,7 +40871,12 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40805
40871
|
this.commands.disableTrackChanges();
|
|
40806
40872
|
this.setEditable(true, false);
|
|
40807
40873
|
this.setOptions({ documentMode: "editing" });
|
|
40808
|
-
toggleHeaderFooterEditMode(
|
|
40874
|
+
toggleHeaderFooterEditMode({
|
|
40875
|
+
editor: this,
|
|
40876
|
+
focusedSectionEditor: null,
|
|
40877
|
+
isEditMode: false,
|
|
40878
|
+
documentMode: cleanedMode
|
|
40879
|
+
});
|
|
40809
40880
|
}
|
|
40810
40881
|
}
|
|
40811
40882
|
/**
|
|
@@ -40982,29 +41053,26 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40982
41053
|
};
|
|
40983
41054
|
}
|
|
40984
41055
|
/**
|
|
40985
|
-
|
|
40986
|
-
|
|
40987
|
-
|
|
40988
|
-
*
|
|
40989
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
40990
|
-
* @returns {void}
|
|
40991
|
-
*/
|
|
40992
|
-
initDefaultStyles(element = this.element) {
|
|
40993
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
40994
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41056
|
+
* Attach styles and attributes to the editor element
|
|
41057
|
+
*/
|
|
41058
|
+
updateEditorStyles(element, proseMirror) {
|
|
40995
41059
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
40996
|
-
if (!proseMirror || !
|
|
41060
|
+
if (!proseMirror || !element) {
|
|
40997
41061
|
return;
|
|
40998
41062
|
}
|
|
40999
41063
|
proseMirror.setAttribute("role", "document");
|
|
41000
41064
|
proseMirror.setAttribute("aria-multiline", true);
|
|
41001
41065
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
41002
41066
|
proseMirror.setAttribute("aria-description", "");
|
|
41003
|
-
|
|
41004
|
-
|
|
41005
|
-
|
|
41006
|
-
|
|
41007
|
-
|
|
41067
|
+
if (pageSize) {
|
|
41068
|
+
element.style.width = pageSize.width + "in";
|
|
41069
|
+
element.style.minWidth = pageSize.width + "in";
|
|
41070
|
+
element.style.minHeight = pageSize.height + "in";
|
|
41071
|
+
}
|
|
41072
|
+
if (pageMargins) {
|
|
41073
|
+
element.style.paddingLeft = pageMargins.left + "in";
|
|
41074
|
+
element.style.paddingRight = pageMargins.right + "in";
|
|
41075
|
+
}
|
|
41008
41076
|
element.style.boxSizing = "border-box";
|
|
41009
41077
|
element.style.isolation = "isolate";
|
|
41010
41078
|
proseMirror.style.outline = "none";
|
|
@@ -41025,6 +41093,19 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41025
41093
|
proseMirror.style.paddingTop = "1in";
|
|
41026
41094
|
proseMirror.style.paddingBottom = "1in";
|
|
41027
41095
|
}
|
|
41096
|
+
}
|
|
41097
|
+
/**
|
|
41098
|
+
* Initialize default styles for the editor container and ProseMirror.
|
|
41099
|
+
* Get page size and margins from the converter.
|
|
41100
|
+
* Set document default font and font size.
|
|
41101
|
+
*
|
|
41102
|
+
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
41103
|
+
* @returns {void}
|
|
41104
|
+
*/
|
|
41105
|
+
initDefaultStyles(element = this.element) {
|
|
41106
|
+
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
41107
|
+
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41108
|
+
this.updateEditorStyles(element, proseMirror);
|
|
41028
41109
|
this.initMobileStyles(element);
|
|
41029
41110
|
}
|
|
41030
41111
|
/**
|
|
@@ -41236,10 +41317,25 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41236
41317
|
*/
|
|
41237
41318
|
destroy() {
|
|
41238
41319
|
this.emit("destroy");
|
|
41239
|
-
|
|
41320
|
+
this.unmount();
|
|
41321
|
+
this.destroyHeaderFooterEditors();
|
|
41240
41322
|
__privateMethod$1(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
41241
41323
|
this.removeAllListeners();
|
|
41242
41324
|
}
|
|
41325
|
+
destroyHeaderFooterEditors() {
|
|
41326
|
+
try {
|
|
41327
|
+
const editors = [
|
|
41328
|
+
...this.converter.headerEditors,
|
|
41329
|
+
...this.converter.footerEditors
|
|
41330
|
+
];
|
|
41331
|
+
for (let editorData of editors) {
|
|
41332
|
+
editorData.editor.destroy();
|
|
41333
|
+
}
|
|
41334
|
+
this.converter.headerEditors.length = 0;
|
|
41335
|
+
this.converter.footerEditors.length = 0;
|
|
41336
|
+
} catch (error) {
|
|
41337
|
+
}
|
|
41338
|
+
}
|
|
41243
41339
|
/**
|
|
41244
41340
|
* Check if migrations are needed for the data
|
|
41245
41341
|
* @static
|
|
@@ -41257,7 +41353,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41257
41353
|
* @returns {Object | void} Migration results
|
|
41258
41354
|
*/
|
|
41259
41355
|
processCollaborationMigrations() {
|
|
41260
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.
|
|
41356
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2-rev10");
|
|
41261
41357
|
if (!this.options.ydoc) return;
|
|
41262
41358
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
41263
41359
|
let docVersion = metaMap.get("version");
|
|
@@ -41301,6 +41397,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41301
41397
|
__privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
|
|
41302
41398
|
this.initDefaultStyles();
|
|
41303
41399
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
41400
|
+
updateYdocDocxData(this);
|
|
41304
41401
|
this.initializeCollaborationData(true);
|
|
41305
41402
|
} else {
|
|
41306
41403
|
__privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -41452,7 +41549,7 @@ init_fn = function(options2) {
|
|
|
41452
41549
|
this.emit("beforeCreate", { editor: this });
|
|
41453
41550
|
this.on("contentError", this.options.onContentError);
|
|
41454
41551
|
this.on("exception", this.options.onException);
|
|
41455
|
-
|
|
41552
|
+
this.mount(this.options.element);
|
|
41456
41553
|
this.initDefaultStyles();
|
|
41457
41554
|
this.setDocumentMode(options2.documentMode);
|
|
41458
41555
|
if (this.options.isHeadless) return;
|
|
@@ -41476,10 +41573,6 @@ init_fn = function(options2) {
|
|
|
41476
41573
|
__privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
|
|
41477
41574
|
__privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
|
|
41478
41575
|
}
|
|
41479
|
-
window.setTimeout(() => {
|
|
41480
|
-
if (this.isDestroyed) return;
|
|
41481
|
-
this.emit("create", { editor: this });
|
|
41482
|
-
}, 0);
|
|
41483
41576
|
};
|
|
41484
41577
|
initRichText_fn = function(options2) {
|
|
41485
41578
|
if (!options2.extensions || !options2.extensions.length) {
|
|
@@ -41491,7 +41584,7 @@ initRichText_fn = function(options2) {
|
|
|
41491
41584
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
41492
41585
|
this.emit("beforeCreate", { editor: this });
|
|
41493
41586
|
this.on("contentError", this.options.onContentError);
|
|
41494
|
-
|
|
41587
|
+
this.mount(this.options.element);
|
|
41495
41588
|
this.on("create", this.options.onCreate);
|
|
41496
41589
|
this.on("update", this.options.onUpdate);
|
|
41497
41590
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -41502,10 +41595,6 @@ initRichText_fn = function(options2) {
|
|
|
41502
41595
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
41503
41596
|
this.on("commentClick", this.options.onCommentClicked);
|
|
41504
41597
|
this.on("locked", this.options.onDocumentLocked);
|
|
41505
|
-
window.setTimeout(() => {
|
|
41506
|
-
if (this.isDestroyed) return;
|
|
41507
|
-
this.emit("create", { editor: this });
|
|
41508
|
-
}, 0);
|
|
41509
41598
|
};
|
|
41510
41599
|
onFocus_fn = function({ editor, event }) {
|
|
41511
41600
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -41626,14 +41715,15 @@ createDocFromHTML_fn = function(content) {
|
|
|
41626
41715
|
}
|
|
41627
41716
|
return DOMParser$1.fromSchema(this.schema).parse(parsedContent);
|
|
41628
41717
|
};
|
|
41629
|
-
createView_fn = function() {
|
|
41718
|
+
createView_fn = function(element) {
|
|
41630
41719
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
41631
41720
|
const state2 = { schema: this.schema };
|
|
41632
41721
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
41633
|
-
this.view = new EditorView(
|
|
41722
|
+
this.view = new EditorView(element, {
|
|
41634
41723
|
...this.options.editorProps,
|
|
41635
41724
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
41636
41725
|
state: EditorState.create(state2),
|
|
41726
|
+
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
41637
41727
|
handleDoubleClick: async (view, pos, event) => {
|
|
41638
41728
|
if (this.options.documentMode !== "editing") return;
|
|
41639
41729
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -41647,7 +41737,12 @@ createView_fn = function() {
|
|
|
41647
41737
|
event.stopPropagation();
|
|
41648
41738
|
if (!this.options.editable) {
|
|
41649
41739
|
this.setEditable(true, false);
|
|
41650
|
-
toggleHeaderFooterEditMode(
|
|
41740
|
+
toggleHeaderFooterEditMode({
|
|
41741
|
+
editor: this,
|
|
41742
|
+
focusedSectionEditor: null,
|
|
41743
|
+
isEditMode: false,
|
|
41744
|
+
documentMode: this.options.documentMode
|
|
41745
|
+
});
|
|
41651
41746
|
const pm = document.querySelector(".ProseMirror");
|
|
41652
41747
|
pm.classList.remove("header-footer-edit");
|
|
41653
41748
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -41660,8 +41755,6 @@ createView_fn = function() {
|
|
|
41660
41755
|
});
|
|
41661
41756
|
this.view.updateState(newState);
|
|
41662
41757
|
this.createNodeViews();
|
|
41663
|
-
const dom = this.view.dom;
|
|
41664
|
-
dom.editor = this;
|
|
41665
41758
|
this.options.telemetry?.sendReport();
|
|
41666
41759
|
};
|
|
41667
41760
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
@@ -41688,7 +41781,9 @@ initComments_fn = function() {
|
|
|
41688
41781
|
}, 50);
|
|
41689
41782
|
};
|
|
41690
41783
|
initPagination_fn = async function() {
|
|
41691
|
-
if (this.options.isHeadless || !this.extensionService)
|
|
41784
|
+
if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) {
|
|
41785
|
+
return;
|
|
41786
|
+
}
|
|
41692
41787
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
41693
41788
|
if (pagination && this.options.pagination) {
|
|
41694
41789
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -41700,7 +41795,7 @@ initPagination_fn = async function() {
|
|
|
41700
41795
|
}
|
|
41701
41796
|
};
|
|
41702
41797
|
dispatchTransaction_fn = function(transaction) {
|
|
41703
|
-
if (this.
|
|
41798
|
+
if (this.isDestroyed) return;
|
|
41704
41799
|
let state2;
|
|
41705
41800
|
try {
|
|
41706
41801
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -41752,6 +41847,11 @@ dispatchTransaction_fn = function(transaction) {
|
|
|
41752
41847
|
transaction
|
|
41753
41848
|
});
|
|
41754
41849
|
};
|
|
41850
|
+
handleNodeSelection_fn = function(view, pos) {
|
|
41851
|
+
if (this.options.isHeaderOrFooter) {
|
|
41852
|
+
return setImageNodeSelection(view, pos);
|
|
41853
|
+
}
|
|
41854
|
+
};
|
|
41755
41855
|
prepareDocumentForImport_fn = function(doc2) {
|
|
41756
41856
|
const newState = EditorState.create({
|
|
41757
41857
|
schema: this.schema,
|
|
@@ -44094,7 +44194,7 @@ const Paragraph = Node$1.create({
|
|
|
44094
44194
|
},
|
|
44095
44195
|
addPmPlugins() {
|
|
44096
44196
|
const { view } = this.editor;
|
|
44097
|
-
|
|
44197
|
+
new Plugin({
|
|
44098
44198
|
name: "dropcapPlugin",
|
|
44099
44199
|
key: new PluginKey("dropcapPlugin"),
|
|
44100
44200
|
state: {
|
|
@@ -44114,7 +44214,7 @@ const Paragraph = Node$1.create({
|
|
|
44114
44214
|
}
|
|
44115
44215
|
}
|
|
44116
44216
|
});
|
|
44117
|
-
return [
|
|
44217
|
+
return [];
|
|
44118
44218
|
}
|
|
44119
44219
|
});
|
|
44120
44220
|
const getDropcapDecorations = (state2, view) => {
|
|
@@ -44467,7 +44567,16 @@ const HardBreak = Node$1.create({
|
|
|
44467
44567
|
};
|
|
44468
44568
|
},
|
|
44469
44569
|
parseDOM() {
|
|
44470
|
-
return [{
|
|
44570
|
+
return [{
|
|
44571
|
+
tag: 'span[linebreaktype="page"]',
|
|
44572
|
+
getAttrs: (dom) => {
|
|
44573
|
+
if (!(dom instanceof HTMLElement)) return false;
|
|
44574
|
+
return {
|
|
44575
|
+
pageBreakSource: dom.getAttribute("pagebreaksource") || null,
|
|
44576
|
+
pageBreakType: dom.getAttribute("linebreaktype") || null
|
|
44577
|
+
};
|
|
44578
|
+
}
|
|
44579
|
+
}];
|
|
44471
44580
|
},
|
|
44472
44581
|
renderDOM({ htmlAttributes }) {
|
|
44473
44582
|
return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -47464,6 +47573,8 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47464
47573
|
if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true) {
|
|
47465
47574
|
return removedNodes;
|
|
47466
47575
|
}
|
|
47576
|
+
const hasDeletion = transactionDeletedAnything(tr);
|
|
47577
|
+
if (!hasDeletion) return removedNodes;
|
|
47467
47578
|
tr.steps.forEach((step, stepIndex) => {
|
|
47468
47579
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
47469
47580
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -47480,6 +47591,14 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47480
47591
|
});
|
|
47481
47592
|
return removedNodes;
|
|
47482
47593
|
}
|
|
47594
|
+
function transactionDeletedAnything(tr) {
|
|
47595
|
+
return tr.steps.some((step) => {
|
|
47596
|
+
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) {
|
|
47597
|
+
return step.from !== step.to;
|
|
47598
|
+
}
|
|
47599
|
+
return false;
|
|
47600
|
+
});
|
|
47601
|
+
}
|
|
47483
47602
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
47484
47603
|
let removedAnnotations = [];
|
|
47485
47604
|
try {
|
|
@@ -47875,8 +47994,18 @@ const FieldAnnotation = Node$1.create({
|
|
|
47875
47994
|
};
|
|
47876
47995
|
}
|
|
47877
47996
|
},
|
|
47997
|
+
defaultDisplayLabel: {
|
|
47998
|
+
default: "",
|
|
47999
|
+
parseDOM: (elem) => elem.getAttribute("data-default-display-label"),
|
|
48000
|
+
renderDOM: (attrs) => {
|
|
48001
|
+
if (!attrs.defaultDisplayLabel) return {};
|
|
48002
|
+
return {
|
|
48003
|
+
"data-default-display-label": attrs.defaultDisplayLabel
|
|
48004
|
+
};
|
|
48005
|
+
}
|
|
48006
|
+
},
|
|
47878
48007
|
displayLabel: {
|
|
47879
|
-
default: "
|
|
48008
|
+
default: "",
|
|
47880
48009
|
parseDOM: (elem) => elem.getAttribute("data-display-label"),
|
|
47881
48010
|
renderDOM: (attrs) => {
|
|
47882
48011
|
if (!attrs.displayLabel) return {};
|
|
@@ -48192,6 +48321,7 @@ const FieldAnnotation = Node$1.create({
|
|
|
48192
48321
|
return renderer();
|
|
48193
48322
|
},
|
|
48194
48323
|
addCommands() {
|
|
48324
|
+
const annotationTypes = this.options.types;
|
|
48195
48325
|
return {
|
|
48196
48326
|
/**
|
|
48197
48327
|
* Add field annotation.
|
|
@@ -48213,7 +48343,12 @@ const FieldAnnotation = Node$1.create({
|
|
|
48213
48343
|
let currentMarks = $pos.marks();
|
|
48214
48344
|
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
48215
48345
|
let formatAttrs = getFormatAttrsFromMarks(currentMarks);
|
|
48216
|
-
let
|
|
48346
|
+
let defaultDisplayLabel = attrs.defaultDisplayLabel ? attrs.defaultDisplayLabel : attrs.displayLabel || "";
|
|
48347
|
+
let node2 = schema.nodes[this.name].create({
|
|
48348
|
+
...attrs,
|
|
48349
|
+
...formatAttrs,
|
|
48350
|
+
defaultDisplayLabel
|
|
48351
|
+
}, null, null);
|
|
48217
48352
|
state2.tr.insert(newPos, node2).setSelection(Selection.near(tr.doc.resolve(newPos + node2.nodeSize)));
|
|
48218
48353
|
if (editorFocus) {
|
|
48219
48354
|
this.editor.view.focus();
|
|
@@ -48221,9 +48356,9 @@ const FieldAnnotation = Node$1.create({
|
|
|
48221
48356
|
}
|
|
48222
48357
|
return true;
|
|
48223
48358
|
},
|
|
48224
|
-
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({
|
|
48359
|
+
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state: state2, commands: commands2 }) => {
|
|
48225
48360
|
const { from: from2 } = state2.selection;
|
|
48226
|
-
commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
48361
|
+
return commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
48227
48362
|
},
|
|
48228
48363
|
/**
|
|
48229
48364
|
* Replace field annotation.
|
|
@@ -48233,24 +48368,113 @@ const FieldAnnotation = Node$1.create({
|
|
|
48233
48368
|
* from: 20,
|
|
48234
48369
|
* to: 45,
|
|
48235
48370
|
* attrs: {
|
|
48236
|
-
*
|
|
48237
|
-
*
|
|
48371
|
+
* fieldType: 'TEXTINPUT'
|
|
48372
|
+
* fieldColor: '#980043'
|
|
48238
48373
|
* }
|
|
48239
48374
|
* ])
|
|
48240
48375
|
*/
|
|
48241
|
-
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch,
|
|
48376
|
+
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => {
|
|
48242
48377
|
if (!dispatch) return true;
|
|
48243
|
-
tr.setMeta("fieldAnnotationReplace", true);
|
|
48244
48378
|
fieldsArray.forEach((annotation) => {
|
|
48245
48379
|
let { from: from2, to, attrs } = annotation;
|
|
48246
48380
|
let { schema } = editor;
|
|
48247
48381
|
let newPosFrom = tr.mapping.map(from2);
|
|
48248
48382
|
let newPosTo = tr.mapping.map(to);
|
|
48249
|
-
let
|
|
48383
|
+
let defaultDisplayLabel = attrs.defaultDisplayLabel ? attrs.defaultDisplayLabel : attrs.displayLabel || "";
|
|
48384
|
+
let node2 = schema.nodes[this.name].create({
|
|
48385
|
+
...attrs,
|
|
48386
|
+
defaultDisplayLabel
|
|
48387
|
+
}, null, null);
|
|
48250
48388
|
tr.replaceWith(newPosFrom, newPosTo, node2);
|
|
48251
48389
|
});
|
|
48252
48390
|
return true;
|
|
48253
48391
|
},
|
|
48392
|
+
/**
|
|
48393
|
+
* Replace annotations with a label (as text node) in selection.
|
|
48394
|
+
* @param options Additional options.
|
|
48395
|
+
* @example
|
|
48396
|
+
* editor.commands.replaceFieldAnnotationsWithLabelInSelection()
|
|
48397
|
+
*/
|
|
48398
|
+
replaceFieldAnnotationsWithLabelInSelection: (options2 = {}) => ({ commands: commands2 }) => {
|
|
48399
|
+
return commands2.replaceFieldAnnotationsWithLabel(null, {
|
|
48400
|
+
...options2,
|
|
48401
|
+
isInSelection: true
|
|
48402
|
+
});
|
|
48403
|
+
},
|
|
48404
|
+
/**
|
|
48405
|
+
* Replace annotations with a label (as text node).
|
|
48406
|
+
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
48407
|
+
* @param options.isInSelection Find in selection instead of field IDs.
|
|
48408
|
+
* @param options.addToHistory Add to history or not.
|
|
48409
|
+
* @param options.types Annotation types to replace.
|
|
48410
|
+
* @example
|
|
48411
|
+
* editor.commands.replaceFieldAnnotationsWithLabel(['1', '2'])
|
|
48412
|
+
*/
|
|
48413
|
+
replaceFieldAnnotationsWithLabel: (fieldIdOrArray, {
|
|
48414
|
+
isInSelection = false,
|
|
48415
|
+
addToHistory = false,
|
|
48416
|
+
types: types2 = annotationTypes
|
|
48417
|
+
} = {}) => ({ dispatch, state: state2, tr }) => {
|
|
48418
|
+
let { from: from2, to } = state2.selection;
|
|
48419
|
+
let annotations = isInSelection ? findFieldAnnotationsBetween(from2, to, state2.doc) : findFieldAnnotationsByFieldId(fieldIdOrArray, state2);
|
|
48420
|
+
annotations = types2.length ? annotations.filter(({ node: node2 }) => types2.includes(node2.attrs.type)) : annotations;
|
|
48421
|
+
if (!annotations.length) {
|
|
48422
|
+
return true;
|
|
48423
|
+
}
|
|
48424
|
+
if (!addToHistory) {
|
|
48425
|
+
tr.setMeta("addToHistory", false);
|
|
48426
|
+
}
|
|
48427
|
+
if (dispatch) {
|
|
48428
|
+
annotations.forEach((annotation) => {
|
|
48429
|
+
let { pos, node: node2 } = annotation;
|
|
48430
|
+
let newPosFrom = tr.mapping.map(pos);
|
|
48431
|
+
let newPosTo = tr.mapping.map(pos + node2.nodeSize);
|
|
48432
|
+
let currentNode = tr.doc.nodeAt(newPosFrom);
|
|
48433
|
+
let nodeEqual = node2.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
48434
|
+
let $newPosFrom = tr.doc.resolve(newPosFrom);
|
|
48435
|
+
let currentMarks = $newPosFrom.marks();
|
|
48436
|
+
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
48437
|
+
if (nodeEqual) {
|
|
48438
|
+
let label = node2.attrs.displayLabel || " ";
|
|
48439
|
+
let textNode = state2.schema.text(label, currentMarks);
|
|
48440
|
+
tr.replaceWith(newPosFrom, newPosTo, textNode);
|
|
48441
|
+
}
|
|
48442
|
+
});
|
|
48443
|
+
}
|
|
48444
|
+
return true;
|
|
48445
|
+
},
|
|
48446
|
+
/**
|
|
48447
|
+
* Resets all annotations to default values.
|
|
48448
|
+
* @example
|
|
48449
|
+
* editor.commands.resetFieldAnnotations()
|
|
48450
|
+
*/
|
|
48451
|
+
resetFieldAnnotations: () => ({ dispatch, state: state2, tr }) => {
|
|
48452
|
+
let annotations = getAllFieldAnnotations(state2);
|
|
48453
|
+
if (!annotations.length) {
|
|
48454
|
+
return true;
|
|
48455
|
+
}
|
|
48456
|
+
tr.setMeta("fieldAnnotationUpdate", true);
|
|
48457
|
+
if (dispatch) {
|
|
48458
|
+
annotations.forEach(({ pos, node: node2 }) => {
|
|
48459
|
+
let newPos = tr.mapping.map(pos);
|
|
48460
|
+
let currentNode = tr.doc.nodeAt(newPos);
|
|
48461
|
+
let nodeEqual = node2.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
48462
|
+
if (nodeEqual) {
|
|
48463
|
+
let displayLabel = node2.attrs.defaultDisplayLabel || node2.attrs.displayLabel || "";
|
|
48464
|
+
tr.setNodeMarkup(newPos, void 0, {
|
|
48465
|
+
...node2.attrs,
|
|
48466
|
+
// reset displayLabel to default.
|
|
48467
|
+
displayLabel,
|
|
48468
|
+
// reset attrs for specific types.
|
|
48469
|
+
imageSrc: null,
|
|
48470
|
+
rawHtml: null,
|
|
48471
|
+
linkUrl: null
|
|
48472
|
+
});
|
|
48473
|
+
}
|
|
48474
|
+
});
|
|
48475
|
+
}
|
|
48476
|
+
return true;
|
|
48477
|
+
},
|
|
48254
48478
|
/**
|
|
48255
48479
|
* Update annotations associated with a field.
|
|
48256
48480
|
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
@@ -49005,12 +49229,16 @@ const startImageUpload = async ({ editor, view, file }) => {
|
|
|
49005
49229
|
}
|
|
49006
49230
|
let id = {};
|
|
49007
49231
|
let { tr, schema } = view.state;
|
|
49008
|
-
|
|
49232
|
+
let { selection } = tr;
|
|
49233
|
+
if (editor.options.isHeaderOrFooter) {
|
|
49234
|
+
selection = editor.options.lastSelection;
|
|
49235
|
+
}
|
|
49236
|
+
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
49009
49237
|
tr.deleteSelection();
|
|
49010
49238
|
}
|
|
49011
49239
|
let imageMeta = {
|
|
49012
49240
|
type: "add",
|
|
49013
|
-
pos:
|
|
49241
|
+
pos: selection.from,
|
|
49014
49242
|
id
|
|
49015
49243
|
};
|
|
49016
49244
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -54259,7 +54487,8 @@ const Pagination = Extension.create({
|
|
|
54259
54487
|
addStorage() {
|
|
54260
54488
|
return {
|
|
54261
54489
|
height: 0,
|
|
54262
|
-
sectionData: null
|
|
54490
|
+
sectionData: null,
|
|
54491
|
+
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
54263
54492
|
};
|
|
54264
54493
|
},
|
|
54265
54494
|
addCommands() {
|
|
@@ -54302,13 +54531,14 @@ const Pagination = Extension.create({
|
|
|
54302
54531
|
shouldUpdate = true;
|
|
54303
54532
|
shouldInitialize = meta.isReadyToInit;
|
|
54304
54533
|
}
|
|
54534
|
+
const syncMeta = tr.getMeta("y-sync$");
|
|
54535
|
+
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
54536
|
+
return { ...oldState };
|
|
54537
|
+
}
|
|
54305
54538
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
54306
54539
|
if (imagePluginTransaction) {
|
|
54307
54540
|
if (imagePluginTransaction.type === "remove") {
|
|
54308
|
-
|
|
54309
|
-
const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
|
|
54310
|
-
if (domImage.complete) onImageLoad(editor);
|
|
54311
|
-
else domImage.onload = () => onImageLoad(editor);
|
|
54541
|
+
onImageLoad(editor);
|
|
54312
54542
|
}
|
|
54313
54543
|
return { ...oldState };
|
|
54314
54544
|
}
|
|
@@ -54335,6 +54565,7 @@ const Pagination = Extension.create({
|
|
|
54335
54565
|
if (isForceUpdate) shouldUpdate = true;
|
|
54336
54566
|
return {
|
|
54337
54567
|
...oldState,
|
|
54568
|
+
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
54338
54569
|
isReadyToInit: shouldInitialize
|
|
54339
54570
|
};
|
|
54340
54571
|
}
|
|
@@ -54363,6 +54594,10 @@ const Pagination = Extension.create({
|
|
|
54363
54594
|
},
|
|
54364
54595
|
onDestroy() {
|
|
54365
54596
|
cleanupFloatingSeparators();
|
|
54597
|
+
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
54598
|
+
if (headerFooterEditors) {
|
|
54599
|
+
headerFooterEditors.clear();
|
|
54600
|
+
}
|
|
54366
54601
|
}
|
|
54367
54602
|
});
|
|
54368
54603
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
|
|
@@ -54423,6 +54658,7 @@ const performUpdate = (editor, view, previousDecorations) => {
|
|
|
54423
54658
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
54424
54659
|
if (!editor.converter) return DecorationSet.empty;
|
|
54425
54660
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
54661
|
+
if (!pageSize) return DecorationSet.empty;
|
|
54426
54662
|
const { width, height } = pageSize;
|
|
54427
54663
|
if (!width || !height) return DecorationSet.empty;
|
|
54428
54664
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -54461,11 +54697,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54461
54697
|
let pageHeightThreshold = pageHeight;
|
|
54462
54698
|
let footer = null, header = null;
|
|
54463
54699
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
54464
|
-
const
|
|
54700
|
+
const isFirstHeader = true;
|
|
54701
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
54465
54702
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
54466
54703
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
54467
54704
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
54468
|
-
const
|
|
54705
|
+
const isLastFooter = true;
|
|
54706
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
54469
54707
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
54470
54708
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
54471
54709
|
if (!coords) return [];
|
|
@@ -54484,7 +54722,8 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54484
54722
|
if (currentPageNumber === 1) {
|
|
54485
54723
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
54486
54724
|
decorations.pop();
|
|
54487
|
-
const
|
|
54725
|
+
const isFirstHeader2 = true;
|
|
54726
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
54488
54727
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
54489
54728
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
54490
54729
|
}
|
|
@@ -54558,15 +54797,15 @@ function createFinalPagePadding(bufferHeight) {
|
|
|
54558
54797
|
div2.style.height = bufferHeight + "px";
|
|
54559
54798
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
54560
54799
|
}
|
|
54561
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
54562
|
-
const headerDef = sectionData
|
|
54800
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber, isFirstHeader = false) {
|
|
54801
|
+
const headerDef = sectionData?.headers?.[headerId];
|
|
54563
54802
|
const minHeaderHeight = pageMargins.top * 96;
|
|
54564
54803
|
const headerMargin = pageMargins.header * 96;
|
|
54565
54804
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
54566
54805
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
54567
54806
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
54568
54807
|
const availableHeight = headerHeight - headerMargin;
|
|
54569
|
-
|
|
54808
|
+
let editorContainer = document.createElement("div");
|
|
54570
54809
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
54571
54810
|
headerId = "rId" + generateDocxRandomId();
|
|
54572
54811
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -54578,23 +54817,31 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54578
54817
|
};
|
|
54579
54818
|
}
|
|
54580
54819
|
const data = editor.converter.headers[headerId];
|
|
54581
|
-
const
|
|
54582
|
-
|
|
54583
|
-
|
|
54584
|
-
|
|
54585
|
-
|
|
54586
|
-
|
|
54587
|
-
|
|
54588
|
-
|
|
54589
|
-
|
|
54590
|
-
|
|
54591
|
-
|
|
54592
|
-
|
|
54593
|
-
|
|
54594
|
-
|
|
54820
|
+
const pageNumberIndex = currentPageNumber - 1;
|
|
54821
|
+
const editorKey = getHeaderFooterEditorKey({ pageNumber: pageNumberIndex, isHeader: true, isFirstHeader });
|
|
54822
|
+
let editorSection = null;
|
|
54823
|
+
const { headerFooterEditors } = editor.storage.pagination;
|
|
54824
|
+
if (headerFooterEditors.has(editorKey) && editor.converter.headerEditors[pageNumberIndex]) {
|
|
54825
|
+
const editorData = headerFooterEditors.get(editorKey);
|
|
54826
|
+
editorSection = editorData.editor;
|
|
54827
|
+
editorContainer = editorSection.element;
|
|
54828
|
+
} else {
|
|
54829
|
+
editorSection = createHeaderFooterEditor({
|
|
54830
|
+
editor,
|
|
54831
|
+
data,
|
|
54832
|
+
editorContainer,
|
|
54833
|
+
appendToBody: false,
|
|
54834
|
+
sectionId: headerId,
|
|
54835
|
+
type: "header",
|
|
54836
|
+
availableHeight,
|
|
54837
|
+
currentPageNumber
|
|
54838
|
+
});
|
|
54839
|
+
editor.converter.headerEditors.push({ id: headerId, editor: editorSection });
|
|
54840
|
+
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
54841
|
+
broadcastEditorEvents(editor, editorSection);
|
|
54842
|
+
}
|
|
54595
54843
|
editorSection.setEditable(false, false);
|
|
54596
|
-
|
|
54597
|
-
editorContainer.className = "pagination-section-header";
|
|
54844
|
+
editorContainer.classList.add("pagination-section-header");
|
|
54598
54845
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
54599
54846
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
54600
54847
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -54607,12 +54854,12 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54607
54854
|
headerHeight
|
|
54608
54855
|
};
|
|
54609
54856
|
}
|
|
54610
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
54611
|
-
const footerDef = sectionData
|
|
54857
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber, isLastFooter = false) {
|
|
54858
|
+
const footerDef = sectionData?.footers?.[footerId];
|
|
54612
54859
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
54613
54860
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
54614
54861
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
54615
|
-
|
|
54862
|
+
let editorContainer = document.createElement("div");
|
|
54616
54863
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
54617
54864
|
footerId = "rId" + generateDocxRandomId();
|
|
54618
54865
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -54624,23 +54871,31 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54624
54871
|
};
|
|
54625
54872
|
}
|
|
54626
54873
|
const data = editor.converter.footers[footerId];
|
|
54627
|
-
const
|
|
54628
|
-
|
|
54629
|
-
|
|
54630
|
-
|
|
54631
|
-
|
|
54632
|
-
|
|
54633
|
-
|
|
54634
|
-
|
|
54635
|
-
|
|
54636
|
-
|
|
54637
|
-
|
|
54638
|
-
|
|
54639
|
-
|
|
54640
|
-
|
|
54874
|
+
const pageNumberIndex = currentPageNumber - 1;
|
|
54875
|
+
const editorKey = getHeaderFooterEditorKey({ pageNumber: pageNumberIndex, isFooter: true, isLastFooter });
|
|
54876
|
+
let editorSection = null;
|
|
54877
|
+
const { headerFooterEditors } = editor.storage.pagination;
|
|
54878
|
+
if (headerFooterEditors.has(editorKey) && editor.converter.footerEditors[pageNumberIndex]) {
|
|
54879
|
+
const editorData = headerFooterEditors.get(editorKey);
|
|
54880
|
+
editorSection = editorData.editor;
|
|
54881
|
+
editorContainer = editorSection.element;
|
|
54882
|
+
} else {
|
|
54883
|
+
editorSection = createHeaderFooterEditor({
|
|
54884
|
+
editor,
|
|
54885
|
+
data,
|
|
54886
|
+
editorContainer,
|
|
54887
|
+
appendToBody: false,
|
|
54888
|
+
sectionId: footerId,
|
|
54889
|
+
type: "footer",
|
|
54890
|
+
availableHeight: footerHeight,
|
|
54891
|
+
currentPageNumber
|
|
54892
|
+
});
|
|
54893
|
+
editor.converter.footerEditors.push({ id: footerId, editor: editorSection });
|
|
54894
|
+
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
54895
|
+
broadcastEditorEvents(editor, editorSection);
|
|
54896
|
+
}
|
|
54641
54897
|
editorSection.setEditable(false, false);
|
|
54642
|
-
|
|
54643
|
-
editorContainer.className = "pagination-section-footer";
|
|
54898
|
+
editorContainer.classList.add("pagination-section-footer");
|
|
54644
54899
|
editorContainer.style.height = footerHeight + "px";
|
|
54645
54900
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
54646
54901
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -54653,10 +54908,28 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54653
54908
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
54654
54909
|
};
|
|
54655
54910
|
}
|
|
54911
|
+
const getHeaderFooterEditorKey = ({
|
|
54912
|
+
pageNumber,
|
|
54913
|
+
isHeader,
|
|
54914
|
+
isFooter,
|
|
54915
|
+
isFirstHeader = false,
|
|
54916
|
+
isLastFooter = false
|
|
54917
|
+
}) => {
|
|
54918
|
+
if (isFirstHeader) return `first-header-${pageNumber}`;
|
|
54919
|
+
if (isLastFooter) return `last-footer-${pageNumber}`;
|
|
54920
|
+
if (isHeader) return `header-${pageNumber}`;
|
|
54921
|
+
if (isFooter) return `footer-${pageNumber}`;
|
|
54922
|
+
return void 0;
|
|
54923
|
+
};
|
|
54656
54924
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
54657
54925
|
if (editor.options.documentMode !== "editing") return;
|
|
54658
54926
|
editor.setEditable(false, false);
|
|
54659
|
-
toggleHeaderFooterEditMode(
|
|
54927
|
+
toggleHeaderFooterEditMode({
|
|
54928
|
+
editor,
|
|
54929
|
+
focusedSectionEditor: currentFocusedSectionEditor,
|
|
54930
|
+
isEditMode: true,
|
|
54931
|
+
documentMode: editor.options.documentMode
|
|
54932
|
+
});
|
|
54660
54933
|
};
|
|
54661
54934
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
54662
54935
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -55211,7 +55484,7 @@ const Search = Extension.create({
|
|
|
55211
55484
|
}
|
|
55212
55485
|
});
|
|
55213
55486
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
55214
|
-
const nodeResizer = (nodeNames = ["image"]) => {
|
|
55487
|
+
const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
55215
55488
|
let resizeState = {
|
|
55216
55489
|
dragging: false,
|
|
55217
55490
|
startX: 0,
|
|
@@ -55236,8 +55509,13 @@ const nodeResizer = (nodeNames = ["image"]) => {
|
|
|
55236
55509
|
if (tr.getMeta(NodeResizerKey)) {
|
|
55237
55510
|
return oldState;
|
|
55238
55511
|
}
|
|
55239
|
-
|
|
55512
|
+
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
55240
55513
|
const { selection } = newState;
|
|
55514
|
+
const node2 = selection.node;
|
|
55515
|
+
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
55516
|
+
return DecorationSet.empty;
|
|
55517
|
+
}
|
|
55518
|
+
const decorations = [];
|
|
55241
55519
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
55242
55520
|
decorations.push(
|
|
55243
55521
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -55440,7 +55718,7 @@ const nodeResizer = (nodeNames = ["image"]) => {
|
|
|
55440
55718
|
const NodeResizer = Extension.create({
|
|
55441
55719
|
name: "nodeResizer",
|
|
55442
55720
|
addPmPlugins() {
|
|
55443
|
-
return [nodeResizer(["image"])];
|
|
55721
|
+
return [nodeResizer(["image"], this.editor)];
|
|
55444
55722
|
}
|
|
55445
55723
|
});
|
|
55446
55724
|
const getRichTextExtensions = () => {
|
|
@@ -64116,7 +64394,6 @@ const style$2 = cB("icon", `
|
|
|
64116
64394
|
display: inline-block;
|
|
64117
64395
|
position: relative;
|
|
64118
64396
|
fill: currentColor;
|
|
64119
|
-
transform: translateZ(0);
|
|
64120
64397
|
`, [cM("color-transition", {
|
|
64121
64398
|
transition: "color .3s var(--n-bezier)"
|
|
64122
64399
|
}), cM("depth", {
|