@harbour-enterprises/superdoc 0.13.2-rev1 → 0.13.2-rev10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{eventemitter3-DfVviFzP.cjs → eventemitter3-CHxWXmuK.cjs} +1 -1
- package/dist/chunks/{eventemitter3-BrspJk8q.es.js → eventemitter3-KKY27oz-.es.js} +1 -1
- package/dist/chunks/{index-KzH9VKHh.es.js → index-BqLFjUHn.es.js} +2 -2
- package/dist/chunks/{index-B0t3i_io.cjs → index-CweAXNfB.cjs} +2 -2
- package/dist/chunks/{index-D_HUrFWV.es.js → index-DS3W0eVB.es.js} +4 -4
- package/dist/chunks/{index-Bk160jQ2.cjs → index-kOMfCfBT.cjs} +4 -4
- package/dist/chunks/{jszip-BTAcmbVg.cjs → jszip-9bCX1h2W.cjs} +1 -1
- package/dist/chunks/{jszip-DckFs3A7.es.js → jszip-Cl3s9njw.es.js} +1 -1
- package/dist/chunks/{super-editor.es--NMYzIh3.cjs → super-editor.es-Bdu65rjC.cjs} +1090 -816
- package/dist/chunks/{super-editor.es-DyTkLKR1.es.js → super-editor.es-BwWbNxcS.es.js} +1090 -816
- package/dist/chunks/{url-CWyTQ-Xy.cjs → url-B8LY3nwf.cjs} +2 -2
- package/dist/chunks/{url-DsBQArCl.es.js → url-Bq00tGvm.es.js} +2 -2
- package/dist/chunks/{vue-Bi1uWinj.es.js → vue-BBJVqxjL.es.js} +10 -3
- package/dist/chunks/{vue-HIY1g7dm.cjs → vue-BBjMeYfo.cjs} +10 -3
- package/dist/chunks/{xml-js-CdiD26MJ.es.js → xml-js-1F0lia4t.es.js} +2 -2
- package/dist/chunks/{xml-js-Bu1ZZzmb.cjs → xml-js-BuAdLsHD.cjs} +2 -2
- package/dist/style.css +2 -2
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CJ9kHtZx.js → converter-lPrQA7b1.js} +632 -52
- package/dist/super-editor/chunks/{docx-zipper-scQqOWXA.js → docx-zipper-HvG9XskR.js} +1 -1
- package/dist/super-editor/chunks/{editor-DM6yaxu_.js → editor-DbkiH8Up.js} +386 -685
- package/dist/super-editor/chunks/{toolbar-CIHbdcnv.js → toolbar-JdrfUR1G.js} +2 -3
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/core/Editor.d.ts +7 -0
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/InputRule.d.ts +7 -0
- package/dist/super-editor/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/annotator.d.ts +4 -0
- package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts +2 -0
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts.map +1 -0
- package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
- package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.d.ts.map +1 -1
- package/dist/super-editor/extensions/image/imageHelpers/startImageUpload.d.ts.map +1 -1
- package/dist/super-editor/extensions/line-break/line-break.d.ts.map +1 -1
- package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +6 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +2 -2
- package/dist/super-editor/super-editor.es.js +7 -7
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +8 -9
- package/dist/superdoc.es.js +9 -10
- package/dist/superdoc.umd.js +1101 -821
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -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-BBJVqxjL.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$1$1 = class Node2 {
|
|
10945
10945
|
/**
|
|
10946
10946
|
@internal
|
|
10947
10947
|
*/
|
|
@@ -11342,8 +11342,8 @@ let Node$2 = class Node2 {
|
|
|
11342
11342
|
return node2;
|
|
11343
11343
|
}
|
|
11344
11344
|
};
|
|
11345
|
-
Node$
|
|
11346
|
-
class TextNode extends Node$
|
|
11345
|
+
Node$1$1.prototype.text = void 0;
|
|
11346
|
+
class TextNode extends Node$1$1 {
|
|
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$1$1(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$1$1(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$1$1(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$1$1.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
|
+
let ReplaceAroundStep$1 = class ReplaceAroundStep2 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 @@ class ReplaceAroundStep extends Step {
|
|
|
13766
13766
|
}
|
|
13767
13767
|
invert(doc2) {
|
|
13768
13768
|
let gap = this.gapTo - this.gapFrom;
|
|
13769
|
-
return new
|
|
13769
|
+
return new ReplaceAroundStep2(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc2.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
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 @@ class ReplaceAroundStep 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 ReplaceAroundStep2(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 @@ class ReplaceAroundStep 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 ReplaceAroundStep2(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$1);
|
|
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(start2, end2, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
13956
|
+
tr.step(new ReplaceAroundStep$1(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(start2, end2, start2, end2, new Slice(content, 0, 0), wrappers.length, true));
|
|
14001
|
+
tr.step(new ReplaceAroundStep$1(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(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
14023
|
+
tr.step(new ReplaceAroundStep$1(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
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(pos, pos + node2.nodeSize, pos + 1, pos + node2.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
14064
|
+
tr.step(new ReplaceAroundStep$1(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($from.pos, moveInline, this.$to.pos, this.$to.end(), slice2, placedSize);
|
|
14265
|
+
return new ReplaceAroundStep$1($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$1))
|
|
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$1$1.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,6 +18821,583 @@ 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
|
+
}
|
|
18824
19401
|
function exportSchemaToJson(params2) {
|
|
18825
19402
|
const { type: type2 } = params2.node || {};
|
|
18826
19403
|
const router = {
|
|
@@ -20164,12 +20741,11 @@ function prepareHtmlAnnotation(params2) {
|
|
|
20164
20741
|
node: { attrs = {}, marks = [] },
|
|
20165
20742
|
editorSchema
|
|
20166
20743
|
} = params2;
|
|
20167
|
-
const
|
|
20168
|
-
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, "text/html");
|
|
20744
|
+
const paragraphHtmlContainer = sanitizeHtml(attrs.rawHtml);
|
|
20169
20745
|
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
20170
20746
|
const allMarks = [...marks, ...marksFromAttrs];
|
|
20171
20747
|
let state2 = EditorState.create({
|
|
20172
|
-
doc: DOMParser$1.fromSchema(editorSchema).parse(
|
|
20748
|
+
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtmlContainer)
|
|
20173
20749
|
});
|
|
20174
20750
|
if (allMarks.length) {
|
|
20175
20751
|
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
@@ -23234,6 +23810,7 @@ const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
|
23234
23810
|
const footers = elements.filter((el) => el.attributes["Type"] === footerType);
|
|
23235
23811
|
const sectPr = findSectPr(docx["word/document.xml"]) || [];
|
|
23236
23812
|
const allSectPrElements = sectPr.flatMap((el) => el.elements);
|
|
23813
|
+
if (!mainEditor) return;
|
|
23237
23814
|
const editor = { ...mainEditor };
|
|
23238
23815
|
editor.options.annotations = true;
|
|
23239
23816
|
headers.forEach((header) => {
|
|
@@ -23395,7 +23972,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
23395
23972
|
return;
|
|
23396
23973
|
}
|
|
23397
23974
|
}
|
|
23398
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2-
|
|
23975
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2-rev10") {
|
|
23399
23976
|
const customLocation = "docProps/custom.xml";
|
|
23400
23977
|
if (!docx[customLocation]) {
|
|
23401
23978
|
docx[customLocation] = generateCustomXml();
|
|
@@ -23862,7 +24439,7 @@ function storeSuperdocVersion(docx) {
|
|
|
23862
24439
|
function generateCustomXml() {
|
|
23863
24440
|
return DEFAULT_CUSTOM_XML;
|
|
23864
24441
|
}
|
|
23865
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.13.2-
|
|
24442
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.13.2-rev10") {
|
|
23866
24443
|
return {
|
|
23867
24444
|
type: "element",
|
|
23868
24445
|
name: "property",
|
|
@@ -26395,7 +26972,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
26395
26972
|
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);
|
|
26396
26973
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
26397
26974
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
26398
|
-
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;
|
|
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, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
26399
26976
|
function getMarksFromSelection(state2) {
|
|
26400
26977
|
const { from: from2, to, empty: empty2 } = state2.selection;
|
|
26401
26978
|
const marks = [];
|
|
@@ -27584,164 +28161,6 @@ createMarksSchema_fn = function(markExtensions, attributes, editor) {
|
|
|
27584
28161
|
};
|
|
27585
28162
|
__privateAdd$1(_Schema, _Schema_static);
|
|
27586
28163
|
let Schema2 = _Schema;
|
|
27587
|
-
function chainableEditorState(transaction, state2) {
|
|
27588
|
-
let { selection, doc: doc2, storedMarks } = transaction;
|
|
27589
|
-
return {
|
|
27590
|
-
...state2,
|
|
27591
|
-
apply: state2.apply.bind(state2),
|
|
27592
|
-
applyTransaction: state2.applyTransaction.bind(state2),
|
|
27593
|
-
plugins: state2.plugins,
|
|
27594
|
-
schema: state2.schema,
|
|
27595
|
-
reconfigure: state2.reconfigure.bind(state2),
|
|
27596
|
-
toJSON: state2.toJSON.bind(state2),
|
|
27597
|
-
get storedMarks() {
|
|
27598
|
-
return storedMarks;
|
|
27599
|
-
},
|
|
27600
|
-
get selection() {
|
|
27601
|
-
return selection;
|
|
27602
|
-
},
|
|
27603
|
-
get doc() {
|
|
27604
|
-
return doc2;
|
|
27605
|
-
},
|
|
27606
|
-
get tr() {
|
|
27607
|
-
selection = transaction.selection;
|
|
27608
|
-
doc2 = transaction.doc;
|
|
27609
|
-
storedMarks = transaction.storedMarks;
|
|
27610
|
-
return transaction;
|
|
27611
|
-
}
|
|
27612
|
-
};
|
|
27613
|
-
}
|
|
27614
|
-
class CommandService {
|
|
27615
|
-
constructor(props) {
|
|
27616
|
-
__publicField$1(this, "editor");
|
|
27617
|
-
__publicField$1(this, "rawCommands");
|
|
27618
|
-
this.editor = props.editor;
|
|
27619
|
-
this.rawCommands = this.editor.extensionService.commands;
|
|
27620
|
-
}
|
|
27621
|
-
/**
|
|
27622
|
-
* Static method for creating a service.
|
|
27623
|
-
* @param args Arguments for the constructor.
|
|
27624
|
-
*/
|
|
27625
|
-
static create(...args) {
|
|
27626
|
-
return new CommandService(...args);
|
|
27627
|
-
}
|
|
27628
|
-
/**
|
|
27629
|
-
* Get editor state.
|
|
27630
|
-
*/
|
|
27631
|
-
get state() {
|
|
27632
|
-
return this.editor.state;
|
|
27633
|
-
}
|
|
27634
|
-
/**
|
|
27635
|
-
* Get all commands with wrapped command method.
|
|
27636
|
-
*/
|
|
27637
|
-
get commands() {
|
|
27638
|
-
const { editor, state: state2 } = this;
|
|
27639
|
-
const { view } = editor;
|
|
27640
|
-
const { tr } = state2;
|
|
27641
|
-
const props = this.createProps(tr);
|
|
27642
|
-
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
27643
|
-
const method = (...args) => {
|
|
27644
|
-
const fn2 = command2(...args)(props);
|
|
27645
|
-
if (!tr.getMeta("preventDispatch")) {
|
|
27646
|
-
view.dispatch(tr);
|
|
27647
|
-
}
|
|
27648
|
-
return fn2;
|
|
27649
|
-
};
|
|
27650
|
-
return [name, method];
|
|
27651
|
-
});
|
|
27652
|
-
return Object.fromEntries(entries);
|
|
27653
|
-
}
|
|
27654
|
-
/**
|
|
27655
|
-
* Create a chain of commands to call multiple commands at once.
|
|
27656
|
-
*/
|
|
27657
|
-
get chain() {
|
|
27658
|
-
return () => this.createChain();
|
|
27659
|
-
}
|
|
27660
|
-
/**
|
|
27661
|
-
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
27662
|
-
*/
|
|
27663
|
-
get can() {
|
|
27664
|
-
return () => this.createCan();
|
|
27665
|
-
}
|
|
27666
|
-
/**
|
|
27667
|
-
* Creates a chain of commands.
|
|
27668
|
-
* @param startTr Start transaction.
|
|
27669
|
-
* @param shouldDispatch Should dispatch or not.
|
|
27670
|
-
*/
|
|
27671
|
-
createChain(startTr, shouldDispatch = true) {
|
|
27672
|
-
const { editor, state: state2, rawCommands } = this;
|
|
27673
|
-
const { view } = editor;
|
|
27674
|
-
const callbacks2 = [];
|
|
27675
|
-
const hasStartTr = !!startTr;
|
|
27676
|
-
const tr = startTr || state2.tr;
|
|
27677
|
-
const run2 = () => {
|
|
27678
|
-
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
27679
|
-
view.dispatch(tr);
|
|
27680
|
-
}
|
|
27681
|
-
return callbacks2.every((cb) => cb === true);
|
|
27682
|
-
};
|
|
27683
|
-
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
27684
|
-
const chainedCommand = (...args) => {
|
|
27685
|
-
const props = this.createProps(tr, shouldDispatch);
|
|
27686
|
-
const callback = command2(...args)(props);
|
|
27687
|
-
callbacks2.push(callback);
|
|
27688
|
-
return chain;
|
|
27689
|
-
};
|
|
27690
|
-
return [name, chainedCommand];
|
|
27691
|
-
});
|
|
27692
|
-
const chain = {
|
|
27693
|
-
...Object.fromEntries(entries),
|
|
27694
|
-
run: run2
|
|
27695
|
-
};
|
|
27696
|
-
return chain;
|
|
27697
|
-
}
|
|
27698
|
-
/**
|
|
27699
|
-
* Creates a can check for commands.
|
|
27700
|
-
* @param startTr Start transaction.
|
|
27701
|
-
*/
|
|
27702
|
-
createCan(startTr) {
|
|
27703
|
-
const { rawCommands, state: state2 } = this;
|
|
27704
|
-
const dispatch = false;
|
|
27705
|
-
const tr = startTr || state2.tr;
|
|
27706
|
-
const props = this.createProps(tr, dispatch);
|
|
27707
|
-
const commands2 = Object.fromEntries(
|
|
27708
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27709
|
-
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
27710
|
-
})
|
|
27711
|
-
);
|
|
27712
|
-
return {
|
|
27713
|
-
...commands2,
|
|
27714
|
-
chain: () => this.createChain(tr, dispatch)
|
|
27715
|
-
};
|
|
27716
|
-
}
|
|
27717
|
-
/**
|
|
27718
|
-
* Creates default props for the command method.
|
|
27719
|
-
* @param {*} tr Transaction.
|
|
27720
|
-
* @param {*} shouldDispatch Check if should dispatch.
|
|
27721
|
-
* @returns Object with props.
|
|
27722
|
-
*/
|
|
27723
|
-
createProps(tr, shouldDispatch = true) {
|
|
27724
|
-
const { editor, state: state2, rawCommands } = this;
|
|
27725
|
-
const { view } = editor;
|
|
27726
|
-
const props = {
|
|
27727
|
-
tr,
|
|
27728
|
-
editor,
|
|
27729
|
-
view,
|
|
27730
|
-
state: chainableEditorState(tr, state2),
|
|
27731
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
27732
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
27733
|
-
can: () => this.createCan(tr),
|
|
27734
|
-
get commands() {
|
|
27735
|
-
return Object.fromEntries(
|
|
27736
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27737
|
-
return [name, (...args) => command2(...args)(props)];
|
|
27738
|
-
})
|
|
27739
|
-
);
|
|
27740
|
-
}
|
|
27741
|
-
};
|
|
27742
|
-
return props;
|
|
27743
|
-
}
|
|
27744
|
-
}
|
|
27745
28164
|
const first = (commands2) => (props) => {
|
|
27746
28165
|
const items = typeof commands2 === "function" ? commands2(props) : commands2;
|
|
27747
28166
|
for (let i = 0; i < items.length; i += 1) {
|
|
@@ -28103,7 +28522,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28103
28522
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
28104
28523
|
wrap2 = Fragment.from(conn[i].create(null, wrap2));
|
|
28105
28524
|
wrap2 = Fragment.from(before.copy(wrap2));
|
|
28106
|
-
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
28525
|
+
let tr = state2.tr.step(new ReplaceAroundStep$1($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
28107
28526
|
let $joinAt = tr.doc.resolve(end2 + 2 * conn.length);
|
|
28108
28527
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
|
|
28109
28528
|
tr.join($joinAt.pos);
|
|
@@ -28134,7 +28553,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28134
28553
|
let end2 = Fragment.empty;
|
|
28135
28554
|
for (let i = wrap2.length - 1; i >= 0; i--)
|
|
28136
28555
|
end2 = Fragment.from(wrap2[i].copy(end2));
|
|
28137
|
-
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));
|
|
28556
|
+
let tr = state2.tr.step(new ReplaceAroundStep$1($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end2, wrap2.length, 0), 0, true));
|
|
28138
28557
|
dispatch(tr.scrollIntoView());
|
|
28139
28558
|
}
|
|
28140
28559
|
return true;
|
|
@@ -28707,7 +29126,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
28707
29126
|
return;
|
|
28708
29127
|
}
|
|
28709
29128
|
const step = tr.steps[last];
|
|
28710
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
29129
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1)) {
|
|
28711
29130
|
return;
|
|
28712
29131
|
}
|
|
28713
29132
|
const map22 = tr.mapping.maps[last];
|
|
@@ -28853,7 +29272,7 @@ function doWrapInList(tr, range2, wrappers, joinBefore, listType) {
|
|
|
28853
29272
|
let content = Fragment.empty;
|
|
28854
29273
|
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
28855
29274
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
28856
|
-
tr.step(new ReplaceAroundStep(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
29275
|
+
tr.step(new ReplaceAroundStep$1(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
28857
29276
|
let found2 = 0;
|
|
28858
29277
|
for (let i = 0; i < wrappers.length; i++)
|
|
28859
29278
|
if (wrappers[i].type == listType)
|
|
@@ -28886,7 +29305,7 @@ function liftListItem$1(itemType) {
|
|
|
28886
29305
|
function liftToOuterList(state2, dispatch, itemType, range2) {
|
|
28887
29306
|
let tr = state2.tr, end2 = range2.end, endOfList = range2.$to.end(range2.depth);
|
|
28888
29307
|
if (end2 < endOfList) {
|
|
28889
|
-
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
29308
|
+
tr.step(new ReplaceAroundStep$1(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
28890
29309
|
range2 = new NodeRange(tr.doc.resolve(range2.$from.pos), tr.doc.resolve(endOfList), range2.depth);
|
|
28891
29310
|
}
|
|
28892
29311
|
const target = liftTarget(range2);
|
|
@@ -28913,7 +29332,7 @@ function liftOutOfList(state2, dispatch, range2) {
|
|
|
28913
29332
|
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))
|
|
28914
29333
|
return false;
|
|
28915
29334
|
let start2 = $start.pos, end2 = start2 + item.nodeSize;
|
|
28916
|
-
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));
|
|
29335
|
+
tr.step(new ReplaceAroundStep$1(start2 - (atStart ? 1 : 0), end2 + (atEnd ? 1 : 0), start2 + 1, end2 - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
28917
29336
|
dispatch(tr.scrollIntoView());
|
|
28918
29337
|
return true;
|
|
28919
29338
|
}
|
|
@@ -28934,7 +29353,7 @@ function sinkListItem$1(itemType) {
|
|
|
28934
29353
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
28935
29354
|
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
28936
29355
|
let before = range2.start, after = range2.end;
|
|
28937
|
-
dispatch(state2.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
29356
|
+
dispatch(state2.tr.step(new ReplaceAroundStep$1(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
28938
29357
|
}
|
|
28939
29358
|
return true;
|
|
28940
29359
|
};
|
|
@@ -36527,7 +36946,8 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
|
|
|
36527
36946
|
binding.mapping
|
|
36528
36947
|
);
|
|
36529
36948
|
if (anchor !== null && head !== null) {
|
|
36530
|
-
|
|
36949
|
+
const sel = TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
|
|
36950
|
+
tr.setSelection(sel);
|
|
36531
36951
|
}
|
|
36532
36952
|
}
|
|
36533
36953
|
}
|
|
@@ -37308,7 +37728,7 @@ const setMeta = (view, key, value) => {
|
|
|
37308
37728
|
};
|
|
37309
37729
|
const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
37310
37730
|
if (pos === 0) {
|
|
37311
|
-
return Y.createRelativePositionFromTypeIndex(type2, 0, -1);
|
|
37731
|
+
return Y.createRelativePositionFromTypeIndex(type2, 0, type2.length === 0 ? -1 : 0);
|
|
37312
37732
|
}
|
|
37313
37733
|
let n = type2._first === null ? null : (
|
|
37314
37734
|
/** @type {Y.ContentType} */
|
|
@@ -37317,7 +37737,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37317
37737
|
while (n !== null && type2 !== n) {
|
|
37318
37738
|
if (n instanceof Y.XmlText) {
|
|
37319
37739
|
if (n._length >= pos) {
|
|
37320
|
-
return Y.createRelativePositionFromTypeIndex(n, pos, -1);
|
|
37740
|
+
return Y.createRelativePositionFromTypeIndex(n, pos, type2.length === 0 ? -1 : 0);
|
|
37321
37741
|
} else {
|
|
37322
37742
|
pos -= n._length;
|
|
37323
37743
|
}
|
|
@@ -37381,7 +37801,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37381
37801
|
return createRelativePosition(n._item.parent, n._item);
|
|
37382
37802
|
}
|
|
37383
37803
|
}
|
|
37384
|
-
return Y.createRelativePositionFromTypeIndex(type2, type2._length, -1);
|
|
37804
|
+
return Y.createRelativePositionFromTypeIndex(type2, type2._length, type2.length === 0 ? -1 : 0);
|
|
37385
37805
|
};
|
|
37386
37806
|
const createRelativePosition = (type2, item) => {
|
|
37387
37807
|
let typeid = null;
|
|
@@ -37863,523 +38283,120 @@ var shift = {
|
|
|
37863
38283
|
186: ":",
|
|
37864
38284
|
187: "+",
|
|
37865
38285
|
188: "<",
|
|
37866
|
-
189: "_",
|
|
37867
|
-
190: ">",
|
|
37868
|
-
191: "?",
|
|
37869
|
-
192: "~",
|
|
37870
|
-
219: "{",
|
|
37871
|
-
220: "|",
|
|
37872
|
-
221: "}",
|
|
37873
|
-
222: '"'
|
|
37874
|
-
};
|
|
37875
|
-
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
37876
|
-
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
37877
|
-
for (var i = 0; i < 10; i++) base$1[48 + i] = base$1[96 + i] = String(i);
|
|
37878
|
-
for (var i = 1; i <= 24; i++) base$1[i + 111] = "F" + i;
|
|
37879
|
-
for (var i = 65; i <= 90; i++) {
|
|
37880
|
-
base$1[i] = String.fromCharCode(i + 32);
|
|
37881
|
-
shift[i] = String.fromCharCode(i);
|
|
37882
|
-
}
|
|
37883
|
-
for (var code in base$1) if (!shift.hasOwnProperty(code)) shift[code] = base$1[code];
|
|
37884
|
-
function keyName(event) {
|
|
37885
|
-
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
37886
|
-
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$1)[event.keyCode] || event.key || "Unidentified";
|
|
37887
|
-
if (name == "Esc") name = "Escape";
|
|
37888
|
-
if (name == "Del") name = "Delete";
|
|
37889
|
-
if (name == "Left") name = "ArrowLeft";
|
|
37890
|
-
if (name == "Up") name = "ArrowUp";
|
|
37891
|
-
if (name == "Right") name = "ArrowRight";
|
|
37892
|
-
if (name == "Down") name = "ArrowDown";
|
|
37893
|
-
return name;
|
|
37894
|
-
}
|
|
37895
|
-
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
37896
|
-
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
37897
|
-
function normalizeKeyName(name) {
|
|
37898
|
-
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
37899
|
-
if (result == "Space")
|
|
37900
|
-
result = " ";
|
|
37901
|
-
let alt, ctrl, shift2, meta;
|
|
37902
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
37903
|
-
let mod = parts[i];
|
|
37904
|
-
if (/^(cmd|meta|m)$/i.test(mod))
|
|
37905
|
-
meta = true;
|
|
37906
|
-
else if (/^a(lt)?$/i.test(mod))
|
|
37907
|
-
alt = true;
|
|
37908
|
-
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
37909
|
-
ctrl = true;
|
|
37910
|
-
else if (/^s(hift)?$/i.test(mod))
|
|
37911
|
-
shift2 = true;
|
|
37912
|
-
else if (/^mod$/i.test(mod)) {
|
|
37913
|
-
if (mac)
|
|
37914
|
-
meta = true;
|
|
37915
|
-
else
|
|
37916
|
-
ctrl = true;
|
|
37917
|
-
} else
|
|
37918
|
-
throw new Error("Unrecognized modifier name: " + mod);
|
|
37919
|
-
}
|
|
37920
|
-
if (alt)
|
|
37921
|
-
result = "Alt-" + result;
|
|
37922
|
-
if (ctrl)
|
|
37923
|
-
result = "Ctrl-" + result;
|
|
37924
|
-
if (meta)
|
|
37925
|
-
result = "Meta-" + result;
|
|
37926
|
-
if (shift2)
|
|
37927
|
-
result = "Shift-" + result;
|
|
37928
|
-
return result;
|
|
37929
|
-
}
|
|
37930
|
-
function normalize(map22) {
|
|
37931
|
-
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
37932
|
-
for (let prop in map22)
|
|
37933
|
-
copy2[normalizeKeyName(prop)] = map22[prop];
|
|
37934
|
-
return copy2;
|
|
37935
|
-
}
|
|
37936
|
-
function modifiers(name, event, shift2 = true) {
|
|
37937
|
-
if (event.altKey)
|
|
37938
|
-
name = "Alt-" + name;
|
|
37939
|
-
if (event.ctrlKey)
|
|
37940
|
-
name = "Ctrl-" + name;
|
|
37941
|
-
if (event.metaKey)
|
|
37942
|
-
name = "Meta-" + name;
|
|
37943
|
-
if (shift2 && event.shiftKey)
|
|
37944
|
-
name = "Shift-" + name;
|
|
37945
|
-
return name;
|
|
37946
|
-
}
|
|
37947
|
-
function keymap(bindings) {
|
|
37948
|
-
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
37949
|
-
}
|
|
37950
|
-
function keydownHandler(bindings) {
|
|
37951
|
-
let map22 = normalize(bindings);
|
|
37952
|
-
return function(view, event) {
|
|
37953
|
-
let name = keyName(event), baseName, direct = map22[modifiers(name, event)];
|
|
37954
|
-
if (direct && direct(view.state, view.dispatch, view))
|
|
37955
|
-
return true;
|
|
37956
|
-
if (name.length == 1 && name != " ") {
|
|
37957
|
-
if (event.shiftKey) {
|
|
37958
|
-
let noShift = map22[modifiers(name, event, false)];
|
|
37959
|
-
if (noShift && noShift(view.state, view.dispatch, view))
|
|
37960
|
-
return true;
|
|
37961
|
-
}
|
|
37962
|
-
if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
37963
|
-
!(windows && event.ctrlKey && event.altKey) && (baseName = base$1[event.keyCode]) && baseName != name) {
|
|
37964
|
-
let fromCode = map22[modifiers(baseName, event)];
|
|
37965
|
-
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
37966
|
-
return true;
|
|
37967
|
-
}
|
|
37968
|
-
}
|
|
37969
|
-
return false;
|
|
37970
|
-
};
|
|
37971
|
-
}
|
|
37972
|
-
function isExtensionRulesEnabled(extension, enabled) {
|
|
37973
|
-
if (Array.isArray(enabled)) {
|
|
37974
|
-
return enabled.some((enabledExtension) => {
|
|
37975
|
-
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
37976
|
-
return name === extension.name;
|
|
37977
|
-
});
|
|
37978
|
-
}
|
|
37979
|
-
return enabled;
|
|
37980
|
-
}
|
|
37981
|
-
function getHTMLFromFragment(fragment, schema) {
|
|
37982
|
-
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
37983
|
-
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
37984
|
-
const container = temporaryDocument.createElement("div");
|
|
37985
|
-
container.appendChild(documentFragment);
|
|
37986
|
-
return container.innerHTML;
|
|
37987
|
-
}
|
|
37988
|
-
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
37989
|
-
let textBefore = "";
|
|
37990
|
-
const sliceEndPos = $from.parentOffset;
|
|
37991
|
-
$from.parent.nodesBetween(
|
|
37992
|
-
Math.max(0, sliceEndPos - maxMatch),
|
|
37993
|
-
sliceEndPos,
|
|
37994
|
-
(node2, pos, parent, index2) => {
|
|
37995
|
-
const chunk = node2.type.spec.toText?.({
|
|
37996
|
-
node: node2,
|
|
37997
|
-
pos,
|
|
37998
|
-
parent,
|
|
37999
|
-
index: index2
|
|
38000
|
-
}) || node2.textContent || "%leaf%";
|
|
38001
|
-
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
38002
|
-
}
|
|
38003
|
-
);
|
|
38004
|
-
return textBefore;
|
|
38005
|
-
};
|
|
38006
|
-
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
38007
|
-
const { converter } = editor;
|
|
38008
|
-
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
38009
|
-
let cleanedHtml = convertEmToPt(html);
|
|
38010
|
-
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
38011
|
-
const tempDiv = document.createElement("div");
|
|
38012
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
38013
|
-
const paragraphs = tempDiv.querySelectorAll("p");
|
|
38014
|
-
paragraphs.forEach((p) => {
|
|
38015
|
-
const innerHTML3 = p.innerHTML;
|
|
38016
|
-
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
38017
|
-
const styleAttr = p.getAttribute("style") || "";
|
|
38018
|
-
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
38019
|
-
if (msoListMatch) {
|
|
38020
|
-
const [, abstractId, level] = msoListMatch;
|
|
38021
|
-
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
38022
|
-
if (!listNumId) return;
|
|
38023
|
-
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
38024
|
-
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
38025
|
-
p.setAttribute("data-num-id", listNumId);
|
|
38026
|
-
p.setAttribute("data-list-level", level - 1);
|
|
38027
|
-
p.setAttribute("data-start", start2);
|
|
38028
|
-
p.setAttribute("data-lvl-text", lvlText);
|
|
38029
|
-
p.setAttribute("data-num-fmt", numFmt);
|
|
38030
|
-
}
|
|
38031
|
-
extractAndRemoveConditionalPrefix(p);
|
|
38032
|
-
});
|
|
38033
|
-
transformWordLists(tempDiv);
|
|
38034
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38035
|
-
tempDiv.remove();
|
|
38036
|
-
const { dispatch } = editor.view;
|
|
38037
|
-
if (!dispatch) return false;
|
|
38038
|
-
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
38039
|
-
return true;
|
|
38040
|
-
};
|
|
38041
|
-
const getLevelDefinition = (abstractDefinition, level) => {
|
|
38042
|
-
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
38043
|
-
const levelElement = abstractDefinition.elements.find((el) => {
|
|
38044
|
-
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
38045
|
-
});
|
|
38046
|
-
if (!levelElement) return null;
|
|
38047
|
-
const { elements } = levelElement;
|
|
38048
|
-
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
38049
|
-
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
38050
|
-
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
38051
|
-
return { lvlText, start: start2, numFmt, elements };
|
|
38052
|
-
};
|
|
38053
|
-
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
38054
|
-
const { definitions } = editor?.converter?.numbering;
|
|
38055
|
-
if (!definitions) return null;
|
|
38056
|
-
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
38057
|
-
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
38058
|
-
});
|
|
38059
|
-
return matchedDefinition?.attributes?.["w:numId"];
|
|
38060
|
-
};
|
|
38061
|
-
const getListAbstractDefinition = (abstractId, editor) => {
|
|
38062
|
-
const { abstracts = {} } = editor?.converter?.numbering;
|
|
38063
|
-
return abstracts[abstractId] || null;
|
|
38064
|
-
};
|
|
38065
|
-
const transformWordLists = (container) => {
|
|
38066
|
-
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
38067
|
-
const listMap = /* @__PURE__ */ new Map();
|
|
38068
|
-
const listLevels = {};
|
|
38069
|
-
for (const p of paragraphs) {
|
|
38070
|
-
const listId = p.getAttribute("data-num-id");
|
|
38071
|
-
const level = parseInt(p.getAttribute("data-list-level"));
|
|
38072
|
-
const numFmt = p.getAttribute("data-num-fmt");
|
|
38073
|
-
const start2 = p.getAttribute("data-start");
|
|
38074
|
-
const lvlText = p.getAttribute("data-lvl-text");
|
|
38075
|
-
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
38076
|
-
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
38077
|
-
}
|
|
38078
|
-
for (const [id, items] of listMap.entries()) {
|
|
38079
|
-
if (!listLevels[id]) {
|
|
38080
|
-
listLevels[id] = {
|
|
38081
|
-
stack: [],
|
|
38082
|
-
counts: {},
|
|
38083
|
-
prevLevel: null
|
|
38084
|
-
};
|
|
38085
|
-
}
|
|
38086
|
-
const parentStack = [];
|
|
38087
|
-
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
38088
|
-
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
38089
|
-
const li = document.createElement("li");
|
|
38090
|
-
li.innerHTML = p.innerHTML;
|
|
38091
|
-
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
38092
|
-
li.setAttribute("data-num-id", id);
|
|
38093
|
-
li.setAttribute("data-lvl-text", lvlText);
|
|
38094
|
-
li.setAttribute("data-num-fmt", numFmt);
|
|
38095
|
-
if (p.hasAttribute("data-font-family")) {
|
|
38096
|
-
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
38097
|
-
}
|
|
38098
|
-
if (p.hasAttribute("data-font-size")) {
|
|
38099
|
-
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
38100
|
-
}
|
|
38101
|
-
const parentNode2 = p.parentNode;
|
|
38102
|
-
let listForLevel = parentStack[level];
|
|
38103
|
-
if (!listForLevel) {
|
|
38104
|
-
const newList = document.createElement("ol");
|
|
38105
|
-
newList.setAttribute("data-list-id", id);
|
|
38106
|
-
newList.level = level;
|
|
38107
|
-
if (level > 0) {
|
|
38108
|
-
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
38109
|
-
if (parentLi) parentLi.appendChild(newList);
|
|
38110
|
-
} else {
|
|
38111
|
-
parentNode2.insertBefore(newList, p);
|
|
38112
|
-
}
|
|
38113
|
-
parentStack[level] = newList;
|
|
38114
|
-
parentStack.length = level + 1;
|
|
38115
|
-
listForLevel = newList;
|
|
38116
|
-
}
|
|
38117
|
-
listForLevel.appendChild(li);
|
|
38118
|
-
p.remove();
|
|
38119
|
-
});
|
|
38120
|
-
}
|
|
38286
|
+
189: "_",
|
|
38287
|
+
190: ">",
|
|
38288
|
+
191: "?",
|
|
38289
|
+
192: "~",
|
|
38290
|
+
219: "{",
|
|
38291
|
+
220: "|",
|
|
38292
|
+
221: "}",
|
|
38293
|
+
222: '"'
|
|
38121
38294
|
};
|
|
38122
|
-
|
|
38123
|
-
|
|
38124
|
-
|
|
38125
|
-
|
|
38126
|
-
|
|
38127
|
-
|
|
38128
|
-
|
|
38129
|
-
if (currentLevel > levelState.prevLevel) {
|
|
38130
|
-
levelState.stack.push(1);
|
|
38131
|
-
} else if (currentLevel === levelState.prevLevel) {
|
|
38132
|
-
levelState.stack[levelState.stack.length - 1]++;
|
|
38133
|
-
} else {
|
|
38134
|
-
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
38135
|
-
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
38136
|
-
}
|
|
38137
|
-
}
|
|
38138
|
-
levelState.prevLevel = currentLevel;
|
|
38139
|
-
return [...levelState.stack];
|
|
38140
|
-
}
|
|
38141
|
-
function extractAndRemoveConditionalPrefix(p) {
|
|
38142
|
-
const nodes = Array.from(p.childNodes);
|
|
38143
|
-
let fontFamily2 = null;
|
|
38144
|
-
let fontSize2 = null;
|
|
38145
|
-
let start2 = -1, end2 = -1;
|
|
38146
|
-
nodes.forEach((node2, index2) => {
|
|
38147
|
-
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
38148
|
-
start2 = index2;
|
|
38149
|
-
}
|
|
38150
|
-
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
38151
|
-
end2 = index2;
|
|
38152
|
-
}
|
|
38153
|
-
});
|
|
38154
|
-
if (start2 !== -1 && end2 !== -1) {
|
|
38155
|
-
for (let i = start2 + 1; i < end2; i++) {
|
|
38156
|
-
const node2 = nodes[i];
|
|
38157
|
-
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
38158
|
-
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
38159
|
-
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
38160
|
-
}
|
|
38161
|
-
}
|
|
38162
|
-
for (let i = end2; i >= start2; i--) {
|
|
38163
|
-
p.removeChild(p.childNodes[i]);
|
|
38164
|
-
}
|
|
38165
|
-
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
38166
|
-
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
38167
|
-
}
|
|
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);
|
|
38168
38302
|
}
|
|
38169
|
-
|
|
38170
|
-
|
|
38171
|
-
|
|
38172
|
-
|
|
38173
|
-
|
|
38174
|
-
|
|
38175
|
-
|
|
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;
|
|
38176
38314
|
}
|
|
38177
|
-
const
|
|
38178
|
-
|
|
38179
|
-
|
|
38180
|
-
|
|
38181
|
-
|
|
38182
|
-
|
|
38183
|
-
|
|
38184
|
-
|
|
38185
|
-
|
|
38186
|
-
|
|
38187
|
-
|
|
38188
|
-
|
|
38189
|
-
|
|
38190
|
-
if (
|
|
38191
|
-
|
|
38192
|
-
|
|
38193
|
-
|
|
38194
|
-
|
|
38195
|
-
|
|
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);
|
|
38196
38339
|
}
|
|
38340
|
+
if (alt)
|
|
38341
|
+
result = "Alt-" + result;
|
|
38342
|
+
if (ctrl)
|
|
38343
|
+
result = "Ctrl-" + result;
|
|
38344
|
+
if (meta)
|
|
38345
|
+
result = "Meta-" + result;
|
|
38346
|
+
if (shift2)
|
|
38347
|
+
result = "Shift-" + result;
|
|
38197
38348
|
return result;
|
|
38198
|
-
}
|
|
38199
|
-
|
|
38200
|
-
|
|
38201
|
-
|
|
38202
|
-
|
|
38203
|
-
|
|
38204
|
-
|
|
38205
|
-
|
|
38206
|
-
|
|
38207
|
-
|
|
38208
|
-
|
|
38209
|
-
|
|
38210
|
-
|
|
38211
|
-
|
|
38212
|
-
|
|
38213
|
-
|
|
38214
|
-
|
|
38215
|
-
|
|
38216
|
-
|
|
38217
|
-
|
|
38218
|
-
|
|
38219
|
-
|
|
38220
|
-
|
|
38221
|
-
|
|
38222
|
-
|
|
38223
|
-
if (
|
|
38224
|
-
return;
|
|
38225
|
-
|
|
38226
|
-
|
|
38227
|
-
|
|
38228
|
-
|
|
38229
|
-
|
|
38230
|
-
to
|
|
38231
|
-
};
|
|
38232
|
-
const { commands: commands2, chain, can } = new CommandService({
|
|
38233
|
-
editor,
|
|
38234
|
-
state: state2
|
|
38235
|
-
});
|
|
38236
|
-
const handler = rule.handler({
|
|
38237
|
-
state: state2,
|
|
38238
|
-
range: range2,
|
|
38239
|
-
match,
|
|
38240
|
-
commands: commands2,
|
|
38241
|
-
chain,
|
|
38242
|
-
can
|
|
38243
|
-
});
|
|
38244
|
-
if (handler === null || !tr.steps.length) {
|
|
38245
|
-
return;
|
|
38246
|
-
}
|
|
38247
|
-
tr.setMeta(plugin2, {
|
|
38248
|
-
transform: tr,
|
|
38249
|
-
from: from2,
|
|
38250
|
-
to,
|
|
38251
|
-
text
|
|
38252
|
-
});
|
|
38253
|
-
view.dispatch(tr);
|
|
38254
|
-
matched = true;
|
|
38255
|
-
});
|
|
38256
|
-
return matched;
|
|
38257
|
-
};
|
|
38258
|
-
const inputRulesPlugin = ({ editor, rules }) => {
|
|
38259
|
-
const plugin2 = new Plugin({
|
|
38260
|
-
key: new PluginKey("inputRulesPlugin"),
|
|
38261
|
-
state: {
|
|
38262
|
-
init() {
|
|
38263
|
-
return null;
|
|
38264
|
-
},
|
|
38265
|
-
apply(tr, prev, state2) {
|
|
38266
|
-
const stored = tr.getMeta(plugin2);
|
|
38267
|
-
if (stored) {
|
|
38268
|
-
return stored;
|
|
38269
|
-
}
|
|
38270
|
-
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
38271
|
-
const isSimulatedInput = !!simulatedInputMeta;
|
|
38272
|
-
if (isSimulatedInput) {
|
|
38273
|
-
setTimeout(() => {
|
|
38274
|
-
let { text } = simulatedInputMeta;
|
|
38275
|
-
if (typeof text !== "string") {
|
|
38276
|
-
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
38277
|
-
}
|
|
38278
|
-
const { from: from2 } = simulatedInputMeta;
|
|
38279
|
-
const to = from2 + text.length;
|
|
38280
|
-
run({
|
|
38281
|
-
editor,
|
|
38282
|
-
from: from2,
|
|
38283
|
-
to,
|
|
38284
|
-
text,
|
|
38285
|
-
rules,
|
|
38286
|
-
plugin: plugin2
|
|
38287
|
-
});
|
|
38288
|
-
});
|
|
38289
|
-
}
|
|
38290
|
-
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
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;
|
|
38355
|
+
}
|
|
38356
|
+
function modifiers(name, event, shift2 = true) {
|
|
38357
|
+
if (event.altKey)
|
|
38358
|
+
name = "Alt-" + name;
|
|
38359
|
+
if (event.ctrlKey)
|
|
38360
|
+
name = "Ctrl-" + name;
|
|
38361
|
+
if (event.metaKey)
|
|
38362
|
+
name = "Meta-" + name;
|
|
38363
|
+
if (shift2 && event.shiftKey)
|
|
38364
|
+
name = "Shift-" + name;
|
|
38365
|
+
return name;
|
|
38366
|
+
}
|
|
38367
|
+
function keymap(bindings) {
|
|
38368
|
+
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
38369
|
+
}
|
|
38370
|
+
function keydownHandler(bindings) {
|
|
38371
|
+
let map22 = normalize(bindings);
|
|
38372
|
+
return function(view, event) {
|
|
38373
|
+
let name = keyName(event), baseName, direct = map22[modifiers(name, event)];
|
|
38374
|
+
if (direct && direct(view.state, view.dispatch, view))
|
|
38375
|
+
return true;
|
|
38376
|
+
if (name.length == 1 && name != " ") {
|
|
38377
|
+
if (event.shiftKey) {
|
|
38378
|
+
let noShift = map22[modifiers(name, event, false)];
|
|
38379
|
+
if (noShift && noShift(view.state, view.dispatch, view))
|
|
38380
|
+
return true;
|
|
38291
38381
|
}
|
|
38292
|
-
|
|
38293
|
-
|
|
38294
|
-
|
|
38295
|
-
|
|
38296
|
-
|
|
38297
|
-
from: from2,
|
|
38298
|
-
to,
|
|
38299
|
-
text,
|
|
38300
|
-
rules,
|
|
38301
|
-
plugin: plugin2
|
|
38302
|
-
});
|
|
38303
|
-
},
|
|
38304
|
-
// add support for input rules to trigger on enter
|
|
38305
|
-
// this is useful for example for code blocks
|
|
38306
|
-
handleKeyDown(view, event) {
|
|
38307
|
-
if (event.key !== "Enter") {
|
|
38308
|
-
return false;
|
|
38309
|
-
}
|
|
38310
|
-
const { $cursor } = view.state.selection;
|
|
38311
|
-
if ($cursor) {
|
|
38312
|
-
return run({
|
|
38313
|
-
editor,
|
|
38314
|
-
from: $cursor.pos,
|
|
38315
|
-
to: $cursor.pos,
|
|
38316
|
-
text: "\n",
|
|
38317
|
-
rules,
|
|
38318
|
-
plugin: plugin2
|
|
38319
|
-
});
|
|
38320
|
-
}
|
|
38321
|
-
return false;
|
|
38322
|
-
},
|
|
38323
|
-
// Paste handler
|
|
38324
|
-
handlePaste(view, event, slice2) {
|
|
38325
|
-
const clipboard = event.clipboardData;
|
|
38326
|
-
const html = clipboard.getData("text/html");
|
|
38327
|
-
clipboard.getData("text/plain");
|
|
38328
|
-
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
38329
|
-
if (fieldAnnotationContent.length) {
|
|
38330
|
-
return false;
|
|
38331
|
-
}
|
|
38332
|
-
let source;
|
|
38333
|
-
if (!html) {
|
|
38334
|
-
source = "plain-text";
|
|
38335
|
-
} else if (isWordHtml(html)) {
|
|
38336
|
-
source = "word-html";
|
|
38337
|
-
} else {
|
|
38338
|
-
source = "browser-html";
|
|
38339
|
-
}
|
|
38340
|
-
switch (source) {
|
|
38341
|
-
case "plain-text":
|
|
38342
|
-
break;
|
|
38343
|
-
case "word-html":
|
|
38344
|
-
if (editor.options.mode === "docx") {
|
|
38345
|
-
return handleDocxPaste(html, editor, view, plugin2);
|
|
38346
|
-
}
|
|
38347
|
-
case "browser-html":
|
|
38348
|
-
return handleHtmlPaste$1(html, editor);
|
|
38349
|
-
}
|
|
38350
|
-
return false;
|
|
38382
|
+
if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
38383
|
+
!(windows && event.ctrlKey && event.altKey) && (baseName = base$1[event.keyCode]) && baseName != name) {
|
|
38384
|
+
let fromCode = map22[modifiers(baseName, event)];
|
|
38385
|
+
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
38386
|
+
return true;
|
|
38351
38387
|
}
|
|
38352
|
-
},
|
|
38353
|
-
isInputRules: true
|
|
38354
|
-
});
|
|
38355
|
-
return plugin2;
|
|
38356
|
-
};
|
|
38357
|
-
function isWordHtml(html) {
|
|
38358
|
-
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
38359
|
-
}
|
|
38360
|
-
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
38361
|
-
const cleanedHtml = convertEmToPt(html);
|
|
38362
|
-
const tempDiv = document.createElement("div");
|
|
38363
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
38364
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38365
|
-
tempDiv.remove();
|
|
38366
|
-
const { dispatch } = editor.view;
|
|
38367
|
-
if (!dispatch) return false;
|
|
38368
|
-
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
38369
|
-
return true;
|
|
38370
|
-
};
|
|
38371
|
-
const convertEmToPt = (html) => {
|
|
38372
|
-
return html.replace(
|
|
38373
|
-
/font-size\s*:\s*([\d.]+)em/gi,
|
|
38374
|
-
(_, emValue) => {
|
|
38375
|
-
const em = parseFloat(emValue);
|
|
38376
|
-
const pt = Math.round(em * 12 * 100) / 100;
|
|
38377
|
-
return `font-size: ${pt}pt`;
|
|
38378
38388
|
}
|
|
38379
|
-
|
|
38380
|
-
};
|
|
38381
|
-
|
|
38382
|
-
|
|
38389
|
+
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
|
+
}
|
|
38399
|
+
return enabled;
|
|
38383
38400
|
}
|
|
38384
38401
|
const _ExtensionService = class _ExtensionService2 {
|
|
38385
38402
|
constructor(extensions, userExtensions, editor) {
|
|
@@ -39219,6 +39236,7 @@ const createHeaderFooterEditor = ({
|
|
|
39219
39236
|
mediaFiles: editor.storage.image.media,
|
|
39220
39237
|
fonts: editor.options.fonts,
|
|
39221
39238
|
isHeaderOrFooter: true,
|
|
39239
|
+
isHeadless: editor.options.isHeadless,
|
|
39222
39240
|
annotations: true,
|
|
39223
39241
|
currentPageNumber,
|
|
39224
39242
|
parentEditor: editor,
|
|
@@ -39226,13 +39244,15 @@ const createHeaderFooterEditor = ({
|
|
|
39226
39244
|
onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
|
|
39227
39245
|
});
|
|
39228
39246
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
39229
|
-
pm
|
|
39230
|
-
|
|
39231
|
-
|
|
39232
|
-
|
|
39233
|
-
|
|
39234
|
-
|
|
39235
|
-
|
|
39247
|
+
if (pm) {
|
|
39248
|
+
pm.style.maxHeight = "100%";
|
|
39249
|
+
pm.style.minHeight = "100%";
|
|
39250
|
+
pm.style.outline = "none";
|
|
39251
|
+
pm.style.border = "none";
|
|
39252
|
+
pm.setAttribute("role", "textbox");
|
|
39253
|
+
pm.setAttribute("aria-multiline", true);
|
|
39254
|
+
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
39255
|
+
}
|
|
39236
39256
|
return headerFooterEditor;
|
|
39237
39257
|
};
|
|
39238
39258
|
const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
@@ -39251,14 +39271,16 @@ const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
|
39251
39271
|
});
|
|
39252
39272
|
});
|
|
39253
39273
|
};
|
|
39254
|
-
const toggleHeaderFooterEditMode = (editor, focusedSectionEditor, isEditMode) => {
|
|
39274
|
+
const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode, documentMode }) => {
|
|
39255
39275
|
editor.converter.headerEditors.forEach((item) => {
|
|
39256
39276
|
item.editor.setEditable(isEditMode, false);
|
|
39257
39277
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39278
|
+
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39258
39279
|
});
|
|
39259
39280
|
editor.converter.footerEditors.forEach((item) => {
|
|
39260
39281
|
item.editor.setEditable(isEditMode, false);
|
|
39261
39282
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39283
|
+
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39262
39284
|
});
|
|
39263
39285
|
if (isEditMode) {
|
|
39264
39286
|
const pm = document.querySelector(".ProseMirror");
|
|
@@ -40339,6 +40361,19 @@ const deleteHeaderFooterFieldAnnotations = ({ editor, fieldIdOrArray }) => {
|
|
|
40339
40361
|
);
|
|
40340
40362
|
});
|
|
40341
40363
|
};
|
|
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
|
+
};
|
|
40342
40377
|
const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
|
|
40343
40378
|
if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
|
|
40344
40379
|
const { doc: doc2 } = editor.state;
|
|
@@ -40409,6 +40444,7 @@ const AnnotatorHelpers = {
|
|
|
40409
40444
|
getAllHeaderFooterEditors,
|
|
40410
40445
|
updateHeaderFooterFieldAnnotations,
|
|
40411
40446
|
deleteHeaderFooterFieldAnnotations,
|
|
40447
|
+
resetHeaderFooterFieldAnnotations,
|
|
40412
40448
|
cleanUpListsWithAnnotations
|
|
40413
40449
|
};
|
|
40414
40450
|
const CollaborationPluginKey = new PluginKey("collaboration");
|
|
@@ -40588,6 +40624,16 @@ const setWordSelection = (view, pos) => {
|
|
|
40588
40624
|
const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
|
|
40589
40625
|
dispatch(tr);
|
|
40590
40626
|
};
|
|
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
|
+
};
|
|
40591
40637
|
const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
40592
40638
|
/**
|
|
40593
40639
|
* Create a new Editor instance
|
|
@@ -40686,6 +40732,19 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40686
40732
|
this.setHighContrastMode = setHighContrastMode;
|
|
40687
40733
|
initMode();
|
|
40688
40734
|
}
|
|
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
|
+
}
|
|
40689
40748
|
/**
|
|
40690
40749
|
* Set the toolbar for this editor
|
|
40691
40750
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -40734,7 +40793,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40734
40793
|
* @returns {boolean}
|
|
40735
40794
|
*/
|
|
40736
40795
|
get isDestroyed() {
|
|
40737
|
-
return this.view
|
|
40796
|
+
return this.view?.isDestroyed ?? true;
|
|
40738
40797
|
}
|
|
40739
40798
|
/**
|
|
40740
40799
|
* Get the editor element
|
|
@@ -40777,7 +40836,12 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40777
40836
|
this.commands.toggleTrackChangesShowOriginal();
|
|
40778
40837
|
this.setEditable(false, false);
|
|
40779
40838
|
this.setOptions({ documentMode: "viewing" });
|
|
40780
|
-
toggleHeaderFooterEditMode(
|
|
40839
|
+
toggleHeaderFooterEditMode({
|
|
40840
|
+
editor: this,
|
|
40841
|
+
focusedSectionEditor: null,
|
|
40842
|
+
isEditMode: false,
|
|
40843
|
+
documentMode: cleanedMode
|
|
40844
|
+
});
|
|
40781
40845
|
} else if (cleanedMode === "suggesting") {
|
|
40782
40846
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
40783
40847
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -40790,7 +40854,12 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40790
40854
|
this.commands.disableTrackChanges();
|
|
40791
40855
|
this.setEditable(true, false);
|
|
40792
40856
|
this.setOptions({ documentMode: "editing" });
|
|
40793
|
-
toggleHeaderFooterEditMode(
|
|
40857
|
+
toggleHeaderFooterEditMode({
|
|
40858
|
+
editor: this,
|
|
40859
|
+
focusedSectionEditor: null,
|
|
40860
|
+
isEditMode: false,
|
|
40861
|
+
documentMode: cleanedMode
|
|
40862
|
+
});
|
|
40794
40863
|
}
|
|
40795
40864
|
}
|
|
40796
40865
|
/**
|
|
@@ -40967,29 +41036,26 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40967
41036
|
};
|
|
40968
41037
|
}
|
|
40969
41038
|
/**
|
|
40970
|
-
|
|
40971
|
-
|
|
40972
|
-
|
|
40973
|
-
*
|
|
40974
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
40975
|
-
* @returns {void}
|
|
40976
|
-
*/
|
|
40977
|
-
initDefaultStyles(element = this.element) {
|
|
40978
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
40979
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41039
|
+
* Attach styles and attributes to the editor element
|
|
41040
|
+
*/
|
|
41041
|
+
updateEditorStyles(element, proseMirror) {
|
|
40980
41042
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
40981
|
-
if (!proseMirror || !
|
|
41043
|
+
if (!proseMirror || !element) {
|
|
40982
41044
|
return;
|
|
40983
41045
|
}
|
|
40984
41046
|
proseMirror.setAttribute("role", "document");
|
|
40985
41047
|
proseMirror.setAttribute("aria-multiline", true);
|
|
40986
41048
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
40987
41049
|
proseMirror.setAttribute("aria-description", "");
|
|
40988
|
-
|
|
40989
|
-
|
|
40990
|
-
|
|
40991
|
-
|
|
40992
|
-
|
|
41050
|
+
if (pageSize) {
|
|
41051
|
+
element.style.width = pageSize.width + "in";
|
|
41052
|
+
element.style.minWidth = pageSize.width + "in";
|
|
41053
|
+
element.style.minHeight = pageSize.height + "in";
|
|
41054
|
+
}
|
|
41055
|
+
if (pageMargins) {
|
|
41056
|
+
element.style.paddingLeft = pageMargins.left + "in";
|
|
41057
|
+
element.style.paddingRight = pageMargins.right + "in";
|
|
41058
|
+
}
|
|
40993
41059
|
element.style.boxSizing = "border-box";
|
|
40994
41060
|
element.style.isolation = "isolate";
|
|
40995
41061
|
proseMirror.style.outline = "none";
|
|
@@ -41010,6 +41076,19 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41010
41076
|
proseMirror.style.paddingTop = "1in";
|
|
41011
41077
|
proseMirror.style.paddingBottom = "1in";
|
|
41012
41078
|
}
|
|
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);
|
|
41013
41092
|
this.initMobileStyles(element);
|
|
41014
41093
|
}
|
|
41015
41094
|
/**
|
|
@@ -41221,10 +41300,25 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41221
41300
|
*/
|
|
41222
41301
|
destroy() {
|
|
41223
41302
|
this.emit("destroy");
|
|
41224
|
-
|
|
41303
|
+
this.unmount();
|
|
41304
|
+
this.destroyHeaderFooterEditors();
|
|
41225
41305
|
__privateMethod$1(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
41226
41306
|
this.removeAllListeners();
|
|
41227
41307
|
}
|
|
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
|
+
}
|
|
41228
41322
|
/**
|
|
41229
41323
|
* Check if migrations are needed for the data
|
|
41230
41324
|
* @static
|
|
@@ -41242,7 +41336,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41242
41336
|
* @returns {Object | void} Migration results
|
|
41243
41337
|
*/
|
|
41244
41338
|
processCollaborationMigrations() {
|
|
41245
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.2-
|
|
41339
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2-rev10");
|
|
41246
41340
|
if (!this.options.ydoc) return;
|
|
41247
41341
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
41248
41342
|
let docVersion = metaMap.get("version");
|
|
@@ -41438,7 +41532,7 @@ init_fn = function(options2) {
|
|
|
41438
41532
|
this.emit("beforeCreate", { editor: this });
|
|
41439
41533
|
this.on("contentError", this.options.onContentError);
|
|
41440
41534
|
this.on("exception", this.options.onException);
|
|
41441
|
-
|
|
41535
|
+
this.mount(this.options.element);
|
|
41442
41536
|
this.initDefaultStyles();
|
|
41443
41537
|
this.setDocumentMode(options2.documentMode);
|
|
41444
41538
|
if (this.options.isHeadless) return;
|
|
@@ -41462,10 +41556,6 @@ init_fn = function(options2) {
|
|
|
41462
41556
|
__privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
|
|
41463
41557
|
__privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
|
|
41464
41558
|
}
|
|
41465
|
-
window.setTimeout(() => {
|
|
41466
|
-
if (this.isDestroyed) return;
|
|
41467
|
-
this.emit("create", { editor: this });
|
|
41468
|
-
}, 0);
|
|
41469
41559
|
};
|
|
41470
41560
|
initRichText_fn = function(options2) {
|
|
41471
41561
|
if (!options2.extensions || !options2.extensions.length) {
|
|
@@ -41477,7 +41567,7 @@ initRichText_fn = function(options2) {
|
|
|
41477
41567
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
41478
41568
|
this.emit("beforeCreate", { editor: this });
|
|
41479
41569
|
this.on("contentError", this.options.onContentError);
|
|
41480
|
-
|
|
41570
|
+
this.mount(this.options.element);
|
|
41481
41571
|
this.on("create", this.options.onCreate);
|
|
41482
41572
|
this.on("update", this.options.onUpdate);
|
|
41483
41573
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -41488,10 +41578,6 @@ initRichText_fn = function(options2) {
|
|
|
41488
41578
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
41489
41579
|
this.on("commentClick", this.options.onCommentClicked);
|
|
41490
41580
|
this.on("locked", this.options.onDocumentLocked);
|
|
41491
|
-
window.setTimeout(() => {
|
|
41492
|
-
if (this.isDestroyed) return;
|
|
41493
|
-
this.emit("create", { editor: this });
|
|
41494
|
-
}, 0);
|
|
41495
41581
|
};
|
|
41496
41582
|
onFocus_fn = function({ editor, event }) {
|
|
41497
41583
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -41612,14 +41698,15 @@ createDocFromHTML_fn = function(content) {
|
|
|
41612
41698
|
}
|
|
41613
41699
|
return DOMParser$1.fromSchema(this.schema).parse(parsedContent);
|
|
41614
41700
|
};
|
|
41615
|
-
createView_fn = function() {
|
|
41701
|
+
createView_fn = function(element) {
|
|
41616
41702
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
41617
41703
|
const state2 = { schema: this.schema };
|
|
41618
41704
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
41619
|
-
this.view = new EditorView(
|
|
41705
|
+
this.view = new EditorView(element, {
|
|
41620
41706
|
...this.options.editorProps,
|
|
41621
41707
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
41622
41708
|
state: EditorState.create(state2),
|
|
41709
|
+
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
41623
41710
|
handleDoubleClick: async (view, pos, event) => {
|
|
41624
41711
|
if (this.options.documentMode !== "editing") return;
|
|
41625
41712
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -41633,7 +41720,12 @@ createView_fn = function() {
|
|
|
41633
41720
|
event.stopPropagation();
|
|
41634
41721
|
if (!this.options.editable) {
|
|
41635
41722
|
this.setEditable(true, false);
|
|
41636
|
-
toggleHeaderFooterEditMode(
|
|
41723
|
+
toggleHeaderFooterEditMode({
|
|
41724
|
+
editor: this,
|
|
41725
|
+
focusedSectionEditor: null,
|
|
41726
|
+
isEditMode: false,
|
|
41727
|
+
documentMode: this.options.documentMode
|
|
41728
|
+
});
|
|
41637
41729
|
const pm = document.querySelector(".ProseMirror");
|
|
41638
41730
|
pm.classList.remove("header-footer-edit");
|
|
41639
41731
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -41646,8 +41738,6 @@ createView_fn = function() {
|
|
|
41646
41738
|
});
|
|
41647
41739
|
this.view.updateState(newState);
|
|
41648
41740
|
this.createNodeViews();
|
|
41649
|
-
const dom = this.view.dom;
|
|
41650
|
-
dom.editor = this;
|
|
41651
41741
|
this.options.telemetry?.sendReport();
|
|
41652
41742
|
};
|
|
41653
41743
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
@@ -41674,7 +41764,9 @@ initComments_fn = function() {
|
|
|
41674
41764
|
}, 50);
|
|
41675
41765
|
};
|
|
41676
41766
|
initPagination_fn = async function() {
|
|
41677
|
-
if (this.options.isHeadless || !this.extensionService)
|
|
41767
|
+
if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) {
|
|
41768
|
+
return;
|
|
41769
|
+
}
|
|
41678
41770
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
41679
41771
|
if (pagination && this.options.pagination) {
|
|
41680
41772
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -41686,7 +41778,7 @@ initPagination_fn = async function() {
|
|
|
41686
41778
|
}
|
|
41687
41779
|
};
|
|
41688
41780
|
dispatchTransaction_fn = function(transaction) {
|
|
41689
|
-
if (this.
|
|
41781
|
+
if (this.isDestroyed) return;
|
|
41690
41782
|
let state2;
|
|
41691
41783
|
try {
|
|
41692
41784
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -41738,6 +41830,11 @@ dispatchTransaction_fn = function(transaction) {
|
|
|
41738
41830
|
transaction
|
|
41739
41831
|
});
|
|
41740
41832
|
};
|
|
41833
|
+
handleNodeSelection_fn = function(view, pos) {
|
|
41834
|
+
if (this.options.isHeaderOrFooter) {
|
|
41835
|
+
return setImageNodeSelection(view, pos);
|
|
41836
|
+
}
|
|
41837
|
+
};
|
|
41741
41838
|
prepareDocumentForImport_fn = function(doc2) {
|
|
41742
41839
|
const newState = EditorState.create({
|
|
41743
41840
|
schema: this.schema,
|
|
@@ -44080,7 +44177,7 @@ const Paragraph = Node$1.create({
|
|
|
44080
44177
|
},
|
|
44081
44178
|
addPmPlugins() {
|
|
44082
44179
|
const { view } = this.editor;
|
|
44083
|
-
|
|
44180
|
+
new Plugin({
|
|
44084
44181
|
name: "dropcapPlugin",
|
|
44085
44182
|
key: new PluginKey("dropcapPlugin"),
|
|
44086
44183
|
state: {
|
|
@@ -44100,7 +44197,7 @@ const Paragraph = Node$1.create({
|
|
|
44100
44197
|
}
|
|
44101
44198
|
}
|
|
44102
44199
|
});
|
|
44103
|
-
return [
|
|
44200
|
+
return [];
|
|
44104
44201
|
}
|
|
44105
44202
|
});
|
|
44106
44203
|
const getDropcapDecorations = (state2, view) => {
|
|
@@ -44453,7 +44550,16 @@ const HardBreak = Node$1.create({
|
|
|
44453
44550
|
};
|
|
44454
44551
|
},
|
|
44455
44552
|
parseDOM() {
|
|
44456
|
-
return [{
|
|
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
|
+
}];
|
|
44457
44563
|
},
|
|
44458
44564
|
renderDOM({ htmlAttributes }) {
|
|
44459
44565
|
return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -47450,6 +47556,8 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47450
47556
|
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) {
|
|
47451
47557
|
return removedNodes;
|
|
47452
47558
|
}
|
|
47559
|
+
const hasDeletion = transactionDeletedAnything(tr);
|
|
47560
|
+
if (!hasDeletion) return removedNodes;
|
|
47453
47561
|
tr.steps.forEach((step, stepIndex) => {
|
|
47454
47562
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
47455
47563
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -47466,6 +47574,14 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47466
47574
|
});
|
|
47467
47575
|
return removedNodes;
|
|
47468
47576
|
}
|
|
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
|
+
}
|
|
47469
47585
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
47470
47586
|
let removedAnnotations = [];
|
|
47471
47587
|
try {
|
|
@@ -47861,8 +47977,18 @@ const FieldAnnotation = Node$1.create({
|
|
|
47861
47977
|
};
|
|
47862
47978
|
}
|
|
47863
47979
|
},
|
|
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
|
+
},
|
|
47864
47990
|
displayLabel: {
|
|
47865
|
-
default: "
|
|
47991
|
+
default: "",
|
|
47866
47992
|
parseDOM: (elem) => elem.getAttribute("data-display-label"),
|
|
47867
47993
|
renderDOM: (attrs) => {
|
|
47868
47994
|
if (!attrs.displayLabel) return {};
|
|
@@ -48178,6 +48304,7 @@ const FieldAnnotation = Node$1.create({
|
|
|
48178
48304
|
return renderer();
|
|
48179
48305
|
},
|
|
48180
48306
|
addCommands() {
|
|
48307
|
+
const annotationTypes = this.options.types;
|
|
48181
48308
|
return {
|
|
48182
48309
|
/**
|
|
48183
48310
|
* Add field annotation.
|
|
@@ -48199,7 +48326,12 @@ const FieldAnnotation = Node$1.create({
|
|
|
48199
48326
|
let currentMarks = $pos.marks();
|
|
48200
48327
|
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
48201
48328
|
let formatAttrs = getFormatAttrsFromMarks(currentMarks);
|
|
48202
|
-
let
|
|
48329
|
+
let defaultDisplayLabel = attrs.defaultDisplayLabel ? attrs.defaultDisplayLabel : attrs.displayLabel || "";
|
|
48330
|
+
let node2 = schema.nodes[this.name].create({
|
|
48331
|
+
...attrs,
|
|
48332
|
+
...formatAttrs,
|
|
48333
|
+
defaultDisplayLabel
|
|
48334
|
+
}, null, null);
|
|
48203
48335
|
state2.tr.insert(newPos, node2).setSelection(Selection.near(tr.doc.resolve(newPos + node2.nodeSize)));
|
|
48204
48336
|
if (editorFocus) {
|
|
48205
48337
|
this.editor.view.focus();
|
|
@@ -48207,9 +48339,9 @@ const FieldAnnotation = Node$1.create({
|
|
|
48207
48339
|
}
|
|
48208
48340
|
return true;
|
|
48209
48341
|
},
|
|
48210
|
-
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({
|
|
48342
|
+
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state: state2, commands: commands2 }) => {
|
|
48211
48343
|
const { from: from2 } = state2.selection;
|
|
48212
|
-
commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
48344
|
+
return commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
48213
48345
|
},
|
|
48214
48346
|
/**
|
|
48215
48347
|
* Replace field annotation.
|
|
@@ -48219,24 +48351,113 @@ const FieldAnnotation = Node$1.create({
|
|
|
48219
48351
|
* from: 20,
|
|
48220
48352
|
* to: 45,
|
|
48221
48353
|
* attrs: {
|
|
48222
|
-
*
|
|
48223
|
-
*
|
|
48354
|
+
* fieldType: 'TEXTINPUT'
|
|
48355
|
+
* fieldColor: '#980043'
|
|
48224
48356
|
* }
|
|
48225
48357
|
* ])
|
|
48226
48358
|
*/
|
|
48227
|
-
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch,
|
|
48359
|
+
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => {
|
|
48228
48360
|
if (!dispatch) return true;
|
|
48229
|
-
tr.setMeta("fieldAnnotationReplace", true);
|
|
48230
48361
|
fieldsArray.forEach((annotation) => {
|
|
48231
48362
|
let { from: from2, to, attrs } = annotation;
|
|
48232
48363
|
let { schema } = editor;
|
|
48233
48364
|
let newPosFrom = tr.mapping.map(from2);
|
|
48234
48365
|
let newPosTo = tr.mapping.map(to);
|
|
48235
|
-
let
|
|
48366
|
+
let defaultDisplayLabel = attrs.defaultDisplayLabel ? attrs.defaultDisplayLabel : attrs.displayLabel || "";
|
|
48367
|
+
let node2 = schema.nodes[this.name].create({
|
|
48368
|
+
...attrs,
|
|
48369
|
+
defaultDisplayLabel
|
|
48370
|
+
}, null, null);
|
|
48236
48371
|
tr.replaceWith(newPosFrom, newPosTo, node2);
|
|
48237
48372
|
});
|
|
48238
48373
|
return true;
|
|
48239
48374
|
},
|
|
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
|
+
},
|
|
48240
48461
|
/**
|
|
48241
48462
|
* Update annotations associated with a field.
|
|
48242
48463
|
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
@@ -48991,12 +49212,16 @@ const startImageUpload = async ({ editor, view, file }) => {
|
|
|
48991
49212
|
}
|
|
48992
49213
|
let id = {};
|
|
48993
49214
|
let { tr, schema } = view.state;
|
|
48994
|
-
|
|
49215
|
+
let { selection } = tr;
|
|
49216
|
+
if (editor.options.isHeaderOrFooter) {
|
|
49217
|
+
selection = editor.options.lastSelection;
|
|
49218
|
+
}
|
|
49219
|
+
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
48995
49220
|
tr.deleteSelection();
|
|
48996
49221
|
}
|
|
48997
49222
|
let imageMeta = {
|
|
48998
49223
|
type: "add",
|
|
48999
|
-
pos:
|
|
49224
|
+
pos: selection.from,
|
|
49000
49225
|
id
|
|
49001
49226
|
};
|
|
49002
49227
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -54245,7 +54470,8 @@ const Pagination = Extension.create({
|
|
|
54245
54470
|
addStorage() {
|
|
54246
54471
|
return {
|
|
54247
54472
|
height: 0,
|
|
54248
|
-
sectionData: null
|
|
54473
|
+
sectionData: null,
|
|
54474
|
+
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
54249
54475
|
};
|
|
54250
54476
|
},
|
|
54251
54477
|
addCommands() {
|
|
@@ -54288,13 +54514,14 @@ const Pagination = Extension.create({
|
|
|
54288
54514
|
shouldUpdate = true;
|
|
54289
54515
|
shouldInitialize = meta.isReadyToInit;
|
|
54290
54516
|
}
|
|
54517
|
+
const syncMeta = tr.getMeta("y-sync$");
|
|
54518
|
+
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
54519
|
+
return { ...oldState };
|
|
54520
|
+
}
|
|
54291
54521
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
54292
54522
|
if (imagePluginTransaction) {
|
|
54293
54523
|
if (imagePluginTransaction.type === "remove") {
|
|
54294
|
-
|
|
54295
|
-
const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
|
|
54296
|
-
if (domImage.complete) onImageLoad(editor);
|
|
54297
|
-
else domImage.onload = () => onImageLoad(editor);
|
|
54524
|
+
onImageLoad(editor);
|
|
54298
54525
|
}
|
|
54299
54526
|
return { ...oldState };
|
|
54300
54527
|
}
|
|
@@ -54321,6 +54548,7 @@ const Pagination = Extension.create({
|
|
|
54321
54548
|
if (isForceUpdate) shouldUpdate = true;
|
|
54322
54549
|
return {
|
|
54323
54550
|
...oldState,
|
|
54551
|
+
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
54324
54552
|
isReadyToInit: shouldInitialize
|
|
54325
54553
|
};
|
|
54326
54554
|
}
|
|
@@ -54349,6 +54577,10 @@ const Pagination = Extension.create({
|
|
|
54349
54577
|
},
|
|
54350
54578
|
onDestroy() {
|
|
54351
54579
|
cleanupFloatingSeparators();
|
|
54580
|
+
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
54581
|
+
if (headerFooterEditors) {
|
|
54582
|
+
headerFooterEditors.clear();
|
|
54583
|
+
}
|
|
54352
54584
|
}
|
|
54353
54585
|
});
|
|
54354
54586
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
|
|
@@ -54409,6 +54641,7 @@ const performUpdate = (editor, view, previousDecorations) => {
|
|
|
54409
54641
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
54410
54642
|
if (!editor.converter) return DecorationSet.empty;
|
|
54411
54643
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
54644
|
+
if (!pageSize) return DecorationSet.empty;
|
|
54412
54645
|
const { width, height } = pageSize;
|
|
54413
54646
|
if (!width || !height) return DecorationSet.empty;
|
|
54414
54647
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -54447,11 +54680,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54447
54680
|
let pageHeightThreshold = pageHeight;
|
|
54448
54681
|
let footer = null, header = null;
|
|
54449
54682
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
54450
|
-
const
|
|
54683
|
+
const isFirstHeader = true;
|
|
54684
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
54451
54685
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
54452
54686
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
54453
54687
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
54454
|
-
const
|
|
54688
|
+
const isLastFooter = true;
|
|
54689
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
54455
54690
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
54456
54691
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
54457
54692
|
if (!coords) return [];
|
|
@@ -54470,7 +54705,8 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54470
54705
|
if (currentPageNumber === 1) {
|
|
54471
54706
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
54472
54707
|
decorations.pop();
|
|
54473
|
-
const
|
|
54708
|
+
const isFirstHeader2 = true;
|
|
54709
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
54474
54710
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
54475
54711
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
54476
54712
|
}
|
|
@@ -54544,15 +54780,15 @@ function createFinalPagePadding(bufferHeight) {
|
|
|
54544
54780
|
div2.style.height = bufferHeight + "px";
|
|
54545
54781
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
54546
54782
|
}
|
|
54547
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
54548
|
-
const headerDef = sectionData
|
|
54783
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber, isFirstHeader = false) {
|
|
54784
|
+
const headerDef = sectionData?.headers?.[headerId];
|
|
54549
54785
|
const minHeaderHeight = pageMargins.top * 96;
|
|
54550
54786
|
const headerMargin = pageMargins.header * 96;
|
|
54551
54787
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
54552
54788
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
54553
54789
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
54554
54790
|
const availableHeight = headerHeight - headerMargin;
|
|
54555
|
-
|
|
54791
|
+
let editorContainer = document.createElement("div");
|
|
54556
54792
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
54557
54793
|
headerId = "rId" + generateDocxRandomId();
|
|
54558
54794
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -54564,23 +54800,31 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54564
54800
|
};
|
|
54565
54801
|
}
|
|
54566
54802
|
const data = editor.converter.headers[headerId];
|
|
54567
|
-
const
|
|
54568
|
-
|
|
54569
|
-
|
|
54570
|
-
|
|
54571
|
-
|
|
54572
|
-
|
|
54573
|
-
|
|
54574
|
-
|
|
54575
|
-
|
|
54576
|
-
|
|
54577
|
-
|
|
54578
|
-
|
|
54579
|
-
|
|
54580
|
-
|
|
54803
|
+
const pageNumberIndex = currentPageNumber - 1;
|
|
54804
|
+
const editorKey = getHeaderFooterEditorKey({ pageNumber: pageNumberIndex, isHeader: true, isFirstHeader });
|
|
54805
|
+
let editorSection = null;
|
|
54806
|
+
const { headerFooterEditors } = editor.storage.pagination;
|
|
54807
|
+
if (headerFooterEditors.has(editorKey) && editor.converter.headerEditors[pageNumberIndex]) {
|
|
54808
|
+
const editorData = headerFooterEditors.get(editorKey);
|
|
54809
|
+
editorSection = editorData.editor;
|
|
54810
|
+
editorContainer = editorSection.element;
|
|
54811
|
+
} else {
|
|
54812
|
+
editorSection = createHeaderFooterEditor({
|
|
54813
|
+
editor,
|
|
54814
|
+
data,
|
|
54815
|
+
editorContainer,
|
|
54816
|
+
appendToBody: false,
|
|
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
|
+
}
|
|
54581
54826
|
editorSection.setEditable(false, false);
|
|
54582
|
-
|
|
54583
|
-
editorContainer.className = "pagination-section-header";
|
|
54827
|
+
editorContainer.classList.add("pagination-section-header");
|
|
54584
54828
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
54585
54829
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
54586
54830
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -54593,12 +54837,12 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54593
54837
|
headerHeight
|
|
54594
54838
|
};
|
|
54595
54839
|
}
|
|
54596
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
54597
|
-
const footerDef = sectionData
|
|
54840
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber, isLastFooter = false) {
|
|
54841
|
+
const footerDef = sectionData?.footers?.[footerId];
|
|
54598
54842
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
54599
54843
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
54600
54844
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
54601
|
-
|
|
54845
|
+
let editorContainer = document.createElement("div");
|
|
54602
54846
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
54603
54847
|
footerId = "rId" + generateDocxRandomId();
|
|
54604
54848
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -54610,23 +54854,31 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54610
54854
|
};
|
|
54611
54855
|
}
|
|
54612
54856
|
const data = editor.converter.footers[footerId];
|
|
54613
|
-
const
|
|
54614
|
-
|
|
54615
|
-
|
|
54616
|
-
|
|
54617
|
-
|
|
54618
|
-
|
|
54619
|
-
|
|
54620
|
-
|
|
54621
|
-
|
|
54622
|
-
|
|
54623
|
-
|
|
54624
|
-
|
|
54625
|
-
|
|
54626
|
-
|
|
54857
|
+
const pageNumberIndex = currentPageNumber - 1;
|
|
54858
|
+
const editorKey = getHeaderFooterEditorKey({ pageNumber: pageNumberIndex, isFooter: true, isLastFooter });
|
|
54859
|
+
let editorSection = null;
|
|
54860
|
+
const { headerFooterEditors } = editor.storage.pagination;
|
|
54861
|
+
if (headerFooterEditors.has(editorKey) && editor.converter.footerEditors[pageNumberIndex]) {
|
|
54862
|
+
const editorData = headerFooterEditors.get(editorKey);
|
|
54863
|
+
editorSection = editorData.editor;
|
|
54864
|
+
editorContainer = editorSection.element;
|
|
54865
|
+
} else {
|
|
54866
|
+
editorSection = createHeaderFooterEditor({
|
|
54867
|
+
editor,
|
|
54868
|
+
data,
|
|
54869
|
+
editorContainer,
|
|
54870
|
+
appendToBody: false,
|
|
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
|
+
}
|
|
54627
54880
|
editorSection.setEditable(false, false);
|
|
54628
|
-
|
|
54629
|
-
editorContainer.className = "pagination-section-footer";
|
|
54881
|
+
editorContainer.classList.add("pagination-section-footer");
|
|
54630
54882
|
editorContainer.style.height = footerHeight + "px";
|
|
54631
54883
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
54632
54884
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -54639,10 +54891,28 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54639
54891
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
54640
54892
|
};
|
|
54641
54893
|
}
|
|
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
|
+
};
|
|
54642
54907
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
54643
54908
|
if (editor.options.documentMode !== "editing") return;
|
|
54644
54909
|
editor.setEditable(false, false);
|
|
54645
|
-
toggleHeaderFooterEditMode(
|
|
54910
|
+
toggleHeaderFooterEditMode({
|
|
54911
|
+
editor,
|
|
54912
|
+
focusedSectionEditor: currentFocusedSectionEditor,
|
|
54913
|
+
isEditMode: true,
|
|
54914
|
+
documentMode: editor.options.documentMode
|
|
54915
|
+
});
|
|
54646
54916
|
};
|
|
54647
54917
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
54648
54918
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -55197,7 +55467,7 @@ const Search = Extension.create({
|
|
|
55197
55467
|
}
|
|
55198
55468
|
});
|
|
55199
55469
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
55200
|
-
const nodeResizer = (nodeNames = ["image"]) => {
|
|
55470
|
+
const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
55201
55471
|
let resizeState = {
|
|
55202
55472
|
dragging: false,
|
|
55203
55473
|
startX: 0,
|
|
@@ -55222,8 +55492,13 @@ const nodeResizer = (nodeNames = ["image"]) => {
|
|
|
55222
55492
|
if (tr.getMeta(NodeResizerKey)) {
|
|
55223
55493
|
return oldState;
|
|
55224
55494
|
}
|
|
55225
|
-
|
|
55495
|
+
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
55226
55496
|
const { selection } = newState;
|
|
55497
|
+
const node2 = selection.node;
|
|
55498
|
+
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
55499
|
+
return DecorationSet.empty;
|
|
55500
|
+
}
|
|
55501
|
+
const decorations = [];
|
|
55227
55502
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
55228
55503
|
decorations.push(
|
|
55229
55504
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -55426,7 +55701,7 @@ const nodeResizer = (nodeNames = ["image"]) => {
|
|
|
55426
55701
|
const NodeResizer = Extension.create({
|
|
55427
55702
|
name: "nodeResizer",
|
|
55428
55703
|
addPmPlugins() {
|
|
55429
|
-
return [nodeResizer(["image"])];
|
|
55704
|
+
return [nodeResizer(["image"], this.editor)];
|
|
55430
55705
|
}
|
|
55431
55706
|
});
|
|
55432
55707
|
const getRichTextExtensions = () => {
|
|
@@ -64102,7 +64377,6 @@ const style$2 = cB("icon", `
|
|
|
64102
64377
|
display: inline-block;
|
|
64103
64378
|
position: relative;
|
|
64104
64379
|
fill: currentColor;
|
|
64105
|
-
transform: translateZ(0);
|
|
64106
64380
|
`, [cM("color-transition", {
|
|
64107
64381
|
transition: "color .3s var(--n-bezier)"
|
|
64108
64382
|
}), cM("depth", {
|