@harbour-enterprises/superdoc 0.13.2-rev8 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{eventemitter3-KKY27oz-.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
- package/dist/chunks/{eventemitter3-CHxWXmuK.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
- package/dist/chunks/{index-Bd4H2zrq.cjs → index-B4J7wgs6.cjs} +2 -2
- package/dist/chunks/{index-Bdjh4ZPT.cjs → index-Cdsq63Xq.cjs} +4 -4
- package/dist/chunks/{index-DuSTYEOs.es.js → index-Diu6UKHt.es.js} +4 -4
- package/dist/chunks/{index-B1TbritH.es.js → index-Hr3Um-Bg.es.js} +2 -2
- package/dist/chunks/{jszip-9bCX1h2W.cjs → jszip-BTAcmbVg.cjs} +1 -1
- package/dist/chunks/{jszip-Cl3s9njw.es.js → jszip-DckFs3A7.es.js} +1 -1
- package/dist/chunks/{super-editor.es-Cz-ceaxn.cjs → super-editor.es-BM89AzsN.cjs} +704 -859
- package/dist/chunks/{super-editor.es-BY5Eoi9A.es.js → super-editor.es-BNyzbCw0.es.js} +704 -859
- package/dist/chunks/{url-CJP-Jmfp.cjs → url-BIzg4y2i.cjs} +2 -2
- package/dist/chunks/{url-CLwIePTG.es.js → url-CHayXMZH.es.js} +2 -2
- package/dist/chunks/{vue-BBJVqxjL.es.js → vue-Bi1uWinj.es.js} +3 -10
- package/dist/chunks/{vue-BBjMeYfo.cjs → vue-HIY1g7dm.cjs} +3 -10
- package/dist/chunks/{xml-js-k_RETz76.cjs → xml-js-BjqmFOSP.cjs} +225 -239
- package/dist/chunks/{xml-js-Bp5Hoq_3.es.js → xml-js-CfClL-1b.es.js} +225 -239
- package/dist/style.css +1 -2
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-RV0QN3HE.js → converter-CsK9KCaL.js} +55 -637
- package/dist/super-editor/chunks/{docx-zipper-C5TBRQNB.js → docx-zipper-6iKmmME2.js} +1 -1
- package/dist/super-editor/chunks/{editor-XlwZxMCI.js → editor-Cxb-Zwyu.js} +676 -256
- package/dist/super-editor/chunks/{toolbar-52_BMgdJ.js → toolbar-QHIHaeEf.js} +3 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/core/Editor.d.ts +0 -7
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/InputRule.d.ts +0 -7
- package/dist/super-editor/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/core/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/fieldAnnotationHelpers/findRemovedFieldAnnotations.d.ts.map +1 -1
- package/dist/super-editor/extensions/image/imageHelpers/startImageUpload.d.ts.map +1 -1
- package/dist/super-editor/extensions/line-break/line-break.d.ts.map +1 -1
- package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +1 -6
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +1 -2
- package/dist/super-editor/super-editor.es.js +7 -7
- package/dist/super-editor/tests/e2e/test-app/vite.config.d.ts +1 -1
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +9 -8
- package/dist/superdoc.es.js +10 -9
- package/dist/superdoc.umd.js +708 -869
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts +0 -2
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts.map +0 -1
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +0 -3
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-
|
|
1
|
+
import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-Bi1uWinj.es.js";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { UndoManager, Item as Item$2, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
4
4
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -10941,7 +10941,7 @@ class NodeRange {
|
|
|
10941
10941
|
}
|
|
10942
10942
|
}
|
|
10943
10943
|
const emptyAttrs = /* @__PURE__ */ Object.create(null);
|
|
10944
|
-
let Node$
|
|
10944
|
+
let Node$2 = class Node2 {
|
|
10945
10945
|
/**
|
|
10946
10946
|
@internal
|
|
10947
10947
|
*/
|
|
@@ -11342,8 +11342,8 @@ let Node$1$1 = class Node2 {
|
|
|
11342
11342
|
return node2;
|
|
11343
11343
|
}
|
|
11344
11344
|
};
|
|
11345
|
-
Node$
|
|
11346
|
-
class TextNode extends Node$
|
|
11345
|
+
Node$2.prototype.text = void 0;
|
|
11346
|
+
class TextNode extends Node$2 {
|
|
11347
11347
|
/**
|
|
11348
11348
|
@internal
|
|
11349
11349
|
*/
|
|
@@ -11930,7 +11930,7 @@ let NodeType$1 = class NodeType {
|
|
|
11930
11930
|
create(attrs = null, content, marks) {
|
|
11931
11931
|
if (this.isText)
|
|
11932
11932
|
throw new Error("NodeType.create can't construct text nodes");
|
|
11933
|
-
return new Node$
|
|
11933
|
+
return new Node$2(this, this.computeAttrs(attrs), Fragment.from(content), Mark$1.setFrom(marks));
|
|
11934
11934
|
}
|
|
11935
11935
|
/**
|
|
11936
11936
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
@@ -11940,7 +11940,7 @@ let NodeType$1 = class NodeType {
|
|
|
11940
11940
|
createChecked(attrs = null, content, marks) {
|
|
11941
11941
|
content = Fragment.from(content);
|
|
11942
11942
|
this.checkContent(content);
|
|
11943
|
-
return new Node$
|
|
11943
|
+
return new Node$2(this, this.computeAttrs(attrs), content, Mark$1.setFrom(marks));
|
|
11944
11944
|
}
|
|
11945
11945
|
/**
|
|
11946
11946
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
@@ -11963,7 +11963,7 @@ let NodeType$1 = class NodeType {
|
|
|
11963
11963
|
let after = matched && matched.fillBefore(Fragment.empty, true);
|
|
11964
11964
|
if (!after)
|
|
11965
11965
|
return null;
|
|
11966
|
-
return new Node$
|
|
11966
|
+
return new Node$2(this, attrs, content.append(after), Mark$1.setFrom(marks));
|
|
11967
11967
|
}
|
|
11968
11968
|
/**
|
|
11969
11969
|
Returns true if the given fragment is valid content for this node
|
|
@@ -12200,7 +12200,7 @@ let Schema$1 = class Schema {
|
|
|
12200
12200
|
bound.
|
|
12201
12201
|
*/
|
|
12202
12202
|
nodeFromJSON(json) {
|
|
12203
|
-
return Node$
|
|
12203
|
+
return Node$2.fromJSON(this, json);
|
|
12204
12204
|
}
|
|
12205
12205
|
/**
|
|
12206
12206
|
Deserialize a mark from its JSON representation. This method is
|
|
@@ -13726,7 +13726,7 @@ class ReplaceStep extends Step {
|
|
|
13726
13726
|
}
|
|
13727
13727
|
}
|
|
13728
13728
|
Step.jsonID("replace", ReplaceStep);
|
|
13729
|
-
|
|
13729
|
+
class ReplaceAroundStep extends Step {
|
|
13730
13730
|
/**
|
|
13731
13731
|
Create a replace-around step with the given range and gap.
|
|
13732
13732
|
`insert` should be the point in the slice into which the content
|
|
@@ -13766,7 +13766,7 @@ let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
|
13766
13766
|
}
|
|
13767
13767
|
invert(doc2) {
|
|
13768
13768
|
let gap = this.gapTo - this.gapFrom;
|
|
13769
|
-
return new
|
|
13769
|
+
return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc2.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
13770
13770
|
}
|
|
13771
13771
|
map(mapping) {
|
|
13772
13772
|
let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
@@ -13774,7 +13774,7 @@ let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
|
13774
13774
|
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
13775
13775
|
if (from2.deletedAcross && to.deletedAcross || gapFrom < from2.pos || gapTo > to.pos)
|
|
13776
13776
|
return null;
|
|
13777
|
-
return new
|
|
13777
|
+
return new ReplaceAroundStep(from2.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
13778
13778
|
}
|
|
13779
13779
|
toJSON() {
|
|
13780
13780
|
let json = {
|
|
@@ -13797,10 +13797,10 @@ let ReplaceAroundStep$1 = class ReplaceAroundStep2 extends Step {
|
|
|
13797
13797
|
static fromJSON(schema, json) {
|
|
13798
13798
|
if (typeof json.from != "number" || typeof json.to != "number" || typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
13799
13799
|
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
13800
|
-
return new
|
|
13800
|
+
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
13801
13801
|
}
|
|
13802
|
-
}
|
|
13803
|
-
Step.jsonID("replaceAround", ReplaceAroundStep
|
|
13802
|
+
}
|
|
13803
|
+
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
13804
13804
|
function contentBetween(doc2, from2, to) {
|
|
13805
13805
|
let $from = doc2.resolve(from2), dist2 = to - from2, depth = $from.depth;
|
|
13806
13806
|
while (dist2 > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
@@ -13953,7 +13953,7 @@ function lift(tr, range2, target) {
|
|
|
13953
13953
|
} else {
|
|
13954
13954
|
end2++;
|
|
13955
13955
|
}
|
|
13956
|
-
tr.step(new ReplaceAroundStep
|
|
13956
|
+
tr.step(new ReplaceAroundStep(start2, end2, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
13957
13957
|
}
|
|
13958
13958
|
function findWrapping(range2, nodeType, attrs = null, innerRange = range2) {
|
|
13959
13959
|
let around = findWrappingOutside(range2, nodeType);
|
|
@@ -13998,7 +13998,7 @@ function wrap(tr, range2, wrappers) {
|
|
|
13998
13998
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
13999
13999
|
}
|
|
14000
14000
|
let start2 = range2.start, end2 = range2.end;
|
|
14001
|
-
tr.step(new ReplaceAroundStep
|
|
14001
|
+
tr.step(new ReplaceAroundStep(start2, end2, start2, end2, new Slice(content, 0, 0), wrappers.length, true));
|
|
14002
14002
|
}
|
|
14003
14003
|
function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
14004
14004
|
if (!type2.isTextblock)
|
|
@@ -14020,7 +14020,7 @@ function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
|
14020
14020
|
clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type2, void 0, convertNewlines === null);
|
|
14021
14021
|
let mapping = tr.mapping.slice(mapFrom);
|
|
14022
14022
|
let startM = mapping.map(pos, 1), endM = mapping.map(pos + node2.nodeSize, 1);
|
|
14023
|
-
tr.step(new ReplaceAroundStep
|
|
14023
|
+
tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
14024
14024
|
if (convertNewlines === true)
|
|
14025
14025
|
replaceNewlines(tr, node2, pos, mapFrom);
|
|
14026
14026
|
return false;
|
|
@@ -14061,7 +14061,7 @@ function setNodeMarkup(tr, pos, type2, attrs, marks) {
|
|
|
14061
14061
|
return tr.replaceWith(pos, pos + node2.nodeSize, newNode);
|
|
14062
14062
|
if (!type2.validContent(node2.content))
|
|
14063
14063
|
throw new RangeError("Invalid content for node type " + type2.name);
|
|
14064
|
-
tr.step(new ReplaceAroundStep
|
|
14064
|
+
tr.step(new ReplaceAroundStep(pos, pos + node2.nodeSize, pos + 1, pos + node2.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
14065
14065
|
}
|
|
14066
14066
|
function canSplit(doc2, pos, depth = 1, typesAfter) {
|
|
14067
14067
|
let $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
|
|
@@ -14262,7 +14262,7 @@ class Fitter {
|
|
|
14262
14262
|
}
|
|
14263
14263
|
let slice2 = new Slice(content, openStart, openEnd);
|
|
14264
14264
|
if (moveInline > -1)
|
|
14265
|
-
return new ReplaceAroundStep
|
|
14265
|
+
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice2, placedSize);
|
|
14266
14266
|
if (slice2.size || $from.pos != this.$to.pos)
|
|
14267
14267
|
return new ReplaceStep($from.pos, $to.pos, slice2);
|
|
14268
14268
|
return null;
|
|
@@ -15345,7 +15345,7 @@ function selectionToInsertionEnd$1(tr, startLen, bias) {
|
|
|
15345
15345
|
if (last < startLen)
|
|
15346
15346
|
return;
|
|
15347
15347
|
let step = tr.steps[last];
|
|
15348
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
15348
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))
|
|
15349
15349
|
return;
|
|
15350
15350
|
let map3 = tr.mapping.maps[last], end2;
|
|
15351
15351
|
map3.forEach((_from, _to, _newFrom, newTo) => {
|
|
@@ -15760,7 +15760,7 @@ class EditorState {
|
|
|
15760
15760
|
let instance = new EditorState($config);
|
|
15761
15761
|
$config.fields.forEach((field) => {
|
|
15762
15762
|
if (field.name == "doc") {
|
|
15763
|
-
instance.doc = Node$
|
|
15763
|
+
instance.doc = Node$2.fromJSON(config.schema, json.doc);
|
|
15764
15764
|
} else if (field.name == "selection") {
|
|
15765
15765
|
instance.selection = Selection.fromJSON(instance.doc, json.selection);
|
|
15766
15766
|
} else if (field.name == "storedMarks") {
|
|
@@ -18821,583 +18821,6 @@ const createColGroup = (node2, cellMinWidth, overrideCol, overrideValue) => {
|
|
|
18821
18821
|
colgroupValues
|
|
18822
18822
|
};
|
|
18823
18823
|
};
|
|
18824
|
-
function chainableEditorState(transaction, state2) {
|
|
18825
|
-
let { selection, doc: doc2, storedMarks } = transaction;
|
|
18826
|
-
return {
|
|
18827
|
-
...state2,
|
|
18828
|
-
apply: state2.apply.bind(state2),
|
|
18829
|
-
applyTransaction: state2.applyTransaction.bind(state2),
|
|
18830
|
-
plugins: state2.plugins,
|
|
18831
|
-
schema: state2.schema,
|
|
18832
|
-
reconfigure: state2.reconfigure.bind(state2),
|
|
18833
|
-
toJSON: state2.toJSON.bind(state2),
|
|
18834
|
-
get storedMarks() {
|
|
18835
|
-
return storedMarks;
|
|
18836
|
-
},
|
|
18837
|
-
get selection() {
|
|
18838
|
-
return selection;
|
|
18839
|
-
},
|
|
18840
|
-
get doc() {
|
|
18841
|
-
return doc2;
|
|
18842
|
-
},
|
|
18843
|
-
get tr() {
|
|
18844
|
-
selection = transaction.selection;
|
|
18845
|
-
doc2 = transaction.doc;
|
|
18846
|
-
storedMarks = transaction.storedMarks;
|
|
18847
|
-
return transaction;
|
|
18848
|
-
}
|
|
18849
|
-
};
|
|
18850
|
-
}
|
|
18851
|
-
class CommandService {
|
|
18852
|
-
constructor(props) {
|
|
18853
|
-
__publicField$2(this, "editor");
|
|
18854
|
-
__publicField$2(this, "rawCommands");
|
|
18855
|
-
this.editor = props.editor;
|
|
18856
|
-
this.rawCommands = this.editor.extensionService.commands;
|
|
18857
|
-
}
|
|
18858
|
-
/**
|
|
18859
|
-
* Static method for creating a service.
|
|
18860
|
-
* @param args Arguments for the constructor.
|
|
18861
|
-
*/
|
|
18862
|
-
static create(...args) {
|
|
18863
|
-
return new CommandService(...args);
|
|
18864
|
-
}
|
|
18865
|
-
/**
|
|
18866
|
-
* Get editor state.
|
|
18867
|
-
*/
|
|
18868
|
-
get state() {
|
|
18869
|
-
return this.editor.state;
|
|
18870
|
-
}
|
|
18871
|
-
/**
|
|
18872
|
-
* Get all commands with wrapped command method.
|
|
18873
|
-
*/
|
|
18874
|
-
get commands() {
|
|
18875
|
-
const { editor, state: state2 } = this;
|
|
18876
|
-
const { view } = editor;
|
|
18877
|
-
const { tr } = state2;
|
|
18878
|
-
const props = this.createProps(tr);
|
|
18879
|
-
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
18880
|
-
const method = (...args) => {
|
|
18881
|
-
const fn2 = command2(...args)(props);
|
|
18882
|
-
if (!tr.getMeta("preventDispatch")) {
|
|
18883
|
-
view.dispatch(tr);
|
|
18884
|
-
}
|
|
18885
|
-
return fn2;
|
|
18886
|
-
};
|
|
18887
|
-
return [name, method];
|
|
18888
|
-
});
|
|
18889
|
-
return Object.fromEntries(entries);
|
|
18890
|
-
}
|
|
18891
|
-
/**
|
|
18892
|
-
* Create a chain of commands to call multiple commands at once.
|
|
18893
|
-
*/
|
|
18894
|
-
get chain() {
|
|
18895
|
-
return () => this.createChain();
|
|
18896
|
-
}
|
|
18897
|
-
/**
|
|
18898
|
-
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
18899
|
-
*/
|
|
18900
|
-
get can() {
|
|
18901
|
-
return () => this.createCan();
|
|
18902
|
-
}
|
|
18903
|
-
/**
|
|
18904
|
-
* Creates a chain of commands.
|
|
18905
|
-
* @param startTr Start transaction.
|
|
18906
|
-
* @param shouldDispatch Should dispatch or not.
|
|
18907
|
-
*/
|
|
18908
|
-
createChain(startTr, shouldDispatch = true) {
|
|
18909
|
-
const { editor, state: state2, rawCommands } = this;
|
|
18910
|
-
const { view } = editor;
|
|
18911
|
-
const callbacks2 = [];
|
|
18912
|
-
const hasStartTr = !!startTr;
|
|
18913
|
-
const tr = startTr || state2.tr;
|
|
18914
|
-
const run2 = () => {
|
|
18915
|
-
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
18916
|
-
view.dispatch(tr);
|
|
18917
|
-
}
|
|
18918
|
-
return callbacks2.every((cb) => cb === true);
|
|
18919
|
-
};
|
|
18920
|
-
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
18921
|
-
const chainedCommand = (...args) => {
|
|
18922
|
-
const props = this.createProps(tr, shouldDispatch);
|
|
18923
|
-
const callback = command2(...args)(props);
|
|
18924
|
-
callbacks2.push(callback);
|
|
18925
|
-
return chain;
|
|
18926
|
-
};
|
|
18927
|
-
return [name, chainedCommand];
|
|
18928
|
-
});
|
|
18929
|
-
const chain = {
|
|
18930
|
-
...Object.fromEntries(entries),
|
|
18931
|
-
run: run2
|
|
18932
|
-
};
|
|
18933
|
-
return chain;
|
|
18934
|
-
}
|
|
18935
|
-
/**
|
|
18936
|
-
* Creates a can check for commands.
|
|
18937
|
-
* @param startTr Start transaction.
|
|
18938
|
-
*/
|
|
18939
|
-
createCan(startTr) {
|
|
18940
|
-
const { rawCommands, state: state2 } = this;
|
|
18941
|
-
const dispatch = false;
|
|
18942
|
-
const tr = startTr || state2.tr;
|
|
18943
|
-
const props = this.createProps(tr, dispatch);
|
|
18944
|
-
const commands2 = Object.fromEntries(
|
|
18945
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
18946
|
-
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
18947
|
-
})
|
|
18948
|
-
);
|
|
18949
|
-
return {
|
|
18950
|
-
...commands2,
|
|
18951
|
-
chain: () => this.createChain(tr, dispatch)
|
|
18952
|
-
};
|
|
18953
|
-
}
|
|
18954
|
-
/**
|
|
18955
|
-
* Creates default props for the command method.
|
|
18956
|
-
* @param {*} tr Transaction.
|
|
18957
|
-
* @param {*} shouldDispatch Check if should dispatch.
|
|
18958
|
-
* @returns Object with props.
|
|
18959
|
-
*/
|
|
18960
|
-
createProps(tr, shouldDispatch = true) {
|
|
18961
|
-
const { editor, state: state2, rawCommands } = this;
|
|
18962
|
-
const { view } = editor;
|
|
18963
|
-
const props = {
|
|
18964
|
-
tr,
|
|
18965
|
-
editor,
|
|
18966
|
-
view,
|
|
18967
|
-
state: chainableEditorState(tr, state2),
|
|
18968
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
18969
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
18970
|
-
can: () => this.createCan(tr),
|
|
18971
|
-
get commands() {
|
|
18972
|
-
return Object.fromEntries(
|
|
18973
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
18974
|
-
return [name, (...args) => command2(...args)(props)];
|
|
18975
|
-
})
|
|
18976
|
-
);
|
|
18977
|
-
}
|
|
18978
|
-
};
|
|
18979
|
-
return props;
|
|
18980
|
-
}
|
|
18981
|
-
}
|
|
18982
|
-
function getHTMLFromFragment(fragment, schema) {
|
|
18983
|
-
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
18984
|
-
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
18985
|
-
const container = temporaryDocument.createElement("div");
|
|
18986
|
-
container.appendChild(documentFragment);
|
|
18987
|
-
return container.innerHTML;
|
|
18988
|
-
}
|
|
18989
|
-
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
18990
|
-
let textBefore = "";
|
|
18991
|
-
const sliceEndPos = $from.parentOffset;
|
|
18992
|
-
$from.parent.nodesBetween(
|
|
18993
|
-
Math.max(0, sliceEndPos - maxMatch),
|
|
18994
|
-
sliceEndPos,
|
|
18995
|
-
(node2, pos, parent, index2) => {
|
|
18996
|
-
const chunk = node2.type.spec.toText?.({
|
|
18997
|
-
node: node2,
|
|
18998
|
-
pos,
|
|
18999
|
-
parent,
|
|
19000
|
-
index: index2
|
|
19001
|
-
}) || node2.textContent || "%leaf%";
|
|
19002
|
-
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
19003
|
-
}
|
|
19004
|
-
);
|
|
19005
|
-
return textBefore;
|
|
19006
|
-
};
|
|
19007
|
-
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
19008
|
-
const { converter } = editor;
|
|
19009
|
-
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
19010
|
-
let cleanedHtml = convertEmToPt(html);
|
|
19011
|
-
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
19012
|
-
const tempDiv = document.createElement("div");
|
|
19013
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
19014
|
-
const paragraphs = tempDiv.querySelectorAll("p");
|
|
19015
|
-
paragraphs.forEach((p) => {
|
|
19016
|
-
const innerHTML3 = p.innerHTML;
|
|
19017
|
-
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
19018
|
-
const styleAttr = p.getAttribute("style") || "";
|
|
19019
|
-
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
19020
|
-
if (msoListMatch) {
|
|
19021
|
-
const [, abstractId, level] = msoListMatch;
|
|
19022
|
-
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
19023
|
-
if (!listNumId) return;
|
|
19024
|
-
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
19025
|
-
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
19026
|
-
p.setAttribute("data-num-id", listNumId);
|
|
19027
|
-
p.setAttribute("data-list-level", level - 1);
|
|
19028
|
-
p.setAttribute("data-start", start2);
|
|
19029
|
-
p.setAttribute("data-lvl-text", lvlText);
|
|
19030
|
-
p.setAttribute("data-num-fmt", numFmt);
|
|
19031
|
-
}
|
|
19032
|
-
extractAndRemoveConditionalPrefix(p);
|
|
19033
|
-
});
|
|
19034
|
-
transformWordLists(tempDiv);
|
|
19035
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
19036
|
-
tempDiv.remove();
|
|
19037
|
-
const { dispatch } = editor.view;
|
|
19038
|
-
if (!dispatch) return false;
|
|
19039
|
-
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
19040
|
-
return true;
|
|
19041
|
-
};
|
|
19042
|
-
const getLevelDefinition = (abstractDefinition, level) => {
|
|
19043
|
-
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
19044
|
-
const levelElement = abstractDefinition.elements.find((el) => {
|
|
19045
|
-
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
19046
|
-
});
|
|
19047
|
-
if (!levelElement) return null;
|
|
19048
|
-
const { elements } = levelElement;
|
|
19049
|
-
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
19050
|
-
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
19051
|
-
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
19052
|
-
return { lvlText, start: start2, numFmt, elements };
|
|
19053
|
-
};
|
|
19054
|
-
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
19055
|
-
const { definitions } = editor?.converter?.numbering;
|
|
19056
|
-
if (!definitions) return null;
|
|
19057
|
-
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
19058
|
-
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
19059
|
-
});
|
|
19060
|
-
return matchedDefinition?.attributes?.["w:numId"];
|
|
19061
|
-
};
|
|
19062
|
-
const getListAbstractDefinition = (abstractId, editor) => {
|
|
19063
|
-
const { abstracts = {} } = editor?.converter?.numbering;
|
|
19064
|
-
return abstracts[abstractId] || null;
|
|
19065
|
-
};
|
|
19066
|
-
const transformWordLists = (container) => {
|
|
19067
|
-
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
19068
|
-
const listMap = /* @__PURE__ */ new Map();
|
|
19069
|
-
const listLevels = {};
|
|
19070
|
-
for (const p of paragraphs) {
|
|
19071
|
-
const listId = p.getAttribute("data-num-id");
|
|
19072
|
-
const level = parseInt(p.getAttribute("data-list-level"));
|
|
19073
|
-
const numFmt = p.getAttribute("data-num-fmt");
|
|
19074
|
-
const start2 = p.getAttribute("data-start");
|
|
19075
|
-
const lvlText = p.getAttribute("data-lvl-text");
|
|
19076
|
-
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
19077
|
-
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
19078
|
-
}
|
|
19079
|
-
for (const [id, items] of listMap.entries()) {
|
|
19080
|
-
if (!listLevels[id]) {
|
|
19081
|
-
listLevels[id] = {
|
|
19082
|
-
stack: [],
|
|
19083
|
-
counts: {},
|
|
19084
|
-
prevLevel: null
|
|
19085
|
-
};
|
|
19086
|
-
}
|
|
19087
|
-
const parentStack = [];
|
|
19088
|
-
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
19089
|
-
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
19090
|
-
const li = document.createElement("li");
|
|
19091
|
-
li.innerHTML = p.innerHTML;
|
|
19092
|
-
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
19093
|
-
li.setAttribute("data-num-id", id);
|
|
19094
|
-
li.setAttribute("data-lvl-text", lvlText);
|
|
19095
|
-
li.setAttribute("data-num-fmt", numFmt);
|
|
19096
|
-
if (p.hasAttribute("data-font-family")) {
|
|
19097
|
-
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
19098
|
-
}
|
|
19099
|
-
if (p.hasAttribute("data-font-size")) {
|
|
19100
|
-
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
19101
|
-
}
|
|
19102
|
-
const parentNode2 = p.parentNode;
|
|
19103
|
-
let listForLevel = parentStack[level];
|
|
19104
|
-
if (!listForLevel) {
|
|
19105
|
-
const newList = document.createElement("ol");
|
|
19106
|
-
newList.setAttribute("data-list-id", id);
|
|
19107
|
-
newList.level = level;
|
|
19108
|
-
if (level > 0) {
|
|
19109
|
-
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
19110
|
-
if (parentLi) parentLi.appendChild(newList);
|
|
19111
|
-
} else {
|
|
19112
|
-
parentNode2.insertBefore(newList, p);
|
|
19113
|
-
}
|
|
19114
|
-
parentStack[level] = newList;
|
|
19115
|
-
parentStack.length = level + 1;
|
|
19116
|
-
listForLevel = newList;
|
|
19117
|
-
}
|
|
19118
|
-
listForLevel.appendChild(li);
|
|
19119
|
-
p.remove();
|
|
19120
|
-
});
|
|
19121
|
-
}
|
|
19122
|
-
};
|
|
19123
|
-
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
19124
|
-
const levelState = listLevels[listId];
|
|
19125
|
-
if (!levelState.stack) levelState.stack = [];
|
|
19126
|
-
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
19127
|
-
if (levelState.prevLevel === null) {
|
|
19128
|
-
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
19129
|
-
} else {
|
|
19130
|
-
if (currentLevel > levelState.prevLevel) {
|
|
19131
|
-
levelState.stack.push(1);
|
|
19132
|
-
} else if (currentLevel === levelState.prevLevel) {
|
|
19133
|
-
levelState.stack[levelState.stack.length - 1]++;
|
|
19134
|
-
} else {
|
|
19135
|
-
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
19136
|
-
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
19137
|
-
}
|
|
19138
|
-
}
|
|
19139
|
-
levelState.prevLevel = currentLevel;
|
|
19140
|
-
return [...levelState.stack];
|
|
19141
|
-
}
|
|
19142
|
-
function extractAndRemoveConditionalPrefix(p) {
|
|
19143
|
-
const nodes = Array.from(p.childNodes);
|
|
19144
|
-
let fontFamily2 = null;
|
|
19145
|
-
let fontSize2 = null;
|
|
19146
|
-
let start2 = -1, end2 = -1;
|
|
19147
|
-
nodes.forEach((node2, index2) => {
|
|
19148
|
-
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
19149
|
-
start2 = index2;
|
|
19150
|
-
}
|
|
19151
|
-
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
19152
|
-
end2 = index2;
|
|
19153
|
-
}
|
|
19154
|
-
});
|
|
19155
|
-
if (start2 !== -1 && end2 !== -1) {
|
|
19156
|
-
for (let i = start2 + 1; i < end2; i++) {
|
|
19157
|
-
const node2 = nodes[i];
|
|
19158
|
-
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
19159
|
-
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
19160
|
-
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
19161
|
-
}
|
|
19162
|
-
}
|
|
19163
|
-
for (let i = end2; i >= start2; i--) {
|
|
19164
|
-
p.removeChild(p.childNodes[i]);
|
|
19165
|
-
}
|
|
19166
|
-
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
19167
|
-
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
19168
|
-
}
|
|
19169
|
-
}
|
|
19170
|
-
class InputRule {
|
|
19171
|
-
constructor(config) {
|
|
19172
|
-
__publicField$2(this, "match");
|
|
19173
|
-
__publicField$2(this, "handler");
|
|
19174
|
-
this.match = config.match;
|
|
19175
|
-
this.handler = config.handler;
|
|
19176
|
-
}
|
|
19177
|
-
}
|
|
19178
|
-
const inputRuleMatcherHandler = (text, match) => {
|
|
19179
|
-
if (isRegExp(match)) {
|
|
19180
|
-
return match.exec(text);
|
|
19181
|
-
}
|
|
19182
|
-
const inputRuleMatch = match(text);
|
|
19183
|
-
if (!inputRuleMatch) {
|
|
19184
|
-
return null;
|
|
19185
|
-
}
|
|
19186
|
-
const result = [inputRuleMatch.text];
|
|
19187
|
-
result.index = inputRuleMatch.index;
|
|
19188
|
-
result.input = text;
|
|
19189
|
-
result.data = inputRuleMatch.data;
|
|
19190
|
-
if (inputRuleMatch.replaceWith) {
|
|
19191
|
-
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
19192
|
-
console.warn(
|
|
19193
|
-
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
19194
|
-
);
|
|
19195
|
-
}
|
|
19196
|
-
result.push(inputRuleMatch.replaceWith);
|
|
19197
|
-
}
|
|
19198
|
-
return result;
|
|
19199
|
-
};
|
|
19200
|
-
const run = (config) => {
|
|
19201
|
-
const {
|
|
19202
|
-
editor,
|
|
19203
|
-
from: from2,
|
|
19204
|
-
to,
|
|
19205
|
-
text,
|
|
19206
|
-
rules,
|
|
19207
|
-
plugin: plugin2
|
|
19208
|
-
} = config;
|
|
19209
|
-
const { view } = editor;
|
|
19210
|
-
if (view.composing) {
|
|
19211
|
-
return false;
|
|
19212
|
-
}
|
|
19213
|
-
const $from = view.state.doc.resolve(from2);
|
|
19214
|
-
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
19215
|
-
return false;
|
|
19216
|
-
}
|
|
19217
|
-
let matched = false;
|
|
19218
|
-
const textBefore = getTextContentFromNodes($from) + text;
|
|
19219
|
-
rules.forEach((rule) => {
|
|
19220
|
-
if (matched) {
|
|
19221
|
-
return;
|
|
19222
|
-
}
|
|
19223
|
-
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
19224
|
-
if (!match) {
|
|
19225
|
-
return;
|
|
19226
|
-
}
|
|
19227
|
-
const tr = view.state.tr;
|
|
19228
|
-
const state2 = chainableEditorState(tr, view.state);
|
|
19229
|
-
const range2 = {
|
|
19230
|
-
from: from2 - (match[0].length - text.length),
|
|
19231
|
-
to
|
|
19232
|
-
};
|
|
19233
|
-
const { commands: commands2, chain, can } = new CommandService({
|
|
19234
|
-
editor,
|
|
19235
|
-
state: state2
|
|
19236
|
-
});
|
|
19237
|
-
const handler = rule.handler({
|
|
19238
|
-
state: state2,
|
|
19239
|
-
range: range2,
|
|
19240
|
-
match,
|
|
19241
|
-
commands: commands2,
|
|
19242
|
-
chain,
|
|
19243
|
-
can
|
|
19244
|
-
});
|
|
19245
|
-
if (handler === null || !tr.steps.length) {
|
|
19246
|
-
return;
|
|
19247
|
-
}
|
|
19248
|
-
tr.setMeta(plugin2, {
|
|
19249
|
-
transform: tr,
|
|
19250
|
-
from: from2,
|
|
19251
|
-
to,
|
|
19252
|
-
text
|
|
19253
|
-
});
|
|
19254
|
-
view.dispatch(tr);
|
|
19255
|
-
matched = true;
|
|
19256
|
-
});
|
|
19257
|
-
return matched;
|
|
19258
|
-
};
|
|
19259
|
-
const inputRulesPlugin = ({ editor, rules }) => {
|
|
19260
|
-
const plugin2 = new Plugin({
|
|
19261
|
-
key: new PluginKey("inputRulesPlugin"),
|
|
19262
|
-
state: {
|
|
19263
|
-
init() {
|
|
19264
|
-
return null;
|
|
19265
|
-
},
|
|
19266
|
-
apply(tr, prev, state2) {
|
|
19267
|
-
const stored = tr.getMeta(plugin2);
|
|
19268
|
-
if (stored) {
|
|
19269
|
-
return stored;
|
|
19270
|
-
}
|
|
19271
|
-
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
19272
|
-
const isSimulatedInput = !!simulatedInputMeta;
|
|
19273
|
-
if (isSimulatedInput) {
|
|
19274
|
-
setTimeout(() => {
|
|
19275
|
-
let { text } = simulatedInputMeta;
|
|
19276
|
-
if (typeof text !== "string") {
|
|
19277
|
-
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
19278
|
-
}
|
|
19279
|
-
const { from: from2 } = simulatedInputMeta;
|
|
19280
|
-
const to = from2 + text.length;
|
|
19281
|
-
run({
|
|
19282
|
-
editor,
|
|
19283
|
-
from: from2,
|
|
19284
|
-
to,
|
|
19285
|
-
text,
|
|
19286
|
-
rules,
|
|
19287
|
-
plugin: plugin2
|
|
19288
|
-
});
|
|
19289
|
-
});
|
|
19290
|
-
}
|
|
19291
|
-
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
19292
|
-
}
|
|
19293
|
-
},
|
|
19294
|
-
props: {
|
|
19295
|
-
handleTextInput(view, from2, to, text) {
|
|
19296
|
-
return run({
|
|
19297
|
-
editor,
|
|
19298
|
-
from: from2,
|
|
19299
|
-
to,
|
|
19300
|
-
text,
|
|
19301
|
-
rules,
|
|
19302
|
-
plugin: plugin2
|
|
19303
|
-
});
|
|
19304
|
-
},
|
|
19305
|
-
// add support for input rules to trigger on enter
|
|
19306
|
-
// this is useful for example for code blocks
|
|
19307
|
-
handleKeyDown(view, event) {
|
|
19308
|
-
if (event.key !== "Enter") {
|
|
19309
|
-
return false;
|
|
19310
|
-
}
|
|
19311
|
-
const { $cursor } = view.state.selection;
|
|
19312
|
-
if ($cursor) {
|
|
19313
|
-
return run({
|
|
19314
|
-
editor,
|
|
19315
|
-
from: $cursor.pos,
|
|
19316
|
-
to: $cursor.pos,
|
|
19317
|
-
text: "\n",
|
|
19318
|
-
rules,
|
|
19319
|
-
plugin: plugin2
|
|
19320
|
-
});
|
|
19321
|
-
}
|
|
19322
|
-
return false;
|
|
19323
|
-
},
|
|
19324
|
-
// Paste handler
|
|
19325
|
-
handlePaste(view, event, slice2) {
|
|
19326
|
-
const clipboard = event.clipboardData;
|
|
19327
|
-
const html = clipboard.getData("text/html");
|
|
19328
|
-
clipboard.getData("text/plain");
|
|
19329
|
-
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
19330
|
-
if (fieldAnnotationContent.length) {
|
|
19331
|
-
return false;
|
|
19332
|
-
}
|
|
19333
|
-
let source;
|
|
19334
|
-
if (!html) {
|
|
19335
|
-
source = "plain-text";
|
|
19336
|
-
} else if (isWordHtml(html)) {
|
|
19337
|
-
source = "word-html";
|
|
19338
|
-
} else {
|
|
19339
|
-
source = "browser-html";
|
|
19340
|
-
}
|
|
19341
|
-
switch (source) {
|
|
19342
|
-
case "plain-text":
|
|
19343
|
-
break;
|
|
19344
|
-
case "word-html":
|
|
19345
|
-
if (editor.options.mode === "docx") {
|
|
19346
|
-
return handleDocxPaste(html, editor, view, plugin2);
|
|
19347
|
-
}
|
|
19348
|
-
case "browser-html":
|
|
19349
|
-
return handleHtmlPaste$1(html, editor);
|
|
19350
|
-
}
|
|
19351
|
-
return false;
|
|
19352
|
-
}
|
|
19353
|
-
},
|
|
19354
|
-
isInputRules: true
|
|
19355
|
-
});
|
|
19356
|
-
return plugin2;
|
|
19357
|
-
};
|
|
19358
|
-
function isWordHtml(html) {
|
|
19359
|
-
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
19360
|
-
}
|
|
19361
|
-
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
19362
|
-
const htmlWithPtSizing = convertEmToPt(html);
|
|
19363
|
-
const cleanedHtml = sanitizeHtml(htmlWithPtSizing);
|
|
19364
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
19365
|
-
const { dispatch } = editor.view;
|
|
19366
|
-
if (!dispatch) return false;
|
|
19367
|
-
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
19368
|
-
return true;
|
|
19369
|
-
};
|
|
19370
|
-
const convertEmToPt = (html) => {
|
|
19371
|
-
return html.replace(
|
|
19372
|
-
/font-size\s*:\s*([\d.]+)em/gi,
|
|
19373
|
-
(_, emValue) => {
|
|
19374
|
-
const em = parseFloat(emValue);
|
|
19375
|
-
const pt = Math.round(em * 12 * 100) / 100;
|
|
19376
|
-
return `font-size: ${pt}pt`;
|
|
19377
|
-
}
|
|
19378
|
-
);
|
|
19379
|
-
};
|
|
19380
|
-
function cleanHtmlUnnecessaryTags(html) {
|
|
19381
|
-
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
19382
|
-
}
|
|
19383
|
-
function sanitizeHtml(html, forbiddenTags = ["meta", "svg", "script", "style", "button"]) {
|
|
19384
|
-
const container = document.createElement("div");
|
|
19385
|
-
container.innerHTML = html;
|
|
19386
|
-
const walkAndClean = (node2) => {
|
|
19387
|
-
for (const child of [...node2.children]) {
|
|
19388
|
-
if (forbiddenTags.includes(child.tagName.toLowerCase())) {
|
|
19389
|
-
child.remove();
|
|
19390
|
-
continue;
|
|
19391
|
-
}
|
|
19392
|
-
if (child.hasAttribute("linebreaktype")) {
|
|
19393
|
-
child.removeAttribute("linebreaktype");
|
|
19394
|
-
}
|
|
19395
|
-
walkAndClean(child);
|
|
19396
|
-
}
|
|
19397
|
-
};
|
|
19398
|
-
walkAndClean(container);
|
|
19399
|
-
return container;
|
|
19400
|
-
}
|
|
19401
18824
|
function exportSchemaToJson(params2) {
|
|
19402
18825
|
const { type: type2 } = params2.node || {};
|
|
19403
18826
|
const router = {
|
|
@@ -19435,13 +18858,13 @@ function exportSchemaToJson(params2) {
|
|
|
19435
18858
|
function translateBodyNode(params2) {
|
|
19436
18859
|
let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
|
|
19437
18860
|
if (params2.converter) {
|
|
19438
|
-
const hasHeader = sectPr
|
|
18861
|
+
const hasHeader = sectPr.elements.some((n) => n.name === "w:headerReference");
|
|
19439
18862
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
19440
18863
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
19441
18864
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
19442
18865
|
sectPr.elements.push(defaultHeader);
|
|
19443
18866
|
}
|
|
19444
|
-
const hasFooter = sectPr
|
|
18867
|
+
const hasFooter = sectPr.elements.some((n) => n.name === "w:footerReference");
|
|
19445
18868
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
19446
18869
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
19447
18870
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
@@ -20741,11 +20164,12 @@ function prepareHtmlAnnotation(params2) {
|
|
|
20741
20164
|
node: { attrs = {}, marks = [] },
|
|
20742
20165
|
editorSchema
|
|
20743
20166
|
} = params2;
|
|
20744
|
-
const
|
|
20167
|
+
const parser = new window.DOMParser();
|
|
20168
|
+
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, "text/html");
|
|
20745
20169
|
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
20746
20170
|
const allMarks = [...marks, ...marksFromAttrs];
|
|
20747
20171
|
let state2 = EditorState.create({
|
|
20748
|
-
doc: DOMParser$1.fromSchema(editorSchema).parse(
|
|
20172
|
+
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtml)
|
|
20749
20173
|
});
|
|
20750
20174
|
if (allMarks.length) {
|
|
20751
20175
|
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
@@ -23800,7 +23224,7 @@ function addDefaultStylesIfMissing(styles) {
|
|
|
23800
23224
|
});
|
|
23801
23225
|
return updatedStyles;
|
|
23802
23226
|
}
|
|
23803
|
-
const importHeadersFooters = (docx, converter,
|
|
23227
|
+
const importHeadersFooters = (docx, converter, editor) => {
|
|
23804
23228
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
23805
23229
|
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
23806
23230
|
const { elements } = relationships;
|
|
@@ -23810,9 +23234,6 @@ const importHeadersFooters = (docx, converter, mainEditor) => {
|
|
|
23810
23234
|
const footers = elements.filter((el) => el.attributes["Type"] === footerType);
|
|
23811
23235
|
const sectPr = findSectPr(docx["word/document.xml"]) || [];
|
|
23812
23236
|
const allSectPrElements = sectPr.flatMap((el) => el.elements);
|
|
23813
|
-
if (!mainEditor) return;
|
|
23814
|
-
const editor = { ...mainEditor };
|
|
23815
|
-
editor.options.annotations = true;
|
|
23816
23237
|
headers.forEach((header) => {
|
|
23817
23238
|
const { rId, referenceFile, currentFileName } = getHeaderFooterSectionData(header, docx);
|
|
23818
23239
|
const sectPrHeader = allSectPrElements.find((el) => el.name === "w:headerReference" && el.attributes["r:id"] === rId);
|
|
@@ -23972,7 +23393,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
23972
23393
|
return;
|
|
23973
23394
|
}
|
|
23974
23395
|
}
|
|
23975
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2
|
|
23396
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2") {
|
|
23976
23397
|
const customLocation = "docProps/custom.xml";
|
|
23977
23398
|
if (!docx[customLocation]) {
|
|
23978
23399
|
docx[customLocation] = generateCustomXml();
|
|
@@ -24439,7 +23860,7 @@ function storeSuperdocVersion(docx) {
|
|
|
24439
23860
|
function generateCustomXml() {
|
|
24440
23861
|
return DEFAULT_CUSTOM_XML;
|
|
24441
23862
|
}
|
|
24442
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.13.2
|
|
23863
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.13.2") {
|
|
24443
23864
|
return {
|
|
24444
23865
|
type: "element",
|
|
24445
23866
|
name: "property",
|
|
@@ -26972,7 +26393,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
26972
26393
|
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
26973
26394
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
26974
26395
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
26975
|
-
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn,
|
|
26396
|
+
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
26976
26397
|
function getMarksFromSelection(state2) {
|
|
26977
26398
|
const { from: from2, to, empty: empty2 } = state2.selection;
|
|
26978
26399
|
const marks = [];
|
|
@@ -28161,6 +27582,164 @@ createMarksSchema_fn = function(markExtensions, attributes, editor) {
|
|
|
28161
27582
|
};
|
|
28162
27583
|
__privateAdd$1(_Schema, _Schema_static);
|
|
28163
27584
|
let Schema2 = _Schema;
|
|
27585
|
+
function chainableEditorState(transaction, state2) {
|
|
27586
|
+
let { selection, doc: doc2, storedMarks } = transaction;
|
|
27587
|
+
return {
|
|
27588
|
+
...state2,
|
|
27589
|
+
apply: state2.apply.bind(state2),
|
|
27590
|
+
applyTransaction: state2.applyTransaction.bind(state2),
|
|
27591
|
+
plugins: state2.plugins,
|
|
27592
|
+
schema: state2.schema,
|
|
27593
|
+
reconfigure: state2.reconfigure.bind(state2),
|
|
27594
|
+
toJSON: state2.toJSON.bind(state2),
|
|
27595
|
+
get storedMarks() {
|
|
27596
|
+
return storedMarks;
|
|
27597
|
+
},
|
|
27598
|
+
get selection() {
|
|
27599
|
+
return selection;
|
|
27600
|
+
},
|
|
27601
|
+
get doc() {
|
|
27602
|
+
return doc2;
|
|
27603
|
+
},
|
|
27604
|
+
get tr() {
|
|
27605
|
+
selection = transaction.selection;
|
|
27606
|
+
doc2 = transaction.doc;
|
|
27607
|
+
storedMarks = transaction.storedMarks;
|
|
27608
|
+
return transaction;
|
|
27609
|
+
}
|
|
27610
|
+
};
|
|
27611
|
+
}
|
|
27612
|
+
class CommandService {
|
|
27613
|
+
constructor(props) {
|
|
27614
|
+
__publicField$1(this, "editor");
|
|
27615
|
+
__publicField$1(this, "rawCommands");
|
|
27616
|
+
this.editor = props.editor;
|
|
27617
|
+
this.rawCommands = this.editor.extensionService.commands;
|
|
27618
|
+
}
|
|
27619
|
+
/**
|
|
27620
|
+
* Static method for creating a service.
|
|
27621
|
+
* @param args Arguments for the constructor.
|
|
27622
|
+
*/
|
|
27623
|
+
static create(...args) {
|
|
27624
|
+
return new CommandService(...args);
|
|
27625
|
+
}
|
|
27626
|
+
/**
|
|
27627
|
+
* Get editor state.
|
|
27628
|
+
*/
|
|
27629
|
+
get state() {
|
|
27630
|
+
return this.editor.state;
|
|
27631
|
+
}
|
|
27632
|
+
/**
|
|
27633
|
+
* Get all commands with wrapped command method.
|
|
27634
|
+
*/
|
|
27635
|
+
get commands() {
|
|
27636
|
+
const { editor, state: state2 } = this;
|
|
27637
|
+
const { view } = editor;
|
|
27638
|
+
const { tr } = state2;
|
|
27639
|
+
const props = this.createProps(tr);
|
|
27640
|
+
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
27641
|
+
const method = (...args) => {
|
|
27642
|
+
const fn2 = command2(...args)(props);
|
|
27643
|
+
if (!tr.getMeta("preventDispatch")) {
|
|
27644
|
+
view.dispatch(tr);
|
|
27645
|
+
}
|
|
27646
|
+
return fn2;
|
|
27647
|
+
};
|
|
27648
|
+
return [name, method];
|
|
27649
|
+
});
|
|
27650
|
+
return Object.fromEntries(entries);
|
|
27651
|
+
}
|
|
27652
|
+
/**
|
|
27653
|
+
* Create a chain of commands to call multiple commands at once.
|
|
27654
|
+
*/
|
|
27655
|
+
get chain() {
|
|
27656
|
+
return () => this.createChain();
|
|
27657
|
+
}
|
|
27658
|
+
/**
|
|
27659
|
+
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
27660
|
+
*/
|
|
27661
|
+
get can() {
|
|
27662
|
+
return () => this.createCan();
|
|
27663
|
+
}
|
|
27664
|
+
/**
|
|
27665
|
+
* Creates a chain of commands.
|
|
27666
|
+
* @param startTr Start transaction.
|
|
27667
|
+
* @param shouldDispatch Should dispatch or not.
|
|
27668
|
+
*/
|
|
27669
|
+
createChain(startTr, shouldDispatch = true) {
|
|
27670
|
+
const { editor, state: state2, rawCommands } = this;
|
|
27671
|
+
const { view } = editor;
|
|
27672
|
+
const callbacks2 = [];
|
|
27673
|
+
const hasStartTr = !!startTr;
|
|
27674
|
+
const tr = startTr || state2.tr;
|
|
27675
|
+
const run2 = () => {
|
|
27676
|
+
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
27677
|
+
view.dispatch(tr);
|
|
27678
|
+
}
|
|
27679
|
+
return callbacks2.every((cb) => cb === true);
|
|
27680
|
+
};
|
|
27681
|
+
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
27682
|
+
const chainedCommand = (...args) => {
|
|
27683
|
+
const props = this.createProps(tr, shouldDispatch);
|
|
27684
|
+
const callback = command2(...args)(props);
|
|
27685
|
+
callbacks2.push(callback);
|
|
27686
|
+
return chain;
|
|
27687
|
+
};
|
|
27688
|
+
return [name, chainedCommand];
|
|
27689
|
+
});
|
|
27690
|
+
const chain = {
|
|
27691
|
+
...Object.fromEntries(entries),
|
|
27692
|
+
run: run2
|
|
27693
|
+
};
|
|
27694
|
+
return chain;
|
|
27695
|
+
}
|
|
27696
|
+
/**
|
|
27697
|
+
* Creates a can check for commands.
|
|
27698
|
+
* @param startTr Start transaction.
|
|
27699
|
+
*/
|
|
27700
|
+
createCan(startTr) {
|
|
27701
|
+
const { rawCommands, state: state2 } = this;
|
|
27702
|
+
const dispatch = false;
|
|
27703
|
+
const tr = startTr || state2.tr;
|
|
27704
|
+
const props = this.createProps(tr, dispatch);
|
|
27705
|
+
const commands2 = Object.fromEntries(
|
|
27706
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27707
|
+
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
27708
|
+
})
|
|
27709
|
+
);
|
|
27710
|
+
return {
|
|
27711
|
+
...commands2,
|
|
27712
|
+
chain: () => this.createChain(tr, dispatch)
|
|
27713
|
+
};
|
|
27714
|
+
}
|
|
27715
|
+
/**
|
|
27716
|
+
* Creates default props for the command method.
|
|
27717
|
+
* @param {*} tr Transaction.
|
|
27718
|
+
* @param {*} shouldDispatch Check if should dispatch.
|
|
27719
|
+
* @returns Object with props.
|
|
27720
|
+
*/
|
|
27721
|
+
createProps(tr, shouldDispatch = true) {
|
|
27722
|
+
const { editor, state: state2, rawCommands } = this;
|
|
27723
|
+
const { view } = editor;
|
|
27724
|
+
const props = {
|
|
27725
|
+
tr,
|
|
27726
|
+
editor,
|
|
27727
|
+
view,
|
|
27728
|
+
state: chainableEditorState(tr, state2),
|
|
27729
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
27730
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
27731
|
+
can: () => this.createCan(tr),
|
|
27732
|
+
get commands() {
|
|
27733
|
+
return Object.fromEntries(
|
|
27734
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
27735
|
+
return [name, (...args) => command2(...args)(props)];
|
|
27736
|
+
})
|
|
27737
|
+
);
|
|
27738
|
+
}
|
|
27739
|
+
};
|
|
27740
|
+
return props;
|
|
27741
|
+
}
|
|
27742
|
+
}
|
|
28164
27743
|
const first = (commands2) => (props) => {
|
|
28165
27744
|
const items = typeof commands2 === "function" ? commands2(props) : commands2;
|
|
28166
27745
|
for (let i = 0; i < items.length; i += 1) {
|
|
@@ -28522,7 +28101,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28522
28101
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
28523
28102
|
wrap2 = Fragment.from(conn[i].create(null, wrap2));
|
|
28524
28103
|
wrap2 = Fragment.from(before.copy(wrap2));
|
|
28525
|
-
let tr = state2.tr.step(new ReplaceAroundStep
|
|
28104
|
+
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
28526
28105
|
let $joinAt = tr.doc.resolve(end2 + 2 * conn.length);
|
|
28527
28106
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
|
|
28528
28107
|
tr.join($joinAt.pos);
|
|
@@ -28553,7 +28132,7 @@ function deleteBarrier(state2, $cut, dispatch, dir) {
|
|
|
28553
28132
|
let end2 = Fragment.empty;
|
|
28554
28133
|
for (let i = wrap2.length - 1; i >= 0; i--)
|
|
28555
28134
|
end2 = Fragment.from(wrap2[i].copy(end2));
|
|
28556
|
-
let tr = state2.tr.step(new ReplaceAroundStep
|
|
28135
|
+
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - wrap2.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end2, wrap2.length, 0), 0, true));
|
|
28557
28136
|
dispatch(tr.scrollIntoView());
|
|
28558
28137
|
}
|
|
28559
28138
|
return true;
|
|
@@ -29126,7 +28705,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
29126
28705
|
return;
|
|
29127
28706
|
}
|
|
29128
28707
|
const step = tr.steps[last];
|
|
29129
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
28708
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
29130
28709
|
return;
|
|
29131
28710
|
}
|
|
29132
28711
|
const map22 = tr.mapping.maps[last];
|
|
@@ -29272,7 +28851,7 @@ function doWrapInList(tr, range2, wrappers, joinBefore, listType) {
|
|
|
29272
28851
|
let content = Fragment.empty;
|
|
29273
28852
|
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
29274
28853
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
29275
|
-
tr.step(new ReplaceAroundStep
|
|
28854
|
+
tr.step(new ReplaceAroundStep(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
29276
28855
|
let found2 = 0;
|
|
29277
28856
|
for (let i = 0; i < wrappers.length; i++)
|
|
29278
28857
|
if (wrappers[i].type == listType)
|
|
@@ -29305,7 +28884,7 @@ function liftListItem$1(itemType) {
|
|
|
29305
28884
|
function liftToOuterList(state2, dispatch, itemType, range2) {
|
|
29306
28885
|
let tr = state2.tr, end2 = range2.end, endOfList = range2.$to.end(range2.depth);
|
|
29307
28886
|
if (end2 < endOfList) {
|
|
29308
|
-
tr.step(new ReplaceAroundStep
|
|
28887
|
+
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
29309
28888
|
range2 = new NodeRange(tr.doc.resolve(range2.$from.pos), tr.doc.resolve(endOfList), range2.depth);
|
|
29310
28889
|
}
|
|
29311
28890
|
const target = liftTarget(range2);
|
|
@@ -29332,7 +28911,7 @@ function liftOutOfList(state2, dispatch, range2) {
|
|
|
29332
28911
|
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))
|
|
29333
28912
|
return false;
|
|
29334
28913
|
let start2 = $start.pos, end2 = start2 + item.nodeSize;
|
|
29335
|
-
tr.step(new ReplaceAroundStep
|
|
28914
|
+
tr.step(new ReplaceAroundStep(start2 - (atStart ? 1 : 0), end2 + (atEnd ? 1 : 0), start2 + 1, end2 - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
29336
28915
|
dispatch(tr.scrollIntoView());
|
|
29337
28916
|
return true;
|
|
29338
28917
|
}
|
|
@@ -29353,7 +28932,7 @@ function sinkListItem$1(itemType) {
|
|
|
29353
28932
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
29354
28933
|
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
29355
28934
|
let before = range2.start, after = range2.end;
|
|
29356
|
-
dispatch(state2.tr.step(new ReplaceAroundStep
|
|
28935
|
+
dispatch(state2.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
29357
28936
|
}
|
|
29358
28937
|
return true;
|
|
29359
28938
|
};
|
|
@@ -36946,8 +36525,7 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
|
|
|
36946
36525
|
binding.mapping
|
|
36947
36526
|
);
|
|
36948
36527
|
if (anchor !== null && head !== null) {
|
|
36949
|
-
|
|
36950
|
-
tr.setSelection(sel);
|
|
36528
|
+
tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));
|
|
36951
36529
|
}
|
|
36952
36530
|
}
|
|
36953
36531
|
}
|
|
@@ -37728,7 +37306,7 @@ const setMeta = (view, key, value) => {
|
|
|
37728
37306
|
};
|
|
37729
37307
|
const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
37730
37308
|
if (pos === 0) {
|
|
37731
|
-
return Y.createRelativePositionFromTypeIndex(type2, 0,
|
|
37309
|
+
return Y.createRelativePositionFromTypeIndex(type2, 0, -1);
|
|
37732
37310
|
}
|
|
37733
37311
|
let n = type2._first === null ? null : (
|
|
37734
37312
|
/** @type {Y.ContentType} */
|
|
@@ -37737,7 +37315,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37737
37315
|
while (n !== null && type2 !== n) {
|
|
37738
37316
|
if (n instanceof Y.XmlText) {
|
|
37739
37317
|
if (n._length >= pos) {
|
|
37740
|
-
return Y.createRelativePositionFromTypeIndex(n, pos,
|
|
37318
|
+
return Y.createRelativePositionFromTypeIndex(n, pos, -1);
|
|
37741
37319
|
} else {
|
|
37742
37320
|
pos -= n._length;
|
|
37743
37321
|
}
|
|
@@ -37801,7 +37379,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
|
37801
37379
|
return createRelativePosition(n._item.parent, n._item);
|
|
37802
37380
|
}
|
|
37803
37381
|
}
|
|
37804
|
-
return Y.createRelativePositionFromTypeIndex(type2, type2._length,
|
|
37382
|
+
return Y.createRelativePositionFromTypeIndex(type2, type2._length, -1);
|
|
37805
37383
|
};
|
|
37806
37384
|
const createRelativePosition = (type2, item) => {
|
|
37807
37385
|
let typeid = null;
|
|
@@ -38398,6 +37976,409 @@ function isExtensionRulesEnabled(extension, enabled) {
|
|
|
38398
37976
|
}
|
|
38399
37977
|
return enabled;
|
|
38400
37978
|
}
|
|
37979
|
+
function getHTMLFromFragment(fragment, schema) {
|
|
37980
|
+
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
37981
|
+
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
37982
|
+
const container = temporaryDocument.createElement("div");
|
|
37983
|
+
container.appendChild(documentFragment);
|
|
37984
|
+
return container.innerHTML;
|
|
37985
|
+
}
|
|
37986
|
+
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
37987
|
+
let textBefore = "";
|
|
37988
|
+
const sliceEndPos = $from.parentOffset;
|
|
37989
|
+
$from.parent.nodesBetween(
|
|
37990
|
+
Math.max(0, sliceEndPos - maxMatch),
|
|
37991
|
+
sliceEndPos,
|
|
37992
|
+
(node2, pos, parent, index2) => {
|
|
37993
|
+
const chunk = node2.type.spec.toText?.({
|
|
37994
|
+
node: node2,
|
|
37995
|
+
pos,
|
|
37996
|
+
parent,
|
|
37997
|
+
index: index2
|
|
37998
|
+
}) || node2.textContent || "%leaf%";
|
|
37999
|
+
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
38000
|
+
}
|
|
38001
|
+
);
|
|
38002
|
+
return textBefore;
|
|
38003
|
+
};
|
|
38004
|
+
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
38005
|
+
const { converter } = editor;
|
|
38006
|
+
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
38007
|
+
let cleanedHtml = convertEmToPt(html);
|
|
38008
|
+
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
38009
|
+
const tempDiv = document.createElement("div");
|
|
38010
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
38011
|
+
const paragraphs = tempDiv.querySelectorAll("p");
|
|
38012
|
+
paragraphs.forEach((p) => {
|
|
38013
|
+
const innerHTML3 = p.innerHTML;
|
|
38014
|
+
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
38015
|
+
const styleAttr = p.getAttribute("style") || "";
|
|
38016
|
+
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
38017
|
+
if (msoListMatch) {
|
|
38018
|
+
const [, abstractId, level] = msoListMatch;
|
|
38019
|
+
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
38020
|
+
if (!listNumId) return;
|
|
38021
|
+
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
38022
|
+
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
38023
|
+
p.setAttribute("data-num-id", listNumId);
|
|
38024
|
+
p.setAttribute("data-list-level", level - 1);
|
|
38025
|
+
p.setAttribute("data-start", start2);
|
|
38026
|
+
p.setAttribute("data-lvl-text", lvlText);
|
|
38027
|
+
p.setAttribute("data-num-fmt", numFmt);
|
|
38028
|
+
}
|
|
38029
|
+
extractAndRemoveConditionalPrefix(p);
|
|
38030
|
+
});
|
|
38031
|
+
transformWordLists(tempDiv);
|
|
38032
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38033
|
+
tempDiv.remove();
|
|
38034
|
+
const { dispatch } = editor.view;
|
|
38035
|
+
if (!dispatch) return false;
|
|
38036
|
+
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
38037
|
+
return true;
|
|
38038
|
+
};
|
|
38039
|
+
const getLevelDefinition = (abstractDefinition, level) => {
|
|
38040
|
+
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
38041
|
+
const levelElement = abstractDefinition.elements.find((el) => {
|
|
38042
|
+
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
38043
|
+
});
|
|
38044
|
+
if (!levelElement) return null;
|
|
38045
|
+
const { elements } = levelElement;
|
|
38046
|
+
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
38047
|
+
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
38048
|
+
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
38049
|
+
return { lvlText, start: start2, numFmt, elements };
|
|
38050
|
+
};
|
|
38051
|
+
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
38052
|
+
const { definitions } = editor?.converter?.numbering;
|
|
38053
|
+
if (!definitions) return null;
|
|
38054
|
+
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
38055
|
+
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
38056
|
+
});
|
|
38057
|
+
return matchedDefinition?.attributes?.["w:numId"];
|
|
38058
|
+
};
|
|
38059
|
+
const getListAbstractDefinition = (abstractId, editor) => {
|
|
38060
|
+
const { abstracts = {} } = editor?.converter?.numbering;
|
|
38061
|
+
return abstracts[abstractId] || null;
|
|
38062
|
+
};
|
|
38063
|
+
const transformWordLists = (container) => {
|
|
38064
|
+
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
38065
|
+
const listMap = /* @__PURE__ */ new Map();
|
|
38066
|
+
const listLevels = {};
|
|
38067
|
+
for (const p of paragraphs) {
|
|
38068
|
+
const listId = p.getAttribute("data-num-id");
|
|
38069
|
+
const level = parseInt(p.getAttribute("data-list-level"));
|
|
38070
|
+
const numFmt = p.getAttribute("data-num-fmt");
|
|
38071
|
+
const start2 = p.getAttribute("data-start");
|
|
38072
|
+
const lvlText = p.getAttribute("data-lvl-text");
|
|
38073
|
+
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
38074
|
+
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
38075
|
+
}
|
|
38076
|
+
for (const [id, items] of listMap.entries()) {
|
|
38077
|
+
if (!listLevels[id]) {
|
|
38078
|
+
listLevels[id] = {
|
|
38079
|
+
stack: [],
|
|
38080
|
+
counts: {},
|
|
38081
|
+
prevLevel: null
|
|
38082
|
+
};
|
|
38083
|
+
}
|
|
38084
|
+
const parentStack = [];
|
|
38085
|
+
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
38086
|
+
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
38087
|
+
const li = document.createElement("li");
|
|
38088
|
+
li.innerHTML = p.innerHTML;
|
|
38089
|
+
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
38090
|
+
li.setAttribute("data-num-id", id);
|
|
38091
|
+
li.setAttribute("data-lvl-text", lvlText);
|
|
38092
|
+
li.setAttribute("data-num-fmt", numFmt);
|
|
38093
|
+
if (p.hasAttribute("data-font-family")) {
|
|
38094
|
+
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
38095
|
+
}
|
|
38096
|
+
if (p.hasAttribute("data-font-size")) {
|
|
38097
|
+
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
38098
|
+
}
|
|
38099
|
+
const parentNode2 = p.parentNode;
|
|
38100
|
+
let listForLevel = parentStack[level];
|
|
38101
|
+
if (!listForLevel) {
|
|
38102
|
+
const newList = document.createElement("ol");
|
|
38103
|
+
newList.setAttribute("data-list-id", id);
|
|
38104
|
+
newList.level = level;
|
|
38105
|
+
if (level > 0) {
|
|
38106
|
+
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
38107
|
+
if (parentLi) parentLi.appendChild(newList);
|
|
38108
|
+
} else {
|
|
38109
|
+
parentNode2.insertBefore(newList, p);
|
|
38110
|
+
}
|
|
38111
|
+
parentStack[level] = newList;
|
|
38112
|
+
parentStack.length = level + 1;
|
|
38113
|
+
listForLevel = newList;
|
|
38114
|
+
}
|
|
38115
|
+
listForLevel.appendChild(li);
|
|
38116
|
+
p.remove();
|
|
38117
|
+
});
|
|
38118
|
+
}
|
|
38119
|
+
};
|
|
38120
|
+
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
38121
|
+
const levelState = listLevels[listId];
|
|
38122
|
+
if (!levelState.stack) levelState.stack = [];
|
|
38123
|
+
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
38124
|
+
if (levelState.prevLevel === null) {
|
|
38125
|
+
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
38126
|
+
} else {
|
|
38127
|
+
if (currentLevel > levelState.prevLevel) {
|
|
38128
|
+
levelState.stack.push(1);
|
|
38129
|
+
} else if (currentLevel === levelState.prevLevel) {
|
|
38130
|
+
levelState.stack[levelState.stack.length - 1]++;
|
|
38131
|
+
} else {
|
|
38132
|
+
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
38133
|
+
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
38134
|
+
}
|
|
38135
|
+
}
|
|
38136
|
+
levelState.prevLevel = currentLevel;
|
|
38137
|
+
return [...levelState.stack];
|
|
38138
|
+
}
|
|
38139
|
+
function extractAndRemoveConditionalPrefix(p) {
|
|
38140
|
+
const nodes = Array.from(p.childNodes);
|
|
38141
|
+
let fontFamily2 = null;
|
|
38142
|
+
let fontSize2 = null;
|
|
38143
|
+
let start2 = -1, end2 = -1;
|
|
38144
|
+
nodes.forEach((node2, index2) => {
|
|
38145
|
+
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
38146
|
+
start2 = index2;
|
|
38147
|
+
}
|
|
38148
|
+
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
38149
|
+
end2 = index2;
|
|
38150
|
+
}
|
|
38151
|
+
});
|
|
38152
|
+
if (start2 !== -1 && end2 !== -1) {
|
|
38153
|
+
for (let i = start2 + 1; i < end2; i++) {
|
|
38154
|
+
const node2 = nodes[i];
|
|
38155
|
+
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
38156
|
+
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
38157
|
+
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
38158
|
+
}
|
|
38159
|
+
}
|
|
38160
|
+
for (let i = end2; i >= start2; i--) {
|
|
38161
|
+
p.removeChild(p.childNodes[i]);
|
|
38162
|
+
}
|
|
38163
|
+
if (fontFamily2) p.setAttribute("data-font-family", fontFamily2);
|
|
38164
|
+
if (fontSize2) p.setAttribute("data-font-size", fontSize2);
|
|
38165
|
+
}
|
|
38166
|
+
}
|
|
38167
|
+
class InputRule {
|
|
38168
|
+
constructor(config) {
|
|
38169
|
+
__publicField$1(this, "match");
|
|
38170
|
+
__publicField$1(this, "handler");
|
|
38171
|
+
this.match = config.match;
|
|
38172
|
+
this.handler = config.handler;
|
|
38173
|
+
}
|
|
38174
|
+
}
|
|
38175
|
+
const inputRuleMatcherHandler = (text, match) => {
|
|
38176
|
+
if (isRegExp(match)) {
|
|
38177
|
+
return match.exec(text);
|
|
38178
|
+
}
|
|
38179
|
+
const inputRuleMatch = match(text);
|
|
38180
|
+
if (!inputRuleMatch) {
|
|
38181
|
+
return null;
|
|
38182
|
+
}
|
|
38183
|
+
const result = [inputRuleMatch.text];
|
|
38184
|
+
result.index = inputRuleMatch.index;
|
|
38185
|
+
result.input = text;
|
|
38186
|
+
result.data = inputRuleMatch.data;
|
|
38187
|
+
if (inputRuleMatch.replaceWith) {
|
|
38188
|
+
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
38189
|
+
console.warn(
|
|
38190
|
+
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
38191
|
+
);
|
|
38192
|
+
}
|
|
38193
|
+
result.push(inputRuleMatch.replaceWith);
|
|
38194
|
+
}
|
|
38195
|
+
return result;
|
|
38196
|
+
};
|
|
38197
|
+
const run = (config) => {
|
|
38198
|
+
const {
|
|
38199
|
+
editor,
|
|
38200
|
+
from: from2,
|
|
38201
|
+
to,
|
|
38202
|
+
text,
|
|
38203
|
+
rules,
|
|
38204
|
+
plugin: plugin2
|
|
38205
|
+
} = config;
|
|
38206
|
+
const { view } = editor;
|
|
38207
|
+
if (view.composing) {
|
|
38208
|
+
return false;
|
|
38209
|
+
}
|
|
38210
|
+
const $from = view.state.doc.resolve(from2);
|
|
38211
|
+
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
38212
|
+
return false;
|
|
38213
|
+
}
|
|
38214
|
+
let matched = false;
|
|
38215
|
+
const textBefore = getTextContentFromNodes($from) + text;
|
|
38216
|
+
rules.forEach((rule) => {
|
|
38217
|
+
if (matched) {
|
|
38218
|
+
return;
|
|
38219
|
+
}
|
|
38220
|
+
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
38221
|
+
if (!match) {
|
|
38222
|
+
return;
|
|
38223
|
+
}
|
|
38224
|
+
const tr = view.state.tr;
|
|
38225
|
+
const state2 = chainableEditorState(tr, view.state);
|
|
38226
|
+
const range2 = {
|
|
38227
|
+
from: from2 - (match[0].length - text.length),
|
|
38228
|
+
to
|
|
38229
|
+
};
|
|
38230
|
+
const { commands: commands2, chain, can } = new CommandService({
|
|
38231
|
+
editor,
|
|
38232
|
+
state: state2
|
|
38233
|
+
});
|
|
38234
|
+
const handler = rule.handler({
|
|
38235
|
+
state: state2,
|
|
38236
|
+
range: range2,
|
|
38237
|
+
match,
|
|
38238
|
+
commands: commands2,
|
|
38239
|
+
chain,
|
|
38240
|
+
can
|
|
38241
|
+
});
|
|
38242
|
+
if (handler === null || !tr.steps.length) {
|
|
38243
|
+
return;
|
|
38244
|
+
}
|
|
38245
|
+
tr.setMeta(plugin2, {
|
|
38246
|
+
transform: tr,
|
|
38247
|
+
from: from2,
|
|
38248
|
+
to,
|
|
38249
|
+
text
|
|
38250
|
+
});
|
|
38251
|
+
view.dispatch(tr);
|
|
38252
|
+
matched = true;
|
|
38253
|
+
});
|
|
38254
|
+
return matched;
|
|
38255
|
+
};
|
|
38256
|
+
const inputRulesPlugin = ({ editor, rules }) => {
|
|
38257
|
+
const plugin2 = new Plugin({
|
|
38258
|
+
key: new PluginKey("inputRulesPlugin"),
|
|
38259
|
+
state: {
|
|
38260
|
+
init() {
|
|
38261
|
+
return null;
|
|
38262
|
+
},
|
|
38263
|
+
apply(tr, prev, state2) {
|
|
38264
|
+
const stored = tr.getMeta(plugin2);
|
|
38265
|
+
if (stored) {
|
|
38266
|
+
return stored;
|
|
38267
|
+
}
|
|
38268
|
+
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
38269
|
+
const isSimulatedInput = !!simulatedInputMeta;
|
|
38270
|
+
if (isSimulatedInput) {
|
|
38271
|
+
setTimeout(() => {
|
|
38272
|
+
let { text } = simulatedInputMeta;
|
|
38273
|
+
if (typeof text !== "string") {
|
|
38274
|
+
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
38275
|
+
}
|
|
38276
|
+
const { from: from2 } = simulatedInputMeta;
|
|
38277
|
+
const to = from2 + text.length;
|
|
38278
|
+
run({
|
|
38279
|
+
editor,
|
|
38280
|
+
from: from2,
|
|
38281
|
+
to,
|
|
38282
|
+
text,
|
|
38283
|
+
rules,
|
|
38284
|
+
plugin: plugin2
|
|
38285
|
+
});
|
|
38286
|
+
});
|
|
38287
|
+
}
|
|
38288
|
+
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
38289
|
+
}
|
|
38290
|
+
},
|
|
38291
|
+
props: {
|
|
38292
|
+
handleTextInput(view, from2, to, text) {
|
|
38293
|
+
return run({
|
|
38294
|
+
editor,
|
|
38295
|
+
from: from2,
|
|
38296
|
+
to,
|
|
38297
|
+
text,
|
|
38298
|
+
rules,
|
|
38299
|
+
plugin: plugin2
|
|
38300
|
+
});
|
|
38301
|
+
},
|
|
38302
|
+
// add support for input rules to trigger on enter
|
|
38303
|
+
// this is useful for example for code blocks
|
|
38304
|
+
handleKeyDown(view, event) {
|
|
38305
|
+
if (event.key !== "Enter") {
|
|
38306
|
+
return false;
|
|
38307
|
+
}
|
|
38308
|
+
const { $cursor } = view.state.selection;
|
|
38309
|
+
if ($cursor) {
|
|
38310
|
+
return run({
|
|
38311
|
+
editor,
|
|
38312
|
+
from: $cursor.pos,
|
|
38313
|
+
to: $cursor.pos,
|
|
38314
|
+
text: "\n",
|
|
38315
|
+
rules,
|
|
38316
|
+
plugin: plugin2
|
|
38317
|
+
});
|
|
38318
|
+
}
|
|
38319
|
+
return false;
|
|
38320
|
+
},
|
|
38321
|
+
// Paste handler
|
|
38322
|
+
handlePaste(view, event, slice2) {
|
|
38323
|
+
const clipboard = event.clipboardData;
|
|
38324
|
+
const html = clipboard.getData("text/html");
|
|
38325
|
+
clipboard.getData("text/plain");
|
|
38326
|
+
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
38327
|
+
if (fieldAnnotationContent.length) {
|
|
38328
|
+
return false;
|
|
38329
|
+
}
|
|
38330
|
+
let source;
|
|
38331
|
+
if (!html) {
|
|
38332
|
+
source = "plain-text";
|
|
38333
|
+
} else if (isWordHtml(html)) {
|
|
38334
|
+
source = "word-html";
|
|
38335
|
+
} else {
|
|
38336
|
+
source = "browser-html";
|
|
38337
|
+
}
|
|
38338
|
+
switch (source) {
|
|
38339
|
+
case "plain-text":
|
|
38340
|
+
break;
|
|
38341
|
+
case "word-html":
|
|
38342
|
+
if (editor.options.mode === "docx") {
|
|
38343
|
+
return handleDocxPaste(html, editor, view, plugin2);
|
|
38344
|
+
}
|
|
38345
|
+
case "browser-html":
|
|
38346
|
+
return handleHtmlPaste$1(html, editor);
|
|
38347
|
+
}
|
|
38348
|
+
return false;
|
|
38349
|
+
}
|
|
38350
|
+
},
|
|
38351
|
+
isInputRules: true
|
|
38352
|
+
});
|
|
38353
|
+
return plugin2;
|
|
38354
|
+
};
|
|
38355
|
+
function isWordHtml(html) {
|
|
38356
|
+
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
38357
|
+
}
|
|
38358
|
+
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
38359
|
+
const cleanedHtml = convertEmToPt(html);
|
|
38360
|
+
const tempDiv = document.createElement("div");
|
|
38361
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
38362
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
38363
|
+
tempDiv.remove();
|
|
38364
|
+
const { dispatch } = editor.view;
|
|
38365
|
+
if (!dispatch) return false;
|
|
38366
|
+
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
38367
|
+
return true;
|
|
38368
|
+
};
|
|
38369
|
+
const convertEmToPt = (html) => {
|
|
38370
|
+
return html.replace(
|
|
38371
|
+
/font-size\s*:\s*([\d.]+)em/gi,
|
|
38372
|
+
(_, emValue) => {
|
|
38373
|
+
const em = parseFloat(emValue);
|
|
38374
|
+
const pt = Math.round(em * 12 * 100) / 100;
|
|
38375
|
+
return `font-size: ${pt}pt`;
|
|
38376
|
+
}
|
|
38377
|
+
);
|
|
38378
|
+
};
|
|
38379
|
+
function cleanHtmlUnnecessaryTags(html) {
|
|
38380
|
+
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
38381
|
+
}
|
|
38401
38382
|
const _ExtensionService = class _ExtensionService2 {
|
|
38402
38383
|
constructor(extensions, userExtensions, editor) {
|
|
38403
38384
|
__privateAdd$1(this, _ExtensionService_instances);
|
|
@@ -39236,7 +39217,6 @@ const createHeaderFooterEditor = ({
|
|
|
39236
39217
|
mediaFiles: editor.storage.image.media,
|
|
39237
39218
|
fonts: editor.options.fonts,
|
|
39238
39219
|
isHeaderOrFooter: true,
|
|
39239
|
-
isHeadless: editor.options.isHeadless,
|
|
39240
39220
|
annotations: true,
|
|
39241
39221
|
currentPageNumber,
|
|
39242
39222
|
parentEditor: editor,
|
|
@@ -39244,15 +39224,13 @@ const createHeaderFooterEditor = ({
|
|
|
39244
39224
|
onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
|
|
39245
39225
|
});
|
|
39246
39226
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
39247
|
-
|
|
39248
|
-
|
|
39249
|
-
|
|
39250
|
-
|
|
39251
|
-
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
39255
|
-
}
|
|
39227
|
+
pm.style.maxHeight = "100%";
|
|
39228
|
+
pm.style.minHeight = "100%";
|
|
39229
|
+
pm.style.outline = "none";
|
|
39230
|
+
pm.style.border = "none";
|
|
39231
|
+
pm.setAttribute("role", "textbox");
|
|
39232
|
+
pm.setAttribute("aria-multiline", true);
|
|
39233
|
+
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
39256
39234
|
return headerFooterEditor;
|
|
39257
39235
|
};
|
|
39258
39236
|
const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
@@ -39271,16 +39249,14 @@ const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
|
39271
39249
|
});
|
|
39272
39250
|
});
|
|
39273
39251
|
};
|
|
39274
|
-
const toggleHeaderFooterEditMode = (
|
|
39252
|
+
const toggleHeaderFooterEditMode = (editor, focusedSectionEditor, isEditMode) => {
|
|
39275
39253
|
editor.converter.headerEditors.forEach((item) => {
|
|
39276
39254
|
item.editor.setEditable(isEditMode, false);
|
|
39277
39255
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39278
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39279
39256
|
});
|
|
39280
39257
|
editor.converter.footerEditors.forEach((item) => {
|
|
39281
39258
|
item.editor.setEditable(isEditMode, false);
|
|
39282
39259
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
39283
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
39284
39260
|
});
|
|
39285
39261
|
if (isEditMode) {
|
|
39286
39262
|
const pm = document.querySelector(".ProseMirror");
|
|
@@ -40610,16 +40586,6 @@ const setWordSelection = (view, pos) => {
|
|
|
40610
40586
|
const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
|
|
40611
40587
|
dispatch(tr);
|
|
40612
40588
|
};
|
|
40613
|
-
const setImageNodeSelection = (view, pos) => {
|
|
40614
|
-
const { doc: doc2 } = view.state;
|
|
40615
|
-
const node2 = doc2.nodeAt(pos);
|
|
40616
|
-
if (node2 && node2.type.name === "image") {
|
|
40617
|
-
const tr = view.state.tr.setSelection(NodeSelection.create(doc2, pos));
|
|
40618
|
-
view.dispatch(tr);
|
|
40619
|
-
return true;
|
|
40620
|
-
}
|
|
40621
|
-
return false;
|
|
40622
|
-
};
|
|
40623
40589
|
const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
40624
40590
|
/**
|
|
40625
40591
|
* Create a new Editor instance
|
|
@@ -40718,19 +40684,6 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40718
40684
|
this.setHighContrastMode = setHighContrastMode;
|
|
40719
40685
|
initMode();
|
|
40720
40686
|
}
|
|
40721
|
-
mount(el) {
|
|
40722
|
-
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
40723
|
-
window.setTimeout(() => {
|
|
40724
|
-
if (this.isDestroyed) return;
|
|
40725
|
-
this.emit("create", { editor: this });
|
|
40726
|
-
}, 0);
|
|
40727
|
-
}
|
|
40728
|
-
unmount() {
|
|
40729
|
-
if (this.view) {
|
|
40730
|
-
this.view.destroy();
|
|
40731
|
-
}
|
|
40732
|
-
this.view = null;
|
|
40733
|
-
}
|
|
40734
40687
|
/**
|
|
40735
40688
|
* Set the toolbar for this editor
|
|
40736
40689
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -40779,7 +40732,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40779
40732
|
* @returns {boolean}
|
|
40780
40733
|
*/
|
|
40781
40734
|
get isDestroyed() {
|
|
40782
|
-
return this.view
|
|
40735
|
+
return this.view.isDestroyed;
|
|
40783
40736
|
}
|
|
40784
40737
|
/**
|
|
40785
40738
|
* Get the editor element
|
|
@@ -40822,12 +40775,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40822
40775
|
this.commands.toggleTrackChangesShowOriginal();
|
|
40823
40776
|
this.setEditable(false, false);
|
|
40824
40777
|
this.setOptions({ documentMode: "viewing" });
|
|
40825
|
-
toggleHeaderFooterEditMode(
|
|
40826
|
-
editor: this,
|
|
40827
|
-
focusedSectionEditor: null,
|
|
40828
|
-
isEditMode: false,
|
|
40829
|
-
documentMode: cleanedMode
|
|
40830
|
-
});
|
|
40778
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
40831
40779
|
} else if (cleanedMode === "suggesting") {
|
|
40832
40780
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
40833
40781
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -40840,12 +40788,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40840
40788
|
this.commands.disableTrackChanges();
|
|
40841
40789
|
this.setEditable(true, false);
|
|
40842
40790
|
this.setOptions({ documentMode: "editing" });
|
|
40843
|
-
toggleHeaderFooterEditMode(
|
|
40844
|
-
editor: this,
|
|
40845
|
-
focusedSectionEditor: null,
|
|
40846
|
-
isEditMode: false,
|
|
40847
|
-
documentMode: cleanedMode
|
|
40848
|
-
});
|
|
40791
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
40849
40792
|
}
|
|
40850
40793
|
}
|
|
40851
40794
|
/**
|
|
@@ -41022,26 +40965,29 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41022
40965
|
};
|
|
41023
40966
|
}
|
|
41024
40967
|
/**
|
|
41025
|
-
|
|
41026
|
-
|
|
41027
|
-
|
|
40968
|
+
* Initialize default styles for the editor container and ProseMirror.
|
|
40969
|
+
* Get page size and margins from the converter.
|
|
40970
|
+
* Set document default font and font size.
|
|
40971
|
+
*
|
|
40972
|
+
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
40973
|
+
* @returns {void}
|
|
40974
|
+
*/
|
|
40975
|
+
initDefaultStyles(element = this.element) {
|
|
40976
|
+
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
40977
|
+
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41028
40978
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
41029
|
-
if (!proseMirror || !
|
|
40979
|
+
if (!proseMirror || !pageSize || !pageMargins) {
|
|
41030
40980
|
return;
|
|
41031
40981
|
}
|
|
41032
40982
|
proseMirror.setAttribute("role", "document");
|
|
41033
40983
|
proseMirror.setAttribute("aria-multiline", true);
|
|
41034
40984
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
41035
40985
|
proseMirror.setAttribute("aria-description", "");
|
|
41036
|
-
|
|
41037
|
-
|
|
41038
|
-
|
|
41039
|
-
|
|
41040
|
-
|
|
41041
|
-
if (pageMargins) {
|
|
41042
|
-
element.style.paddingLeft = pageMargins.left + "in";
|
|
41043
|
-
element.style.paddingRight = pageMargins.right + "in";
|
|
41044
|
-
}
|
|
40986
|
+
element.style.width = pageSize.width + "in";
|
|
40987
|
+
element.style.minWidth = pageSize.width + "in";
|
|
40988
|
+
element.style.minHeight = pageSize.height + "in";
|
|
40989
|
+
element.style.paddingLeft = pageMargins.left + "in";
|
|
40990
|
+
element.style.paddingRight = pageMargins.right + "in";
|
|
41045
40991
|
element.style.boxSizing = "border-box";
|
|
41046
40992
|
element.style.isolation = "isolate";
|
|
41047
40993
|
proseMirror.style.outline = "none";
|
|
@@ -41062,19 +41008,6 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41062
41008
|
proseMirror.style.paddingTop = "1in";
|
|
41063
41009
|
proseMirror.style.paddingBottom = "1in";
|
|
41064
41010
|
}
|
|
41065
|
-
}
|
|
41066
|
-
/**
|
|
41067
|
-
* Initialize default styles for the editor container and ProseMirror.
|
|
41068
|
-
* Get page size and margins from the converter.
|
|
41069
|
-
* Set document default font and font size.
|
|
41070
|
-
*
|
|
41071
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
41072
|
-
* @returns {void}
|
|
41073
|
-
*/
|
|
41074
|
-
initDefaultStyles(element = this.element) {
|
|
41075
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
41076
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
41077
|
-
this.updateEditorStyles(element, proseMirror);
|
|
41078
41011
|
this.initMobileStyles(element);
|
|
41079
41012
|
}
|
|
41080
41013
|
/**
|
|
@@ -41286,22 +41219,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41286
41219
|
*/
|
|
41287
41220
|
destroy() {
|
|
41288
41221
|
this.emit("destroy");
|
|
41289
|
-
this.
|
|
41290
|
-
this.destroyHeaderFooterEditors();
|
|
41222
|
+
if (this.view) this.view.destroy();
|
|
41291
41223
|
__privateMethod$1(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
41292
41224
|
this.removeAllListeners();
|
|
41293
41225
|
}
|
|
41294
|
-
destroyHeaderFooterEditors() {
|
|
41295
|
-
const editors = [
|
|
41296
|
-
...this.converter.headerEditors,
|
|
41297
|
-
...this.converter.footerEditors
|
|
41298
|
-
];
|
|
41299
|
-
for (let editorData of editors) {
|
|
41300
|
-
editorData.editor.destroy();
|
|
41301
|
-
}
|
|
41302
|
-
this.converter.headerEditors.length = 0;
|
|
41303
|
-
this.converter.footerEditors.length = 0;
|
|
41304
|
-
}
|
|
41305
41226
|
/**
|
|
41306
41227
|
* Check if migrations are needed for the data
|
|
41307
41228
|
* @static
|
|
@@ -41319,7 +41240,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41319
41240
|
* @returns {Object | void} Migration results
|
|
41320
41241
|
*/
|
|
41321
41242
|
processCollaborationMigrations() {
|
|
41322
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.2
|
|
41243
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2");
|
|
41323
41244
|
if (!this.options.ydoc) return;
|
|
41324
41245
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
41325
41246
|
let docVersion = metaMap.get("version");
|
|
@@ -41363,7 +41284,6 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41363
41284
|
__privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
|
|
41364
41285
|
this.initDefaultStyles();
|
|
41365
41286
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
41366
|
-
updateYdocDocxData(this);
|
|
41367
41287
|
this.initializeCollaborationData(true);
|
|
41368
41288
|
} else {
|
|
41369
41289
|
__privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -41515,7 +41435,7 @@ init_fn = function(options2) {
|
|
|
41515
41435
|
this.emit("beforeCreate", { editor: this });
|
|
41516
41436
|
this.on("contentError", this.options.onContentError);
|
|
41517
41437
|
this.on("exception", this.options.onException);
|
|
41518
|
-
this.
|
|
41438
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
41519
41439
|
this.initDefaultStyles();
|
|
41520
41440
|
this.setDocumentMode(options2.documentMode);
|
|
41521
41441
|
if (this.options.isHeadless) return;
|
|
@@ -41539,6 +41459,10 @@ init_fn = function(options2) {
|
|
|
41539
41459
|
__privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
|
|
41540
41460
|
__privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
|
|
41541
41461
|
}
|
|
41462
|
+
window.setTimeout(() => {
|
|
41463
|
+
if (this.isDestroyed) return;
|
|
41464
|
+
this.emit("create", { editor: this });
|
|
41465
|
+
}, 0);
|
|
41542
41466
|
};
|
|
41543
41467
|
initRichText_fn = function(options2) {
|
|
41544
41468
|
if (!options2.extensions || !options2.extensions.length) {
|
|
@@ -41550,7 +41474,7 @@ initRichText_fn = function(options2) {
|
|
|
41550
41474
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
41551
41475
|
this.emit("beforeCreate", { editor: this });
|
|
41552
41476
|
this.on("contentError", this.options.onContentError);
|
|
41553
|
-
this.
|
|
41477
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
41554
41478
|
this.on("create", this.options.onCreate);
|
|
41555
41479
|
this.on("update", this.options.onUpdate);
|
|
41556
41480
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -41561,6 +41485,10 @@ initRichText_fn = function(options2) {
|
|
|
41561
41485
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
41562
41486
|
this.on("commentClick", this.options.onCommentClicked);
|
|
41563
41487
|
this.on("locked", this.options.onDocumentLocked);
|
|
41488
|
+
window.setTimeout(() => {
|
|
41489
|
+
if (this.isDestroyed) return;
|
|
41490
|
+
this.emit("create", { editor: this });
|
|
41491
|
+
}, 0);
|
|
41564
41492
|
};
|
|
41565
41493
|
onFocus_fn = function({ editor, event }) {
|
|
41566
41494
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -41681,15 +41609,14 @@ createDocFromHTML_fn = function(content) {
|
|
|
41681
41609
|
}
|
|
41682
41610
|
return DOMParser$1.fromSchema(this.schema).parse(parsedContent);
|
|
41683
41611
|
};
|
|
41684
|
-
createView_fn = function(
|
|
41612
|
+
createView_fn = function() {
|
|
41685
41613
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
41686
41614
|
const state2 = { schema: this.schema };
|
|
41687
41615
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
41688
|
-
this.view = new EditorView(element, {
|
|
41616
|
+
this.view = new EditorView(this.options.element, {
|
|
41689
41617
|
...this.options.editorProps,
|
|
41690
41618
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
41691
41619
|
state: EditorState.create(state2),
|
|
41692
|
-
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
41693
41620
|
handleDoubleClick: async (view, pos, event) => {
|
|
41694
41621
|
if (this.options.documentMode !== "editing") return;
|
|
41695
41622
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -41703,12 +41630,7 @@ createView_fn = function(element) {
|
|
|
41703
41630
|
event.stopPropagation();
|
|
41704
41631
|
if (!this.options.editable) {
|
|
41705
41632
|
this.setEditable(true, false);
|
|
41706
|
-
toggleHeaderFooterEditMode(
|
|
41707
|
-
editor: this,
|
|
41708
|
-
focusedSectionEditor: null,
|
|
41709
|
-
isEditMode: false,
|
|
41710
|
-
documentMode: this.options.documentMode
|
|
41711
|
-
});
|
|
41633
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
41712
41634
|
const pm = document.querySelector(".ProseMirror");
|
|
41713
41635
|
pm.classList.remove("header-footer-edit");
|
|
41714
41636
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -41721,6 +41643,8 @@ createView_fn = function(element) {
|
|
|
41721
41643
|
});
|
|
41722
41644
|
this.view.updateState(newState);
|
|
41723
41645
|
this.createNodeViews();
|
|
41646
|
+
const dom = this.view.dom;
|
|
41647
|
+
dom.editor = this;
|
|
41724
41648
|
this.options.telemetry?.sendReport();
|
|
41725
41649
|
};
|
|
41726
41650
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
@@ -41747,9 +41671,7 @@ initComments_fn = function() {
|
|
|
41747
41671
|
}, 50);
|
|
41748
41672
|
};
|
|
41749
41673
|
initPagination_fn = async function() {
|
|
41750
|
-
if (this.options.isHeadless || !this.extensionService
|
|
41751
|
-
return;
|
|
41752
|
-
}
|
|
41674
|
+
if (this.options.isHeadless || !this.extensionService) return;
|
|
41753
41675
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
41754
41676
|
if (pagination && this.options.pagination) {
|
|
41755
41677
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -41761,7 +41683,7 @@ initPagination_fn = async function() {
|
|
|
41761
41683
|
}
|
|
41762
41684
|
};
|
|
41763
41685
|
dispatchTransaction_fn = function(transaction) {
|
|
41764
|
-
if (this.isDestroyed) return;
|
|
41686
|
+
if (this.view.isDestroyed) return;
|
|
41765
41687
|
let state2;
|
|
41766
41688
|
try {
|
|
41767
41689
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -41813,11 +41735,6 @@ dispatchTransaction_fn = function(transaction) {
|
|
|
41813
41735
|
transaction
|
|
41814
41736
|
});
|
|
41815
41737
|
};
|
|
41816
|
-
handleNodeSelection_fn = function(view, pos) {
|
|
41817
|
-
if (this.options.isHeaderOrFooter) {
|
|
41818
|
-
return setImageNodeSelection(view, pos);
|
|
41819
|
-
}
|
|
41820
|
-
};
|
|
41821
41738
|
prepareDocumentForImport_fn = function(doc2) {
|
|
41822
41739
|
const newState = EditorState.create({
|
|
41823
41740
|
schema: this.schema,
|
|
@@ -44160,7 +44077,7 @@ const Paragraph = Node$1.create({
|
|
|
44160
44077
|
},
|
|
44161
44078
|
addPmPlugins() {
|
|
44162
44079
|
const { view } = this.editor;
|
|
44163
|
-
new Plugin({
|
|
44080
|
+
const dropcapPlugin = new Plugin({
|
|
44164
44081
|
name: "dropcapPlugin",
|
|
44165
44082
|
key: new PluginKey("dropcapPlugin"),
|
|
44166
44083
|
state: {
|
|
@@ -44180,7 +44097,7 @@ const Paragraph = Node$1.create({
|
|
|
44180
44097
|
}
|
|
44181
44098
|
}
|
|
44182
44099
|
});
|
|
44183
|
-
return [];
|
|
44100
|
+
return [dropcapPlugin];
|
|
44184
44101
|
}
|
|
44185
44102
|
});
|
|
44186
44103
|
const getDropcapDecorations = (state2, view) => {
|
|
@@ -44533,16 +44450,7 @@ const HardBreak = Node$1.create({
|
|
|
44533
44450
|
};
|
|
44534
44451
|
},
|
|
44535
44452
|
parseDOM() {
|
|
44536
|
-
return [{
|
|
44537
|
-
tag: 'span[linebreaktype="page"]',
|
|
44538
|
-
getAttrs: (dom) => {
|
|
44539
|
-
if (!(dom instanceof HTMLElement)) return false;
|
|
44540
|
-
return {
|
|
44541
|
-
pageBreakSource: dom.getAttribute("pagebreaksource") || null,
|
|
44542
|
-
pageBreakType: dom.getAttribute("linebreaktype") || null
|
|
44543
|
-
};
|
|
44544
|
-
}
|
|
44545
|
-
}];
|
|
44453
|
+
return [{ tag: "span" }];
|
|
44546
44454
|
},
|
|
44547
44455
|
renderDOM({ htmlAttributes }) {
|
|
44548
44456
|
return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -47539,8 +47447,6 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47539
47447
|
if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true) {
|
|
47540
47448
|
return removedNodes;
|
|
47541
47449
|
}
|
|
47542
|
-
const hasDeletion = transactionDeletedAnything(tr);
|
|
47543
|
-
if (!hasDeletion) return removedNodes;
|
|
47544
47450
|
tr.steps.forEach((step, stepIndex) => {
|
|
47545
47451
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
47546
47452
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -47557,14 +47463,6 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
47557
47463
|
});
|
|
47558
47464
|
return removedNodes;
|
|
47559
47465
|
}
|
|
47560
|
-
function transactionDeletedAnything(tr) {
|
|
47561
|
-
return tr.steps.some((step) => {
|
|
47562
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) {
|
|
47563
|
-
return step.from !== step.to;
|
|
47564
|
-
}
|
|
47565
|
-
return false;
|
|
47566
|
-
});
|
|
47567
|
-
}
|
|
47568
47466
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
47569
47467
|
let removedAnnotations = [];
|
|
47570
47468
|
try {
|
|
@@ -49090,16 +48988,12 @@ const startImageUpload = async ({ editor, view, file }) => {
|
|
|
49090
48988
|
}
|
|
49091
48989
|
let id = {};
|
|
49092
48990
|
let { tr, schema } = view.state;
|
|
49093
|
-
|
|
49094
|
-
if (editor.options.isHeaderOrFooter) {
|
|
49095
|
-
selection = editor.options.lastSelection;
|
|
49096
|
-
}
|
|
49097
|
-
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
48991
|
+
if (!tr.selection.empty) {
|
|
49098
48992
|
tr.deleteSelection();
|
|
49099
48993
|
}
|
|
49100
48994
|
let imageMeta = {
|
|
49101
48995
|
type: "add",
|
|
49102
|
-
pos: selection.from,
|
|
48996
|
+
pos: tr.selection.from,
|
|
49103
48997
|
id
|
|
49104
48998
|
};
|
|
49105
48999
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -54348,8 +54242,7 @@ const Pagination = Extension.create({
|
|
|
54348
54242
|
addStorage() {
|
|
54349
54243
|
return {
|
|
54350
54244
|
height: 0,
|
|
54351
|
-
sectionData: null
|
|
54352
|
-
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
54245
|
+
sectionData: null
|
|
54353
54246
|
};
|
|
54354
54247
|
},
|
|
54355
54248
|
addCommands() {
|
|
@@ -54392,14 +54285,13 @@ const Pagination = Extension.create({
|
|
|
54392
54285
|
shouldUpdate = true;
|
|
54393
54286
|
shouldInitialize = meta.isReadyToInit;
|
|
54394
54287
|
}
|
|
54395
|
-
const syncMeta = tr.getMeta("y-sync$");
|
|
54396
|
-
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
54397
|
-
return { ...oldState };
|
|
54398
|
-
}
|
|
54399
54288
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
54400
54289
|
if (imagePluginTransaction) {
|
|
54401
54290
|
if (imagePluginTransaction.type === "remove") {
|
|
54402
|
-
|
|
54291
|
+
const imagePos = imagePluginTransaction.pos;
|
|
54292
|
+
const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
|
|
54293
|
+
if (domImage.complete) onImageLoad(editor);
|
|
54294
|
+
else domImage.onload = () => onImageLoad(editor);
|
|
54403
54295
|
}
|
|
54404
54296
|
return { ...oldState };
|
|
54405
54297
|
}
|
|
@@ -54426,7 +54318,6 @@ const Pagination = Extension.create({
|
|
|
54426
54318
|
if (isForceUpdate) shouldUpdate = true;
|
|
54427
54319
|
return {
|
|
54428
54320
|
...oldState,
|
|
54429
|
-
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
54430
54321
|
isReadyToInit: shouldInitialize
|
|
54431
54322
|
};
|
|
54432
54323
|
}
|
|
@@ -54455,10 +54346,6 @@ const Pagination = Extension.create({
|
|
|
54455
54346
|
},
|
|
54456
54347
|
onDestroy() {
|
|
54457
54348
|
cleanupFloatingSeparators();
|
|
54458
|
-
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
54459
|
-
if (headerFooterEditors) {
|
|
54460
|
-
headerFooterEditors.clear();
|
|
54461
|
-
}
|
|
54462
54349
|
}
|
|
54463
54350
|
});
|
|
54464
54351
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
|
|
@@ -54519,7 +54406,6 @@ const performUpdate = (editor, view, previousDecorations) => {
|
|
|
54519
54406
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
54520
54407
|
if (!editor.converter) return DecorationSet.empty;
|
|
54521
54408
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
54522
|
-
if (!pageSize) return DecorationSet.empty;
|
|
54523
54409
|
const { width, height } = pageSize;
|
|
54524
54410
|
if (!width || !height) return DecorationSet.empty;
|
|
54525
54411
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -54558,13 +54444,11 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54558
54444
|
let pageHeightThreshold = pageHeight;
|
|
54559
54445
|
let footer = null, header = null;
|
|
54560
54446
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
54561
|
-
const
|
|
54562
|
-
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
54447
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
|
|
54563
54448
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
54564
54449
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
54565
54450
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
54566
|
-
const
|
|
54567
|
-
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
54451
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
|
|
54568
54452
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
54569
54453
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
54570
54454
|
if (!coords) return [];
|
|
@@ -54583,8 +54467,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
54583
54467
|
if (currentPageNumber === 1) {
|
|
54584
54468
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
54585
54469
|
decorations.pop();
|
|
54586
|
-
const
|
|
54587
|
-
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
54470
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
|
|
54588
54471
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
54589
54472
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
54590
54473
|
}
|
|
@@ -54658,15 +54541,15 @@ function createFinalPagePadding(bufferHeight) {
|
|
|
54658
54541
|
div2.style.height = bufferHeight + "px";
|
|
54659
54542
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
54660
54543
|
}
|
|
54661
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber
|
|
54662
|
-
const headerDef = sectionData
|
|
54544
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
54545
|
+
const headerDef = sectionData.headers?.[headerId];
|
|
54663
54546
|
const minHeaderHeight = pageMargins.top * 96;
|
|
54664
54547
|
const headerMargin = pageMargins.header * 96;
|
|
54665
54548
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
54666
54549
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
54667
54550
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
54668
54551
|
const availableHeight = headerHeight - headerMargin;
|
|
54669
|
-
|
|
54552
|
+
const editorContainer = document.createElement("div");
|
|
54670
54553
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
54671
54554
|
headerId = "rId" + generateDocxRandomId();
|
|
54672
54555
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -54678,31 +54561,23 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54678
54561
|
};
|
|
54679
54562
|
}
|
|
54680
54563
|
const data = editor.converter.headers[headerId];
|
|
54681
|
-
const
|
|
54682
|
-
|
|
54683
|
-
|
|
54684
|
-
|
|
54685
|
-
|
|
54686
|
-
|
|
54687
|
-
|
|
54688
|
-
|
|
54689
|
-
|
|
54690
|
-
|
|
54691
|
-
|
|
54692
|
-
|
|
54693
|
-
|
|
54694
|
-
|
|
54695
|
-
sectionId: headerId,
|
|
54696
|
-
type: "header",
|
|
54697
|
-
availableHeight,
|
|
54698
|
-
currentPageNumber
|
|
54699
|
-
});
|
|
54700
|
-
editor.converter.headerEditors.push({ id: headerId, editor: editorSection });
|
|
54701
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
54702
|
-
broadcastEditorEvents(editor, editorSection);
|
|
54703
|
-
}
|
|
54564
|
+
const editorSection = createHeaderFooterEditor({
|
|
54565
|
+
editor,
|
|
54566
|
+
data,
|
|
54567
|
+
editorContainer,
|
|
54568
|
+
appendToBody: false,
|
|
54569
|
+
sectionId: headerId,
|
|
54570
|
+
type: "header",
|
|
54571
|
+
availableHeight,
|
|
54572
|
+
currentPageNumber
|
|
54573
|
+
});
|
|
54574
|
+
editor.converter.headerEditors.push({
|
|
54575
|
+
id: headerId,
|
|
54576
|
+
editor: editorSection
|
|
54577
|
+
});
|
|
54704
54578
|
editorSection.setEditable(false, false);
|
|
54705
|
-
|
|
54579
|
+
broadcastEditorEvents(editor, editorSection);
|
|
54580
|
+
editorContainer.className = "pagination-section-header";
|
|
54706
54581
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
54707
54582
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
54708
54583
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -54715,12 +54590,12 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
54715
54590
|
headerHeight
|
|
54716
54591
|
};
|
|
54717
54592
|
}
|
|
54718
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber
|
|
54719
|
-
const footerDef = sectionData
|
|
54593
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
54594
|
+
const footerDef = sectionData.footers?.[footerId];
|
|
54720
54595
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
54721
54596
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
54722
54597
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
54723
|
-
|
|
54598
|
+
const editorContainer = document.createElement("div");
|
|
54724
54599
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
54725
54600
|
footerId = "rId" + generateDocxRandomId();
|
|
54726
54601
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -54732,31 +54607,23 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54732
54607
|
};
|
|
54733
54608
|
}
|
|
54734
54609
|
const data = editor.converter.footers[footerId];
|
|
54735
|
-
const
|
|
54736
|
-
|
|
54737
|
-
|
|
54738
|
-
|
|
54739
|
-
|
|
54740
|
-
|
|
54741
|
-
|
|
54742
|
-
|
|
54743
|
-
|
|
54744
|
-
|
|
54745
|
-
|
|
54746
|
-
|
|
54747
|
-
|
|
54748
|
-
|
|
54749
|
-
sectionId: footerId,
|
|
54750
|
-
type: "footer",
|
|
54751
|
-
availableHeight: footerHeight,
|
|
54752
|
-
currentPageNumber
|
|
54753
|
-
});
|
|
54754
|
-
editor.converter.footerEditors.push({ id: footerId, editor: editorSection });
|
|
54755
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
54756
|
-
broadcastEditorEvents(editor, editorSection);
|
|
54757
|
-
}
|
|
54610
|
+
const editorSection = createHeaderFooterEditor({
|
|
54611
|
+
editor,
|
|
54612
|
+
data,
|
|
54613
|
+
editorContainer,
|
|
54614
|
+
appendToBody: false,
|
|
54615
|
+
sectionId: footerId,
|
|
54616
|
+
type: "footer",
|
|
54617
|
+
availableHeight: footerHeight,
|
|
54618
|
+
currentPageNumber
|
|
54619
|
+
});
|
|
54620
|
+
editor.converter.footerEditors.push({
|
|
54621
|
+
id: footerId,
|
|
54622
|
+
editor: editorSection
|
|
54623
|
+
});
|
|
54758
54624
|
editorSection.setEditable(false, false);
|
|
54759
|
-
|
|
54625
|
+
broadcastEditorEvents(editor, editorSection);
|
|
54626
|
+
editorContainer.className = "pagination-section-footer";
|
|
54760
54627
|
editorContainer.style.height = footerHeight + "px";
|
|
54761
54628
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
54762
54629
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -54769,28 +54636,10 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
54769
54636
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
54770
54637
|
};
|
|
54771
54638
|
}
|
|
54772
|
-
const getHeaderFooterEditorKey = ({
|
|
54773
|
-
pageNumber,
|
|
54774
|
-
isHeader,
|
|
54775
|
-
isFooter,
|
|
54776
|
-
isFirstHeader = false,
|
|
54777
|
-
isLastFooter = false
|
|
54778
|
-
}) => {
|
|
54779
|
-
if (isFirstHeader) return `first-header-${pageNumber}`;
|
|
54780
|
-
if (isLastFooter) return `last-footer-${pageNumber}`;
|
|
54781
|
-
if (isHeader) return `header-${pageNumber}`;
|
|
54782
|
-
if (isFooter) return `footer-${pageNumber}`;
|
|
54783
|
-
return void 0;
|
|
54784
|
-
};
|
|
54785
54639
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
54786
54640
|
if (editor.options.documentMode !== "editing") return;
|
|
54787
54641
|
editor.setEditable(false, false);
|
|
54788
|
-
toggleHeaderFooterEditMode(
|
|
54789
|
-
editor,
|
|
54790
|
-
focusedSectionEditor: currentFocusedSectionEditor,
|
|
54791
|
-
isEditMode: true,
|
|
54792
|
-
documentMode: editor.options.documentMode
|
|
54793
|
-
});
|
|
54642
|
+
toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
|
|
54794
54643
|
};
|
|
54795
54644
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
54796
54645
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -55345,7 +55194,7 @@ const Search = Extension.create({
|
|
|
55345
55194
|
}
|
|
55346
55195
|
});
|
|
55347
55196
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
55348
|
-
const nodeResizer = (nodeNames = ["image"]
|
|
55197
|
+
const nodeResizer = (nodeNames = ["image"]) => {
|
|
55349
55198
|
let resizeState = {
|
|
55350
55199
|
dragging: false,
|
|
55351
55200
|
startX: 0,
|
|
@@ -55370,13 +55219,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
55370
55219
|
if (tr.getMeta(NodeResizerKey)) {
|
|
55371
55220
|
return oldState;
|
|
55372
55221
|
}
|
|
55373
|
-
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
55374
|
-
const { selection } = newState;
|
|
55375
|
-
const node2 = selection.node;
|
|
55376
|
-
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
55377
|
-
return DecorationSet.empty;
|
|
55378
|
-
}
|
|
55379
55222
|
const decorations = [];
|
|
55223
|
+
const { selection } = newState;
|
|
55380
55224
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
55381
55225
|
decorations.push(
|
|
55382
55226
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -55579,7 +55423,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
55579
55423
|
const NodeResizer = Extension.create({
|
|
55580
55424
|
name: "nodeResizer",
|
|
55581
55425
|
addPmPlugins() {
|
|
55582
|
-
return [nodeResizer(["image"]
|
|
55426
|
+
return [nodeResizer(["image"])];
|
|
55583
55427
|
}
|
|
55584
55428
|
});
|
|
55585
55429
|
const getRichTextExtensions = () => {
|
|
@@ -64255,6 +64099,7 @@ const style$2 = cB("icon", `
|
|
|
64255
64099
|
display: inline-block;
|
|
64256
64100
|
position: relative;
|
|
64257
64101
|
fill: currentColor;
|
|
64102
|
+
transform: translateZ(0);
|
|
64258
64103
|
`, [cM("color-transition", {
|
|
64259
64104
|
transition: "color .3s var(--n-bezier)"
|
|
64260
64105
|
}), cM("depth", {
|