@harbour-enterprises/superdoc 0.13.2-rev9 → 0.13.2
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-KKY27oz-.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
- package/dist/chunks/{eventemitter3-CHxWXmuK.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
- package/dist/chunks/{index-CweAXNfB.cjs → index-B4J7wgs6.cjs} +2 -2
- package/dist/chunks/{index-kOMfCfBT.cjs → index-Cdsq63Xq.cjs} +4 -4
- package/dist/chunks/{index-DS3W0eVB.es.js → index-Diu6UKHt.es.js} +4 -4
- package/dist/chunks/{index-BqLFjUHn.es.js → index-Hr3Um-Bg.es.js} +2 -2
- package/dist/chunks/{jszip-9bCX1h2W.cjs → jszip-BTAcmbVg.cjs} +1 -1
- package/dist/chunks/{jszip-Cl3s9njw.es.js → jszip-DckFs3A7.es.js} +1 -1
- package/dist/chunks/{super-editor.es-TaswSSDL.cjs → super-editor.es-BM89AzsN.cjs} +811 -1088
- package/dist/chunks/{super-editor.es-BE0HKCoV.es.js → super-editor.es-BNyzbCw0.es.js} +811 -1088
- package/dist/chunks/{url-B8LY3nwf.cjs → url-BIzg4y2i.cjs} +2 -2
- package/dist/chunks/{url-Bq00tGvm.es.js → url-CHayXMZH.es.js} +2 -2
- package/dist/chunks/{vue-BBJVqxjL.es.js → vue-Bi1uWinj.es.js} +3 -10
- package/dist/chunks/{vue-BBjMeYfo.cjs → vue-HIY1g7dm.cjs} +3 -10
- package/dist/chunks/{xml-js-BuAdLsHD.cjs → xml-js-BjqmFOSP.cjs} +102 -81
- package/dist/chunks/{xml-js-1F0lia4t.es.js → xml-js-CfClL-1b.es.js} +102 -81
- package/dist/style.css +1 -2
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BvRopd2F.js → converter-CsK9KCaL.js} +55 -637
- package/dist/super-editor/chunks/{docx-zipper-CZ8M74hv.js → docx-zipper-6iKmmME2.js} +1 -1
- package/dist/super-editor/chunks/{editor-D1rD0fdS.js → editor-Cxb-Zwyu.js} +685 -387
- package/dist/super-editor/chunks/{toolbar-CvP4K1yD.js → toolbar-QHIHaeEf.js} +3 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/core/Editor.d.ts +0 -7
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/InputRule.d.ts +0 -7
- package/dist/super-editor/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/annotator.d.ts +0 -4
- package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
- 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 +1 -6
- 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 +1 -2
- package/dist/super-editor/super-editor.es.js +7 -7
- 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 +9 -8
- package/dist/superdoc.es.js +10 -9
- package/dist/superdoc.umd.js +815 -1098
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts +0 -2
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts.map +0 -1
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +0 -3
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-
|
|
1
|
+
import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-Bi1uWinj.es.js";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { UndoManager, Item as Item$2, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
4
4
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -10941,7 +10941,7 @@ class NodeRange {
|
|
|
10941
10941
|
}
|
|
10942
10942
|
}
|
|
10943
10943
|
const emptyAttrs = /* @__PURE__ */ Object.create(null);
|
|
10944
|
-
let Node$
|
|
10944
|
+
let Node$2 = class Node2 {
|
|
10945
10945
|
/**
|
|
10946
10946
|
@internal
|
|
10947
10947
|
*/
|
|
@@ -11342,8 +11342,8 @@ let Node$1$1 = class Node2 {
|
|
|
11342
11342
|
return node2;
|
|
11343
11343
|
}
|
|
11344
11344
|
};
|
|
11345
|
-
Node$
|
|
11346
|
-
class TextNode extends Node$
|
|
11345
|
+
Node$2.prototype.text = void 0;
|
|
11346
|
+
class TextNode extends Node$2 {
|
|
11347
11347
|
/**
|
|
11348
11348
|
@internal
|
|
11349
11349
|
*/
|
|
@@ -11930,7 +11930,7 @@ let NodeType$1 = class NodeType {
|
|
|
11930
11930
|
create(attrs = null, content, marks) {
|
|
11931
11931
|
if (this.isText)
|
|
11932
11932
|
throw new Error("NodeType.create can't construct text nodes");
|
|
11933
|
-
return new Node$
|
|
11933
|
+
return new Node$2(this, this.computeAttrs(attrs), Fragment.from(content), Mark$1.setFrom(marks));
|
|
11934
11934
|
}
|
|
11935
11935
|
/**
|
|
11936
11936
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
@@ -11940,7 +11940,7 @@ let NodeType$1 = class NodeType {
|
|
|
11940
11940
|
createChecked(attrs = null, content, marks) {
|
|
11941
11941
|
content = Fragment.from(content);
|
|
11942
11942
|
this.checkContent(content);
|
|
11943
|
-
return new Node$
|
|
11943
|
+
return new Node$2(this, this.computeAttrs(attrs), content, Mark$1.setFrom(marks));
|
|
11944
11944
|
}
|
|
11945
11945
|
/**
|
|
11946
11946
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
@@ -11963,7 +11963,7 @@ let NodeType$1 = class NodeType {
|
|
|
11963
11963
|
let after = matched && matched.fillBefore(Fragment.empty, true);
|
|
11964
11964
|
if (!after)
|
|
11965
11965
|
return null;
|
|
11966
|
-
return new Node$
|
|
11966
|
+
return new Node$2(this, attrs, content.append(after), Mark$1.setFrom(marks));
|
|
11967
11967
|
}
|
|
11968
11968
|
/**
|
|
11969
11969
|
Returns true if the given fragment is valid content for this node
|
|
@@ -12200,7 +12200,7 @@ let Schema$1 = class Schema {
|
|
|
12200
12200
|
bound.
|
|
12201
12201
|
*/
|
|
12202
12202
|
nodeFromJSON(json) {
|
|
12203
|
-
return Node$
|
|
12203
|
+
return Node$2.fromJSON(this, json);
|
|
12204
12204
|
}
|
|
12205
12205
|
/**
|
|
12206
12206
|
Deserialize a mark from its JSON representation. This method is
|
|
@@ -13726,7 +13726,7 @@ class ReplaceStep extends Step {
|
|
|
13726
13726
|
}
|
|
13727
13727
|
}
|
|
13728
13728
|
Step.jsonID("replace", ReplaceStep);
|
|
13729
|
-
|
|
13729
|
+
class ReplaceAroundStep extends Step {
|
|
13730
13730
|
/**
|
|
13731
13731
|
Create a replace-around step with the given range and gap.
|
|
13732
13732
|
`insert` should be the point in the slice into which the content
|
|
@@ -13766,7 +13766,7 @@ let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
|
13766
13766
|
}
|
|
13767
13767
|
invert(doc2) {
|
|
13768
13768
|
let gap = this.gapTo - this.gapFrom;
|
|
13769
|
-
return new
|
|
13769
|
+
return new ReplaceAroundStep(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);
|
|
13770
13770
|
}
|
|
13771
13771
|
map(mapping) {
|
|
13772
13772
|
let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
@@ -13774,7 +13774,7 @@ let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
|
13774
13774
|
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
13775
13775
|
if (from2.deletedAcross && to.deletedAcross || gapFrom < from2.pos || gapTo > to.pos)
|
|
13776
13776
|
return null;
|
|
13777
|
-
return new
|
|
13777
|
+
return new ReplaceAroundStep(from2.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
13778
13778
|
}
|
|
13779
13779
|
toJSON() {
|
|
13780
13780
|
let json = {
|
|
@@ -13797,10 +13797,10 @@ let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
|
13797
13797
|
static fromJSON(schema, json) {
|
|
13798
13798
|
if (typeof json.from != "number" || typeof json.to != "number" || typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
13799
13799
|
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
13800
|
-
return new
|
|
13800
|
+
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
13801
13801
|
}
|
|
13802
|
-
}
|
|
13803
|
-
Step.jsonID("replaceAround", ReplaceAroundStep
|
|
13802
|
+
}
|
|
13803
|
+
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
13804
13804
|
function contentBetween(doc2, from2, to) {
|
|
13805
13805
|
let $from = doc2.resolve(from2), dist2 = to - from2, depth = $from.depth;
|
|
13806
13806
|
while (dist2 > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
@@ -13953,7 +13953,7 @@ function lift(tr, range2, target) {
|
|
|
13953
13953
|
} else {
|
|
13954
13954
|
end2++;
|
|
13955
13955
|
}
|
|
13956
|
-
tr.step(new ReplaceAroundStep
|
|
13956
|
+
tr.step(new ReplaceAroundStep(start2, end2, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
13957
13957
|
}
|
|
13958
13958
|
function findWrapping(range2, nodeType, attrs = null, innerRange = range2) {
|
|
13959
13959
|
let around = findWrappingOutside(range2, nodeType);
|
|
@@ -13998,7 +13998,7 @@ function wrap(tr, range2, wrappers) {
|
|
|
13998
13998
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
13999
13999
|
}
|
|
14000
14000
|
let start2 = range2.start, end2 = range2.end;
|
|
14001
|
-
tr.step(new ReplaceAroundStep
|
|
14001
|
+
tr.step(new ReplaceAroundStep(start2, end2, start2, end2, new Slice(content, 0, 0), wrappers.length, true));
|
|
14002
14002
|
}
|
|
14003
14003
|
function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
14004
14004
|
if (!type2.isTextblock)
|
|
@@ -14020,7 +14020,7 @@ function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
|
14020
14020
|
clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type2, void 0, convertNewlines === null);
|
|
14021
14021
|
let mapping = tr.mapping.slice(mapFrom);
|
|
14022
14022
|
let startM = mapping.map(pos, 1), endM = mapping.map(pos + node2.nodeSize, 1);
|
|
14023
|
-
tr.step(new ReplaceAroundStep
|
|
14023
|
+
tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
14024
14024
|
if (convertNewlines === true)
|
|
14025
14025
|
replaceNewlines(tr, node2, pos, mapFrom);
|
|
14026
14026
|
return false;
|
|
@@ -14061,7 +14061,7 @@ function setNodeMarkup(tr, pos, type2, attrs, marks) {
|
|
|
14061
14061
|
return tr.replaceWith(pos, pos + node2.nodeSize, newNode);
|
|
14062
14062
|
if (!type2.validContent(node2.content))
|
|
14063
14063
|
throw new RangeError("Invalid content for node type " + type2.name);
|
|
14064
|
-
tr.step(new ReplaceAroundStep
|
|
14064
|
+
tr.step(new ReplaceAroundStep(pos, pos + node2.nodeSize, pos + 1, pos + node2.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
14065
14065
|
}
|
|
14066
14066
|
function canSplit(doc2, pos, depth = 1, typesAfter) {
|
|
14067
14067
|
let $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
|
|
@@ -14262,7 +14262,7 @@ class Fitter {
|
|
|
14262
14262
|
}
|
|
14263
14263
|
let slice2 = new Slice(content, openStart, openEnd);
|
|
14264
14264
|
if (moveInline > -1)
|
|
14265
|
-
return new ReplaceAroundStep
|
|
14265
|
+
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice2, placedSize);
|
|
14266
14266
|
if (slice2.size || $from.pos != this.$to.pos)
|
|
14267
14267
|
return new ReplaceStep($from.pos, $to.pos, slice2);
|
|
14268
14268
|
return null;
|
|
@@ -15345,7 +15345,7 @@ function selectionToInsertionEnd$1(tr, startLen, bias) {
|
|
|
15345
15345
|
if (last < startLen)
|
|
15346
15346
|
return;
|
|
15347
15347
|
let step = tr.steps[last];
|
|
15348
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
15348
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))
|
|
15349
15349
|
return;
|
|
15350
15350
|
let map3 = tr.mapping.maps[last], end2;
|
|
15351
15351
|
map3.forEach((_from, _to, _newFrom, newTo) => {
|
|
@@ -15760,7 +15760,7 @@ class EditorState {
|
|
|
15760
15760
|
let instance = new EditorState($config);
|
|
15761
15761
|
$config.fields.forEach((field) => {
|
|
15762
15762
|
if (field.name == "doc") {
|
|
15763
|
-
instance.doc = Node$
|
|
15763
|
+
instance.doc = Node$2.fromJSON(config.schema, json.doc);
|
|
15764
15764
|
} else if (field.name == "selection") {
|
|
15765
15765
|
instance.selection = Selection.fromJSON(instance.doc, json.selection);
|
|
15766
15766
|
} else if (field.name == "storedMarks") {
|
|
@@ -18821,583 +18821,6 @@ const createColGroup = (node2, cellMinWidth, overrideCol, overrideValue) => {
|
|
|
18821
18821
|
colgroupValues
|
|
18822
18822
|
};
|
|
18823
18823
|
};
|
|
18824
|
-
function chainableEditorState(transaction, state2) {
|
|
18825
|
-
let { selection, doc: doc2, storedMarks } = transaction;
|
|
18826
|
-
return {
|
|
18827
|
-
...state2,
|
|
18828
|
-
apply: state2.apply.bind(state2),
|
|
18829
|
-
applyTransaction: state2.applyTransaction.bind(state2),
|
|
18830
|
-
plugins: state2.plugins,
|
|
18831
|
-
schema: state2.schema,
|
|
18832
|
-
reconfigure: state2.reconfigure.bind(state2),
|
|
18833
|
-
toJSON: state2.toJSON.bind(state2),
|
|
18834
|
-
get storedMarks() {
|
|
18835
|
-
return storedMarks;
|
|
18836
|
-
},
|
|
18837
|
-
get selection() {
|
|
18838
|
-
return selection;
|
|
18839
|
-
},
|
|
18840
|
-
get doc() {
|
|
18841
|
-
return doc2;
|
|
18842
|
-
},
|
|
18843
|
-
get tr() {
|
|
18844
|
-
selection = transaction.selection;
|
|
18845
|
-
doc2 = transaction.doc;
|
|
18846
|
-
storedMarks = transaction.storedMarks;
|
|
18847
|
-
return transaction;
|
|
18848
|
-
}
|
|
18849
|
-
};
|
|
18850
|
-
}
|
|
18851
|
-
class CommandService {
|
|
18852
|
-
constructor(props) {
|
|
18853
|
-
__publicField$2(this, "editor");
|
|
18854
|
-
__publicField$2(this, "rawCommands");
|
|
18855
|
-
this.editor = props.editor;
|
|
18856
|
-
this.rawCommands = this.editor.extensionService.commands;
|
|
18857
|
-
}
|
|
18858
|
-
/**
|
|
18859
|
-
* Static method for creating a service.
|
|
18860
|
-
* @param args Arguments for the constructor.
|
|
18861
|
-
*/
|
|
18862
|
-
static create(...args) {
|
|
18863
|
-
return new CommandService(...args);
|
|
18864
|
-
}
|
|
18865
|
-
/**
|
|
18866
|
-
* Get editor state.
|
|
18867
|
-
*/
|
|
18868
|
-
get state() {
|
|
18869
|
-
return this.editor.state;
|
|
18870
|
-
}
|
|
18871
|
-
/**
|
|
18872
|
-
* Get all commands with wrapped command method.
|
|
18873
|
-
*/
|
|
18874
|
-
get commands() {
|
|
18875
|
-
const { editor, state: state2 } = this;
|
|
18876
|
-
const { view } = editor;
|
|
18877
|
-
const { tr } = state2;
|
|
18878
|
-
const props = this.createProps(tr);
|
|
18879
|
-
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
18880
|
-
const method = (...args) => {
|
|
18881
|
-
const fn2 = command2(...args)(props);
|
|
18882
|
-
if (!tr.getMeta("preventDispatch")) {
|
|
18883
|
-
view.dispatch(tr);
|
|
18884
|
-
}
|
|
18885
|
-
return fn2;
|
|
18886
|
-
};
|
|
18887
|
-
return [name, method];
|
|
18888
|
-
});
|
|
18889
|
-
return Object.fromEntries(entries);
|
|
18890
|
-
}
|
|
18891
|
-
/**
|
|
18892
|
-
* Create a chain of commands to call multiple commands at once.
|
|
18893
|
-
*/
|
|
18894
|
-
get chain() {
|
|
18895
|
-
return () => this.createChain();
|
|
18896
|
-
}
|
|
18897
|
-
/**
|
|
18898
|
-
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
18899
|
-
*/
|
|
18900
|
-
get can() {
|
|
18901
|
-
return () => this.createCan();
|
|
18902
|
-
}
|
|
18903
|
-
/**
|
|
18904
|
-
* Creates a chain of commands.
|
|
18905
|
-
* @param startTr Start transaction.
|
|
18906
|
-
* @param shouldDispatch Should dispatch or not.
|
|
18907
|
-
*/
|
|
18908
|
-
createChain(startTr, shouldDispatch = true) {
|
|
18909
|
-
const { editor, state: state2, rawCommands } = this;
|
|
18910
|
-
const { view } = editor;
|
|
18911
|
-
const callbacks2 = [];
|
|
18912
|
-
const hasStartTr = !!startTr;
|
|
18913
|
-
const tr = startTr || state2.tr;
|
|
18914
|
-
const run2 = () => {
|
|
18915
|
-
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
18916
|
-
view.dispatch(tr);
|
|
18917
|
-
}
|
|
18918
|
-
return callbacks2.every((cb) => cb === true);
|
|
18919
|
-
};
|
|
18920
|
-
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
18921
|
-
const chainedCommand = (...args) => {
|
|
18922
|
-
const props = this.createProps(tr, shouldDispatch);
|
|
18923
|
-
const callback = command2(...args)(props);
|
|
18924
|
-
callbacks2.push(callback);
|
|
18925
|
-
return chain;
|
|
18926
|
-
};
|
|
18927
|
-
return [name, chainedCommand];
|
|
18928
|
-
});
|
|
18929
|
-
const chain = {
|
|
18930
|
-
...Object.fromEntries(entries),
|
|
18931
|
-
run: run2
|
|
18932
|
-
};
|
|
18933
|
-
return chain;
|
|
18934
|
-
}
|
|
18935
|
-
/**
|
|
18936
|
-
* Creates a can check for commands.
|
|
18937
|
-
* @param startTr Start transaction.
|
|
18938
|
-
*/
|
|
18939
|
-
createCan(startTr) {
|
|
18940
|
-
const { rawCommands, state: state2 } = this;
|
|
18941
|
-
const dispatch = false;
|
|
18942
|
-
const tr = startTr || state2.tr;
|
|
18943
|
-
const props = this.createProps(tr, dispatch);
|
|
18944
|
-
const commands2 = Object.fromEntries(
|
|
18945
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
18946
|
-
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
18947
|
-
})
|
|
18948
|
-
);
|
|
18949
|
-
return {
|
|
18950
|
-
...commands2,
|
|
18951
|
-
chain: () => this.createChain(tr, dispatch)
|
|
18952
|
-
};
|
|
18953
|
-
}
|
|
18954
|
-
/**
|
|
18955
|
-
* Creates default props for the command method.
|
|
18956
|
-
* @param {*} tr Transaction.
|
|
18957
|
-
* @param {*} shouldDispatch Check if should dispatch.
|
|
18958
|
-
* @returns Object with props.
|
|
18959
|
-
*/
|
|
18960
|
-
createProps(tr, shouldDispatch = true) {
|
|
18961
|
-
const { editor, state: state2, rawCommands } = this;
|
|
18962
|
-
const { view } = editor;
|
|
18963
|
-
const props = {
|
|
18964
|
-
tr,
|
|
18965
|
-
editor,
|
|
18966
|
-
view,
|
|
18967
|
-
state: chainableEditorState(tr, state2),
|
|
18968
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
18969
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
18970
|
-
can: () => this.createCan(tr),
|
|
18971
|
-
get commands() {
|
|
18972
|
-
return Object.fromEntries(
|
|
18973
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
18974
|
-
return [name, (...args) => command2(...args)(props)];
|
|
18975
|
-
})
|
|
18976
|
-
);
|
|
18977
|
-
}
|
|
18978
|
-
};
|
|
18979
|
-
return props;
|
|
18980
|
-
}
|
|
18981
|
-
}
|
|
18982
|
-
function getHTMLFromFragment(fragment, schema) {
|
|
18983
|
-
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
18984
|
-
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
18985
|
-
const container = temporaryDocument.createElement("div");
|
|
18986
|
-
container.appendChild(documentFragment);
|
|
18987
|
-
return container.innerHTML;
|
|
18988
|
-
}
|
|
18989
|
-
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
18990
|
-
let textBefore = "";
|
|
18991
|
-
const sliceEndPos = $from.parentOffset;
|
|
18992
|
-
$from.parent.nodesBetween(
|
|
18993
|
-
Math.max(0, sliceEndPos - maxMatch),
|
|
18994
|
-
sliceEndPos,
|
|
18995
|
-
(node2, pos, parent, index2) => {
|
|
18996
|
-
const chunk = node2.type.spec.toText?.({
|
|
18997
|
-
node: node2,
|
|
18998
|
-
pos,
|
|
18999
|
-
parent,
|
|
19000
|
-
index: index2
|
|
19001
|
-
}) || node2.textContent || "%leaf%";
|
|
19002
|
-
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
19003
|
-
}
|
|
19004
|
-
);
|
|
19005
|
-
return textBefore;
|
|
19006
|
-
};
|
|
19007
|
-
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
19008
|
-
const { converter } = editor;
|
|
19009
|
-
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
19010
|
-
let cleanedHtml = convertEmToPt(html);
|
|
19011
|
-
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
19012
|
-
const tempDiv = document.createElement("div");
|
|
19013
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
19014
|
-
const paragraphs = tempDiv.querySelectorAll("p");
|
|
19015
|
-
paragraphs.forEach((p) => {
|
|
19016
|
-
const innerHTML3 = p.innerHTML;
|
|
19017
|
-
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
19018
|
-
const styleAttr = p.getAttribute("style") || "";
|
|
19019
|
-
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
19020
|
-
if (msoListMatch) {
|
|
19021
|
-
const [, abstractId, level] = msoListMatch;
|
|
19022
|
-
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
19023
|
-
if (!listNumId) return;
|
|
19024
|
-
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
19025
|
-
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
19026
|
-
p.setAttribute("data-num-id", listNumId);
|
|
19027
|
-
p.setAttribute("data-list-level", level - 1);
|
|
19028
|
-
p.setAttribute("data-start", start2);
|
|
19029
|
-
p.setAttribute("data-lvl-text", lvlText);
|
|
19030
|
-
p.setAttribute("data-num-fmt", numFmt);
|
|
19031
|
-
}
|
|
19032
|
-
extractAndRemoveConditionalPrefix(p);
|
|
19033
|
-
});
|
|
19034
|
-
transformWordLists(tempDiv);
|
|
19035
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
19036
|
-
tempDiv.remove();
|
|
19037
|
-
const { dispatch } = editor.view;
|
|
19038
|
-
if (!dispatch) return false;
|
|
19039
|
-
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
19040
|
-
return true;
|
|
19041
|
-
};
|
|
19042
|
-
const getLevelDefinition = (abstractDefinition, level) => {
|
|
19043
|
-
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
19044
|
-
const levelElement = abstractDefinition.elements.find((el) => {
|
|
19045
|
-
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
19046
|
-
});
|
|
19047
|
-
if (!levelElement) return null;
|
|
19048
|
-
const { elements } = levelElement;
|
|
19049
|
-
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
19050
|
-
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
19051
|
-
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
19052
|
-
return { lvlText, start: start2, numFmt, elements };
|
|
19053
|
-
};
|
|
19054
|
-
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
19055
|
-
const { definitions } = editor?.converter?.numbering;
|
|
19056
|
-
if (!definitions) return null;
|
|
19057
|
-
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
19058
|
-
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
19059
|
-
});
|
|
19060
|
-
return matchedDefinition?.attributes?.["w:numId"];
|
|
19061
|
-
};
|
|
19062
|
-
const getListAbstractDefinition = (abstractId, editor) => {
|
|
19063
|
-
const { abstracts = {} } = editor?.converter?.numbering;
|
|
19064
|
-
return abstracts[abstractId] || null;
|
|
19065
|
-
};
|
|
19066
|
-
const transformWordLists = (container) => {
|
|
19067
|
-
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
19068
|
-
const listMap = /* @__PURE__ */ new Map();
|
|
19069
|
-
const listLevels = {};
|
|
19070
|
-
for (const p of paragraphs) {
|
|
19071
|
-
const listId = p.getAttribute("data-num-id");
|
|
19072
|
-
const level = parseInt(p.getAttribute("data-list-level"));
|
|
19073
|
-
const numFmt = p.getAttribute("data-num-fmt");
|
|
19074
|
-
const start2 = p.getAttribute("data-start");
|
|
19075
|
-
const lvlText = p.getAttribute("data-lvl-text");
|
|
19076
|
-
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
19077
|
-
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
19078
|
-
}
|
|
19079
|
-
for (const [id, items] of listMap.entries()) {
|
|
19080
|
-
if (!listLevels[id]) {
|
|
19081
|
-
listLevels[id] = {
|
|
19082
|
-
stack: [],
|
|
19083
|
-
counts: {},
|
|
19084
|
-
prevLevel: null
|
|
19085
|
-
};
|
|
19086
|
-
}
|
|
19087
|
-
const parentStack = [];
|
|
19088
|
-
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
19089
|
-
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
19090
|
-
const li = document.createElement("li");
|
|
19091
|
-
li.innerHTML = p.innerHTML;
|
|
19092
|
-
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
19093
|
-
li.setAttribute("data-num-id", id);
|
|
19094
|
-
li.setAttribute("data-lvl-text", lvlText);
|
|
19095
|
-
li.setAttribute("data-num-fmt", numFmt);
|
|
19096
|
-
if (p.hasAttribute("data-font-family")) {
|
|
19097
|
-
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
19098
|
-
}
|
|
19099
|
-
if (p.hasAttribute("data-font-size")) {
|
|
19100
|
-
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
19101
|
-
}
|
|
19102
|
-
const parentNode2 = p.parentNode;
|
|
19103
|
-
let listForLevel = parentStack[level];
|
|
19104
|
-
if (!listForLevel) {
|
|
19105
|
-
const newList = document.createElement("ol");
|
|
19106
|
-
newList.setAttribute("data-list-id", id);
|
|
19107
|
-
newList.level = level;
|
|
19108
|
-
if (level > 0) {
|
|
19109
|
-
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
19110
|
-
if (parentLi) parentLi.appendChild(newList);
|
|
19111
|
-
} else {
|
|
19112
|
-
parentNode2.insertBefore(newList, p);
|
|
19113
|
-
}
|
|
19114
|
-
parentStack[level] = newList;
|
|
19115
|
-
parentStack.length = level + 1;
|
|
19116
|
-
listForLevel = newList;
|
|
19117
|
-
}
|
|
19118
|
-
listForLevel.appendChild(li);
|
|
19119
|
-
p.remove();
|
|
19120
|
-
});
|
|
19121
|
-
}
|
|
19122
|
-
};
|
|
19123
|
-
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
19124
|
-
const levelState = listLevels[listId];
|
|
19125
|
-
if (!levelState.stack) levelState.stack = [];
|
|
19126
|
-
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
19127
|
-
if (levelState.prevLevel === null) {
|
|
19128
|
-
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
19129
|
-
} else {
|
|
19130
|
-
if (currentLevel > levelState.prevLevel) {
|
|
19131
|
-
levelState.stack.push(1);
|
|
19132
|
-
} else if (currentLevel === levelState.prevLevel) {
|
|
19133
|
-
levelState.stack[levelState.stack.length - 1]++;
|
|
19134
|
-
} else {
|
|
19135
|
-
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
19136
|
-
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
19137
|
-
}
|
|
19138
|
-
}
|
|
19139
|
-
levelState.prevLevel = currentLevel;
|
|
19140
|
-
return [...levelState.stack];
|
|
19141
|
-
}
|
|
19142
|
-
function extractAndRemoveConditionalPrefix(p) {
|
|
19143
|
-
const nodes = Array.from(p.childNodes);
|
|
19144
|
-
let fontFamily2 = null;
|
|
19145
|
-
let fontSize2 = null;
|
|
19146
|
-
let start2 = -1, end2 = -1;
|
|
19147
|
-
nodes.forEach((node2, index2) => {
|
|
19148
|
-
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
19149
|
-
start2 = index2;
|
|
19150
|
-
}
|
|
19151
|
-
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
19152
|
-
end2 = index2;
|
|
19153
|
-
}
|
|
19154
|
-
});
|
|
19155
|
-
if (start2 !== -1 && end2 !== -1) {
|
|
19156
|
-
for (let i = start2 + 1; i < end2; i++) {
|
|
19157
|
-
const node2 = nodes[i];
|
|
19158
|
-
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
19159
|
-
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
19160
|
-
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
19161
|
-
}
|
|
19162
|
-
}
|
|
19163
|
-
for (let i = end2; i >= start2; i--) {
|
|
19164
|
-
p.removeChild(p.childNodes[i]);
|
|
19165
|
-
}
|
|
19166
|
-
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
19167
|
-
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
19168
|
-
}
|
|
19169
|
-
}
|
|
19170
|
-
class InputRule {
|
|
19171
|
-
constructor(config) {
|
|
19172
|
-
__publicField$2(this, "match");
|
|
19173
|
-
__publicField$2(this, "handler");
|
|
19174
|
-
this.match = config.match;
|
|
19175
|
-
this.handler = config.handler;
|
|
19176
|
-
}
|
|
19177
|
-
}
|
|
19178
|
-
const inputRuleMatcherHandler = (text, match) => {
|
|
19179
|
-
if (isRegExp(match)) {
|
|
19180
|
-
return match.exec(text);
|
|
19181
|
-
}
|
|
19182
|
-
const inputRuleMatch = match(text);
|
|
19183
|
-
if (!inputRuleMatch) {
|
|
19184
|
-
return null;
|
|
19185
|
-
}
|
|
19186
|
-
const result = [inputRuleMatch.text];
|
|
19187
|
-
result.index = inputRuleMatch.index;
|
|
19188
|
-
result.input = text;
|
|
19189
|
-
result.data = inputRuleMatch.data;
|
|
19190
|
-
if (inputRuleMatch.replaceWith) {
|
|
19191
|
-
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
19192
|
-
console.warn(
|
|
19193
|
-
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
19194
|
-
);
|
|
19195
|
-
}
|
|
19196
|
-
result.push(inputRuleMatch.replaceWith);
|
|
19197
|
-
}
|
|
19198
|
-
return result;
|
|
19199
|
-
};
|
|
19200
|
-
const run = (config) => {
|
|
19201
|
-
const {
|
|
19202
|
-
editor,
|
|
19203
|
-
from: from2,
|
|
19204
|
-
to,
|
|
19205
|
-
text,
|
|
19206
|
-
rules,
|
|
19207
|
-
plugin: plugin2
|
|
19208
|
-
} = config;
|
|
19209
|
-
const { view } = editor;
|
|
19210
|
-
if (view.composing) {
|
|
19211
|
-
return false;
|
|
19212
|
-
}
|
|
19213
|
-
const $from = view.state.doc.resolve(from2);
|
|
19214
|
-
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
19215
|
-
return false;
|
|
19216
|
-
}
|
|
19217
|
-
let matched = false;
|
|
19218
|
-
const textBefore = getTextContentFromNodes($from) + text;
|
|
19219
|
-
rules.forEach((rule) => {
|
|
19220
|
-
if (matched) {
|
|
19221
|
-
return;
|
|
19222
|
-
}
|
|
19223
|
-
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
19224
|
-
if (!match) {
|
|
19225
|
-
return;
|
|
19226
|
-
}
|
|
19227
|
-
const tr = view.state.tr;
|
|
19228
|
-
const state2 = chainableEditorState(tr, view.state);
|
|
19229
|
-
const range2 = {
|
|
19230
|
-
from: from2 - (match[0].length - text.length),
|
|
19231
|
-
to
|
|
19232
|
-
};
|
|
19233
|
-
const { commands: commands2, chain, can } = new CommandService({
|
|
19234
|
-
editor,
|
|
19235
|
-
state: state2
|
|
19236
|
-
});
|
|
19237
|
-
const handler = rule.handler({
|
|
19238
|
-
state: state2,
|
|
19239
|
-
range: range2,
|
|
19240
|
-
match,
|
|
19241
|
-
commands: commands2,
|
|
19242
|
-
chain,
|
|
19243
|
-
can
|
|
19244
|
-
});
|
|
19245
|
-
if (handler === null || !tr.steps.length) {
|
|
19246
|
-
return;
|
|
19247
|
-
}
|
|
19248
|
-
tr.setMeta(plugin2, {
|
|
19249
|
-
transform: tr,
|
|
19250
|
-
from: from2,
|
|
19251
|
-
to,
|
|
19252
|
-
text
|
|
19253
|
-
});
|
|
19254
|
-
view.dispatch(tr);
|
|
19255
|
-
matched = true;
|
|
19256
|
-
});
|
|
19257
|
-
return matched;
|
|
19258
|
-
};
|
|
19259
|
-
const inputRulesPlugin = ({ editor, rules }) => {
|
|
19260
|
-
const plugin2 = new Plugin({
|
|
19261
|
-
key: new PluginKey("inputRulesPlugin"),
|
|
19262
|
-
state: {
|
|
19263
|
-
init() {
|
|
19264
|
-
return null;
|
|
19265
|
-
},
|
|
19266
|
-
apply(tr, prev, state2) {
|
|
19267
|
-
const stored = tr.getMeta(plugin2);
|
|
19268
|
-
if (stored) {
|
|
19269
|
-
return stored;
|
|
19270
|
-
}
|
|
19271
|
-
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
19272
|
-
const isSimulatedInput = !!simulatedInputMeta;
|
|
19273
|
-
if (isSimulatedInput) {
|
|
19274
|
-
setTimeout(() => {
|
|
19275
|
-
let { text } = simulatedInputMeta;
|
|
19276
|
-
if (typeof text !== "string") {
|
|
19277
|
-
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
19278
|
-
}
|
|
19279
|
-
const { from: from2 } = simulatedInputMeta;
|
|
19280
|
-
const to = from2 + text.length;
|
|
19281
|
-
run({
|
|
19282
|
-
editor,
|
|
19283
|
-
from: from2,
|
|
19284
|
-
to,
|
|
19285
|
-
text,
|
|
19286
|
-
rules,
|
|
19287
|
-
plugin: plugin2
|
|
19288
|
-
});
|
|
19289
|
-
});
|
|
19290
|
-
}
|
|
19291
|
-
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
19292
|
-
}
|
|
19293
|
-
},
|
|
19294
|
-
props: {
|
|
19295
|
-
handleTextInput(view, from2, to, text) {
|
|
19296
|
-
return run({
|
|
19297
|
-
editor,
|
|
19298
|
-
from: from2,
|
|
19299
|
-
to,
|
|
19300
|
-
text,
|
|
19301
|
-
rules,
|
|
19302
|
-
plugin: plugin2
|
|
19303
|
-
});
|
|
19304
|
-
},
|
|
19305
|
-
// add support for input rules to trigger on enter
|
|
19306
|
-
// this is useful for example for code blocks
|
|
19307
|
-
handleKeyDown(view, event) {
|
|
19308
|
-
if (event.key !== "Enter") {
|
|
19309
|
-
return false;
|
|
19310
|
-
}
|
|
19311
|
-
const { $cursor } = view.state.selection;
|
|
19312
|
-
if ($cursor) {
|
|
19313
|
-
return run({
|
|
19314
|
-
editor,
|
|
19315
|
-
from: $cursor.pos,
|
|
19316
|
-
to: $cursor.pos,
|
|
19317
|
-
text: "\n",
|
|
19318
|
-
rules,
|
|
19319
|
-
plugin: plugin2
|
|
19320
|
-
});
|
|
19321
|
-
}
|
|
19322
|
-
return false;
|
|
19323
|
-
},
|
|
19324
|
-
// Paste handler
|
|
19325
|
-
handlePaste(view, event, slice2) {
|
|
19326
|
-
const clipboard = event.clipboardData;
|
|
19327
|
-
const html = clipboard.getData("text/html");
|
|
19328
|
-
clipboard.getData("text/plain");
|
|
19329
|
-
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
19330
|
-
if (fieldAnnotationContent.length) {
|
|
19331
|
-
return false;
|
|
19332
|
-
}
|
|
19333
|
-
let source;
|
|
19334
|
-
if (!html) {
|
|
19335
|
-
source = "plain-text";
|
|
19336
|
-
} else if (isWordHtml(html)) {
|
|
19337
|
-
source = "word-html";
|
|
19338
|
-
} else {
|
|
19339
|
-
source = "browser-html";
|
|
19340
|
-
}
|
|
19341
|
-
switch (source) {
|
|
19342
|
-
case "plain-text":
|
|
19343
|
-
break;
|
|
19344
|
-
case "word-html":
|
|
19345
|
-
if (editor.options.mode === "docx") {
|
|
19346
|
-
return handleDocxPaste(html, editor, view, plugin2);
|
|
19347
|
-
}
|
|
19348
|
-
case "browser-html":
|
|
19349
|
-
return handleHtmlPaste$1(html, editor);
|
|
19350
|
-
}
|
|
19351
|
-
return false;
|
|
19352
|
-
}
|
|
19353
|
-
},
|
|
19354
|
-
isInputRules: true
|
|
19355
|
-
});
|
|
19356
|
-
return plugin2;
|
|
19357
|
-
};
|
|
19358
|
-
function isWordHtml(html) {
|
|
19359
|
-
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
19360
|
-
}
|
|
19361
|
-
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
19362
|
-
const htmlWithPtSizing = convertEmToPt(html);
|
|
19363
|
-
const cleanedHtml = sanitizeHtml(htmlWithPtSizing);
|
|
19364
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
19365
|
-
const { dispatch } = editor.view;
|
|
19366
|
-
if (!dispatch) return false;
|
|
19367
|
-
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
19368
|
-
return true;
|
|
19369
|
-
};
|
|
19370
|
-
const convertEmToPt = (html) => {
|
|
19371
|
-
return html.replace(
|
|
19372
|
-
/font-size\s*:\s*([\d.]+)em/gi,
|
|
19373
|
-
(_, emValue) => {
|
|
19374
|
-
const em = parseFloat(emValue);
|
|
19375
|
-
const pt = Math.round(em * 12 * 100) / 100;
|
|
19376
|
-
return `font-size: ${pt}pt`;
|
|
19377
|
-
}
|
|
19378
|
-
);
|
|
19379
|
-
};
|
|
19380
|
-
function cleanHtmlUnnecessaryTags(html) {
|
|
19381
|
-
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
19382
|
-
}
|
|
19383
|
-
function sanitizeHtml(html, forbiddenTags = ["meta", "svg", "script", "style", "button"]) {
|
|
19384
|
-
const container = document.createElement("div");
|
|
19385
|
-
container.innerHTML = html;
|
|
19386
|
-
const walkAndClean = (node2) => {
|
|
19387
|
-
for (const child of [...node2.children]) {
|
|
19388
|
-
if (forbiddenTags.includes(child.tagName.toLowerCase())) {
|
|
19389
|
-
child.remove();
|
|
19390
|
-
continue;
|
|
19391
|
-
}
|
|
19392
|
-
if (child.hasAttribute("linebreaktype")) {
|
|
19393
|
-
child.removeAttribute("linebreaktype");
|
|
19394
|
-
}
|
|
19395
|
-
walkAndClean(child);
|
|
19396
|
-
}
|
|
19397
|
-
};
|
|
19398
|
-
walkAndClean(container);
|
|
19399
|
-
return container;
|
|
19400
|
-
}
|
|
19401
18824
|
function exportSchemaToJson(params2) {
|
|
19402
18825
|
const { type: type2 } = params2.node || {};
|
|
19403
18826
|
const router = {
|
|
@@ -19435,13 +18858,13 @@ function exportSchemaToJson(params2) {
|
|
|
19435
18858
|
function translateBodyNode(params2) {
|
|
19436
18859
|
let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
|
|
19437
18860
|
if (params2.converter) {
|
|
19438
|
-
const hasHeader = sectPr
|
|
18861
|
+
const hasHeader = sectPr.elements.some((n) => n.name === "w:headerReference");
|
|
19439
18862
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
19440
18863
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
19441
18864
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
19442
18865
|
sectPr.elements.push(defaultHeader);
|
|
19443
18866
|
}
|
|
19444
|
-
const hasFooter = sectPr
|
|
18867
|
+
const hasFooter = sectPr.elements.some((n) => n.name === "w:footerReference");
|
|
19445
18868
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
19446
18869
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
19447
18870
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
@@ -20741,11 +20164,12 @@ function prepareHtmlAnnotation(params2) {
|
|
|
20741
20164
|
node: { attrs = {}, marks = [] },
|
|
20742
20165
|
editorSchema
|
|
20743
20166
|
} = params2;
|
|
20744
|
-
const
|
|
20167
|
+
const parser = new window.DOMParser();
|
|
20168
|
+
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, "text/html");
|
|
20745
20169
|
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
20746
20170
|
const allMarks = [...marks, ...marksFromAttrs];
|
|
20747
20171
|
let state2 = EditorState.create({
|
|
20748
|
-
doc: DOMParser$1.fromSchema(editorSchema).parse(
|
|
20172
|
+
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtml)
|
|
20749
20173
|
});
|
|
20750
20174
|
if (allMarks.length) {
|
|
20751
20175
|
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
@@ -23800,7 +23224,7 @@ function addDefaultStylesIfMissing(styles) {
|
|
|
23800
23224
|
});
|
|
23801
23225
|
return updatedStyles;
|
|
23802
23226
|
}
|
|
23803
|
-
const importHeadersFooters = (docx, converter,
|
|
23227
|
+
const importHeadersFooters = (docx, converter, editor) => {
|
|
23804
23228
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
23805
23229
|
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
23806
23230
|
const { elements } = relationships;
|
|
@@ -23810,9 +23234,6 @@ const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
|
23810
23234
|
const footers = elements.filter((el) => el.attributes["Type"] === footerType);
|
|
23811
23235
|
const sectPr = findSectPr(docx["word/document.xml"]) || [];
|
|
23812
23236
|
const allSectPrElements = sectPr.flatMap((el) => el.elements);
|
|
23813
|
-
if (!mainEditor) return;
|
|
23814
|
-
const editor = { ...mainEditor };
|
|
23815
|
-
editor.options.annotations = true;
|
|
23816
23237
|
headers.forEach((header) => {
|
|
23817
23238
|
const { rId, referenceFile, currentFileName } = getHeaderFooterSectionData(header, docx);
|
|
23818
23239
|
const sectPrHeader = allSectPrElements.find((el) => el.name === "w:headerReference" && el.attributes["r:id"] === rId);
|
|
@@ -23972,7 +23393,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
23972
23393
|
return;
|
|
23973
23394
|
}
|
|
23974
23395
|
}
|
|
23975
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2
|
|
23396
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2") {
|
|
23976
23397
|
const customLocation = "docProps/custom.xml";
|
|
23977
23398
|
if (!docx[customLocation]) {
|
|
23978
23399
|
docx[customLocation] = generateCustomXml();
|
|
@@ -24439,7 +23860,7 @@ function storeSuperdocVersion(docx) {
|
|
|
24439
23860
|
function generateCustomXml() {
|
|
24440
23861
|
return DEFAULT_CUSTOM_XML;
|
|
24441
23862
|
}
|
|
24442
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.13.2
|
|
23863
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.13.2") {
|
|
24443
23864
|
return {
|
|
24444
23865
|
type: "element",
|
|
24445
23866
|
name: "property",
|
|
@@ -26972,7 +26393,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
26972
26393
|
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);
|
|
26973
26394
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
26974
26395
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
26975
|
-
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,
|
|
26396
|
+
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;
|
|
26976
26397
|
function getMarksFromSelection(state2) {
|
|
26977
26398
|
const { from: from2, to, empty: empty2 } = state2.selection;
|
|
26978
26399
|
const marks = [];
|
|
@@ -28161,6 +27582,164 @@ createMarksSchema_fn = function(markExtensions, attributes, editor) {
|
|
|
28161
27582
|
};
|
|
28162
27583
|
__privateAdd$1(_Schema, _Schema_static);
|
|
28163
27584
|
let Schema2 = _Schema;
|
|
27585
|
+
function chainableEditorState(transaction, state2) {
|
|
27586
|
+
let { selection, doc: doc2, storedMarks } = transaction;
|
|
27587
|
+
return {
|
|
27588
|
+
...state2,
|
|
27589
|
+
apply: state2.apply.bind(state2),
|
|
27590
|
+
applyTransaction: state2.applyTransaction.bind(state2),
|
|
27591
|
+
plugins: state2.plugins,
|
|
27592
|
+
schema: state2.schema,
|
|
27593
|
+
reconfigure: state2.reconfigure.bind(state2),
|
|
27594
|
+
toJSON: state2.toJSON.bind(state2),
|
|
27595
|
+
get storedMarks() {
|
|
27596
|
+
return storedMarks;
|
|
27597
|
+
},
|
|
27598
|
+
get selection() {
|
|
27599
|
+
return selection;
|
|
27600
|
+
},
|
|
27601
|
+
get doc() {
|
|
27602
|
+
return doc2;
|
|
27603
|
+
},
|
|
27604
|
+
get tr() {
|
|
27605
|
+
selection = transaction.selection;
|
|
27606
|
+
doc2 = transaction.doc;
|
|
27607
|
+
storedMarks = transaction.storedMarks;
|
|
27608
|
+
return transaction;
|
|
27609
|
+
}
|
|
27610
|
+
};
|
|
27611
|
+
}
|
|
27612
|
+
class CommandService {
|
|
27613
|
+
constructor(props) {
|
|
27614
|
+
__publicField$1(this, "editor");
|
|
27615
|
+
__publicField$1(this, "rawCommands");
|
|
27616
|
+
this.editor = props.editor;
|
|
27617
|
+
this.rawCommands = this.editor.extensionService.commands;
|
|
27618
|
+
}
|
|
27619
|
+
/**
|
|
27620
|
+
* Static method for creating a service.
|
|
27621
|
+
* @param args Arguments for the constructor.
|
|
27622
|
+
*/
|
|
27623
|
+
static create(...args) {
|
|
27624
|
+
return new CommandService(...args);
|
|
27625
|
+
}
|
|
27626
|
+
/**
|
|
27627
|
+
* Get editor state.
|
|
27628
|
+
*/
|
|
27629
|
+
get state() {
|
|
27630
|
+
return this.editor.state;
|
|
27631
|
+
}
|
|
27632
|
+
/**
|
|
27633
|
+
* Get all commands with wrapped command method.
|
|
27634
|
+
*/
|
|
27635
|
+
get commands() {
|
|
27636
|
+
const { editor, state: state2 } = this;
|
|
27637
|
+
const { view } = editor;
|
|
27638
|
+
const { tr } = state2;
|
|
27639
|
+
const props = this.createProps(tr);
|
|
27640
|
+
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
27641
|
+
const method = (...args) => {
|
|
27642
|
+
const fn2 = command2(...args)(props);
|
|
27643
|
+
if (!tr.getMeta("preventDispatch")) {
|
|
27644
|
+
view.dispatch(tr);
|
|
27645
|
+
}
|
|
27646
|
+
return fn2;
|
|
27647
|
+
};
|
|
27648
|
+
return [name, method];
|
|
27649
|
+
});
|
|
27650
|
+
return Object.fromEntries(entries);
|
|
27651
|
+
}
|
|
27652
|
+
/**
|
|
27653
|
+
* Create a chain of commands to call multiple commands at once.
|
|
27654
|
+
*/
|
|
27655
|
+
get chain() {
|
|
27656
|
+
return () => this.createChain();
|
|
27657
|
+
}
|
|
27658
|
+
/**
|
|
27659
|
+
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
27660
|
+
*/
|
|
27661
|
+
get can() {
|
|
27662
|
+
return () => this.createCan();
|
|
27663
|
+
}
|
|
27664
|
+
/**
|
|
27665
|
+
* Creates a chain of commands.
|
|
27666
|
+
* @param startTr Start transaction.
|
|
27667
|
+
* @param shouldDispatch Should dispatch or not.
|
|
27668
|
+
*/
|
|
27669
|
+
createChain(startTr, shouldDispatch = true) {
|
|
27670
|
+
const { editor, state: state2, rawCommands } = this;
|
|
27671
|
+
const { view } = editor;
|
|
27672
|
+
const callbacks2 = [];
|
|
27673
|
+
const hasStartTr = !!startTr;
|
|
27674
|
+
const tr = startTr || state2.tr;
|
|
27675
|
+
const run2 = () => {
|
|
27676
|
+
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
27677
|
+
view.dispatch(tr);
|
|
27678
|
+
}
|
|
27679
|
+
return callbacks2.every((cb) => cb === true);
|
|
27680
|
+
};
|
|
27681
|
+
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
27682
|
+
const chainedCommand = (...args) => {
|
|
27683
|
+
const props = this.createProps(tr, shouldDispatch);
|
|
27684
|
+
const callback = command2(...args)(props);
|
|
27685
|
+
callbacks2.push(callback);
|
|
27686
|
+
return chain;
|
|
27687
|
+
};
|
|
27688
|
+
return [name, chainedCommand];
|
|
27689
|
+
});
|
|
27690
|
+
const chain = {
|
|
27691
|
+
...Object.fromEntries(entries),
|
|
27692
|
+
run: run2
|
|
27693
|
+
};
|
|
27694
|
+
return chain;
|
|
27695
|
+
}
|
|
27696
|
+
/**
|
|
27697
|
+
* Creates a can check for commands.
|
|
27698
|
+
* @param startTr Start transaction.
|
|
27699
|
+
*/
|
|
27700
|
+
createCan(startTr) {
|
|
27701
|
+
const { rawCommands, state: state2 } = this;
|
|
27702
|
+
const dispatch = false;
|
|
27703
|
+
const tr = startTr || state2.tr;
|
|
27704
|
+
const props = this.createProps(tr, dispatch);
|
|
27705
|
+
const commands2 = Object.fromEntries(
|
|
27706
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27707
|
+
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
27708
|
+
})
|
|
27709
|
+
);
|
|
27710
|
+
return {
|
|
27711
|
+
...commands2,
|
|
27712
|
+
chain: () => this.createChain(tr, dispatch)
|
|
27713
|
+
};
|
|
27714
|
+
}
|
|
27715
|
+
/**
|
|
27716
|
+
* Creates default props for the command method.
|
|
27717
|
+
* @param {*} tr Transaction.
|
|
27718
|
+
* @param {*} shouldDispatch Check if should dispatch.
|
|
27719
|
+
* @returns Object with props.
|
|
27720
|
+
*/
|
|
27721
|
+
createProps(tr, shouldDispatch = true) {
|
|
27722
|
+
const { editor, state: state2, rawCommands } = this;
|
|
27723
|
+
const { view } = editor;
|
|
27724
|
+
const props = {
|
|
27725
|
+
tr,
|
|
27726
|
+
editor,
|
|
27727
|
+
view,
|
|
27728
|
+
state: chainableEditorState(tr, state2),
|
|
27729
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
27730
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
27731
|
+
can: () => this.createCan(tr),
|
|
27732
|
+
get commands() {
|
|
27733
|
+
return Object.fromEntries(
|
|
27734
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27735
|
+
return [name, (...args) => command2(...args)(props)];
|
|
27736
|
+
})
|
|
27737
|
+
);
|
|
27738
|
+
}
|
|
27739
|
+
};
|
|
27740
|
+
return props;
|
|
27741
|
+
}
|
|
27742
|
+
}
|
|
28164
27743
|
const first = (commands2) => (props) => {
|
|
28165
27744
|
const items = typeof commands2 === "function" ? commands2(props) : commands2;
|
|
28166
27745
|
for (let i = 0; i < items.length; i += 1) {
|
|
@@ -28522,7 +28101,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28522
28101
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
28523
28102
|
wrap2 = Fragment.from(conn[i].create(null, wrap2));
|
|
28524
28103
|
wrap2 = Fragment.from(before.copy(wrap2));
|
|
28525
|
-
let tr = state2.tr.step(new ReplaceAroundStep
|
|
28104
|
+
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
28526
28105
|
let $joinAt = tr.doc.resolve(end2 + 2 * conn.length);
|
|
28527
28106
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
|
|
28528
28107
|
tr.join($joinAt.pos);
|
|
@@ -28553,7 +28132,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28553
28132
|
let end2 = Fragment.empty;
|
|
28554
28133
|
for (let i = wrap2.length - 1; i >= 0; i--)
|
|
28555
28134
|
end2 = Fragment.from(wrap2[i].copy(end2));
|
|
28556
|
-
let tr = state2.tr.step(new ReplaceAroundStep
|
|
28135
|
+
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));
|
|
28557
28136
|
dispatch(tr.scrollIntoView());
|
|
28558
28137
|
}
|
|
28559
28138
|
return true;
|
|
@@ -29126,7 +28705,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
29126
28705
|
return;
|
|
29127
28706
|
}
|
|
29128
28707
|
const step = tr.steps[last];
|
|
29129
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
28708
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
29130
28709
|
return;
|
|
29131
28710
|
}
|
|
29132
28711
|
const map22 = tr.mapping.maps[last];
|
|
@@ -29272,7 +28851,7 @@ function doWrapInList(tr, range2, wrappers, joinBefore, listType) {
|
|
|
29272
28851
|
let content = Fragment.empty;
|
|
29273
28852
|
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
29274
28853
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
29275
|
-
tr.step(new ReplaceAroundStep
|
|
28854
|
+
tr.step(new ReplaceAroundStep(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
29276
28855
|
let found2 = 0;
|
|
29277
28856
|
for (let i = 0; i < wrappers.length; i++)
|
|
29278
28857
|
if (wrappers[i].type == listType)
|
|
@@ -29305,7 +28884,7 @@ function liftListItem$1(itemType) {
|
|
|
29305
28884
|
function liftToOuterList(state2, dispatch, itemType, range2) {
|
|
29306
28885
|
let tr = state2.tr, end2 = range2.end, endOfList = range2.$to.end(range2.depth);
|
|
29307
28886
|
if (end2 < endOfList) {
|
|
29308
|
-
tr.step(new ReplaceAroundStep
|
|
28887
|
+
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
29309
28888
|
range2 = new NodeRange(tr.doc.resolve(range2.$from.pos), tr.doc.resolve(endOfList), range2.depth);
|
|
29310
28889
|
}
|
|
29311
28890
|
const target = liftTarget(range2);
|
|
@@ -29332,7 +28911,7 @@ function liftOutOfList(state2, dispatch, range2) {
|
|
|
29332
28911
|
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))
|
|
29333
28912
|
return false;
|
|
29334
28913
|
let start2 = $start.pos, end2 = start2 + item.nodeSize;
|
|
29335
|
-
tr.step(new ReplaceAroundStep
|
|
28914
|
+
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));
|
|
29336
28915
|
dispatch(tr.scrollIntoView());
|
|
29337
28916
|
return true;
|
|
29338
28917
|
}
|
|
@@ -29353,7 +28932,7 @@ function sinkListItem$1(itemType) {
|
|
|
29353
28932
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
29354
28933
|
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
29355
28934
|
let before = range2.start, after = range2.end;
|
|
29356
|
-
dispatch(state2.tr.step(new ReplaceAroundStep
|
|
28935
|
+
dispatch(state2.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
29357
28936
|
}
|
|
29358
28937
|
return true;
|
|
29359
28938
|
};
|
|
@@ -36946,8 +36525,7 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
|
|
|
36946
36525
|
binding.mapping
|
|
36947
36526
|
);
|
|
36948
36527
|
if (anchor !== null && head !== null) {
|
|
36949
|
-
|
|
36950
|
-
tr.setSelection(sel);
|
|
36528
|
+
tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));
|
|
36951
36529
|
}
|
|
36952
36530
|
}
|
|
36953
36531
|
}
|
|
@@ -37728,7 +37306,7 @@ const setMeta = (view, key, value) => {
|
|
|
37728
37306
|
};
|
|
37729
37307
|
const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
37730
37308
|
if (pos === 0) {
|
|
37731
|
-
return Y.createRelativePositionFromTypeIndex(type2, 0,
|
|
37309
|
+
return Y.createRelativePositionFromTypeIndex(type2, 0, -1);
|
|
37732
37310
|
}
|
|
37733
37311
|
let n = type2._first === null ? null : (
|
|
37734
37312
|
/** @type {Y.ContentType} */
|
|
@@ -37737,7 +37315,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37737
37315
|
while (n !== null && type2 !== n) {
|
|
37738
37316
|
if (n instanceof Y.XmlText) {
|
|
37739
37317
|
if (n._length >= pos) {
|
|
37740
|
-
return Y.createRelativePositionFromTypeIndex(n, pos,
|
|
37318
|
+
return Y.createRelativePositionFromTypeIndex(n, pos, -1);
|
|
37741
37319
|
} else {
|
|
37742
37320
|
pos -= n._length;
|
|
37743
37321
|
}
|
|
@@ -37801,7 +37379,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37801
37379
|
return createRelativePosition(n._item.parent, n._item);
|
|
37802
37380
|
}
|
|
37803
37381
|
}
|
|
37804
|
-
return Y.createRelativePositionFromTypeIndex(type2, type2._length,
|
|
37382
|
+
return Y.createRelativePositionFromTypeIndex(type2, type2._length, -1);
|
|
37805
37383
|
};
|
|
37806
37384
|
const createRelativePosition = (type2, item) => {
|
|
37807
37385
|
let typeid = null;
|
|
@@ -38292,111 +37870,514 @@ var shift = {
|
|
|
38292
37870
|
221: "}",
|
|
38293
37871
|
222: '"'
|
|
38294
37872
|
};
|
|
38295
|
-
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
38296
|
-
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
38297
|
-
for (var i = 0; i < 10; i++) base$1[48 + i] = base$1[96 + i] = String(i);
|
|
38298
|
-
for (var i = 1; i <= 24; i++) base$1[i + 111] = "F" + i;
|
|
38299
|
-
for (var i = 65; i <= 90; i++) {
|
|
38300
|
-
base$1[i] = String.fromCharCode(i + 32);
|
|
38301
|
-
shift[i] = String.fromCharCode(i);
|
|
38302
|
-
}
|
|
38303
|
-
for (var code in base$1) if (!shift.hasOwnProperty(code)) shift[code] = base$1[code];
|
|
38304
|
-
function keyName(event) {
|
|
38305
|
-
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
38306
|
-
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$1)[event.keyCode] || event.key || "Unidentified";
|
|
38307
|
-
if (name == "Esc") name = "Escape";
|
|
38308
|
-
if (name == "Del") name = "Delete";
|
|
38309
|
-
if (name == "Left") name = "ArrowLeft";
|
|
38310
|
-
if (name == "Up") name = "ArrowUp";
|
|
38311
|
-
if (name == "Right") name = "ArrowRight";
|
|
38312
|
-
if (name == "Down") name = "ArrowDown";
|
|
38313
|
-
return name;
|
|
38314
|
-
}
|
|
38315
|
-
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
38316
|
-
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
38317
|
-
function normalizeKeyName(name) {
|
|
38318
|
-
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
38319
|
-
if (result == "Space")
|
|
38320
|
-
result = " ";
|
|
38321
|
-
let alt, ctrl, shift2, meta;
|
|
38322
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
38323
|
-
let mod = parts[i];
|
|
38324
|
-
if (/^(cmd|meta|m)$/i.test(mod))
|
|
38325
|
-
meta = true;
|
|
38326
|
-
else if (/^a(lt)?$/i.test(mod))
|
|
38327
|
-
alt = true;
|
|
38328
|
-
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
38329
|
-
ctrl = true;
|
|
38330
|
-
else if (/^s(hift)?$/i.test(mod))
|
|
38331
|
-
shift2 = true;
|
|
38332
|
-
else if (/^mod$/i.test(mod)) {
|
|
38333
|
-
if (mac)
|
|
38334
|
-
meta = true;
|
|
38335
|
-
else
|
|
38336
|
-
ctrl = true;
|
|
38337
|
-
} else
|
|
38338
|
-
throw new Error("Unrecognized modifier name: " + mod);
|
|
37873
|
+
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
37874
|
+
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
37875
|
+
for (var i = 0; i < 10; i++) base$1[48 + i] = base$1[96 + i] = String(i);
|
|
37876
|
+
for (var i = 1; i <= 24; i++) base$1[i + 111] = "F" + i;
|
|
37877
|
+
for (var i = 65; i <= 90; i++) {
|
|
37878
|
+
base$1[i] = String.fromCharCode(i + 32);
|
|
37879
|
+
shift[i] = String.fromCharCode(i);
|
|
37880
|
+
}
|
|
37881
|
+
for (var code in base$1) if (!shift.hasOwnProperty(code)) shift[code] = base$1[code];
|
|
37882
|
+
function keyName(event) {
|
|
37883
|
+
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
37884
|
+
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$1)[event.keyCode] || event.key || "Unidentified";
|
|
37885
|
+
if (name == "Esc") name = "Escape";
|
|
37886
|
+
if (name == "Del") name = "Delete";
|
|
37887
|
+
if (name == "Left") name = "ArrowLeft";
|
|
37888
|
+
if (name == "Up") name = "ArrowUp";
|
|
37889
|
+
if (name == "Right") name = "ArrowRight";
|
|
37890
|
+
if (name == "Down") name = "ArrowDown";
|
|
37891
|
+
return name;
|
|
37892
|
+
}
|
|
37893
|
+
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
37894
|
+
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
37895
|
+
function normalizeKeyName(name) {
|
|
37896
|
+
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
37897
|
+
if (result == "Space")
|
|
37898
|
+
result = " ";
|
|
37899
|
+
let alt, ctrl, shift2, meta;
|
|
37900
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
37901
|
+
let mod = parts[i];
|
|
37902
|
+
if (/^(cmd|meta|m)$/i.test(mod))
|
|
37903
|
+
meta = true;
|
|
37904
|
+
else if (/^a(lt)?$/i.test(mod))
|
|
37905
|
+
alt = true;
|
|
37906
|
+
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
37907
|
+
ctrl = true;
|
|
37908
|
+
else if (/^s(hift)?$/i.test(mod))
|
|
37909
|
+
shift2 = true;
|
|
37910
|
+
else if (/^mod$/i.test(mod)) {
|
|
37911
|
+
if (mac)
|
|
37912
|
+
meta = true;
|
|
37913
|
+
else
|
|
37914
|
+
ctrl = true;
|
|
37915
|
+
} else
|
|
37916
|
+
throw new Error("Unrecognized modifier name: " + mod);
|
|
37917
|
+
}
|
|
37918
|
+
if (alt)
|
|
37919
|
+
result = "Alt-" + result;
|
|
37920
|
+
if (ctrl)
|
|
37921
|
+
result = "Ctrl-" + result;
|
|
37922
|
+
if (meta)
|
|
37923
|
+
result = "Meta-" + result;
|
|
37924
|
+
if (shift2)
|
|
37925
|
+
result = "Shift-" + result;
|
|
37926
|
+
return result;
|
|
37927
|
+
}
|
|
37928
|
+
function normalize(map22) {
|
|
37929
|
+
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
37930
|
+
for (let prop in map22)
|
|
37931
|
+
copy2[normalizeKeyName(prop)] = map22[prop];
|
|
37932
|
+
return copy2;
|
|
37933
|
+
}
|
|
37934
|
+
function modifiers(name, event, shift2 = true) {
|
|
37935
|
+
if (event.altKey)
|
|
37936
|
+
name = "Alt-" + name;
|
|
37937
|
+
if (event.ctrlKey)
|
|
37938
|
+
name = "Ctrl-" + name;
|
|
37939
|
+
if (event.metaKey)
|
|
37940
|
+
name = "Meta-" + name;
|
|
37941
|
+
if (shift2 && event.shiftKey)
|
|
37942
|
+
name = "Shift-" + name;
|
|
37943
|
+
return name;
|
|
37944
|
+
}
|
|
37945
|
+
function keymap(bindings) {
|
|
37946
|
+
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
37947
|
+
}
|
|
37948
|
+
function keydownHandler(bindings) {
|
|
37949
|
+
let map22 = normalize(bindings);
|
|
37950
|
+
return function(view, event) {
|
|
37951
|
+
let name = keyName(event), baseName, direct = map22[modifiers(name, event)];
|
|
37952
|
+
if (direct && direct(view.state, view.dispatch, view))
|
|
37953
|
+
return true;
|
|
37954
|
+
if (name.length == 1 && name != " ") {
|
|
37955
|
+
if (event.shiftKey) {
|
|
37956
|
+
let noShift = map22[modifiers(name, event, false)];
|
|
37957
|
+
if (noShift && noShift(view.state, view.dispatch, view))
|
|
37958
|
+
return true;
|
|
37959
|
+
}
|
|
37960
|
+
if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
37961
|
+
!(windows && event.ctrlKey && event.altKey) && (baseName = base$1[event.keyCode]) && baseName != name) {
|
|
37962
|
+
let fromCode = map22[modifiers(baseName, event)];
|
|
37963
|
+
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
37964
|
+
return true;
|
|
37965
|
+
}
|
|
37966
|
+
}
|
|
37967
|
+
return false;
|
|
37968
|
+
};
|
|
37969
|
+
}
|
|
37970
|
+
function isExtensionRulesEnabled(extension, enabled) {
|
|
37971
|
+
if (Array.isArray(enabled)) {
|
|
37972
|
+
return enabled.some((enabledExtension) => {
|
|
37973
|
+
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
37974
|
+
return name === extension.name;
|
|
37975
|
+
});
|
|
37976
|
+
}
|
|
37977
|
+
return enabled;
|
|
37978
|
+
}
|
|
37979
|
+
function getHTMLFromFragment(fragment, schema) {
|
|
37980
|
+
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
37981
|
+
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
37982
|
+
const container = temporaryDocument.createElement("div");
|
|
37983
|
+
container.appendChild(documentFragment);
|
|
37984
|
+
return container.innerHTML;
|
|
37985
|
+
}
|
|
37986
|
+
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
37987
|
+
let textBefore = "";
|
|
37988
|
+
const sliceEndPos = $from.parentOffset;
|
|
37989
|
+
$from.parent.nodesBetween(
|
|
37990
|
+
Math.max(0, sliceEndPos - maxMatch),
|
|
37991
|
+
sliceEndPos,
|
|
37992
|
+
(node2, pos, parent, index2) => {
|
|
37993
|
+
const chunk = node2.type.spec.toText?.({
|
|
37994
|
+
node: node2,
|
|
37995
|
+
pos,
|
|
37996
|
+
parent,
|
|
37997
|
+
index: index2
|
|
37998
|
+
}) || node2.textContent || "%leaf%";
|
|
37999
|
+
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
38000
|
+
}
|
|
38001
|
+
);
|
|
38002
|
+
return textBefore;
|
|
38003
|
+
};
|
|
38004
|
+
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
38005
|
+
const { converter } = editor;
|
|
38006
|
+
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
38007
|
+
let cleanedHtml = convertEmToPt(html);
|
|
38008
|
+
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
38009
|
+
const tempDiv = document.createElement("div");
|
|
38010
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
38011
|
+
const paragraphs = tempDiv.querySelectorAll("p");
|
|
38012
|
+
paragraphs.forEach((p) => {
|
|
38013
|
+
const innerHTML3 = p.innerHTML;
|
|
38014
|
+
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
38015
|
+
const styleAttr = p.getAttribute("style") || "";
|
|
38016
|
+
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
38017
|
+
if (msoListMatch) {
|
|
38018
|
+
const [, abstractId, level] = msoListMatch;
|
|
38019
|
+
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
38020
|
+
if (!listNumId) return;
|
|
38021
|
+
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
38022
|
+
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
38023
|
+
p.setAttribute("data-num-id", listNumId);
|
|
38024
|
+
p.setAttribute("data-list-level", level - 1);
|
|
38025
|
+
p.setAttribute("data-start", start2);
|
|
38026
|
+
p.setAttribute("data-lvl-text", lvlText);
|
|
38027
|
+
p.setAttribute("data-num-fmt", numFmt);
|
|
38028
|
+
}
|
|
38029
|
+
extractAndRemoveConditionalPrefix(p);
|
|
38030
|
+
});
|
|
38031
|
+
transformWordLists(tempDiv);
|
|
38032
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38033
|
+
tempDiv.remove();
|
|
38034
|
+
const { dispatch } = editor.view;
|
|
38035
|
+
if (!dispatch) return false;
|
|
38036
|
+
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
38037
|
+
return true;
|
|
38038
|
+
};
|
|
38039
|
+
const getLevelDefinition = (abstractDefinition, level) => {
|
|
38040
|
+
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
38041
|
+
const levelElement = abstractDefinition.elements.find((el) => {
|
|
38042
|
+
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
38043
|
+
});
|
|
38044
|
+
if (!levelElement) return null;
|
|
38045
|
+
const { elements } = levelElement;
|
|
38046
|
+
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
38047
|
+
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
38048
|
+
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
38049
|
+
return { lvlText, start: start2, numFmt, elements };
|
|
38050
|
+
};
|
|
38051
|
+
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
38052
|
+
const { definitions } = editor?.converter?.numbering;
|
|
38053
|
+
if (!definitions) return null;
|
|
38054
|
+
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
38055
|
+
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
38056
|
+
});
|
|
38057
|
+
return matchedDefinition?.attributes?.["w:numId"];
|
|
38058
|
+
};
|
|
38059
|
+
const getListAbstractDefinition = (abstractId, editor) => {
|
|
38060
|
+
const { abstracts = {} } = editor?.converter?.numbering;
|
|
38061
|
+
return abstracts[abstractId] || null;
|
|
38062
|
+
};
|
|
38063
|
+
const transformWordLists = (container) => {
|
|
38064
|
+
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
38065
|
+
const listMap = /* @__PURE__ */ new Map();
|
|
38066
|
+
const listLevels = {};
|
|
38067
|
+
for (const p of paragraphs) {
|
|
38068
|
+
const listId = p.getAttribute("data-num-id");
|
|
38069
|
+
const level = parseInt(p.getAttribute("data-list-level"));
|
|
38070
|
+
const numFmt = p.getAttribute("data-num-fmt");
|
|
38071
|
+
const start2 = p.getAttribute("data-start");
|
|
38072
|
+
const lvlText = p.getAttribute("data-lvl-text");
|
|
38073
|
+
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
38074
|
+
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
38075
|
+
}
|
|
38076
|
+
for (const [id, items] of listMap.entries()) {
|
|
38077
|
+
if (!listLevels[id]) {
|
|
38078
|
+
listLevels[id] = {
|
|
38079
|
+
stack: [],
|
|
38080
|
+
counts: {},
|
|
38081
|
+
prevLevel: null
|
|
38082
|
+
};
|
|
38083
|
+
}
|
|
38084
|
+
const parentStack = [];
|
|
38085
|
+
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
38086
|
+
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
38087
|
+
const li = document.createElement("li");
|
|
38088
|
+
li.innerHTML = p.innerHTML;
|
|
38089
|
+
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
38090
|
+
li.setAttribute("data-num-id", id);
|
|
38091
|
+
li.setAttribute("data-lvl-text", lvlText);
|
|
38092
|
+
li.setAttribute("data-num-fmt", numFmt);
|
|
38093
|
+
if (p.hasAttribute("data-font-family")) {
|
|
38094
|
+
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
38095
|
+
}
|
|
38096
|
+
if (p.hasAttribute("data-font-size")) {
|
|
38097
|
+
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
38098
|
+
}
|
|
38099
|
+
const parentNode2 = p.parentNode;
|
|
38100
|
+
let listForLevel = parentStack[level];
|
|
38101
|
+
if (!listForLevel) {
|
|
38102
|
+
const newList = document.createElement("ol");
|
|
38103
|
+
newList.setAttribute("data-list-id", id);
|
|
38104
|
+
newList.level = level;
|
|
38105
|
+
if (level > 0) {
|
|
38106
|
+
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
38107
|
+
if (parentLi) parentLi.appendChild(newList);
|
|
38108
|
+
} else {
|
|
38109
|
+
parentNode2.insertBefore(newList, p);
|
|
38110
|
+
}
|
|
38111
|
+
parentStack[level] = newList;
|
|
38112
|
+
parentStack.length = level + 1;
|
|
38113
|
+
listForLevel = newList;
|
|
38114
|
+
}
|
|
38115
|
+
listForLevel.appendChild(li);
|
|
38116
|
+
p.remove();
|
|
38117
|
+
});
|
|
38118
|
+
}
|
|
38119
|
+
};
|
|
38120
|
+
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
38121
|
+
const levelState = listLevels[listId];
|
|
38122
|
+
if (!levelState.stack) levelState.stack = [];
|
|
38123
|
+
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
38124
|
+
if (levelState.prevLevel === null) {
|
|
38125
|
+
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
38126
|
+
} else {
|
|
38127
|
+
if (currentLevel > levelState.prevLevel) {
|
|
38128
|
+
levelState.stack.push(1);
|
|
38129
|
+
} else if (currentLevel === levelState.prevLevel) {
|
|
38130
|
+
levelState.stack[levelState.stack.length - 1]++;
|
|
38131
|
+
} else {
|
|
38132
|
+
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
38133
|
+
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
38134
|
+
}
|
|
38339
38135
|
}
|
|
38340
|
-
|
|
38341
|
-
|
|
38342
|
-
if (ctrl)
|
|
38343
|
-
result = "Ctrl-" + result;
|
|
38344
|
-
if (meta)
|
|
38345
|
-
result = "Meta-" + result;
|
|
38346
|
-
if (shift2)
|
|
38347
|
-
result = "Shift-" + result;
|
|
38348
|
-
return result;
|
|
38349
|
-
}
|
|
38350
|
-
function normalize(map22) {
|
|
38351
|
-
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
38352
|
-
for (let prop in map22)
|
|
38353
|
-
copy2[normalizeKeyName(prop)] = map22[prop];
|
|
38354
|
-
return copy2;
|
|
38136
|
+
levelState.prevLevel = currentLevel;
|
|
38137
|
+
return [...levelState.stack];
|
|
38355
38138
|
}
|
|
38356
|
-
function
|
|
38357
|
-
|
|
38358
|
-
|
|
38359
|
-
|
|
38360
|
-
|
|
38361
|
-
|
|
38362
|
-
|
|
38363
|
-
|
|
38364
|
-
|
|
38365
|
-
|
|
38139
|
+
function extractAndRemoveConditionalPrefix(p) {
|
|
38140
|
+
const nodes = Array.from(p.childNodes);
|
|
38141
|
+
let fontFamily2 = null;
|
|
38142
|
+
let fontSize2 = null;
|
|
38143
|
+
let start2 = -1, end2 = -1;
|
|
38144
|
+
nodes.forEach((node2, index2) => {
|
|
38145
|
+
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
38146
|
+
start2 = index2;
|
|
38147
|
+
}
|
|
38148
|
+
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
38149
|
+
end2 = index2;
|
|
38150
|
+
}
|
|
38151
|
+
});
|
|
38152
|
+
if (start2 !== -1 && end2 !== -1) {
|
|
38153
|
+
for (let i = start2 + 1; i < end2; i++) {
|
|
38154
|
+
const node2 = nodes[i];
|
|
38155
|
+
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
38156
|
+
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
38157
|
+
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
38158
|
+
}
|
|
38159
|
+
}
|
|
38160
|
+
for (let i = end2; i >= start2; i--) {
|
|
38161
|
+
p.removeChild(p.childNodes[i]);
|
|
38162
|
+
}
|
|
38163
|
+
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
38164
|
+
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
38165
|
+
}
|
|
38366
38166
|
}
|
|
38367
|
-
|
|
38368
|
-
|
|
38167
|
+
class InputRule {
|
|
38168
|
+
constructor(config) {
|
|
38169
|
+
__publicField$1(this, "match");
|
|
38170
|
+
__publicField$1(this, "handler");
|
|
38171
|
+
this.match = config.match;
|
|
38172
|
+
this.handler = config.handler;
|
|
38173
|
+
}
|
|
38369
38174
|
}
|
|
38370
|
-
|
|
38371
|
-
|
|
38372
|
-
|
|
38373
|
-
|
|
38374
|
-
|
|
38375
|
-
|
|
38376
|
-
|
|
38377
|
-
|
|
38378
|
-
|
|
38379
|
-
|
|
38380
|
-
|
|
38381
|
-
|
|
38382
|
-
|
|
38383
|
-
|
|
38384
|
-
|
|
38385
|
-
|
|
38386
|
-
|
|
38387
|
-
}
|
|
38175
|
+
const inputRuleMatcherHandler = (text, match) => {
|
|
38176
|
+
if (isRegExp(match)) {
|
|
38177
|
+
return match.exec(text);
|
|
38178
|
+
}
|
|
38179
|
+
const inputRuleMatch = match(text);
|
|
38180
|
+
if (!inputRuleMatch) {
|
|
38181
|
+
return null;
|
|
38182
|
+
}
|
|
38183
|
+
const result = [inputRuleMatch.text];
|
|
38184
|
+
result.index = inputRuleMatch.index;
|
|
38185
|
+
result.input = text;
|
|
38186
|
+
result.data = inputRuleMatch.data;
|
|
38187
|
+
if (inputRuleMatch.replaceWith) {
|
|
38188
|
+
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
38189
|
+
console.warn(
|
|
38190
|
+
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
38191
|
+
);
|
|
38388
38192
|
}
|
|
38193
|
+
result.push(inputRuleMatch.replaceWith);
|
|
38194
|
+
}
|
|
38195
|
+
return result;
|
|
38196
|
+
};
|
|
38197
|
+
const run = (config) => {
|
|
38198
|
+
const {
|
|
38199
|
+
editor,
|
|
38200
|
+
from: from2,
|
|
38201
|
+
to,
|
|
38202
|
+
text,
|
|
38203
|
+
rules,
|
|
38204
|
+
plugin: plugin2
|
|
38205
|
+
} = config;
|
|
38206
|
+
const { view } = editor;
|
|
38207
|
+
if (view.composing) {
|
|
38389
38208
|
return false;
|
|
38390
|
-
};
|
|
38391
|
-
}
|
|
38392
|
-
function isExtensionRulesEnabled(extension, enabled) {
|
|
38393
|
-
if (Array.isArray(enabled)) {
|
|
38394
|
-
return enabled.some((enabledExtension) => {
|
|
38395
|
-
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
38396
|
-
return name === extension.name;
|
|
38397
|
-
});
|
|
38398
38209
|
}
|
|
38399
|
-
|
|
38210
|
+
const $from = view.state.doc.resolve(from2);
|
|
38211
|
+
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
38212
|
+
return false;
|
|
38213
|
+
}
|
|
38214
|
+
let matched = false;
|
|
38215
|
+
const textBefore = getTextContentFromNodes($from) + text;
|
|
38216
|
+
rules.forEach((rule) => {
|
|
38217
|
+
if (matched) {
|
|
38218
|
+
return;
|
|
38219
|
+
}
|
|
38220
|
+
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
38221
|
+
if (!match) {
|
|
38222
|
+
return;
|
|
38223
|
+
}
|
|
38224
|
+
const tr = view.state.tr;
|
|
38225
|
+
const state2 = chainableEditorState(tr, view.state);
|
|
38226
|
+
const range2 = {
|
|
38227
|
+
from: from2 - (match[0].length - text.length),
|
|
38228
|
+
to
|
|
38229
|
+
};
|
|
38230
|
+
const { commands: commands2, chain, can } = new CommandService({
|
|
38231
|
+
editor,
|
|
38232
|
+
state: state2
|
|
38233
|
+
});
|
|
38234
|
+
const handler = rule.handler({
|
|
38235
|
+
state: state2,
|
|
38236
|
+
range: range2,
|
|
38237
|
+
match,
|
|
38238
|
+
commands: commands2,
|
|
38239
|
+
chain,
|
|
38240
|
+
can
|
|
38241
|
+
});
|
|
38242
|
+
if (handler === null || !tr.steps.length) {
|
|
38243
|
+
return;
|
|
38244
|
+
}
|
|
38245
|
+
tr.setMeta(plugin2, {
|
|
38246
|
+
transform: tr,
|
|
38247
|
+
from: from2,
|
|
38248
|
+
to,
|
|
38249
|
+
text
|
|
38250
|
+
});
|
|
38251
|
+
view.dispatch(tr);
|
|
38252
|
+
matched = true;
|
|
38253
|
+
});
|
|
38254
|
+
return matched;
|
|
38255
|
+
};
|
|
38256
|
+
const inputRulesPlugin = ({ editor, rules }) => {
|
|
38257
|
+
const plugin2 = new Plugin({
|
|
38258
|
+
key: new PluginKey("inputRulesPlugin"),
|
|
38259
|
+
state: {
|
|
38260
|
+
init() {
|
|
38261
|
+
return null;
|
|
38262
|
+
},
|
|
38263
|
+
apply(tr, prev, state2) {
|
|
38264
|
+
const stored = tr.getMeta(plugin2);
|
|
38265
|
+
if (stored) {
|
|
38266
|
+
return stored;
|
|
38267
|
+
}
|
|
38268
|
+
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
38269
|
+
const isSimulatedInput = !!simulatedInputMeta;
|
|
38270
|
+
if (isSimulatedInput) {
|
|
38271
|
+
setTimeout(() => {
|
|
38272
|
+
let { text } = simulatedInputMeta;
|
|
38273
|
+
if (typeof text !== "string") {
|
|
38274
|
+
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
38275
|
+
}
|
|
38276
|
+
const { from: from2 } = simulatedInputMeta;
|
|
38277
|
+
const to = from2 + text.length;
|
|
38278
|
+
run({
|
|
38279
|
+
editor,
|
|
38280
|
+
from: from2,
|
|
38281
|
+
to,
|
|
38282
|
+
text,
|
|
38283
|
+
rules,
|
|
38284
|
+
plugin: plugin2
|
|
38285
|
+
});
|
|
38286
|
+
});
|
|
38287
|
+
}
|
|
38288
|
+
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
38289
|
+
}
|
|
38290
|
+
},
|
|
38291
|
+
props: {
|
|
38292
|
+
handleTextInput(view, from2, to, text) {
|
|
38293
|
+
return run({
|
|
38294
|
+
editor,
|
|
38295
|
+
from: from2,
|
|
38296
|
+
to,
|
|
38297
|
+
text,
|
|
38298
|
+
rules,
|
|
38299
|
+
plugin: plugin2
|
|
38300
|
+
});
|
|
38301
|
+
},
|
|
38302
|
+
// add support for input rules to trigger on enter
|
|
38303
|
+
// this is useful for example for code blocks
|
|
38304
|
+
handleKeyDown(view, event) {
|
|
38305
|
+
if (event.key !== "Enter") {
|
|
38306
|
+
return false;
|
|
38307
|
+
}
|
|
38308
|
+
const { $cursor } = view.state.selection;
|
|
38309
|
+
if ($cursor) {
|
|
38310
|
+
return run({
|
|
38311
|
+
editor,
|
|
38312
|
+
from: $cursor.pos,
|
|
38313
|
+
to: $cursor.pos,
|
|
38314
|
+
text: "\n",
|
|
38315
|
+
rules,
|
|
38316
|
+
plugin: plugin2
|
|
38317
|
+
});
|
|
38318
|
+
}
|
|
38319
|
+
return false;
|
|
38320
|
+
},
|
|
38321
|
+
// Paste handler
|
|
38322
|
+
handlePaste(view, event, slice2) {
|
|
38323
|
+
const clipboard = event.clipboardData;
|
|
38324
|
+
const html = clipboard.getData("text/html");
|
|
38325
|
+
clipboard.getData("text/plain");
|
|
38326
|
+
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
38327
|
+
if (fieldAnnotationContent.length) {
|
|
38328
|
+
return false;
|
|
38329
|
+
}
|
|
38330
|
+
let source;
|
|
38331
|
+
if (!html) {
|
|
38332
|
+
source = "plain-text";
|
|
38333
|
+
} else if (isWordHtml(html)) {
|
|
38334
|
+
source = "word-html";
|
|
38335
|
+
} else {
|
|
38336
|
+
source = "browser-html";
|
|
38337
|
+
}
|
|
38338
|
+
switch (source) {
|
|
38339
|
+
case "plain-text":
|
|
38340
|
+
break;
|
|
38341
|
+
case "word-html":
|
|
38342
|
+
if (editor.options.mode === "docx") {
|
|
38343
|
+
return handleDocxPaste(html, editor, view, plugin2);
|
|
38344
|
+
}
|
|
38345
|
+
case "browser-html":
|
|
38346
|
+
return handleHtmlPaste$1(html, editor);
|
|
38347
|
+
}
|
|
38348
|
+
return false;
|
|
38349
|
+
}
|
|
38350
|
+
},
|
|
38351
|
+
isInputRules: true
|
|
38352
|
+
});
|
|
38353
|
+
return plugin2;
|
|
38354
|
+
};
|
|
38355
|
+
function isWordHtml(html) {
|
|
38356
|
+
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
38357
|
+
}
|
|
38358
|
+
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
38359
|
+
const cleanedHtml = convertEmToPt(html);
|
|
38360
|
+
const tempDiv = document.createElement("div");
|
|
38361
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
38362
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38363
|
+
tempDiv.remove();
|
|
38364
|
+
const { dispatch } = editor.view;
|
|
38365
|
+
if (!dispatch) return false;
|
|
38366
|
+
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
38367
|
+
return true;
|
|
38368
|
+
};
|
|
38369
|
+
const convertEmToPt = (html) => {
|
|
38370
|
+
return html.replace(
|
|
38371
|
+
/font-size\s*:\s*([\d.]+)em/gi,
|
|
38372
|
+
(_, emValue) => {
|
|
38373
|
+
const em = parseFloat(emValue);
|
|
38374
|
+
const pt = Math.round(em * 12 * 100) / 100;
|
|
38375
|
+
return `font-size: ${pt}pt`;
|
|
38376
|
+
}
|
|
38377
|
+
);
|
|
38378
|
+
};
|
|
38379
|
+
function cleanHtmlUnnecessaryTags(html) {
|
|
38380
|
+
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
38400
38381
|
}
|
|
38401
38382
|
const _ExtensionService = class _ExtensionService2 {
|
|
38402
38383
|
constructor(extensions, userExtensions, editor) {
|
|
@@ -39236,7 +39217,6 @@ const createHeaderFooterEditor = ({
|
|
|
39236
39217
|
mediaFiles: editor.storage.image.media,
|
|
39237
39218
|
fonts: editor.options.fonts,
|
|
39238
39219
|
isHeaderOrFooter: true,
|
|
39239
|
-
isHeadless: editor.options.isHeadless,
|
|
39240
39220
|
annotations: true,
|
|
39241
39221
|
currentPageNumber,
|
|
39242
39222
|
parentEditor: editor,
|
|
@@ -39244,15 +39224,13 @@ const createHeaderFooterEditor = ({
|
|
|
39244
39224
|
onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
|
|
39245
39225
|
});
|
|
39246
39226
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
39247
|
-
|
|
39248
|
-
|
|
39249
|
-
|
|
39250
|
-
|
|
39251
|
-
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
39255
|
-
}
|
|
39227
|
+
pm.style.maxHeight = "100%";
|
|
39228
|
+
pm.style.minHeight = "100%";
|
|
39229
|
+
pm.style.outline = "none";
|
|
39230
|
+
pm.style.border = "none";
|
|
39231
|
+
pm.setAttribute("role", "textbox");
|
|
39232
|
+
pm.setAttribute("aria-multiline", true);
|
|
39233
|
+
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
39256
39234
|
return headerFooterEditor;
|
|
39257
39235
|
};
|
|
39258
39236
|
const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
@@ -39271,16 +39249,14 @@ const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
|
39271
39249
|
});
|
|
39272
39250
|
});
|
|
39273
39251
|
};
|
|
39274
|
-
const toggleHeaderFooterEditMode = (
|
|
39252
|
+
const toggleHeaderFooterEditMode = (editor, focusedSectionEditor, isEditMode) => {
|
|
39275
39253
|
editor.converter.headerEditors.forEach((item) => {
|
|
39276
39254
|
item.editor.setEditable(isEditMode, false);
|
|
39277
39255
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39278
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39279
39256
|
});
|
|
39280
39257
|
editor.converter.footerEditors.forEach((item) => {
|
|
39281
39258
|
item.editor.setEditable(isEditMode, false);
|
|
39282
39259
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39283
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39284
39260
|
});
|
|
39285
39261
|
if (isEditMode) {
|
|
39286
39262
|
const pm = document.querySelector(".ProseMirror");
|
|
@@ -40361,19 +40337,6 @@ const deleteHeaderFooterFieldAnnotations = ({ editor, fieldIdOrArray }) => {
|
|
|
40361
40337
|
);
|
|
40362
40338
|
});
|
|
40363
40339
|
};
|
|
40364
|
-
const resetHeaderFooterFieldAnnotations = ({ editor }) => {
|
|
40365
|
-
if (!editor) return;
|
|
40366
|
-
const sectionEditors = getAllHeaderFooterEditors(editor);
|
|
40367
|
-
sectionEditors.forEach(({ editor: sectionEditor, sectionId, type: type2 }) => {
|
|
40368
|
-
sectionEditor.commands.resetFieldAnnotations();
|
|
40369
|
-
onHeaderFooterDataUpdate(
|
|
40370
|
-
{ editor: sectionEditor },
|
|
40371
|
-
editor,
|
|
40372
|
-
sectionId,
|
|
40373
|
-
type2
|
|
40374
|
-
);
|
|
40375
|
-
});
|
|
40376
|
-
};
|
|
40377
40340
|
const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
|
|
40378
40341
|
if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
|
|
40379
40342
|
const { doc: doc2 } = editor.state;
|
|
@@ -40444,7 +40407,6 @@ const AnnotatorHelpers = {
|
|
|
40444
40407
|
getAllHeaderFooterEditors,
|
|
40445
40408
|
updateHeaderFooterFieldAnnotations,
|
|
40446
40409
|
deleteHeaderFooterFieldAnnotations,
|
|
40447
|
-
resetHeaderFooterFieldAnnotations,
|
|
40448
40410
|
cleanUpListsWithAnnotations
|
|
40449
40411
|
};
|
|
40450
40412
|
const CollaborationPluginKey = new PluginKey("collaboration");
|
|
@@ -40624,16 +40586,6 @@ const setWordSelection = (view, pos) => {
|
|
|
40624
40586
|
const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
|
|
40625
40587
|
dispatch(tr);
|
|
40626
40588
|
};
|
|
40627
|
-
const setImageNodeSelection = (view, pos) => {
|
|
40628
|
-
const { doc: doc2 } = view.state;
|
|
40629
|
-
const node2 = doc2.nodeAt(pos);
|
|
40630
|
-
if (node2 && node2.type.name === "image") {
|
|
40631
|
-
const tr = view.state.tr.setSelection(NodeSelection.create(doc2, pos));
|
|
40632
|
-
view.dispatch(tr);
|
|
40633
|
-
return true;
|
|
40634
|
-
}
|
|
40635
|
-
return false;
|
|
40636
|
-
};
|
|
40637
40589
|
const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
40638
40590
|
/**
|
|
40639
40591
|
* Create a new Editor instance
|
|
@@ -40732,19 +40684,6 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40732
40684
|
this.setHighContrastMode = setHighContrastMode;
|
|
40733
40685
|
initMode();
|
|
40734
40686
|
}
|
|
40735
|
-
mount(el) {
|
|
40736
|
-
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
40737
|
-
window.setTimeout(() => {
|
|
40738
|
-
if (this.isDestroyed) return;
|
|
40739
|
-
this.emit("create", { editor: this });
|
|
40740
|
-
}, 0);
|
|
40741
|
-
}
|
|
40742
|
-
unmount() {
|
|
40743
|
-
if (this.view) {
|
|
40744
|
-
this.view.destroy();
|
|
40745
|
-
}
|
|
40746
|
-
this.view = null;
|
|
40747
|
-
}
|
|
40748
40687
|
/**
|
|
40749
40688
|
* Set the toolbar for this editor
|
|
40750
40689
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -40793,7 +40732,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40793
40732
|
* @returns {boolean}
|
|
40794
40733
|
*/
|
|
40795
40734
|
get isDestroyed() {
|
|
40796
|
-
return this.view
|
|
40735
|
+
return this.view.isDestroyed;
|
|
40797
40736
|
}
|
|
40798
40737
|
/**
|
|
40799
40738
|
* Get the editor element
|
|
@@ -40836,12 +40775,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40836
40775
|
this.commands.toggleTrackChangesShowOriginal();
|
|
40837
40776
|
this.setEditable(false, false);
|
|
40838
40777
|
this.setOptions({ documentMode: "viewing" });
|
|
40839
|
-
toggleHeaderFooterEditMode(
|
|
40840
|
-
editor: this,
|
|
40841
|
-
focusedSectionEditor: null,
|
|
40842
|
-
isEditMode: false,
|
|
40843
|
-
documentMode: cleanedMode
|
|
40844
|
-
});
|
|
40778
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
40845
40779
|
} else if (cleanedMode === "suggesting") {
|
|
40846
40780
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
40847
40781
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -40854,12 +40788,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40854
40788
|
this.commands.disableTrackChanges();
|
|
40855
40789
|
this.setEditable(true, false);
|
|
40856
40790
|
this.setOptions({ documentMode: "editing" });
|
|
40857
|
-
toggleHeaderFooterEditMode(
|
|
40858
|
-
editor: this,
|
|
40859
|
-
focusedSectionEditor: null,
|
|
40860
|
-
isEditMode: false,
|
|
40861
|
-
documentMode: cleanedMode
|
|
40862
|
-
});
|
|
40791
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
40863
40792
|
}
|
|
40864
40793
|
}
|
|
40865
40794
|
/**
|
|
@@ -41036,26 +40965,29 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41036
40965
|
};
|
|
41037
40966
|
}
|
|
41038
40967
|
/**
|
|
41039
|
-
|
|
41040
|
-
|
|
41041
|
-
|
|
40968
|
+
* Initialize default styles for the editor container and ProseMirror.
|
|
40969
|
+
* Get page size and margins from the converter.
|
|
40970
|
+
* Set document default font and font size.
|
|
40971
|
+
*
|
|
40972
|
+
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
40973
|
+
* @returns {void}
|
|
40974
|
+
*/
|
|
40975
|
+
initDefaultStyles(element = this.element) {
|
|
40976
|
+
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
40977
|
+
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41042
40978
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
41043
|
-
if (!proseMirror || !
|
|
40979
|
+
if (!proseMirror || !pageSize || !pageMargins) {
|
|
41044
40980
|
return;
|
|
41045
40981
|
}
|
|
41046
40982
|
proseMirror.setAttribute("role", "document");
|
|
41047
40983
|
proseMirror.setAttribute("aria-multiline", true);
|
|
41048
40984
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
41049
40985
|
proseMirror.setAttribute("aria-description", "");
|
|
41050
|
-
|
|
41051
|
-
|
|
41052
|
-
|
|
41053
|
-
|
|
41054
|
-
|
|
41055
|
-
if (pageMargins) {
|
|
41056
|
-
element.style.paddingLeft = pageMargins.left + "in";
|
|
41057
|
-
element.style.paddingRight = pageMargins.right + "in";
|
|
41058
|
-
}
|
|
40986
|
+
element.style.width = pageSize.width + "in";
|
|
40987
|
+
element.style.minWidth = pageSize.width + "in";
|
|
40988
|
+
element.style.minHeight = pageSize.height + "in";
|
|
40989
|
+
element.style.paddingLeft = pageMargins.left + "in";
|
|
40990
|
+
element.style.paddingRight = pageMargins.right + "in";
|
|
41059
40991
|
element.style.boxSizing = "border-box";
|
|
41060
40992
|
element.style.isolation = "isolate";
|
|
41061
40993
|
proseMirror.style.outline = "none";
|
|
@@ -41076,19 +41008,6 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41076
41008
|
proseMirror.style.paddingTop = "1in";
|
|
41077
41009
|
proseMirror.style.paddingBottom = "1in";
|
|
41078
41010
|
}
|
|
41079
|
-
}
|
|
41080
|
-
/**
|
|
41081
|
-
* Initialize default styles for the editor container and ProseMirror.
|
|
41082
|
-
* Get page size and margins from the converter.
|
|
41083
|
-
* Set document default font and font size.
|
|
41084
|
-
*
|
|
41085
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
41086
|
-
* @returns {void}
|
|
41087
|
-
*/
|
|
41088
|
-
initDefaultStyles(element = this.element) {
|
|
41089
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
41090
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41091
|
-
this.updateEditorStyles(element, proseMirror);
|
|
41092
41011
|
this.initMobileStyles(element);
|
|
41093
41012
|
}
|
|
41094
41013
|
/**
|
|
@@ -41300,25 +41219,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41300
41219
|
*/
|
|
41301
41220
|
destroy() {
|
|
41302
41221
|
this.emit("destroy");
|
|
41303
|
-
this.
|
|
41304
|
-
this.destroyHeaderFooterEditors();
|
|
41222
|
+
if (this.view) this.view.destroy();
|
|
41305
41223
|
__privateMethod$1(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
41306
41224
|
this.removeAllListeners();
|
|
41307
41225
|
}
|
|
41308
|
-
destroyHeaderFooterEditors() {
|
|
41309
|
-
try {
|
|
41310
|
-
const editors = [
|
|
41311
|
-
...this.converter.headerEditors,
|
|
41312
|
-
...this.converter.footerEditors
|
|
41313
|
-
];
|
|
41314
|
-
for (let editorData of editors) {
|
|
41315
|
-
editorData.editor.destroy();
|
|
41316
|
-
}
|
|
41317
|
-
this.converter.headerEditors.length = 0;
|
|
41318
|
-
this.converter.footerEditors.length = 0;
|
|
41319
|
-
} catch (error) {
|
|
41320
|
-
}
|
|
41321
|
-
}
|
|
41322
41226
|
/**
|
|
41323
41227
|
* Check if migrations are needed for the data
|
|
41324
41228
|
* @static
|
|
@@ -41336,7 +41240,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41336
41240
|
* @returns {Object | void} Migration results
|
|
41337
41241
|
*/
|
|
41338
41242
|
processCollaborationMigrations() {
|
|
41339
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.2
|
|
41243
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2");
|
|
41340
41244
|
if (!this.options.ydoc) return;
|
|
41341
41245
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
41342
41246
|
let docVersion = metaMap.get("version");
|
|
@@ -41380,7 +41284,6 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41380
41284
|
__privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
|
|
41381
41285
|
this.initDefaultStyles();
|
|
41382
41286
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
41383
|
-
updateYdocDocxData(this);
|
|
41384
41287
|
this.initializeCollaborationData(true);
|
|
41385
41288
|
} else {
|
|
41386
41289
|
__privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -41532,7 +41435,7 @@ init_fn = function(options2) {
|
|
|
41532
41435
|
this.emit("beforeCreate", { editor: this });
|
|
41533
41436
|
this.on("contentError", this.options.onContentError);
|
|
41534
41437
|
this.on("exception", this.options.onException);
|
|
41535
|
-
this.
|
|
41438
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
41536
41439
|
this.initDefaultStyles();
|
|
41537
41440
|
this.setDocumentMode(options2.documentMode);
|
|
41538
41441
|
if (this.options.isHeadless) return;
|
|
@@ -41556,6 +41459,10 @@ init_fn = function(options2) {
|
|
|
41556
41459
|
__privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
|
|
41557
41460
|
__privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
|
|
41558
41461
|
}
|
|
41462
|
+
window.setTimeout(() => {
|
|
41463
|
+
if (this.isDestroyed) return;
|
|
41464
|
+
this.emit("create", { editor: this });
|
|
41465
|
+
}, 0);
|
|
41559
41466
|
};
|
|
41560
41467
|
initRichText_fn = function(options2) {
|
|
41561
41468
|
if (!options2.extensions || !options2.extensions.length) {
|
|
@@ -41567,7 +41474,7 @@ initRichText_fn = function(options2) {
|
|
|
41567
41474
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
41568
41475
|
this.emit("beforeCreate", { editor: this });
|
|
41569
41476
|
this.on("contentError", this.options.onContentError);
|
|
41570
|
-
this.
|
|
41477
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
41571
41478
|
this.on("create", this.options.onCreate);
|
|
41572
41479
|
this.on("update", this.options.onUpdate);
|
|
41573
41480
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -41578,6 +41485,10 @@ initRichText_fn = function(options2) {
|
|
|
41578
41485
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
41579
41486
|
this.on("commentClick", this.options.onCommentClicked);
|
|
41580
41487
|
this.on("locked", this.options.onDocumentLocked);
|
|
41488
|
+
window.setTimeout(() => {
|
|
41489
|
+
if (this.isDestroyed) return;
|
|
41490
|
+
this.emit("create", { editor: this });
|
|
41491
|
+
}, 0);
|
|
41581
41492
|
};
|
|
41582
41493
|
onFocus_fn = function({ editor, event }) {
|
|
41583
41494
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -41698,15 +41609,14 @@ createDocFromHTML_fn = function(content) {
|
|
|
41698
41609
|
}
|
|
41699
41610
|
return DOMParser$1.fromSchema(this.schema).parse(parsedContent);
|
|
41700
41611
|
};
|
|
41701
|
-
createView_fn = function(
|
|
41612
|
+
createView_fn = function() {
|
|
41702
41613
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
41703
41614
|
const state2 = { schema: this.schema };
|
|
41704
41615
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
41705
|
-
this.view = new EditorView(element, {
|
|
41616
|
+
this.view = new EditorView(this.options.element, {
|
|
41706
41617
|
...this.options.editorProps,
|
|
41707
41618
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
41708
41619
|
state: EditorState.create(state2),
|
|
41709
|
-
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
41710
41620
|
handleDoubleClick: async (view, pos, event) => {
|
|
41711
41621
|
if (this.options.documentMode !== "editing") return;
|
|
41712
41622
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -41720,12 +41630,7 @@ createView_fn = function(element) {
|
|
|
41720
41630
|
event.stopPropagation();
|
|
41721
41631
|
if (!this.options.editable) {
|
|
41722
41632
|
this.setEditable(true, false);
|
|
41723
|
-
toggleHeaderFooterEditMode(
|
|
41724
|
-
editor: this,
|
|
41725
|
-
focusedSectionEditor: null,
|
|
41726
|
-
isEditMode: false,
|
|
41727
|
-
documentMode: this.options.documentMode
|
|
41728
|
-
});
|
|
41633
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
41729
41634
|
const pm = document.querySelector(".ProseMirror");
|
|
41730
41635
|
pm.classList.remove("header-footer-edit");
|
|
41731
41636
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -41738,6 +41643,8 @@ createView_fn = function(element) {
|
|
|
41738
41643
|
});
|
|
41739
41644
|
this.view.updateState(newState);
|
|
41740
41645
|
this.createNodeViews();
|
|
41646
|
+
const dom = this.view.dom;
|
|
41647
|
+
dom.editor = this;
|
|
41741
41648
|
this.options.telemetry?.sendReport();
|
|
41742
41649
|
};
|
|
41743
41650
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
@@ -41764,9 +41671,7 @@ initComments_fn = function() {
|
|
|
41764
41671
|
}, 50);
|
|
41765
41672
|
};
|
|
41766
41673
|
initPagination_fn = async function() {
|
|
41767
|
-
if (this.options.isHeadless || !this.extensionService
|
|
41768
|
-
return;
|
|
41769
|
-
}
|
|
41674
|
+
if (this.options.isHeadless || !this.extensionService) return;
|
|
41770
41675
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
41771
41676
|
if (pagination && this.options.pagination) {
|
|
41772
41677
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -41778,7 +41683,7 @@ initPagination_fn = async function() {
|
|
|
41778
41683
|
}
|
|
41779
41684
|
};
|
|
41780
41685
|
dispatchTransaction_fn = function(transaction) {
|
|
41781
|
-
if (this.isDestroyed) return;
|
|
41686
|
+
if (this.view.isDestroyed) return;
|
|
41782
41687
|
let state2;
|
|
41783
41688
|
try {
|
|
41784
41689
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -41830,11 +41735,6 @@ dispatchTransaction_fn = function(transaction) {
|
|
|
41830
41735
|
transaction
|
|
41831
41736
|
});
|
|
41832
41737
|
};
|
|
41833
|
-
handleNodeSelection_fn = function(view, pos) {
|
|
41834
|
-
if (this.options.isHeaderOrFooter) {
|
|
41835
|
-
return setImageNodeSelection(view, pos);
|
|
41836
|
-
}
|
|
41837
|
-
};
|
|
41838
41738
|
prepareDocumentForImport_fn = function(doc2) {
|
|
41839
41739
|
const newState = EditorState.create({
|
|
41840
41740
|
schema: this.schema,
|
|
@@ -44177,7 +44077,7 @@ const Paragraph = Node$1.create({
|
|
|
44177
44077
|
},
|
|
44178
44078
|
addPmPlugins() {
|
|
44179
44079
|
const { view } = this.editor;
|
|
44180
|
-
new Plugin({
|
|
44080
|
+
const dropcapPlugin = new Plugin({
|
|
44181
44081
|
name: "dropcapPlugin",
|
|
44182
44082
|
key: new PluginKey("dropcapPlugin"),
|
|
44183
44083
|
state: {
|
|
@@ -44197,7 +44097,7 @@ const Paragraph = Node$1.create({
|
|
|
44197
44097
|
}
|
|
44198
44098
|
}
|
|
44199
44099
|
});
|
|
44200
|
-
return [];
|
|
44100
|
+
return [dropcapPlugin];
|
|
44201
44101
|
}
|
|
44202
44102
|
});
|
|
44203
44103
|
const getDropcapDecorations = (state2, view) => {
|
|
@@ -44550,16 +44450,7 @@ const HardBreak = Node$1.create({
|
|
|
44550
44450
|
};
|
|
44551
44451
|
},
|
|
44552
44452
|
parseDOM() {
|
|
44553
|
-
return [{
|
|
44554
|
-
tag: 'span[linebreaktype="page"]',
|
|
44555
|
-
getAttrs: (dom) => {
|
|
44556
|
-
if (!(dom instanceof HTMLElement)) return false;
|
|
44557
|
-
return {
|
|
44558
|
-
pageBreakSource: dom.getAttribute("pagebreaksource") || null,
|
|
44559
|
-
pageBreakType: dom.getAttribute("linebreaktype") || null
|
|
44560
|
-
};
|
|
44561
|
-
}
|
|
44562
|
-
}];
|
|
44453
|
+
return [{ tag: "span" }];
|
|
44563
44454
|
},
|
|
44564
44455
|
renderDOM({ htmlAttributes }) {
|
|
44565
44456
|
return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -47556,8 +47447,6 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47556
47447
|
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) {
|
|
47557
47448
|
return removedNodes;
|
|
47558
47449
|
}
|
|
47559
|
-
const hasDeletion = transactionDeletedAnything(tr);
|
|
47560
|
-
if (!hasDeletion) return removedNodes;
|
|
47561
47450
|
tr.steps.forEach((step, stepIndex) => {
|
|
47562
47451
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
47563
47452
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -47574,14 +47463,6 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47574
47463
|
});
|
|
47575
47464
|
return removedNodes;
|
|
47576
47465
|
}
|
|
47577
|
-
function transactionDeletedAnything(tr) {
|
|
47578
|
-
return tr.steps.some((step) => {
|
|
47579
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) {
|
|
47580
|
-
return step.from !== step.to;
|
|
47581
|
-
}
|
|
47582
|
-
return false;
|
|
47583
|
-
});
|
|
47584
|
-
}
|
|
47585
47466
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
47586
47467
|
let removedAnnotations = [];
|
|
47587
47468
|
try {
|
|
@@ -47977,18 +47858,8 @@ const FieldAnnotation = Node$1.create({
|
|
|
47977
47858
|
};
|
|
47978
47859
|
}
|
|
47979
47860
|
},
|
|
47980
|
-
defaultDisplayLabel: {
|
|
47981
|
-
default: "",
|
|
47982
|
-
parseDOM: (elem) => elem.getAttribute("data-default-display-label"),
|
|
47983
|
-
renderDOM: (attrs) => {
|
|
47984
|
-
if (!attrs.defaultDisplayLabel) return {};
|
|
47985
|
-
return {
|
|
47986
|
-
"data-default-display-label": attrs.defaultDisplayLabel
|
|
47987
|
-
};
|
|
47988
|
-
}
|
|
47989
|
-
},
|
|
47990
47861
|
displayLabel: {
|
|
47991
|
-
default: "",
|
|
47862
|
+
default: "Text field",
|
|
47992
47863
|
parseDOM: (elem) => elem.getAttribute("data-display-label"),
|
|
47993
47864
|
renderDOM: (attrs) => {
|
|
47994
47865
|
if (!attrs.displayLabel) return {};
|
|
@@ -48304,7 +48175,6 @@ const FieldAnnotation = Node$1.create({
|
|
|
48304
48175
|
return renderer();
|
|
48305
48176
|
},
|
|
48306
48177
|
addCommands() {
|
|
48307
|
-
const annotationTypes = this.options.types;
|
|
48308
48178
|
return {
|
|
48309
48179
|
/**
|
|
48310
48180
|
* Add field annotation.
|
|
@@ -48326,12 +48196,7 @@ const FieldAnnotation = Node$1.create({
|
|
|
48326
48196
|
let currentMarks = $pos.marks();
|
|
48327
48197
|
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
48328
48198
|
let formatAttrs = getFormatAttrsFromMarks(currentMarks);
|
|
48329
|
-
let
|
|
48330
|
-
let node2 = schema.nodes[this.name].create({
|
|
48331
|
-
...attrs,
|
|
48332
|
-
...formatAttrs,
|
|
48333
|
-
defaultDisplayLabel
|
|
48334
|
-
}, null, null);
|
|
48199
|
+
let node2 = schema.nodes[this.name].create({ ...attrs, ...formatAttrs }, null, null);
|
|
48335
48200
|
state2.tr.insert(newPos, node2).setSelection(Selection.near(tr.doc.resolve(newPos + node2.nodeSize)));
|
|
48336
48201
|
if (editorFocus) {
|
|
48337
48202
|
this.editor.view.focus();
|
|
@@ -48339,9 +48204,9 @@ const FieldAnnotation = Node$1.create({
|
|
|
48339
48204
|
}
|
|
48340
48205
|
return true;
|
|
48341
48206
|
},
|
|
48342
|
-
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state: state2, commands: commands2 }) => {
|
|
48207
|
+
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ editor, dispatch, state: state2, tr, commands: commands2 }) => {
|
|
48343
48208
|
const { from: from2 } = state2.selection;
|
|
48344
|
-
|
|
48209
|
+
commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
48345
48210
|
},
|
|
48346
48211
|
/**
|
|
48347
48212
|
* Replace field annotation.
|
|
@@ -48351,113 +48216,24 @@ const FieldAnnotation = Node$1.create({
|
|
|
48351
48216
|
* from: 20,
|
|
48352
48217
|
* to: 45,
|
|
48353
48218
|
* attrs: {
|
|
48354
|
-
*
|
|
48355
|
-
*
|
|
48219
|
+
* fieldType: 'TEXTINPUT'
|
|
48220
|
+
* fieldColor: '#980043'
|
|
48356
48221
|
* }
|
|
48357
48222
|
* ])
|
|
48358
48223
|
*/
|
|
48359
|
-
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => {
|
|
48224
|
+
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, state: state2, tr }) => {
|
|
48360
48225
|
if (!dispatch) return true;
|
|
48226
|
+
tr.setMeta("fieldAnnotationReplace", true);
|
|
48361
48227
|
fieldsArray.forEach((annotation) => {
|
|
48362
48228
|
let { from: from2, to, attrs } = annotation;
|
|
48363
48229
|
let { schema } = editor;
|
|
48364
48230
|
let newPosFrom = tr.mapping.map(from2);
|
|
48365
48231
|
let newPosTo = tr.mapping.map(to);
|
|
48366
|
-
let
|
|
48367
|
-
let node2 = schema.nodes[this.name].create({
|
|
48368
|
-
...attrs,
|
|
48369
|
-
defaultDisplayLabel
|
|
48370
|
-
}, null, null);
|
|
48232
|
+
let node2 = schema.nodes[this.name].create({ ...attrs }, null, null);
|
|
48371
48233
|
tr.replaceWith(newPosFrom, newPosTo, node2);
|
|
48372
48234
|
});
|
|
48373
48235
|
return true;
|
|
48374
48236
|
},
|
|
48375
|
-
/**
|
|
48376
|
-
* Replace annotations with a label (as text node) in selection.
|
|
48377
|
-
* @param options Additional options.
|
|
48378
|
-
* @example
|
|
48379
|
-
* editor.commands.replaceFieldAnnotationsWithLabelInSelection()
|
|
48380
|
-
*/
|
|
48381
|
-
replaceFieldAnnotationsWithLabelInSelection: (options2 = {}) => ({ commands: commands2 }) => {
|
|
48382
|
-
return commands2.replaceFieldAnnotationsWithLabel(null, {
|
|
48383
|
-
...options2,
|
|
48384
|
-
isInSelection: true
|
|
48385
|
-
});
|
|
48386
|
-
},
|
|
48387
|
-
/**
|
|
48388
|
-
* Replace annotations with a label (as text node).
|
|
48389
|
-
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
48390
|
-
* @param options.isInSelection Find in selection instead of field IDs.
|
|
48391
|
-
* @param options.addToHistory Add to history or not.
|
|
48392
|
-
* @param options.types Annotation types to replace.
|
|
48393
|
-
* @example
|
|
48394
|
-
* editor.commands.replaceFieldAnnotationsWithLabel(['1', '2'])
|
|
48395
|
-
*/
|
|
48396
|
-
replaceFieldAnnotationsWithLabel: (fieldIdOrArray, {
|
|
48397
|
-
isInSelection = false,
|
|
48398
|
-
addToHistory = false,
|
|
48399
|
-
types: types2 = annotationTypes
|
|
48400
|
-
} = {}) => ({ dispatch, state: state2, tr }) => {
|
|
48401
|
-
let { from: from2, to } = state2.selection;
|
|
48402
|
-
let annotations = isInSelection ? findFieldAnnotationsBetween(from2, to, state2.doc) : findFieldAnnotationsByFieldId(fieldIdOrArray, state2);
|
|
48403
|
-
annotations = types2.length ? annotations.filter(({ node: node2 }) => types2.includes(node2.attrs.type)) : annotations;
|
|
48404
|
-
if (!annotations.length) {
|
|
48405
|
-
return true;
|
|
48406
|
-
}
|
|
48407
|
-
if (!addToHistory) {
|
|
48408
|
-
tr.setMeta("addToHistory", false);
|
|
48409
|
-
}
|
|
48410
|
-
if (dispatch) {
|
|
48411
|
-
annotations.forEach((annotation) => {
|
|
48412
|
-
let { pos, node: node2 } = annotation;
|
|
48413
|
-
let newPosFrom = tr.mapping.map(pos);
|
|
48414
|
-
let newPosTo = tr.mapping.map(pos + node2.nodeSize);
|
|
48415
|
-
let currentNode = tr.doc.nodeAt(newPosFrom);
|
|
48416
|
-
let nodeEqual = node2.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
48417
|
-
let $newPosFrom = tr.doc.resolve(newPosFrom);
|
|
48418
|
-
let currentMarks = $newPosFrom.marks();
|
|
48419
|
-
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
48420
|
-
if (nodeEqual) {
|
|
48421
|
-
let label = node2.attrs.displayLabel || " ";
|
|
48422
|
-
let textNode = state2.schema.text(label, currentMarks);
|
|
48423
|
-
tr.replaceWith(newPosFrom, newPosTo, textNode);
|
|
48424
|
-
}
|
|
48425
|
-
});
|
|
48426
|
-
}
|
|
48427
|
-
return true;
|
|
48428
|
-
},
|
|
48429
|
-
/**
|
|
48430
|
-
* Resets all annotations to default values.
|
|
48431
|
-
* @example
|
|
48432
|
-
* editor.commands.resetFieldAnnotations()
|
|
48433
|
-
*/
|
|
48434
|
-
resetFieldAnnotations: () => ({ dispatch, state: state2, tr }) => {
|
|
48435
|
-
let annotations = getAllFieldAnnotations(state2);
|
|
48436
|
-
if (!annotations.length) {
|
|
48437
|
-
return true;
|
|
48438
|
-
}
|
|
48439
|
-
tr.setMeta("fieldAnnotationUpdate", true);
|
|
48440
|
-
if (dispatch) {
|
|
48441
|
-
annotations.forEach(({ pos, node: node2 }) => {
|
|
48442
|
-
let newPos = tr.mapping.map(pos);
|
|
48443
|
-
let currentNode = tr.doc.nodeAt(newPos);
|
|
48444
|
-
let nodeEqual = node2.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
48445
|
-
if (nodeEqual) {
|
|
48446
|
-
let displayLabel = node2.attrs.defaultDisplayLabel || node2.attrs.displayLabel || "";
|
|
48447
|
-
tr.setNodeMarkup(newPos, void 0, {
|
|
48448
|
-
...node2.attrs,
|
|
48449
|
-
// reset displayLabel to default.
|
|
48450
|
-
displayLabel,
|
|
48451
|
-
// reset attrs for specific types.
|
|
48452
|
-
imageSrc: null,
|
|
48453
|
-
rawHtml: null,
|
|
48454
|
-
linkUrl: null
|
|
48455
|
-
});
|
|
48456
|
-
}
|
|
48457
|
-
});
|
|
48458
|
-
}
|
|
48459
|
-
return true;
|
|
48460
|
-
},
|
|
48461
48237
|
/**
|
|
48462
48238
|
* Update annotations associated with a field.
|
|
48463
48239
|
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
@@ -49212,16 +48988,12 @@ const startImageUpload = async ({ editor, view, file }) => {
|
|
|
49212
48988
|
}
|
|
49213
48989
|
let id = {};
|
|
49214
48990
|
let { tr, schema } = view.state;
|
|
49215
|
-
|
|
49216
|
-
if (editor.options.isHeaderOrFooter) {
|
|
49217
|
-
selection = editor.options.lastSelection;
|
|
49218
|
-
}
|
|
49219
|
-
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
48991
|
+
if (!tr.selection.empty) {
|
|
49220
48992
|
tr.deleteSelection();
|
|
49221
48993
|
}
|
|
49222
48994
|
let imageMeta = {
|
|
49223
48995
|
type: "add",
|
|
49224
|
-
pos: selection.from,
|
|
48996
|
+
pos: tr.selection.from,
|
|
49225
48997
|
id
|
|
49226
48998
|
};
|
|
49227
48999
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -54470,8 +54242,7 @@ const Pagination = Extension.create({
|
|
|
54470
54242
|
addStorage() {
|
|
54471
54243
|
return {
|
|
54472
54244
|
height: 0,
|
|
54473
|
-
sectionData: null
|
|
54474
|
-
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
54245
|
+
sectionData: null
|
|
54475
54246
|
};
|
|
54476
54247
|
},
|
|
54477
54248
|
addCommands() {
|
|
@@ -54514,14 +54285,13 @@ const Pagination = Extension.create({
|
|
|
54514
54285
|
shouldUpdate = true;
|
|
54515
54286
|
shouldInitialize = meta.isReadyToInit;
|
|
54516
54287
|
}
|
|
54517
|
-
const syncMeta = tr.getMeta("y-sync$");
|
|
54518
|
-
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
54519
|
-
return { ...oldState };
|
|
54520
|
-
}
|
|
54521
54288
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
54522
54289
|
if (imagePluginTransaction) {
|
|
54523
54290
|
if (imagePluginTransaction.type === "remove") {
|
|
54524
|
-
|
|
54291
|
+
const imagePos = imagePluginTransaction.pos;
|
|
54292
|
+
const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
|
|
54293
|
+
if (domImage.complete) onImageLoad(editor);
|
|
54294
|
+
else domImage.onload = () => onImageLoad(editor);
|
|
54525
54295
|
}
|
|
54526
54296
|
return { ...oldState };
|
|
54527
54297
|
}
|
|
@@ -54548,7 +54318,6 @@ const Pagination = Extension.create({
|
|
|
54548
54318
|
if (isForceUpdate) shouldUpdate = true;
|
|
54549
54319
|
return {
|
|
54550
54320
|
...oldState,
|
|
54551
|
-
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
54552
54321
|
isReadyToInit: shouldInitialize
|
|
54553
54322
|
};
|
|
54554
54323
|
}
|
|
@@ -54577,10 +54346,6 @@ const Pagination = Extension.create({
|
|
|
54577
54346
|
},
|
|
54578
54347
|
onDestroy() {
|
|
54579
54348
|
cleanupFloatingSeparators();
|
|
54580
|
-
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
54581
|
-
if (headerFooterEditors) {
|
|
54582
|
-
headerFooterEditors.clear();
|
|
54583
|
-
}
|
|
54584
54349
|
}
|
|
54585
54350
|
});
|
|
54586
54351
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
|
|
@@ -54641,7 +54406,6 @@ const performUpdate = (editor, view, previousDecorations) => {
|
|
|
54641
54406
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
54642
54407
|
if (!editor.converter) return DecorationSet.empty;
|
|
54643
54408
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
54644
|
-
if (!pageSize) return DecorationSet.empty;
|
|
54645
54409
|
const { width, height } = pageSize;
|
|
54646
54410
|
if (!width || !height) return DecorationSet.empty;
|
|
54647
54411
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -54680,13 +54444,11 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54680
54444
|
let pageHeightThreshold = pageHeight;
|
|
54681
54445
|
let footer = null, header = null;
|
|
54682
54446
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
54683
|
-
const
|
|
54684
|
-
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
54447
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
|
|
54685
54448
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
54686
54449
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
54687
54450
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
54688
|
-
const
|
|
54689
|
-
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
54451
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
|
|
54690
54452
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
54691
54453
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
54692
54454
|
if (!coords) return [];
|
|
@@ -54705,8 +54467,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54705
54467
|
if (currentPageNumber === 1) {
|
|
54706
54468
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
54707
54469
|
decorations.pop();
|
|
54708
|
-
const
|
|
54709
|
-
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
54470
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
|
|
54710
54471
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
54711
54472
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
54712
54473
|
}
|
|
@@ -54780,15 +54541,15 @@ function createFinalPagePadding(bufferHeight) {
|
|
|
54780
54541
|
div2.style.height = bufferHeight + "px";
|
|
54781
54542
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
54782
54543
|
}
|
|
54783
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber
|
|
54784
|
-
const headerDef = sectionData
|
|
54544
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
54545
|
+
const headerDef = sectionData.headers?.[headerId];
|
|
54785
54546
|
const minHeaderHeight = pageMargins.top * 96;
|
|
54786
54547
|
const headerMargin = pageMargins.header * 96;
|
|
54787
54548
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
54788
54549
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
54789
54550
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
54790
54551
|
const availableHeight = headerHeight - headerMargin;
|
|
54791
|
-
|
|
54552
|
+
const editorContainer = document.createElement("div");
|
|
54792
54553
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
54793
54554
|
headerId = "rId" + generateDocxRandomId();
|
|
54794
54555
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -54800,31 +54561,23 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54800
54561
|
};
|
|
54801
54562
|
}
|
|
54802
54563
|
const data = editor.converter.headers[headerId];
|
|
54803
|
-
const
|
|
54804
|
-
|
|
54805
|
-
|
|
54806
|
-
|
|
54807
|
-
|
|
54808
|
-
|
|
54809
|
-
|
|
54810
|
-
|
|
54811
|
-
|
|
54812
|
-
|
|
54813
|
-
|
|
54814
|
-
|
|
54815
|
-
|
|
54816
|
-
|
|
54817
|
-
sectionId: headerId,
|
|
54818
|
-
type: "header",
|
|
54819
|
-
availableHeight,
|
|
54820
|
-
currentPageNumber
|
|
54821
|
-
});
|
|
54822
|
-
editor.converter.headerEditors.push({ id: headerId, editor: editorSection });
|
|
54823
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
54824
|
-
broadcastEditorEvents(editor, editorSection);
|
|
54825
|
-
}
|
|
54564
|
+
const editorSection = createHeaderFooterEditor({
|
|
54565
|
+
editor,
|
|
54566
|
+
data,
|
|
54567
|
+
editorContainer,
|
|
54568
|
+
appendToBody: false,
|
|
54569
|
+
sectionId: headerId,
|
|
54570
|
+
type: "header",
|
|
54571
|
+
availableHeight,
|
|
54572
|
+
currentPageNumber
|
|
54573
|
+
});
|
|
54574
|
+
editor.converter.headerEditors.push({
|
|
54575
|
+
id: headerId,
|
|
54576
|
+
editor: editorSection
|
|
54577
|
+
});
|
|
54826
54578
|
editorSection.setEditable(false, false);
|
|
54827
|
-
|
|
54579
|
+
broadcastEditorEvents(editor, editorSection);
|
|
54580
|
+
editorContainer.className = "pagination-section-header";
|
|
54828
54581
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
54829
54582
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
54830
54583
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -54837,12 +54590,12 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54837
54590
|
headerHeight
|
|
54838
54591
|
};
|
|
54839
54592
|
}
|
|
54840
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber
|
|
54841
|
-
const footerDef = sectionData
|
|
54593
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
54594
|
+
const footerDef = sectionData.footers?.[footerId];
|
|
54842
54595
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
54843
54596
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
54844
54597
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
54845
|
-
|
|
54598
|
+
const editorContainer = document.createElement("div");
|
|
54846
54599
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
54847
54600
|
footerId = "rId" + generateDocxRandomId();
|
|
54848
54601
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -54854,31 +54607,23 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54854
54607
|
};
|
|
54855
54608
|
}
|
|
54856
54609
|
const data = editor.converter.footers[footerId];
|
|
54857
|
-
const
|
|
54858
|
-
|
|
54859
|
-
|
|
54860
|
-
|
|
54861
|
-
|
|
54862
|
-
|
|
54863
|
-
|
|
54864
|
-
|
|
54865
|
-
|
|
54866
|
-
|
|
54867
|
-
|
|
54868
|
-
|
|
54869
|
-
|
|
54870
|
-
|
|
54871
|
-
sectionId: footerId,
|
|
54872
|
-
type: "footer",
|
|
54873
|
-
availableHeight: footerHeight,
|
|
54874
|
-
currentPageNumber
|
|
54875
|
-
});
|
|
54876
|
-
editor.converter.footerEditors.push({ id: footerId, editor: editorSection });
|
|
54877
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
54878
|
-
broadcastEditorEvents(editor, editorSection);
|
|
54879
|
-
}
|
|
54610
|
+
const editorSection = createHeaderFooterEditor({
|
|
54611
|
+
editor,
|
|
54612
|
+
data,
|
|
54613
|
+
editorContainer,
|
|
54614
|
+
appendToBody: false,
|
|
54615
|
+
sectionId: footerId,
|
|
54616
|
+
type: "footer",
|
|
54617
|
+
availableHeight: footerHeight,
|
|
54618
|
+
currentPageNumber
|
|
54619
|
+
});
|
|
54620
|
+
editor.converter.footerEditors.push({
|
|
54621
|
+
id: footerId,
|
|
54622
|
+
editor: editorSection
|
|
54623
|
+
});
|
|
54880
54624
|
editorSection.setEditable(false, false);
|
|
54881
|
-
|
|
54625
|
+
broadcastEditorEvents(editor, editorSection);
|
|
54626
|
+
editorContainer.className = "pagination-section-footer";
|
|
54882
54627
|
editorContainer.style.height = footerHeight + "px";
|
|
54883
54628
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
54884
54629
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -54891,28 +54636,10 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54891
54636
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
54892
54637
|
};
|
|
54893
54638
|
}
|
|
54894
|
-
const getHeaderFooterEditorKey = ({
|
|
54895
|
-
pageNumber,
|
|
54896
|
-
isHeader,
|
|
54897
|
-
isFooter,
|
|
54898
|
-
isFirstHeader = false,
|
|
54899
|
-
isLastFooter = false
|
|
54900
|
-
}) => {
|
|
54901
|
-
if (isFirstHeader) return `first-header-${pageNumber}`;
|
|
54902
|
-
if (isLastFooter) return `last-footer-${pageNumber}`;
|
|
54903
|
-
if (isHeader) return `header-${pageNumber}`;
|
|
54904
|
-
if (isFooter) return `footer-${pageNumber}`;
|
|
54905
|
-
return void 0;
|
|
54906
|
-
};
|
|
54907
54639
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
54908
54640
|
if (editor.options.documentMode !== "editing") return;
|
|
54909
54641
|
editor.setEditable(false, false);
|
|
54910
|
-
toggleHeaderFooterEditMode(
|
|
54911
|
-
editor,
|
|
54912
|
-
focusedSectionEditor: currentFocusedSectionEditor,
|
|
54913
|
-
isEditMode: true,
|
|
54914
|
-
documentMode: editor.options.documentMode
|
|
54915
|
-
});
|
|
54642
|
+
toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
|
|
54916
54643
|
};
|
|
54917
54644
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
54918
54645
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -55467,7 +55194,7 @@ const Search = Extension.create({
|
|
|
55467
55194
|
}
|
|
55468
55195
|
});
|
|
55469
55196
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
55470
|
-
const nodeResizer = (nodeNames = ["image"]
|
|
55197
|
+
const nodeResizer = (nodeNames = ["image"]) => {
|
|
55471
55198
|
let resizeState = {
|
|
55472
55199
|
dragging: false,
|
|
55473
55200
|
startX: 0,
|
|
@@ -55492,13 +55219,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
55492
55219
|
if (tr.getMeta(NodeResizerKey)) {
|
|
55493
55220
|
return oldState;
|
|
55494
55221
|
}
|
|
55495
|
-
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
55496
|
-
const { selection } = newState;
|
|
55497
|
-
const node2 = selection.node;
|
|
55498
|
-
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
55499
|
-
return DecorationSet.empty;
|
|
55500
|
-
}
|
|
55501
55222
|
const decorations = [];
|
|
55223
|
+
const { selection } = newState;
|
|
55502
55224
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
55503
55225
|
decorations.push(
|
|
55504
55226
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -55701,7 +55423,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
55701
55423
|
const NodeResizer = Extension.create({
|
|
55702
55424
|
name: "nodeResizer",
|
|
55703
55425
|
addPmPlugins() {
|
|
55704
|
-
return [nodeResizer(["image"]
|
|
55426
|
+
return [nodeResizer(["image"])];
|
|
55705
55427
|
}
|
|
55706
55428
|
});
|
|
55707
55429
|
const getRichTextExtensions = () => {
|
|
@@ -64377,6 +64099,7 @@ const style$2 = cB("icon", `
|
|
|
64377
64099
|
display: inline-block;
|
|
64378
64100
|
position: relative;
|
|
64379
64101
|
fill: currentColor;
|
|
64102
|
+
transform: translateZ(0);
|
|
64380
64103
|
`, [cM("color-transition", {
|
|
64381
64104
|
transition: "color .3s var(--n-bezier)"
|
|
64382
64105
|
}), cM("depth", {
|