@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
package/dist/superdoc.umd.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
const pdfjsLib__namespace = /* @__PURE__ */ _interopNamespaceDefault(pdfjsLib);
|
|
23
23
|
const pdfjsViewer__namespace = /* @__PURE__ */ _interopNamespaceDefault(pdfjsViewer);
|
|
24
24
|
/**
|
|
25
|
-
* @vue/shared v3.5.
|
|
25
|
+
* @vue/shared v3.5.16
|
|
26
26
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
27
27
|
* @license MIT
|
|
28
28
|
**/
|
|
@@ -622,7 +622,6 @@
|
|
|
622
622
|
}
|
|
623
623
|
};
|
|
624
624
|
class Dep {
|
|
625
|
-
// TODO isolatedDeclarations "__v_skip"
|
|
626
625
|
constructor(computed2) {
|
|
627
626
|
this.computed = computed2;
|
|
628
627
|
this.version = 0;
|
|
@@ -631,7 +630,6 @@
|
|
|
631
630
|
this.map = void 0;
|
|
632
631
|
this.key = void 0;
|
|
633
632
|
this.sc = 0;
|
|
634
|
-
this.__v_skip = true;
|
|
635
633
|
}
|
|
636
634
|
track(debugInfo) {
|
|
637
635
|
if (!activeSub || !shouldTrack || activeSub === this.computed) {
|
|
@@ -4101,8 +4099,6 @@
|
|
|
4101
4099
|
const initSlots = (instance, children, optimized) => {
|
|
4102
4100
|
const slots = instance.slots = createInternalObject();
|
|
4103
4101
|
if (instance.vnode.shapeFlag & 32) {
|
|
4104
|
-
const cacheIndexes = children.__;
|
|
4105
|
-
if (cacheIndexes) def(slots, "__", cacheIndexes, true);
|
|
4106
4102
|
const type2 = children._;
|
|
4107
4103
|
if (type2) {
|
|
4108
4104
|
assignSlots(slots, children, optimized);
|
|
@@ -4260,8 +4256,6 @@
|
|
|
4260
4256
|
}
|
|
4261
4257
|
if (ref3 != null && parentComponent) {
|
|
4262
4258
|
setRef(ref3, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
|
4263
|
-
} else if (ref3 == null && n1 && n1.ref != null) {
|
|
4264
|
-
setRef(n1.ref, null, parentSuspense, n1, true);
|
|
4265
4259
|
}
|
|
4266
4260
|
};
|
|
4267
4261
|
const processText = (n1, n2, container, anchor) => {
|
|
@@ -4735,8 +4729,7 @@
|
|
|
4735
4729
|
}
|
|
4736
4730
|
toggleRecurse(instance, true);
|
|
4737
4731
|
{
|
|
4738
|
-
if (root2.ce
|
|
4739
|
-
root2.ce._def.shadowRoot !== false) {
|
|
4732
|
+
if (root2.ce) {
|
|
4740
4733
|
root2.ce._injectChildStyle(type2);
|
|
4741
4734
|
}
|
|
4742
4735
|
const subTree = instance.subTree = renderComponentRoot(instance);
|
|
@@ -6527,7 +6520,7 @@
|
|
|
6527
6520
|
return createVNode(type2, propsOrChildren, children);
|
|
6528
6521
|
}
|
|
6529
6522
|
}
|
|
6530
|
-
const version$1 = "3.5.
|
|
6523
|
+
const version$1 = "3.5.16";
|
|
6531
6524
|
let policy = void 0;
|
|
6532
6525
|
const tt = typeof window !== "undefined" && window.trustedTypes;
|
|
6533
6526
|
if (tt) {
|
|
@@ -18325,7 +18318,7 @@
|
|
|
18325
18318
|
}
|
|
18326
18319
|
}
|
|
18327
18320
|
const emptyAttrs = /* @__PURE__ */ Object.create(null);
|
|
18328
|
-
let Node$
|
|
18321
|
+
let Node$2 = class Node2 {
|
|
18329
18322
|
/**
|
|
18330
18323
|
@internal
|
|
18331
18324
|
*/
|
|
@@ -18726,8 +18719,8 @@
|
|
|
18726
18719
|
return node2;
|
|
18727
18720
|
}
|
|
18728
18721
|
};
|
|
18729
|
-
Node$
|
|
18730
|
-
class TextNode extends Node$
|
|
18722
|
+
Node$2.prototype.text = void 0;
|
|
18723
|
+
class TextNode extends Node$2 {
|
|
18731
18724
|
/**
|
|
18732
18725
|
@internal
|
|
18733
18726
|
*/
|
|
@@ -19314,7 +19307,7 @@
|
|
|
19314
19307
|
create(attrs = null, content, marks) {
|
|
19315
19308
|
if (this.isText)
|
|
19316
19309
|
throw new Error("NodeType.create can't construct text nodes");
|
|
19317
|
-
return new Node$
|
|
19310
|
+
return new Node$2(this, this.computeAttrs(attrs), Fragment.from(content), Mark$1.setFrom(marks));
|
|
19318
19311
|
}
|
|
19319
19312
|
/**
|
|
19320
19313
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
@@ -19324,7 +19317,7 @@
|
|
|
19324
19317
|
createChecked(attrs = null, content, marks) {
|
|
19325
19318
|
content = Fragment.from(content);
|
|
19326
19319
|
this.checkContent(content);
|
|
19327
|
-
return new Node$
|
|
19320
|
+
return new Node$2(this, this.computeAttrs(attrs), content, Mark$1.setFrom(marks));
|
|
19328
19321
|
}
|
|
19329
19322
|
/**
|
|
19330
19323
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
@@ -19347,7 +19340,7 @@
|
|
|
19347
19340
|
let after = matched && matched.fillBefore(Fragment.empty, true);
|
|
19348
19341
|
if (!after)
|
|
19349
19342
|
return null;
|
|
19350
|
-
return new Node$
|
|
19343
|
+
return new Node$2(this, attrs, content.append(after), Mark$1.setFrom(marks));
|
|
19351
19344
|
}
|
|
19352
19345
|
/**
|
|
19353
19346
|
Returns true if the given fragment is valid content for this node
|
|
@@ -19584,7 +19577,7 @@
|
|
|
19584
19577
|
bound.
|
|
19585
19578
|
*/
|
|
19586
19579
|
nodeFromJSON(json) {
|
|
19587
|
-
return Node$
|
|
19580
|
+
return Node$2.fromJSON(this, json);
|
|
19588
19581
|
}
|
|
19589
19582
|
/**
|
|
19590
19583
|
Deserialize a mark from its JSON representation. This method is
|
|
@@ -21110,7 +21103,7 @@
|
|
|
21110
21103
|
}
|
|
21111
21104
|
}
|
|
21112
21105
|
Step.jsonID("replace", ReplaceStep);
|
|
21113
|
-
|
|
21106
|
+
class ReplaceAroundStep extends Step {
|
|
21114
21107
|
/**
|
|
21115
21108
|
Create a replace-around step with the given range and gap.
|
|
21116
21109
|
`insert` should be the point in the slice into which the content
|
|
@@ -21150,7 +21143,7 @@
|
|
|
21150
21143
|
}
|
|
21151
21144
|
invert(doc2) {
|
|
21152
21145
|
let gap = this.gapTo - this.gapFrom;
|
|
21153
|
-
return new
|
|
21146
|
+
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);
|
|
21154
21147
|
}
|
|
21155
21148
|
map(mapping) {
|
|
21156
21149
|
let from2 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
@@ -21158,7 +21151,7 @@
|
|
|
21158
21151
|
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
21159
21152
|
if (from2.deletedAcross && to.deletedAcross || gapFrom < from2.pos || gapTo > to.pos)
|
|
21160
21153
|
return null;
|
|
21161
|
-
return new
|
|
21154
|
+
return new ReplaceAroundStep(from2.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
21162
21155
|
}
|
|
21163
21156
|
toJSON() {
|
|
21164
21157
|
let json = {
|
|
@@ -21181,10 +21174,10 @@
|
|
|
21181
21174
|
static fromJSON(schema, json) {
|
|
21182
21175
|
if (typeof json.from != "number" || typeof json.to != "number" || typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
21183
21176
|
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
21184
|
-
return new
|
|
21177
|
+
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
21185
21178
|
}
|
|
21186
|
-
}
|
|
21187
|
-
Step.jsonID("replaceAround", ReplaceAroundStep
|
|
21179
|
+
}
|
|
21180
|
+
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
21188
21181
|
function contentBetween(doc2, from2, to) {
|
|
21189
21182
|
let $from = doc2.resolve(from2), dist2 = to - from2, depth = $from.depth;
|
|
21190
21183
|
while (dist2 > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
@@ -21337,7 +21330,7 @@
|
|
|
21337
21330
|
} else {
|
|
21338
21331
|
end2++;
|
|
21339
21332
|
}
|
|
21340
|
-
tr.step(new ReplaceAroundStep
|
|
21333
|
+
tr.step(new ReplaceAroundStep(start2, end2, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
21341
21334
|
}
|
|
21342
21335
|
function findWrapping(range2, nodeType, attrs = null, innerRange = range2) {
|
|
21343
21336
|
let around = findWrappingOutside(range2, nodeType);
|
|
@@ -21382,7 +21375,7 @@
|
|
|
21382
21375
|
content = Fragment.from(wrappers[i2].type.create(wrappers[i2].attrs, content));
|
|
21383
21376
|
}
|
|
21384
21377
|
let start2 = range2.start, end2 = range2.end;
|
|
21385
|
-
tr.step(new ReplaceAroundStep
|
|
21378
|
+
tr.step(new ReplaceAroundStep(start2, end2, start2, end2, new Slice(content, 0, 0), wrappers.length, true));
|
|
21386
21379
|
}
|
|
21387
21380
|
function setBlockType$1(tr, from2, to, type2, attrs) {
|
|
21388
21381
|
if (!type2.isTextblock)
|
|
@@ -21404,7 +21397,7 @@
|
|
|
21404
21397
|
clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type2, void 0, convertNewlines === null);
|
|
21405
21398
|
let mapping = tr.mapping.slice(mapFrom);
|
|
21406
21399
|
let startM = mapping.map(pos, 1), endM = mapping.map(pos + node2.nodeSize, 1);
|
|
21407
|
-
tr.step(new ReplaceAroundStep
|
|
21400
|
+
tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type2.create(attrsHere, null, node2.marks)), 0, 0), 1, true));
|
|
21408
21401
|
if (convertNewlines === true)
|
|
21409
21402
|
replaceNewlines(tr, node2, pos, mapFrom);
|
|
21410
21403
|
return false;
|
|
@@ -21445,7 +21438,7 @@
|
|
|
21445
21438
|
return tr.replaceWith(pos, pos + node2.nodeSize, newNode);
|
|
21446
21439
|
if (!type2.validContent(node2.content))
|
|
21447
21440
|
throw new RangeError("Invalid content for node type " + type2.name);
|
|
21448
|
-
tr.step(new ReplaceAroundStep
|
|
21441
|
+
tr.step(new ReplaceAroundStep(pos, pos + node2.nodeSize, pos + 1, pos + node2.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
21449
21442
|
}
|
|
21450
21443
|
function canSplit(doc2, pos, depth = 1, typesAfter) {
|
|
21451
21444
|
let $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
|
|
@@ -21646,7 +21639,7 @@
|
|
|
21646
21639
|
}
|
|
21647
21640
|
let slice = new Slice(content, openStart, openEnd);
|
|
21648
21641
|
if (moveInline > -1)
|
|
21649
|
-
return new ReplaceAroundStep
|
|
21642
|
+
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize);
|
|
21650
21643
|
if (slice.size || $from.pos != this.$to.pos)
|
|
21651
21644
|
return new ReplaceStep($from.pos, $to.pos, slice);
|
|
21652
21645
|
return null;
|
|
@@ -22729,7 +22722,7 @@
|
|
|
22729
22722
|
if (last < startLen)
|
|
22730
22723
|
return;
|
|
22731
22724
|
let step = tr.steps[last];
|
|
22732
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
22725
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))
|
|
22733
22726
|
return;
|
|
22734
22727
|
let map2 = tr.mapping.maps[last], end2;
|
|
22735
22728
|
map2.forEach((_from, _to, _newFrom, newTo) => {
|
|
@@ -23144,7 +23137,7 @@
|
|
|
23144
23137
|
let instance = new EditorState($config);
|
|
23145
23138
|
$config.fields.forEach((field) => {
|
|
23146
23139
|
if (field.name == "doc") {
|
|
23147
|
-
instance.doc = Node$
|
|
23140
|
+
instance.doc = Node$2.fromJSON(config.schema, json.doc);
|
|
23148
23141
|
} else if (field.name == "selection") {
|
|
23149
23142
|
instance.selection = Selection.fromJSON(instance.doc, json.selection);
|
|
23150
23143
|
} else if (field.name == "storedMarks") {
|
|
@@ -26205,583 +26198,6 @@
|
|
|
26205
26198
|
colgroupValues
|
|
26206
26199
|
};
|
|
26207
26200
|
};
|
|
26208
|
-
function chainableEditorState(transaction, state2) {
|
|
26209
|
-
let { selection, doc: doc2, storedMarks } = transaction;
|
|
26210
|
-
return {
|
|
26211
|
-
...state2,
|
|
26212
|
-
apply: state2.apply.bind(state2),
|
|
26213
|
-
applyTransaction: state2.applyTransaction.bind(state2),
|
|
26214
|
-
plugins: state2.plugins,
|
|
26215
|
-
schema: state2.schema,
|
|
26216
|
-
reconfigure: state2.reconfigure.bind(state2),
|
|
26217
|
-
toJSON: state2.toJSON.bind(state2),
|
|
26218
|
-
get storedMarks() {
|
|
26219
|
-
return storedMarks;
|
|
26220
|
-
},
|
|
26221
|
-
get selection() {
|
|
26222
|
-
return selection;
|
|
26223
|
-
},
|
|
26224
|
-
get doc() {
|
|
26225
|
-
return doc2;
|
|
26226
|
-
},
|
|
26227
|
-
get tr() {
|
|
26228
|
-
selection = transaction.selection;
|
|
26229
|
-
doc2 = transaction.doc;
|
|
26230
|
-
storedMarks = transaction.storedMarks;
|
|
26231
|
-
return transaction;
|
|
26232
|
-
}
|
|
26233
|
-
};
|
|
26234
|
-
}
|
|
26235
|
-
class CommandService {
|
|
26236
|
-
constructor(props) {
|
|
26237
|
-
__publicField$2(this, "editor");
|
|
26238
|
-
__publicField$2(this, "rawCommands");
|
|
26239
|
-
this.editor = props.editor;
|
|
26240
|
-
this.rawCommands = this.editor.extensionService.commands;
|
|
26241
|
-
}
|
|
26242
|
-
/**
|
|
26243
|
-
* Static method for creating a service.
|
|
26244
|
-
* @param args Arguments for the constructor.
|
|
26245
|
-
*/
|
|
26246
|
-
static create(...args) {
|
|
26247
|
-
return new CommandService(...args);
|
|
26248
|
-
}
|
|
26249
|
-
/**
|
|
26250
|
-
* Get editor state.
|
|
26251
|
-
*/
|
|
26252
|
-
get state() {
|
|
26253
|
-
return this.editor.state;
|
|
26254
|
-
}
|
|
26255
|
-
/**
|
|
26256
|
-
* Get all commands with wrapped command method.
|
|
26257
|
-
*/
|
|
26258
|
-
get commands() {
|
|
26259
|
-
const { editor, state: state2 } = this;
|
|
26260
|
-
const { view } = editor;
|
|
26261
|
-
const { tr } = state2;
|
|
26262
|
-
const props = this.createProps(tr);
|
|
26263
|
-
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
26264
|
-
const method = (...args) => {
|
|
26265
|
-
const fn = command2(...args)(props);
|
|
26266
|
-
if (!tr.getMeta("preventDispatch")) {
|
|
26267
|
-
view.dispatch(tr);
|
|
26268
|
-
}
|
|
26269
|
-
return fn;
|
|
26270
|
-
};
|
|
26271
|
-
return [name, method];
|
|
26272
|
-
});
|
|
26273
|
-
return Object.fromEntries(entries);
|
|
26274
|
-
}
|
|
26275
|
-
/**
|
|
26276
|
-
* Create a chain of commands to call multiple commands at once.
|
|
26277
|
-
*/
|
|
26278
|
-
get chain() {
|
|
26279
|
-
return () => this.createChain();
|
|
26280
|
-
}
|
|
26281
|
-
/**
|
|
26282
|
-
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
26283
|
-
*/
|
|
26284
|
-
get can() {
|
|
26285
|
-
return () => this.createCan();
|
|
26286
|
-
}
|
|
26287
|
-
/**
|
|
26288
|
-
* Creates a chain of commands.
|
|
26289
|
-
* @param startTr Start transaction.
|
|
26290
|
-
* @param shouldDispatch Should dispatch or not.
|
|
26291
|
-
*/
|
|
26292
|
-
createChain(startTr, shouldDispatch = true) {
|
|
26293
|
-
const { editor, state: state2, rawCommands } = this;
|
|
26294
|
-
const { view } = editor;
|
|
26295
|
-
const callbacks2 = [];
|
|
26296
|
-
const hasStartTr = !!startTr;
|
|
26297
|
-
const tr = startTr || state2.tr;
|
|
26298
|
-
const run2 = () => {
|
|
26299
|
-
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
26300
|
-
view.dispatch(tr);
|
|
26301
|
-
}
|
|
26302
|
-
return callbacks2.every((cb) => cb === true);
|
|
26303
|
-
};
|
|
26304
|
-
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
26305
|
-
const chainedCommand = (...args) => {
|
|
26306
|
-
const props = this.createProps(tr, shouldDispatch);
|
|
26307
|
-
const callback = command2(...args)(props);
|
|
26308
|
-
callbacks2.push(callback);
|
|
26309
|
-
return chain;
|
|
26310
|
-
};
|
|
26311
|
-
return [name, chainedCommand];
|
|
26312
|
-
});
|
|
26313
|
-
const chain = {
|
|
26314
|
-
...Object.fromEntries(entries),
|
|
26315
|
-
run: run2
|
|
26316
|
-
};
|
|
26317
|
-
return chain;
|
|
26318
|
-
}
|
|
26319
|
-
/**
|
|
26320
|
-
* Creates a can check for commands.
|
|
26321
|
-
* @param startTr Start transaction.
|
|
26322
|
-
*/
|
|
26323
|
-
createCan(startTr) {
|
|
26324
|
-
const { rawCommands, state: state2 } = this;
|
|
26325
|
-
const dispatch = false;
|
|
26326
|
-
const tr = startTr || state2.tr;
|
|
26327
|
-
const props = this.createProps(tr, dispatch);
|
|
26328
|
-
const commands2 = Object.fromEntries(
|
|
26329
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
26330
|
-
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
26331
|
-
})
|
|
26332
|
-
);
|
|
26333
|
-
return {
|
|
26334
|
-
...commands2,
|
|
26335
|
-
chain: () => this.createChain(tr, dispatch)
|
|
26336
|
-
};
|
|
26337
|
-
}
|
|
26338
|
-
/**
|
|
26339
|
-
* Creates default props for the command method.
|
|
26340
|
-
* @param {*} tr Transaction.
|
|
26341
|
-
* @param {*} shouldDispatch Check if should dispatch.
|
|
26342
|
-
* @returns Object with props.
|
|
26343
|
-
*/
|
|
26344
|
-
createProps(tr, shouldDispatch = true) {
|
|
26345
|
-
const { editor, state: state2, rawCommands } = this;
|
|
26346
|
-
const { view } = editor;
|
|
26347
|
-
const props = {
|
|
26348
|
-
tr,
|
|
26349
|
-
editor,
|
|
26350
|
-
view,
|
|
26351
|
-
state: chainableEditorState(tr, state2),
|
|
26352
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
26353
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
26354
|
-
can: () => this.createCan(tr),
|
|
26355
|
-
get commands() {
|
|
26356
|
-
return Object.fromEntries(
|
|
26357
|
-
Object.entries(rawCommands).map(([name, command2]) => {
|
|
26358
|
-
return [name, (...args) => command2(...args)(props)];
|
|
26359
|
-
})
|
|
26360
|
-
);
|
|
26361
|
-
}
|
|
26362
|
-
};
|
|
26363
|
-
return props;
|
|
26364
|
-
}
|
|
26365
|
-
}
|
|
26366
|
-
function getHTMLFromFragment(fragment, schema) {
|
|
26367
|
-
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
26368
|
-
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
26369
|
-
const container = temporaryDocument.createElement("div");
|
|
26370
|
-
container.appendChild(documentFragment);
|
|
26371
|
-
return container.innerHTML;
|
|
26372
|
-
}
|
|
26373
|
-
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
26374
|
-
let textBefore = "";
|
|
26375
|
-
const sliceEndPos = $from.parentOffset;
|
|
26376
|
-
$from.parent.nodesBetween(
|
|
26377
|
-
Math.max(0, sliceEndPos - maxMatch),
|
|
26378
|
-
sliceEndPos,
|
|
26379
|
-
(node2, pos, parent, index2) => {
|
|
26380
|
-
const chunk = node2.type.spec.toText?.({
|
|
26381
|
-
node: node2,
|
|
26382
|
-
pos,
|
|
26383
|
-
parent,
|
|
26384
|
-
index: index2
|
|
26385
|
-
}) || node2.textContent || "%leaf%";
|
|
26386
|
-
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
26387
|
-
}
|
|
26388
|
-
);
|
|
26389
|
-
return textBefore;
|
|
26390
|
-
};
|
|
26391
|
-
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
26392
|
-
const { converter } = editor;
|
|
26393
|
-
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
26394
|
-
let cleanedHtml = convertEmToPt(html);
|
|
26395
|
-
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
26396
|
-
const tempDiv = document.createElement("div");
|
|
26397
|
-
tempDiv.innerHTML = cleanedHtml;
|
|
26398
|
-
const paragraphs = tempDiv.querySelectorAll("p");
|
|
26399
|
-
paragraphs.forEach((p2) => {
|
|
26400
|
-
const innerHTML2 = p2.innerHTML;
|
|
26401
|
-
if (!innerHTML2.includes("<!--[if !supportLists]")) return;
|
|
26402
|
-
const styleAttr = p2.getAttribute("style") || "";
|
|
26403
|
-
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
26404
|
-
if (msoListMatch) {
|
|
26405
|
-
const [, abstractId, level] = msoListMatch;
|
|
26406
|
-
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
26407
|
-
if (!listNumId) return;
|
|
26408
|
-
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
26409
|
-
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
26410
|
-
p2.setAttribute("data-num-id", listNumId);
|
|
26411
|
-
p2.setAttribute("data-list-level", level - 1);
|
|
26412
|
-
p2.setAttribute("data-start", start2);
|
|
26413
|
-
p2.setAttribute("data-lvl-text", lvlText);
|
|
26414
|
-
p2.setAttribute("data-num-fmt", numFmt);
|
|
26415
|
-
}
|
|
26416
|
-
extractAndRemoveConditionalPrefix(p2);
|
|
26417
|
-
});
|
|
26418
|
-
transformWordLists(tempDiv);
|
|
26419
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
26420
|
-
tempDiv.remove();
|
|
26421
|
-
const { dispatch } = editor.view;
|
|
26422
|
-
if (!dispatch) return false;
|
|
26423
|
-
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
26424
|
-
return true;
|
|
26425
|
-
};
|
|
26426
|
-
const getLevelDefinition = (abstractDefinition, level) => {
|
|
26427
|
-
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
26428
|
-
const levelElement = abstractDefinition.elements.find((el) => {
|
|
26429
|
-
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
26430
|
-
});
|
|
26431
|
-
if (!levelElement) return null;
|
|
26432
|
-
const { elements } = levelElement;
|
|
26433
|
-
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
26434
|
-
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
26435
|
-
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
26436
|
-
return { lvlText, start: start2, numFmt, elements };
|
|
26437
|
-
};
|
|
26438
|
-
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
26439
|
-
const { definitions } = editor?.converter?.numbering;
|
|
26440
|
-
if (!definitions) return null;
|
|
26441
|
-
const matchedDefinition = Object.values(definitions).find((def2) => {
|
|
26442
|
-
return def2.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
26443
|
-
});
|
|
26444
|
-
return matchedDefinition?.attributes?.["w:numId"];
|
|
26445
|
-
};
|
|
26446
|
-
const getListAbstractDefinition = (abstractId, editor) => {
|
|
26447
|
-
const { abstracts = {} } = editor?.converter?.numbering;
|
|
26448
|
-
return abstracts[abstractId] || null;
|
|
26449
|
-
};
|
|
26450
|
-
const transformWordLists = (container) => {
|
|
26451
|
-
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
26452
|
-
const listMap = /* @__PURE__ */ new Map();
|
|
26453
|
-
const listLevels = {};
|
|
26454
|
-
for (const p2 of paragraphs) {
|
|
26455
|
-
const listId = p2.getAttribute("data-num-id");
|
|
26456
|
-
const level = parseInt(p2.getAttribute("data-list-level"));
|
|
26457
|
-
const numFmt = p2.getAttribute("data-num-fmt");
|
|
26458
|
-
const start2 = p2.getAttribute("data-start");
|
|
26459
|
-
const lvlText = p2.getAttribute("data-lvl-text");
|
|
26460
|
-
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
26461
|
-
listMap.get(listId).push({ p: p2, level, numFmt, start: start2, lvlText });
|
|
26462
|
-
}
|
|
26463
|
-
for (const [id, items] of listMap.entries()) {
|
|
26464
|
-
if (!listLevels[id]) {
|
|
26465
|
-
listLevels[id] = {
|
|
26466
|
-
stack: [],
|
|
26467
|
-
counts: {},
|
|
26468
|
-
prevLevel: null
|
|
26469
|
-
};
|
|
26470
|
-
}
|
|
26471
|
-
const parentStack = [];
|
|
26472
|
-
items.forEach(({ p: p2, level, numFmt, start: start2, lvlText }, index2) => {
|
|
26473
|
-
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
26474
|
-
const li = document.createElement("li");
|
|
26475
|
-
li.innerHTML = p2.innerHTML;
|
|
26476
|
-
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
26477
|
-
li.setAttribute("data-num-id", id);
|
|
26478
|
-
li.setAttribute("data-lvl-text", lvlText);
|
|
26479
|
-
li.setAttribute("data-num-fmt", numFmt);
|
|
26480
|
-
if (p2.hasAttribute("data-font-family")) {
|
|
26481
|
-
li.setAttribute("data-font-family", p2.getAttribute("data-font-family"));
|
|
26482
|
-
}
|
|
26483
|
-
if (p2.hasAttribute("data-font-size")) {
|
|
26484
|
-
li.setAttribute("data-font-size", p2.getAttribute("data-font-size"));
|
|
26485
|
-
}
|
|
26486
|
-
const parentNode2 = p2.parentNode;
|
|
26487
|
-
let listForLevel = parentStack[level];
|
|
26488
|
-
if (!listForLevel) {
|
|
26489
|
-
const newList = document.createElement("ol");
|
|
26490
|
-
newList.setAttribute("data-list-id", id);
|
|
26491
|
-
newList.level = level;
|
|
26492
|
-
if (level > 0) {
|
|
26493
|
-
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
26494
|
-
if (parentLi) parentLi.appendChild(newList);
|
|
26495
|
-
} else {
|
|
26496
|
-
parentNode2.insertBefore(newList, p2);
|
|
26497
|
-
}
|
|
26498
|
-
parentStack[level] = newList;
|
|
26499
|
-
parentStack.length = level + 1;
|
|
26500
|
-
listForLevel = newList;
|
|
26501
|
-
}
|
|
26502
|
-
listForLevel.appendChild(li);
|
|
26503
|
-
p2.remove();
|
|
26504
|
-
});
|
|
26505
|
-
}
|
|
26506
|
-
};
|
|
26507
|
-
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
26508
|
-
const levelState = listLevels[listId];
|
|
26509
|
-
if (!levelState.stack) levelState.stack = [];
|
|
26510
|
-
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
26511
|
-
if (levelState.prevLevel === null) {
|
|
26512
|
-
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
26513
|
-
} else {
|
|
26514
|
-
if (currentLevel > levelState.prevLevel) {
|
|
26515
|
-
levelState.stack.push(1);
|
|
26516
|
-
} else if (currentLevel === levelState.prevLevel) {
|
|
26517
|
-
levelState.stack[levelState.stack.length - 1]++;
|
|
26518
|
-
} else {
|
|
26519
|
-
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
26520
|
-
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
26521
|
-
}
|
|
26522
|
-
}
|
|
26523
|
-
levelState.prevLevel = currentLevel;
|
|
26524
|
-
return [...levelState.stack];
|
|
26525
|
-
}
|
|
26526
|
-
function extractAndRemoveConditionalPrefix(p2) {
|
|
26527
|
-
const nodes = Array.from(p2.childNodes);
|
|
26528
|
-
let fontFamily2 = null;
|
|
26529
|
-
let fontSize2 = null;
|
|
26530
|
-
let start2 = -1, end2 = -1;
|
|
26531
|
-
nodes.forEach((node2, index2) => {
|
|
26532
|
-
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
26533
|
-
start2 = index2;
|
|
26534
|
-
}
|
|
26535
|
-
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
26536
|
-
end2 = index2;
|
|
26537
|
-
}
|
|
26538
|
-
});
|
|
26539
|
-
if (start2 !== -1 && end2 !== -1) {
|
|
26540
|
-
for (let i2 = start2 + 1; i2 < end2; i2++) {
|
|
26541
|
-
const node2 = nodes[i2];
|
|
26542
|
-
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
26543
|
-
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
26544
|
-
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
26545
|
-
}
|
|
26546
|
-
}
|
|
26547
|
-
for (let i2 = end2; i2 >= start2; i2--) {
|
|
26548
|
-
p2.removeChild(p2.childNodes[i2]);
|
|
26549
|
-
}
|
|
26550
|
-
if (fontFamily2) p2.setAttribute("data-font-family", fontFamily2);
|
|
26551
|
-
if (fontSize2) p2.setAttribute("data-font-size", fontSize2);
|
|
26552
|
-
}
|
|
26553
|
-
}
|
|
26554
|
-
class InputRule {
|
|
26555
|
-
constructor(config) {
|
|
26556
|
-
__publicField$2(this, "match");
|
|
26557
|
-
__publicField$2(this, "handler");
|
|
26558
|
-
this.match = config.match;
|
|
26559
|
-
this.handler = config.handler;
|
|
26560
|
-
}
|
|
26561
|
-
}
|
|
26562
|
-
const inputRuleMatcherHandler = (text, match) => {
|
|
26563
|
-
if (isRegExp(match)) {
|
|
26564
|
-
return match.exec(text);
|
|
26565
|
-
}
|
|
26566
|
-
const inputRuleMatch = match(text);
|
|
26567
|
-
if (!inputRuleMatch) {
|
|
26568
|
-
return null;
|
|
26569
|
-
}
|
|
26570
|
-
const result = [inputRuleMatch.text];
|
|
26571
|
-
result.index = inputRuleMatch.index;
|
|
26572
|
-
result.input = text;
|
|
26573
|
-
result.data = inputRuleMatch.data;
|
|
26574
|
-
if (inputRuleMatch.replaceWith) {
|
|
26575
|
-
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
26576
|
-
console.warn(
|
|
26577
|
-
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
26578
|
-
);
|
|
26579
|
-
}
|
|
26580
|
-
result.push(inputRuleMatch.replaceWith);
|
|
26581
|
-
}
|
|
26582
|
-
return result;
|
|
26583
|
-
};
|
|
26584
|
-
const run = (config) => {
|
|
26585
|
-
const {
|
|
26586
|
-
editor,
|
|
26587
|
-
from: from2,
|
|
26588
|
-
to,
|
|
26589
|
-
text,
|
|
26590
|
-
rules,
|
|
26591
|
-
plugin: plugin2
|
|
26592
|
-
} = config;
|
|
26593
|
-
const { view } = editor;
|
|
26594
|
-
if (view.composing) {
|
|
26595
|
-
return false;
|
|
26596
|
-
}
|
|
26597
|
-
const $from = view.state.doc.resolve(from2);
|
|
26598
|
-
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
26599
|
-
return false;
|
|
26600
|
-
}
|
|
26601
|
-
let matched = false;
|
|
26602
|
-
const textBefore = getTextContentFromNodes($from) + text;
|
|
26603
|
-
rules.forEach((rule) => {
|
|
26604
|
-
if (matched) {
|
|
26605
|
-
return;
|
|
26606
|
-
}
|
|
26607
|
-
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
26608
|
-
if (!match) {
|
|
26609
|
-
return;
|
|
26610
|
-
}
|
|
26611
|
-
const tr = view.state.tr;
|
|
26612
|
-
const state2 = chainableEditorState(tr, view.state);
|
|
26613
|
-
const range2 = {
|
|
26614
|
-
from: from2 - (match[0].length - text.length),
|
|
26615
|
-
to
|
|
26616
|
-
};
|
|
26617
|
-
const { commands: commands2, chain, can } = new CommandService({
|
|
26618
|
-
editor,
|
|
26619
|
-
state: state2
|
|
26620
|
-
});
|
|
26621
|
-
const handler = rule.handler({
|
|
26622
|
-
state: state2,
|
|
26623
|
-
range: range2,
|
|
26624
|
-
match,
|
|
26625
|
-
commands: commands2,
|
|
26626
|
-
chain,
|
|
26627
|
-
can
|
|
26628
|
-
});
|
|
26629
|
-
if (handler === null || !tr.steps.length) {
|
|
26630
|
-
return;
|
|
26631
|
-
}
|
|
26632
|
-
tr.setMeta(plugin2, {
|
|
26633
|
-
transform: tr,
|
|
26634
|
-
from: from2,
|
|
26635
|
-
to,
|
|
26636
|
-
text
|
|
26637
|
-
});
|
|
26638
|
-
view.dispatch(tr);
|
|
26639
|
-
matched = true;
|
|
26640
|
-
});
|
|
26641
|
-
return matched;
|
|
26642
|
-
};
|
|
26643
|
-
const inputRulesPlugin = ({ editor, rules }) => {
|
|
26644
|
-
const plugin2 = new Plugin({
|
|
26645
|
-
key: new PluginKey("inputRulesPlugin"),
|
|
26646
|
-
state: {
|
|
26647
|
-
init() {
|
|
26648
|
-
return null;
|
|
26649
|
-
},
|
|
26650
|
-
apply(tr, prev, state2) {
|
|
26651
|
-
const stored = tr.getMeta(plugin2);
|
|
26652
|
-
if (stored) {
|
|
26653
|
-
return stored;
|
|
26654
|
-
}
|
|
26655
|
-
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
26656
|
-
const isSimulatedInput = !!simulatedInputMeta;
|
|
26657
|
-
if (isSimulatedInput) {
|
|
26658
|
-
setTimeout(() => {
|
|
26659
|
-
let { text } = simulatedInputMeta;
|
|
26660
|
-
if (typeof text !== "string") {
|
|
26661
|
-
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
26662
|
-
}
|
|
26663
|
-
const { from: from2 } = simulatedInputMeta;
|
|
26664
|
-
const to = from2 + text.length;
|
|
26665
|
-
run({
|
|
26666
|
-
editor,
|
|
26667
|
-
from: from2,
|
|
26668
|
-
to,
|
|
26669
|
-
text,
|
|
26670
|
-
rules,
|
|
26671
|
-
plugin: plugin2
|
|
26672
|
-
});
|
|
26673
|
-
});
|
|
26674
|
-
}
|
|
26675
|
-
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
26676
|
-
}
|
|
26677
|
-
},
|
|
26678
|
-
props: {
|
|
26679
|
-
handleTextInput(view, from2, to, text) {
|
|
26680
|
-
return run({
|
|
26681
|
-
editor,
|
|
26682
|
-
from: from2,
|
|
26683
|
-
to,
|
|
26684
|
-
text,
|
|
26685
|
-
rules,
|
|
26686
|
-
plugin: plugin2
|
|
26687
|
-
});
|
|
26688
|
-
},
|
|
26689
|
-
// add support for input rules to trigger on enter
|
|
26690
|
-
// this is useful for example for code blocks
|
|
26691
|
-
handleKeyDown(view, event) {
|
|
26692
|
-
if (event.key !== "Enter") {
|
|
26693
|
-
return false;
|
|
26694
|
-
}
|
|
26695
|
-
const { $cursor } = view.state.selection;
|
|
26696
|
-
if ($cursor) {
|
|
26697
|
-
return run({
|
|
26698
|
-
editor,
|
|
26699
|
-
from: $cursor.pos,
|
|
26700
|
-
to: $cursor.pos,
|
|
26701
|
-
text: "\n",
|
|
26702
|
-
rules,
|
|
26703
|
-
plugin: plugin2
|
|
26704
|
-
});
|
|
26705
|
-
}
|
|
26706
|
-
return false;
|
|
26707
|
-
},
|
|
26708
|
-
// Paste handler
|
|
26709
|
-
handlePaste(view, event, slice) {
|
|
26710
|
-
const clipboard = event.clipboardData;
|
|
26711
|
-
const html = clipboard.getData("text/html");
|
|
26712
|
-
clipboard.getData("text/plain");
|
|
26713
|
-
const fieldAnnotationContent = slice.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
26714
|
-
if (fieldAnnotationContent.length) {
|
|
26715
|
-
return false;
|
|
26716
|
-
}
|
|
26717
|
-
let source;
|
|
26718
|
-
if (!html) {
|
|
26719
|
-
source = "plain-text";
|
|
26720
|
-
} else if (isWordHtml(html)) {
|
|
26721
|
-
source = "word-html";
|
|
26722
|
-
} else {
|
|
26723
|
-
source = "browser-html";
|
|
26724
|
-
}
|
|
26725
|
-
switch (source) {
|
|
26726
|
-
case "plain-text":
|
|
26727
|
-
break;
|
|
26728
|
-
case "word-html":
|
|
26729
|
-
if (editor.options.mode === "docx") {
|
|
26730
|
-
return handleDocxPaste(html, editor, view, plugin2);
|
|
26731
|
-
}
|
|
26732
|
-
case "browser-html":
|
|
26733
|
-
return handleHtmlPaste$1(html, editor);
|
|
26734
|
-
}
|
|
26735
|
-
return false;
|
|
26736
|
-
}
|
|
26737
|
-
},
|
|
26738
|
-
isInputRules: true
|
|
26739
|
-
});
|
|
26740
|
-
return plugin2;
|
|
26741
|
-
};
|
|
26742
|
-
function isWordHtml(html) {
|
|
26743
|
-
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
26744
|
-
}
|
|
26745
|
-
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
26746
|
-
const htmlWithPtSizing = convertEmToPt(html);
|
|
26747
|
-
const cleanedHtml = sanitizeHtml(htmlWithPtSizing);
|
|
26748
|
-
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
|
|
26749
|
-
const { dispatch } = editor.view;
|
|
26750
|
-
if (!dispatch) return false;
|
|
26751
|
-
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
26752
|
-
return true;
|
|
26753
|
-
};
|
|
26754
|
-
const convertEmToPt = (html) => {
|
|
26755
|
-
return html.replace(
|
|
26756
|
-
/font-size\s*:\s*([\d.]+)em/gi,
|
|
26757
|
-
(_, emValue) => {
|
|
26758
|
-
const em = parseFloat(emValue);
|
|
26759
|
-
const pt = Math.round(em * 12 * 100) / 100;
|
|
26760
|
-
return `font-size: ${pt}pt`;
|
|
26761
|
-
}
|
|
26762
|
-
);
|
|
26763
|
-
};
|
|
26764
|
-
function cleanHtmlUnnecessaryTags(html) {
|
|
26765
|
-
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
26766
|
-
}
|
|
26767
|
-
function sanitizeHtml(html, forbiddenTags = ["meta", "svg", "script", "style", "button"]) {
|
|
26768
|
-
const container = document.createElement("div");
|
|
26769
|
-
container.innerHTML = html;
|
|
26770
|
-
const walkAndClean = (node2) => {
|
|
26771
|
-
for (const child of [...node2.children]) {
|
|
26772
|
-
if (forbiddenTags.includes(child.tagName.toLowerCase())) {
|
|
26773
|
-
child.remove();
|
|
26774
|
-
continue;
|
|
26775
|
-
}
|
|
26776
|
-
if (child.hasAttribute("linebreaktype")) {
|
|
26777
|
-
child.removeAttribute("linebreaktype");
|
|
26778
|
-
}
|
|
26779
|
-
walkAndClean(child);
|
|
26780
|
-
}
|
|
26781
|
-
};
|
|
26782
|
-
walkAndClean(container);
|
|
26783
|
-
return container;
|
|
26784
|
-
}
|
|
26785
26201
|
function exportSchemaToJson(params2) {
|
|
26786
26202
|
const { type: type2 } = params2.node || {};
|
|
26787
26203
|
const router = {
|
|
@@ -26819,13 +26235,13 @@
|
|
|
26819
26235
|
function translateBodyNode(params2) {
|
|
26820
26236
|
let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
|
|
26821
26237
|
if (params2.converter) {
|
|
26822
|
-
const hasHeader = sectPr
|
|
26238
|
+
const hasHeader = sectPr.elements.some((n) => n.name === "w:headerReference");
|
|
26823
26239
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
26824
26240
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
26825
26241
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
26826
26242
|
sectPr.elements.push(defaultHeader);
|
|
26827
26243
|
}
|
|
26828
|
-
const hasFooter = sectPr
|
|
26244
|
+
const hasFooter = sectPr.elements.some((n) => n.name === "w:footerReference");
|
|
26829
26245
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
26830
26246
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
26831
26247
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
@@ -28125,11 +27541,12 @@
|
|
|
28125
27541
|
node: { attrs = {}, marks = [] },
|
|
28126
27542
|
editorSchema
|
|
28127
27543
|
} = params2;
|
|
28128
|
-
const
|
|
27544
|
+
const parser = new window.DOMParser();
|
|
27545
|
+
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, "text/html");
|
|
28129
27546
|
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
|
|
28130
27547
|
const allMarks = [...marks, ...marksFromAttrs];
|
|
28131
27548
|
let state2 = EditorState.create({
|
|
28132
|
-
doc: DOMParser$1.fromSchema(editorSchema).parse(
|
|
27549
|
+
doc: DOMParser$1.fromSchema(editorSchema).parse(paragraphHtml)
|
|
28133
27550
|
});
|
|
28134
27551
|
if (allMarks.length) {
|
|
28135
27552
|
state2 = applyMarksToHtmlAnnotation(state2, allMarks);
|
|
@@ -31184,7 +30601,7 @@
|
|
|
31184
30601
|
});
|
|
31185
30602
|
return updatedStyles;
|
|
31186
30603
|
}
|
|
31187
|
-
const importHeadersFooters = (docx, converter,
|
|
30604
|
+
const importHeadersFooters = (docx, converter, editor) => {
|
|
31188
30605
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
31189
30606
|
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
31190
30607
|
const { elements } = relationships;
|
|
@@ -31194,9 +30611,6 @@
|
|
|
31194
30611
|
const footers = elements.filter((el) => el.attributes["Type"] === footerType);
|
|
31195
30612
|
const sectPr = findSectPr(docx["word/document.xml"]) || [];
|
|
31196
30613
|
const allSectPrElements = sectPr.flatMap((el) => el.elements);
|
|
31197
|
-
if (!mainEditor) return;
|
|
31198
|
-
const editor = { ...mainEditor };
|
|
31199
|
-
editor.options.annotations = true;
|
|
31200
30614
|
headers.forEach((header) => {
|
|
31201
30615
|
const { rId, referenceFile, currentFileName } = getHeaderFooterSectionData(header, docx);
|
|
31202
30616
|
const sectPrHeader = allSectPrElements.find((el) => el.name === "w:headerReference" && el.attributes["r:id"] === rId);
|
|
@@ -31356,7 +30770,7 @@
|
|
|
31356
30770
|
return;
|
|
31357
30771
|
}
|
|
31358
30772
|
}
|
|
31359
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2
|
|
30773
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.13.2") {
|
|
31360
30774
|
const customLocation = "docProps/custom.xml";
|
|
31361
30775
|
if (!docx[customLocation]) {
|
|
31362
30776
|
docx[customLocation] = generateCustomXml();
|
|
@@ -31823,7 +31237,7 @@
|
|
|
31823
31237
|
function generateCustomXml() {
|
|
31824
31238
|
return DEFAULT_CUSTOM_XML;
|
|
31825
31239
|
}
|
|
31826
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.13.2
|
|
31240
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.13.2") {
|
|
31827
31241
|
return {
|
|
31828
31242
|
type: "element",
|
|
31829
31243
|
name: "property",
|
|
@@ -34356,7 +33770,7 @@
|
|
|
34356
33770
|
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);
|
|
34357
33771
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
34358
33772
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
34359
|
-
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,
|
|
33773
|
+
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;
|
|
34360
33774
|
function getMarksFromSelection(state2) {
|
|
34361
33775
|
const { from: from2, to, empty: empty2 } = state2.selection;
|
|
34362
33776
|
const marks = [];
|
|
@@ -35545,6 +34959,164 @@
|
|
|
35545
34959
|
};
|
|
35546
34960
|
__privateAdd$1(_Schema, _Schema_static);
|
|
35547
34961
|
let Schema = _Schema;
|
|
34962
|
+
function chainableEditorState(transaction, state2) {
|
|
34963
|
+
let { selection, doc: doc2, storedMarks } = transaction;
|
|
34964
|
+
return {
|
|
34965
|
+
...state2,
|
|
34966
|
+
apply: state2.apply.bind(state2),
|
|
34967
|
+
applyTransaction: state2.applyTransaction.bind(state2),
|
|
34968
|
+
plugins: state2.plugins,
|
|
34969
|
+
schema: state2.schema,
|
|
34970
|
+
reconfigure: state2.reconfigure.bind(state2),
|
|
34971
|
+
toJSON: state2.toJSON.bind(state2),
|
|
34972
|
+
get storedMarks() {
|
|
34973
|
+
return storedMarks;
|
|
34974
|
+
},
|
|
34975
|
+
get selection() {
|
|
34976
|
+
return selection;
|
|
34977
|
+
},
|
|
34978
|
+
get doc() {
|
|
34979
|
+
return doc2;
|
|
34980
|
+
},
|
|
34981
|
+
get tr() {
|
|
34982
|
+
selection = transaction.selection;
|
|
34983
|
+
doc2 = transaction.doc;
|
|
34984
|
+
storedMarks = transaction.storedMarks;
|
|
34985
|
+
return transaction;
|
|
34986
|
+
}
|
|
34987
|
+
};
|
|
34988
|
+
}
|
|
34989
|
+
class CommandService {
|
|
34990
|
+
constructor(props) {
|
|
34991
|
+
__publicField$1(this, "editor");
|
|
34992
|
+
__publicField$1(this, "rawCommands");
|
|
34993
|
+
this.editor = props.editor;
|
|
34994
|
+
this.rawCommands = this.editor.extensionService.commands;
|
|
34995
|
+
}
|
|
34996
|
+
/**
|
|
34997
|
+
* Static method for creating a service.
|
|
34998
|
+
* @param args Arguments for the constructor.
|
|
34999
|
+
*/
|
|
35000
|
+
static create(...args) {
|
|
35001
|
+
return new CommandService(...args);
|
|
35002
|
+
}
|
|
35003
|
+
/**
|
|
35004
|
+
* Get editor state.
|
|
35005
|
+
*/
|
|
35006
|
+
get state() {
|
|
35007
|
+
return this.editor.state;
|
|
35008
|
+
}
|
|
35009
|
+
/**
|
|
35010
|
+
* Get all commands with wrapped command method.
|
|
35011
|
+
*/
|
|
35012
|
+
get commands() {
|
|
35013
|
+
const { editor, state: state2 } = this;
|
|
35014
|
+
const { view } = editor;
|
|
35015
|
+
const { tr } = state2;
|
|
35016
|
+
const props = this.createProps(tr);
|
|
35017
|
+
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
35018
|
+
const method = (...args) => {
|
|
35019
|
+
const fn2 = command2(...args)(props);
|
|
35020
|
+
if (!tr.getMeta("preventDispatch")) {
|
|
35021
|
+
view.dispatch(tr);
|
|
35022
|
+
}
|
|
35023
|
+
return fn2;
|
|
35024
|
+
};
|
|
35025
|
+
return [name, method];
|
|
35026
|
+
});
|
|
35027
|
+
return Object.fromEntries(entries);
|
|
35028
|
+
}
|
|
35029
|
+
/**
|
|
35030
|
+
* Create a chain of commands to call multiple commands at once.
|
|
35031
|
+
*/
|
|
35032
|
+
get chain() {
|
|
35033
|
+
return () => this.createChain();
|
|
35034
|
+
}
|
|
35035
|
+
/**
|
|
35036
|
+
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
35037
|
+
*/
|
|
35038
|
+
get can() {
|
|
35039
|
+
return () => this.createCan();
|
|
35040
|
+
}
|
|
35041
|
+
/**
|
|
35042
|
+
* Creates a chain of commands.
|
|
35043
|
+
* @param startTr Start transaction.
|
|
35044
|
+
* @param shouldDispatch Should dispatch or not.
|
|
35045
|
+
*/
|
|
35046
|
+
createChain(startTr, shouldDispatch = true) {
|
|
35047
|
+
const { editor, state: state2, rawCommands } = this;
|
|
35048
|
+
const { view } = editor;
|
|
35049
|
+
const callbacks2 = [];
|
|
35050
|
+
const hasStartTr = !!startTr;
|
|
35051
|
+
const tr = startTr || state2.tr;
|
|
35052
|
+
const run2 = () => {
|
|
35053
|
+
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
35054
|
+
view.dispatch(tr);
|
|
35055
|
+
}
|
|
35056
|
+
return callbacks2.every((cb) => cb === true);
|
|
35057
|
+
};
|
|
35058
|
+
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
35059
|
+
const chainedCommand = (...args) => {
|
|
35060
|
+
const props = this.createProps(tr, shouldDispatch);
|
|
35061
|
+
const callback = command2(...args)(props);
|
|
35062
|
+
callbacks2.push(callback);
|
|
35063
|
+
return chain;
|
|
35064
|
+
};
|
|
35065
|
+
return [name, chainedCommand];
|
|
35066
|
+
});
|
|
35067
|
+
const chain = {
|
|
35068
|
+
...Object.fromEntries(entries),
|
|
35069
|
+
run: run2
|
|
35070
|
+
};
|
|
35071
|
+
return chain;
|
|
35072
|
+
}
|
|
35073
|
+
/**
|
|
35074
|
+
* Creates a can check for commands.
|
|
35075
|
+
* @param startTr Start transaction.
|
|
35076
|
+
*/
|
|
35077
|
+
createCan(startTr) {
|
|
35078
|
+
const { rawCommands, state: state2 } = this;
|
|
35079
|
+
const dispatch = false;
|
|
35080
|
+
const tr = startTr || state2.tr;
|
|
35081
|
+
const props = this.createProps(tr, dispatch);
|
|
35082
|
+
const commands2 = Object.fromEntries(
|
|
35083
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
35084
|
+
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
35085
|
+
})
|
|
35086
|
+
);
|
|
35087
|
+
return {
|
|
35088
|
+
...commands2,
|
|
35089
|
+
chain: () => this.createChain(tr, dispatch)
|
|
35090
|
+
};
|
|
35091
|
+
}
|
|
35092
|
+
/**
|
|
35093
|
+
* Creates default props for the command method.
|
|
35094
|
+
* @param {*} tr Transaction.
|
|
35095
|
+
* @param {*} shouldDispatch Check if should dispatch.
|
|
35096
|
+
* @returns Object with props.
|
|
35097
|
+
*/
|
|
35098
|
+
createProps(tr, shouldDispatch = true) {
|
|
35099
|
+
const { editor, state: state2, rawCommands } = this;
|
|
35100
|
+
const { view } = editor;
|
|
35101
|
+
const props = {
|
|
35102
|
+
tr,
|
|
35103
|
+
editor,
|
|
35104
|
+
view,
|
|
35105
|
+
state: chainableEditorState(tr, state2),
|
|
35106
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
35107
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
35108
|
+
can: () => this.createCan(tr),
|
|
35109
|
+
get commands() {
|
|
35110
|
+
return Object.fromEntries(
|
|
35111
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
35112
|
+
return [name, (...args) => command2(...args)(props)];
|
|
35113
|
+
})
|
|
35114
|
+
);
|
|
35115
|
+
}
|
|
35116
|
+
};
|
|
35117
|
+
return props;
|
|
35118
|
+
}
|
|
35119
|
+
}
|
|
35548
35120
|
const first = (commands2) => (props) => {
|
|
35549
35121
|
const items = typeof commands2 === "function" ? commands2(props) : commands2;
|
|
35550
35122
|
for (let i2 = 0; i2 < items.length; i2 += 1) {
|
|
@@ -35906,7 +35478,7 @@
|
|
|
35906
35478
|
for (let i2 = conn.length - 1; i2 >= 0; i2--)
|
|
35907
35479
|
wrap2 = Fragment.from(conn[i2].create(null, wrap2));
|
|
35908
35480
|
wrap2 = Fragment.from(before.copy(wrap2));
|
|
35909
|
-
let tr = state2.tr.step(new ReplaceAroundStep
|
|
35481
|
+
let tr = state2.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
|
|
35910
35482
|
let $joinAt = tr.doc.resolve(end2 + 2 * conn.length);
|
|
35911
35483
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
|
|
35912
35484
|
tr.join($joinAt.pos);
|
|
@@ -35937,7 +35509,7 @@
|
|
|
35937
35509
|
let end2 = Fragment.empty;
|
|
35938
35510
|
for (let i2 = wrap2.length - 1; i2 >= 0; i2--)
|
|
35939
35511
|
end2 = Fragment.from(wrap2[i2].copy(end2));
|
|
35940
|
-
let tr = state2.tr.step(new ReplaceAroundStep
|
|
35512
|
+
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));
|
|
35941
35513
|
dispatch(tr.scrollIntoView());
|
|
35942
35514
|
}
|
|
35943
35515
|
return true;
|
|
@@ -36510,7 +36082,7 @@
|
|
|
36510
36082
|
return;
|
|
36511
36083
|
}
|
|
36512
36084
|
const step = tr.steps[last];
|
|
36513
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
36085
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
36514
36086
|
return;
|
|
36515
36087
|
}
|
|
36516
36088
|
const map2 = tr.mapping.maps[last];
|
|
@@ -36656,7 +36228,7 @@
|
|
|
36656
36228
|
let content = Fragment.empty;
|
|
36657
36229
|
for (let i2 = wrappers.length - 1; i2 >= 0; i2--)
|
|
36658
36230
|
content = Fragment.from(wrappers[i2].type.create(wrappers[i2].attrs, content));
|
|
36659
|
-
tr.step(new ReplaceAroundStep
|
|
36231
|
+
tr.step(new ReplaceAroundStep(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
36660
36232
|
let found2 = 0;
|
|
36661
36233
|
for (let i2 = 0; i2 < wrappers.length; i2++)
|
|
36662
36234
|
if (wrappers[i2].type == listType)
|
|
@@ -36689,7 +36261,7 @@
|
|
|
36689
36261
|
function liftToOuterList(state2, dispatch, itemType, range2) {
|
|
36690
36262
|
let tr = state2.tr, end2 = range2.end, endOfList = range2.$to.end(range2.depth);
|
|
36691
36263
|
if (end2 < endOfList) {
|
|
36692
|
-
tr.step(new ReplaceAroundStep
|
|
36264
|
+
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
|
|
36693
36265
|
range2 = new NodeRange(tr.doc.resolve(range2.$from.pos), tr.doc.resolve(endOfList), range2.depth);
|
|
36694
36266
|
}
|
|
36695
36267
|
const target = liftTarget(range2);
|
|
@@ -36716,7 +36288,7 @@
|
|
|
36716
36288
|
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))
|
|
36717
36289
|
return false;
|
|
36718
36290
|
let start2 = $start.pos, end2 = start2 + item.nodeSize;
|
|
36719
|
-
tr.step(new ReplaceAroundStep
|
|
36291
|
+
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));
|
|
36720
36292
|
dispatch(tr.scrollIntoView());
|
|
36721
36293
|
return true;
|
|
36722
36294
|
}
|
|
@@ -36737,7 +36309,7 @@
|
|
|
36737
36309
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
36738
36310
|
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
36739
36311
|
let before = range2.start, after = range2.end;
|
|
36740
|
-
dispatch(state2.tr.step(new ReplaceAroundStep
|
|
36312
|
+
dispatch(state2.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
36741
36313
|
}
|
|
36742
36314
|
return true;
|
|
36743
36315
|
};
|
|
@@ -44330,8 +43902,7 @@
|
|
|
44330
43902
|
binding.mapping
|
|
44331
43903
|
);
|
|
44332
43904
|
if (anchor !== null && head !== null) {
|
|
44333
|
-
|
|
44334
|
-
tr.setSelection(sel);
|
|
43905
|
+
tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));
|
|
44335
43906
|
}
|
|
44336
43907
|
}
|
|
44337
43908
|
}
|
|
@@ -45112,7 +44683,7 @@
|
|
|
45112
44683
|
};
|
|
45113
44684
|
const absolutePositionToRelativePosition = (pos, type2, mapping) => {
|
|
45114
44685
|
if (pos === 0) {
|
|
45115
|
-
return Y__namespace.createRelativePositionFromTypeIndex(type2, 0,
|
|
44686
|
+
return Y__namespace.createRelativePositionFromTypeIndex(type2, 0, -1);
|
|
45116
44687
|
}
|
|
45117
44688
|
let n = type2._first === null ? null : (
|
|
45118
44689
|
/** @type {Y.ContentType} */
|
|
@@ -45121,7 +44692,7 @@
|
|
|
45121
44692
|
while (n !== null && type2 !== n) {
|
|
45122
44693
|
if (n instanceof Y__namespace.XmlText) {
|
|
45123
44694
|
if (n._length >= pos) {
|
|
45124
|
-
return Y__namespace.createRelativePositionFromTypeIndex(n, pos,
|
|
44695
|
+
return Y__namespace.createRelativePositionFromTypeIndex(n, pos, -1);
|
|
45125
44696
|
} else {
|
|
45126
44697
|
pos -= n._length;
|
|
45127
44698
|
}
|
|
@@ -45185,7 +44756,7 @@
|
|
|
45185
44756
|
return createRelativePosition(n._item.parent, n._item);
|
|
45186
44757
|
}
|
|
45187
44758
|
}
|
|
45188
|
-
return Y__namespace.createRelativePositionFromTypeIndex(type2, type2._length,
|
|
44759
|
+
return Y__namespace.createRelativePositionFromTypeIndex(type2, type2._length, -1);
|
|
45189
44760
|
};
|
|
45190
44761
|
const createRelativePosition = (type2, item) => {
|
|
45191
44762
|
let typeid = null;
|
|
@@ -45782,6 +45353,409 @@
|
|
|
45782
45353
|
}
|
|
45783
45354
|
return enabled;
|
|
45784
45355
|
}
|
|
45356
|
+
function getHTMLFromFragment(fragment, schema) {
|
|
45357
|
+
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
45358
|
+
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
45359
|
+
const container = temporaryDocument.createElement("div");
|
|
45360
|
+
container.appendChild(documentFragment);
|
|
45361
|
+
return container.innerHTML;
|
|
45362
|
+
}
|
|
45363
|
+
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
45364
|
+
let textBefore = "";
|
|
45365
|
+
const sliceEndPos = $from.parentOffset;
|
|
45366
|
+
$from.parent.nodesBetween(
|
|
45367
|
+
Math.max(0, sliceEndPos - maxMatch),
|
|
45368
|
+
sliceEndPos,
|
|
45369
|
+
(node2, pos, parent, index2) => {
|
|
45370
|
+
const chunk = node2.type.spec.toText?.({
|
|
45371
|
+
node: node2,
|
|
45372
|
+
pos,
|
|
45373
|
+
parent,
|
|
45374
|
+
index: index2
|
|
45375
|
+
}) || node2.textContent || "%leaf%";
|
|
45376
|
+
textBefore += node2.isAtom && !node2.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
45377
|
+
}
|
|
45378
|
+
);
|
|
45379
|
+
return textBefore;
|
|
45380
|
+
};
|
|
45381
|
+
const handleDocxPaste = (html, editor, view, plugin2) => {
|
|
45382
|
+
const { converter } = editor;
|
|
45383
|
+
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
|
|
45384
|
+
let cleanedHtml = convertEmToPt(html);
|
|
45385
|
+
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
45386
|
+
const tempDiv = document.createElement("div");
|
|
45387
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
45388
|
+
const paragraphs = tempDiv.querySelectorAll("p");
|
|
45389
|
+
paragraphs.forEach((p2) => {
|
|
45390
|
+
const innerHTML3 = p2.innerHTML;
|
|
45391
|
+
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
45392
|
+
const styleAttr = p2.getAttribute("style") || "";
|
|
45393
|
+
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
45394
|
+
if (msoListMatch) {
|
|
45395
|
+
const [, abstractId, level] = msoListMatch;
|
|
45396
|
+
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
45397
|
+
if (!listNumId) return;
|
|
45398
|
+
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
45399
|
+
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
45400
|
+
p2.setAttribute("data-num-id", listNumId);
|
|
45401
|
+
p2.setAttribute("data-list-level", level - 1);
|
|
45402
|
+
p2.setAttribute("data-start", start2);
|
|
45403
|
+
p2.setAttribute("data-lvl-text", lvlText);
|
|
45404
|
+
p2.setAttribute("data-num-fmt", numFmt);
|
|
45405
|
+
}
|
|
45406
|
+
extractAndRemoveConditionalPrefix(p2);
|
|
45407
|
+
});
|
|
45408
|
+
transformWordLists(tempDiv);
|
|
45409
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
45410
|
+
tempDiv.remove();
|
|
45411
|
+
const { dispatch } = editor.view;
|
|
45412
|
+
if (!dispatch) return false;
|
|
45413
|
+
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
45414
|
+
return true;
|
|
45415
|
+
};
|
|
45416
|
+
const getLevelDefinition = (abstractDefinition, level) => {
|
|
45417
|
+
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
45418
|
+
const levelElement = abstractDefinition.elements.find((el) => {
|
|
45419
|
+
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
45420
|
+
});
|
|
45421
|
+
if (!levelElement) return null;
|
|
45422
|
+
const { elements } = levelElement;
|
|
45423
|
+
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
45424
|
+
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
45425
|
+
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
45426
|
+
return { lvlText, start: start2, numFmt, elements };
|
|
45427
|
+
};
|
|
45428
|
+
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
45429
|
+
const { definitions } = editor?.converter?.numbering;
|
|
45430
|
+
if (!definitions) return null;
|
|
45431
|
+
const matchedDefinition = Object.values(definitions).find((def2) => {
|
|
45432
|
+
return def2.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
45433
|
+
});
|
|
45434
|
+
return matchedDefinition?.attributes?.["w:numId"];
|
|
45435
|
+
};
|
|
45436
|
+
const getListAbstractDefinition = (abstractId, editor) => {
|
|
45437
|
+
const { abstracts = {} } = editor?.converter?.numbering;
|
|
45438
|
+
return abstracts[abstractId] || null;
|
|
45439
|
+
};
|
|
45440
|
+
const transformWordLists = (container) => {
|
|
45441
|
+
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
45442
|
+
const listMap = /* @__PURE__ */ new Map();
|
|
45443
|
+
const listLevels = {};
|
|
45444
|
+
for (const p2 of paragraphs) {
|
|
45445
|
+
const listId = p2.getAttribute("data-num-id");
|
|
45446
|
+
const level = parseInt(p2.getAttribute("data-list-level"));
|
|
45447
|
+
const numFmt = p2.getAttribute("data-num-fmt");
|
|
45448
|
+
const start2 = p2.getAttribute("data-start");
|
|
45449
|
+
const lvlText = p2.getAttribute("data-lvl-text");
|
|
45450
|
+
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
45451
|
+
listMap.get(listId).push({ p: p2, level, numFmt, start: start2, lvlText });
|
|
45452
|
+
}
|
|
45453
|
+
for (const [id, items] of listMap.entries()) {
|
|
45454
|
+
if (!listLevels[id]) {
|
|
45455
|
+
listLevels[id] = {
|
|
45456
|
+
stack: [],
|
|
45457
|
+
counts: {},
|
|
45458
|
+
prevLevel: null
|
|
45459
|
+
};
|
|
45460
|
+
}
|
|
45461
|
+
const parentStack = [];
|
|
45462
|
+
items.forEach(({ p: p2, level, numFmt, start: start2, lvlText }, index2) => {
|
|
45463
|
+
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
45464
|
+
const li = document.createElement("li");
|
|
45465
|
+
li.innerHTML = p2.innerHTML;
|
|
45466
|
+
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
45467
|
+
li.setAttribute("data-num-id", id);
|
|
45468
|
+
li.setAttribute("data-lvl-text", lvlText);
|
|
45469
|
+
li.setAttribute("data-num-fmt", numFmt);
|
|
45470
|
+
if (p2.hasAttribute("data-font-family")) {
|
|
45471
|
+
li.setAttribute("data-font-family", p2.getAttribute("data-font-family"));
|
|
45472
|
+
}
|
|
45473
|
+
if (p2.hasAttribute("data-font-size")) {
|
|
45474
|
+
li.setAttribute("data-font-size", p2.getAttribute("data-font-size"));
|
|
45475
|
+
}
|
|
45476
|
+
const parentNode2 = p2.parentNode;
|
|
45477
|
+
let listForLevel = parentStack[level];
|
|
45478
|
+
if (!listForLevel) {
|
|
45479
|
+
const newList = document.createElement("ol");
|
|
45480
|
+
newList.setAttribute("data-list-id", id);
|
|
45481
|
+
newList.level = level;
|
|
45482
|
+
if (level > 0) {
|
|
45483
|
+
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
45484
|
+
if (parentLi) parentLi.appendChild(newList);
|
|
45485
|
+
} else {
|
|
45486
|
+
parentNode2.insertBefore(newList, p2);
|
|
45487
|
+
}
|
|
45488
|
+
parentStack[level] = newList;
|
|
45489
|
+
parentStack.length = level + 1;
|
|
45490
|
+
listForLevel = newList;
|
|
45491
|
+
}
|
|
45492
|
+
listForLevel.appendChild(li);
|
|
45493
|
+
p2.remove();
|
|
45494
|
+
});
|
|
45495
|
+
}
|
|
45496
|
+
};
|
|
45497
|
+
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
45498
|
+
const levelState = listLevels[listId];
|
|
45499
|
+
if (!levelState.stack) levelState.stack = [];
|
|
45500
|
+
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
45501
|
+
if (levelState.prevLevel === null) {
|
|
45502
|
+
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
45503
|
+
} else {
|
|
45504
|
+
if (currentLevel > levelState.prevLevel) {
|
|
45505
|
+
levelState.stack.push(1);
|
|
45506
|
+
} else if (currentLevel === levelState.prevLevel) {
|
|
45507
|
+
levelState.stack[levelState.stack.length - 1]++;
|
|
45508
|
+
} else {
|
|
45509
|
+
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
45510
|
+
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
45511
|
+
}
|
|
45512
|
+
}
|
|
45513
|
+
levelState.prevLevel = currentLevel;
|
|
45514
|
+
return [...levelState.stack];
|
|
45515
|
+
}
|
|
45516
|
+
function extractAndRemoveConditionalPrefix(p2) {
|
|
45517
|
+
const nodes = Array.from(p2.childNodes);
|
|
45518
|
+
let fontFamily2 = null;
|
|
45519
|
+
let fontSize2 = null;
|
|
45520
|
+
let start2 = -1, end2 = -1;
|
|
45521
|
+
nodes.forEach((node2, index2) => {
|
|
45522
|
+
if (node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[if !supportLists]")) {
|
|
45523
|
+
start2 = index2;
|
|
45524
|
+
}
|
|
45525
|
+
if (start2 !== -1 && node2.nodeType === Node.COMMENT_NODE && node2.nodeValue.includes("[endif]")) {
|
|
45526
|
+
end2 = index2;
|
|
45527
|
+
}
|
|
45528
|
+
});
|
|
45529
|
+
if (start2 !== -1 && end2 !== -1) {
|
|
45530
|
+
for (let i2 = start2 + 1; i2 < end2; i2++) {
|
|
45531
|
+
const node2 = nodes[i2];
|
|
45532
|
+
if (node2.nodeType === Node.ELEMENT_NODE && node2.style) {
|
|
45533
|
+
fontFamily2 = fontFamily2 || node2.style.fontFamily;
|
|
45534
|
+
fontSize2 = fontSize2 || node2.style.fontSize;
|
|
45535
|
+
}
|
|
45536
|
+
}
|
|
45537
|
+
for (let i2 = end2; i2 >= start2; i2--) {
|
|
45538
|
+
p2.removeChild(p2.childNodes[i2]);
|
|
45539
|
+
}
|
|
45540
|
+
if (fontFamily2) p2.setAttribute("data-font-family", fontFamily2);
|
|
45541
|
+
if (fontSize2) p2.setAttribute("data-font-size", fontSize2);
|
|
45542
|
+
}
|
|
45543
|
+
}
|
|
45544
|
+
class InputRule {
|
|
45545
|
+
constructor(config) {
|
|
45546
|
+
__publicField$1(this, "match");
|
|
45547
|
+
__publicField$1(this, "handler");
|
|
45548
|
+
this.match = config.match;
|
|
45549
|
+
this.handler = config.handler;
|
|
45550
|
+
}
|
|
45551
|
+
}
|
|
45552
|
+
const inputRuleMatcherHandler = (text, match) => {
|
|
45553
|
+
if (isRegExp(match)) {
|
|
45554
|
+
return match.exec(text);
|
|
45555
|
+
}
|
|
45556
|
+
const inputRuleMatch = match(text);
|
|
45557
|
+
if (!inputRuleMatch) {
|
|
45558
|
+
return null;
|
|
45559
|
+
}
|
|
45560
|
+
const result = [inputRuleMatch.text];
|
|
45561
|
+
result.index = inputRuleMatch.index;
|
|
45562
|
+
result.input = text;
|
|
45563
|
+
result.data = inputRuleMatch.data;
|
|
45564
|
+
if (inputRuleMatch.replaceWith) {
|
|
45565
|
+
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
45566
|
+
console.warn(
|
|
45567
|
+
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
45568
|
+
);
|
|
45569
|
+
}
|
|
45570
|
+
result.push(inputRuleMatch.replaceWith);
|
|
45571
|
+
}
|
|
45572
|
+
return result;
|
|
45573
|
+
};
|
|
45574
|
+
const run = (config) => {
|
|
45575
|
+
const {
|
|
45576
|
+
editor,
|
|
45577
|
+
from: from2,
|
|
45578
|
+
to,
|
|
45579
|
+
text,
|
|
45580
|
+
rules,
|
|
45581
|
+
plugin: plugin2
|
|
45582
|
+
} = config;
|
|
45583
|
+
const { view } = editor;
|
|
45584
|
+
if (view.composing) {
|
|
45585
|
+
return false;
|
|
45586
|
+
}
|
|
45587
|
+
const $from = view.state.doc.resolve(from2);
|
|
45588
|
+
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
45589
|
+
return false;
|
|
45590
|
+
}
|
|
45591
|
+
let matched = false;
|
|
45592
|
+
const textBefore = getTextContentFromNodes($from) + text;
|
|
45593
|
+
rules.forEach((rule) => {
|
|
45594
|
+
if (matched) {
|
|
45595
|
+
return;
|
|
45596
|
+
}
|
|
45597
|
+
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
45598
|
+
if (!match) {
|
|
45599
|
+
return;
|
|
45600
|
+
}
|
|
45601
|
+
const tr = view.state.tr;
|
|
45602
|
+
const state2 = chainableEditorState(tr, view.state);
|
|
45603
|
+
const range2 = {
|
|
45604
|
+
from: from2 - (match[0].length - text.length),
|
|
45605
|
+
to
|
|
45606
|
+
};
|
|
45607
|
+
const { commands: commands2, chain, can } = new CommandService({
|
|
45608
|
+
editor,
|
|
45609
|
+
state: state2
|
|
45610
|
+
});
|
|
45611
|
+
const handler = rule.handler({
|
|
45612
|
+
state: state2,
|
|
45613
|
+
range: range2,
|
|
45614
|
+
match,
|
|
45615
|
+
commands: commands2,
|
|
45616
|
+
chain,
|
|
45617
|
+
can
|
|
45618
|
+
});
|
|
45619
|
+
if (handler === null || !tr.steps.length) {
|
|
45620
|
+
return;
|
|
45621
|
+
}
|
|
45622
|
+
tr.setMeta(plugin2, {
|
|
45623
|
+
transform: tr,
|
|
45624
|
+
from: from2,
|
|
45625
|
+
to,
|
|
45626
|
+
text
|
|
45627
|
+
});
|
|
45628
|
+
view.dispatch(tr);
|
|
45629
|
+
matched = true;
|
|
45630
|
+
});
|
|
45631
|
+
return matched;
|
|
45632
|
+
};
|
|
45633
|
+
const inputRulesPlugin = ({ editor, rules }) => {
|
|
45634
|
+
const plugin2 = new Plugin({
|
|
45635
|
+
key: new PluginKey("inputRulesPlugin"),
|
|
45636
|
+
state: {
|
|
45637
|
+
init() {
|
|
45638
|
+
return null;
|
|
45639
|
+
},
|
|
45640
|
+
apply(tr, prev, state2) {
|
|
45641
|
+
const stored = tr.getMeta(plugin2);
|
|
45642
|
+
if (stored) {
|
|
45643
|
+
return stored;
|
|
45644
|
+
}
|
|
45645
|
+
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
45646
|
+
const isSimulatedInput = !!simulatedInputMeta;
|
|
45647
|
+
if (isSimulatedInput) {
|
|
45648
|
+
setTimeout(() => {
|
|
45649
|
+
let { text } = simulatedInputMeta;
|
|
45650
|
+
if (typeof text !== "string") {
|
|
45651
|
+
text = getHTMLFromFragment(Fragment.from(text), state2.schema);
|
|
45652
|
+
}
|
|
45653
|
+
const { from: from2 } = simulatedInputMeta;
|
|
45654
|
+
const to = from2 + text.length;
|
|
45655
|
+
run({
|
|
45656
|
+
editor,
|
|
45657
|
+
from: from2,
|
|
45658
|
+
to,
|
|
45659
|
+
text,
|
|
45660
|
+
rules,
|
|
45661
|
+
plugin: plugin2
|
|
45662
|
+
});
|
|
45663
|
+
});
|
|
45664
|
+
}
|
|
45665
|
+
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
45666
|
+
}
|
|
45667
|
+
},
|
|
45668
|
+
props: {
|
|
45669
|
+
handleTextInput(view, from2, to, text) {
|
|
45670
|
+
return run({
|
|
45671
|
+
editor,
|
|
45672
|
+
from: from2,
|
|
45673
|
+
to,
|
|
45674
|
+
text,
|
|
45675
|
+
rules,
|
|
45676
|
+
plugin: plugin2
|
|
45677
|
+
});
|
|
45678
|
+
},
|
|
45679
|
+
// add support for input rules to trigger on enter
|
|
45680
|
+
// this is useful for example for code blocks
|
|
45681
|
+
handleKeyDown(view, event) {
|
|
45682
|
+
if (event.key !== "Enter") {
|
|
45683
|
+
return false;
|
|
45684
|
+
}
|
|
45685
|
+
const { $cursor } = view.state.selection;
|
|
45686
|
+
if ($cursor) {
|
|
45687
|
+
return run({
|
|
45688
|
+
editor,
|
|
45689
|
+
from: $cursor.pos,
|
|
45690
|
+
to: $cursor.pos,
|
|
45691
|
+
text: "\n",
|
|
45692
|
+
rules,
|
|
45693
|
+
plugin: plugin2
|
|
45694
|
+
});
|
|
45695
|
+
}
|
|
45696
|
+
return false;
|
|
45697
|
+
},
|
|
45698
|
+
// Paste handler
|
|
45699
|
+
handlePaste(view, event, slice2) {
|
|
45700
|
+
const clipboard = event.clipboardData;
|
|
45701
|
+
const html = clipboard.getData("text/html");
|
|
45702
|
+
clipboard.getData("text/plain");
|
|
45703
|
+
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
45704
|
+
if (fieldAnnotationContent.length) {
|
|
45705
|
+
return false;
|
|
45706
|
+
}
|
|
45707
|
+
let source;
|
|
45708
|
+
if (!html) {
|
|
45709
|
+
source = "plain-text";
|
|
45710
|
+
} else if (isWordHtml(html)) {
|
|
45711
|
+
source = "word-html";
|
|
45712
|
+
} else {
|
|
45713
|
+
source = "browser-html";
|
|
45714
|
+
}
|
|
45715
|
+
switch (source) {
|
|
45716
|
+
case "plain-text":
|
|
45717
|
+
break;
|
|
45718
|
+
case "word-html":
|
|
45719
|
+
if (editor.options.mode === "docx") {
|
|
45720
|
+
return handleDocxPaste(html, editor, view, plugin2);
|
|
45721
|
+
}
|
|
45722
|
+
case "browser-html":
|
|
45723
|
+
return handleHtmlPaste$1(html, editor);
|
|
45724
|
+
}
|
|
45725
|
+
return false;
|
|
45726
|
+
}
|
|
45727
|
+
},
|
|
45728
|
+
isInputRules: true
|
|
45729
|
+
});
|
|
45730
|
+
return plugin2;
|
|
45731
|
+
};
|
|
45732
|
+
function isWordHtml(html) {
|
|
45733
|
+
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
45734
|
+
}
|
|
45735
|
+
const handleHtmlPaste$1 = (html, editor, plugin2) => {
|
|
45736
|
+
const cleanedHtml = convertEmToPt(html);
|
|
45737
|
+
const tempDiv = document.createElement("div");
|
|
45738
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
45739
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
45740
|
+
tempDiv.remove();
|
|
45741
|
+
const { dispatch } = editor.view;
|
|
45742
|
+
if (!dispatch) return false;
|
|
45743
|
+
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
45744
|
+
return true;
|
|
45745
|
+
};
|
|
45746
|
+
const convertEmToPt = (html) => {
|
|
45747
|
+
return html.replace(
|
|
45748
|
+
/font-size\s*:\s*([\d.]+)em/gi,
|
|
45749
|
+
(_, emValue) => {
|
|
45750
|
+
const em = parseFloat(emValue);
|
|
45751
|
+
const pt = Math.round(em * 12 * 100) / 100;
|
|
45752
|
+
return `font-size: ${pt}pt`;
|
|
45753
|
+
}
|
|
45754
|
+
);
|
|
45755
|
+
};
|
|
45756
|
+
function cleanHtmlUnnecessaryTags(html) {
|
|
45757
|
+
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
45758
|
+
}
|
|
45785
45759
|
const _ExtensionService = class _ExtensionService2 {
|
|
45786
45760
|
constructor(extensions, userExtensions, editor) {
|
|
45787
45761
|
__privateAdd$1(this, _ExtensionService_instances);
|
|
@@ -46620,7 +46594,6 @@
|
|
|
46620
46594
|
mediaFiles: editor.storage.image.media,
|
|
46621
46595
|
fonts: editor.options.fonts,
|
|
46622
46596
|
isHeaderOrFooter: true,
|
|
46623
|
-
isHeadless: editor.options.isHeadless,
|
|
46624
46597
|
annotations: true,
|
|
46625
46598
|
currentPageNumber,
|
|
46626
46599
|
parentEditor: editor,
|
|
@@ -46628,15 +46601,13 @@
|
|
|
46628
46601
|
onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
|
|
46629
46602
|
});
|
|
46630
46603
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
46631
|
-
|
|
46632
|
-
|
|
46633
|
-
|
|
46634
|
-
|
|
46635
|
-
|
|
46636
|
-
|
|
46637
|
-
|
|
46638
|
-
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
46639
|
-
}
|
|
46604
|
+
pm.style.maxHeight = "100%";
|
|
46605
|
+
pm.style.minHeight = "100%";
|
|
46606
|
+
pm.style.outline = "none";
|
|
46607
|
+
pm.style.border = "none";
|
|
46608
|
+
pm.setAttribute("role", "textbox");
|
|
46609
|
+
pm.setAttribute("aria-multiline", true);
|
|
46610
|
+
pm.setAttribute("aria-label", `${type2} content area. Double click to start typing.`);
|
|
46640
46611
|
return headerFooterEditor;
|
|
46641
46612
|
};
|
|
46642
46613
|
const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
@@ -46655,16 +46626,14 @@
|
|
|
46655
46626
|
});
|
|
46656
46627
|
});
|
|
46657
46628
|
};
|
|
46658
|
-
const toggleHeaderFooterEditMode = (
|
|
46629
|
+
const toggleHeaderFooterEditMode = (editor, focusedSectionEditor, isEditMode) => {
|
|
46659
46630
|
editor.converter.headerEditors.forEach((item) => {
|
|
46660
46631
|
item.editor.setEditable(isEditMode, false);
|
|
46661
46632
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
46662
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
46663
46633
|
});
|
|
46664
46634
|
editor.converter.footerEditors.forEach((item) => {
|
|
46665
46635
|
item.editor.setEditable(isEditMode, false);
|
|
46666
46636
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
46667
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
46668
46637
|
});
|
|
46669
46638
|
if (isEditMode) {
|
|
46670
46639
|
const pm = document.querySelector(".ProseMirror");
|
|
@@ -47994,16 +47963,6 @@
|
|
|
47994
47963
|
const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
|
|
47995
47964
|
dispatch(tr);
|
|
47996
47965
|
};
|
|
47997
|
-
const setImageNodeSelection = (view, pos) => {
|
|
47998
|
-
const { doc: doc2 } = view.state;
|
|
47999
|
-
const node2 = doc2.nodeAt(pos);
|
|
48000
|
-
if (node2 && node2.type.name === "image") {
|
|
48001
|
-
const tr = view.state.tr.setSelection(NodeSelection.create(doc2, pos));
|
|
48002
|
-
view.dispatch(tr);
|
|
48003
|
-
return true;
|
|
48004
|
-
}
|
|
48005
|
-
return false;
|
|
48006
|
-
};
|
|
48007
47966
|
const _Editor = class _Editor2 extends EventEmitter$2 {
|
|
48008
47967
|
/**
|
|
48009
47968
|
* Create a new Editor instance
|
|
@@ -48102,19 +48061,6 @@
|
|
|
48102
48061
|
this.setHighContrastMode = setHighContrastMode;
|
|
48103
48062
|
initMode();
|
|
48104
48063
|
}
|
|
48105
|
-
mount(el) {
|
|
48106
|
-
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
48107
|
-
window.setTimeout(() => {
|
|
48108
|
-
if (this.isDestroyed) return;
|
|
48109
|
-
this.emit("create", { editor: this });
|
|
48110
|
-
}, 0);
|
|
48111
|
-
}
|
|
48112
|
-
unmount() {
|
|
48113
|
-
if (this.view) {
|
|
48114
|
-
this.view.destroy();
|
|
48115
|
-
}
|
|
48116
|
-
this.view = null;
|
|
48117
|
-
}
|
|
48118
48064
|
/**
|
|
48119
48065
|
* Set the toolbar for this editor
|
|
48120
48066
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -48163,7 +48109,7 @@
|
|
|
48163
48109
|
* @returns {boolean}
|
|
48164
48110
|
*/
|
|
48165
48111
|
get isDestroyed() {
|
|
48166
|
-
return this.view
|
|
48112
|
+
return this.view.isDestroyed;
|
|
48167
48113
|
}
|
|
48168
48114
|
/**
|
|
48169
48115
|
* Get the editor element
|
|
@@ -48206,12 +48152,7 @@
|
|
|
48206
48152
|
this.commands.toggleTrackChangesShowOriginal();
|
|
48207
48153
|
this.setEditable(false, false);
|
|
48208
48154
|
this.setOptions({ documentMode: "viewing" });
|
|
48209
|
-
toggleHeaderFooterEditMode(
|
|
48210
|
-
editor: this,
|
|
48211
|
-
focusedSectionEditor: null,
|
|
48212
|
-
isEditMode: false,
|
|
48213
|
-
documentMode: cleanedMode
|
|
48214
|
-
});
|
|
48155
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
48215
48156
|
} else if (cleanedMode === "suggesting") {
|
|
48216
48157
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
48217
48158
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -48224,12 +48165,7 @@
|
|
|
48224
48165
|
this.commands.disableTrackChanges();
|
|
48225
48166
|
this.setEditable(true, false);
|
|
48226
48167
|
this.setOptions({ documentMode: "editing" });
|
|
48227
|
-
toggleHeaderFooterEditMode(
|
|
48228
|
-
editor: this,
|
|
48229
|
-
focusedSectionEditor: null,
|
|
48230
|
-
isEditMode: false,
|
|
48231
|
-
documentMode: cleanedMode
|
|
48232
|
-
});
|
|
48168
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
48233
48169
|
}
|
|
48234
48170
|
}
|
|
48235
48171
|
/**
|
|
@@ -48406,26 +48342,29 @@
|
|
|
48406
48342
|
};
|
|
48407
48343
|
}
|
|
48408
48344
|
/**
|
|
48409
|
-
|
|
48410
|
-
|
|
48411
|
-
|
|
48345
|
+
* Initialize default styles for the editor container and ProseMirror.
|
|
48346
|
+
* Get page size and margins from the converter.
|
|
48347
|
+
* Set document default font and font size.
|
|
48348
|
+
*
|
|
48349
|
+
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
48350
|
+
* @returns {void}
|
|
48351
|
+
*/
|
|
48352
|
+
initDefaultStyles(element = this.element) {
|
|
48353
|
+
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
48354
|
+
const proseMirror = element?.querySelector(".ProseMirror");
|
|
48412
48355
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
48413
|
-
if (!proseMirror || !
|
|
48356
|
+
if (!proseMirror || !pageSize || !pageMargins) {
|
|
48414
48357
|
return;
|
|
48415
48358
|
}
|
|
48416
48359
|
proseMirror.setAttribute("role", "document");
|
|
48417
48360
|
proseMirror.setAttribute("aria-multiline", true);
|
|
48418
48361
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
48419
48362
|
proseMirror.setAttribute("aria-description", "");
|
|
48420
|
-
|
|
48421
|
-
|
|
48422
|
-
|
|
48423
|
-
|
|
48424
|
-
|
|
48425
|
-
if (pageMargins) {
|
|
48426
|
-
element.style.paddingLeft = pageMargins.left + "in";
|
|
48427
|
-
element.style.paddingRight = pageMargins.right + "in";
|
|
48428
|
-
}
|
|
48363
|
+
element.style.width = pageSize.width + "in";
|
|
48364
|
+
element.style.minWidth = pageSize.width + "in";
|
|
48365
|
+
element.style.minHeight = pageSize.height + "in";
|
|
48366
|
+
element.style.paddingLeft = pageMargins.left + "in";
|
|
48367
|
+
element.style.paddingRight = pageMargins.right + "in";
|
|
48429
48368
|
element.style.boxSizing = "border-box";
|
|
48430
48369
|
element.style.isolation = "isolate";
|
|
48431
48370
|
proseMirror.style.outline = "none";
|
|
@@ -48446,19 +48385,6 @@
|
|
|
48446
48385
|
proseMirror.style.paddingTop = "1in";
|
|
48447
48386
|
proseMirror.style.paddingBottom = "1in";
|
|
48448
48387
|
}
|
|
48449
|
-
}
|
|
48450
|
-
/**
|
|
48451
|
-
* Initialize default styles for the editor container and ProseMirror.
|
|
48452
|
-
* Get page size and margins from the converter.
|
|
48453
|
-
* Set document default font and font size.
|
|
48454
|
-
*
|
|
48455
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
48456
|
-
* @returns {void}
|
|
48457
|
-
*/
|
|
48458
|
-
initDefaultStyles(element = this.element) {
|
|
48459
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
48460
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
48461
|
-
this.updateEditorStyles(element, proseMirror);
|
|
48462
48388
|
this.initMobileStyles(element);
|
|
48463
48389
|
}
|
|
48464
48390
|
/**
|
|
@@ -48670,22 +48596,10 @@
|
|
|
48670
48596
|
*/
|
|
48671
48597
|
destroy() {
|
|
48672
48598
|
this.emit("destroy");
|
|
48673
|
-
this.
|
|
48674
|
-
this.destroyHeaderFooterEditors();
|
|
48599
|
+
if (this.view) this.view.destroy();
|
|
48675
48600
|
__privateMethod$1(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
48676
48601
|
this.removeAllListeners();
|
|
48677
48602
|
}
|
|
48678
|
-
destroyHeaderFooterEditors() {
|
|
48679
|
-
const editors = [
|
|
48680
|
-
...this.converter.headerEditors,
|
|
48681
|
-
...this.converter.footerEditors
|
|
48682
|
-
];
|
|
48683
|
-
for (let editorData of editors) {
|
|
48684
|
-
editorData.editor.destroy();
|
|
48685
|
-
}
|
|
48686
|
-
this.converter.headerEditors.length = 0;
|
|
48687
|
-
this.converter.footerEditors.length = 0;
|
|
48688
|
-
}
|
|
48689
48603
|
/**
|
|
48690
48604
|
* Check if migrations are needed for the data
|
|
48691
48605
|
* @static
|
|
@@ -48703,7 +48617,7 @@
|
|
|
48703
48617
|
* @returns {Object | void} Migration results
|
|
48704
48618
|
*/
|
|
48705
48619
|
processCollaborationMigrations() {
|
|
48706
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.2
|
|
48620
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2");
|
|
48707
48621
|
if (!this.options.ydoc) return;
|
|
48708
48622
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
48709
48623
|
let docVersion = metaMap.get("version");
|
|
@@ -48747,7 +48661,6 @@
|
|
|
48747
48661
|
__privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
|
|
48748
48662
|
this.initDefaultStyles();
|
|
48749
48663
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
48750
|
-
updateYdocDocxData(this);
|
|
48751
48664
|
this.initializeCollaborationData(true);
|
|
48752
48665
|
} else {
|
|
48753
48666
|
__privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -48899,7 +48812,7 @@
|
|
|
48899
48812
|
this.emit("beforeCreate", { editor: this });
|
|
48900
48813
|
this.on("contentError", this.options.onContentError);
|
|
48901
48814
|
this.on("exception", this.options.onException);
|
|
48902
|
-
this.
|
|
48815
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
48903
48816
|
this.initDefaultStyles();
|
|
48904
48817
|
this.setDocumentMode(options2.documentMode);
|
|
48905
48818
|
if (this.options.isHeadless) return;
|
|
@@ -48923,6 +48836,10 @@
|
|
|
48923
48836
|
__privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
|
|
48924
48837
|
__privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
|
|
48925
48838
|
}
|
|
48839
|
+
window.setTimeout(() => {
|
|
48840
|
+
if (this.isDestroyed) return;
|
|
48841
|
+
this.emit("create", { editor: this });
|
|
48842
|
+
}, 0);
|
|
48926
48843
|
};
|
|
48927
48844
|
initRichText_fn = function(options2) {
|
|
48928
48845
|
if (!options2.extensions || !options2.extensions.length) {
|
|
@@ -48934,7 +48851,7 @@
|
|
|
48934
48851
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
48935
48852
|
this.emit("beforeCreate", { editor: this });
|
|
48936
48853
|
this.on("contentError", this.options.onContentError);
|
|
48937
|
-
this.
|
|
48854
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
48938
48855
|
this.on("create", this.options.onCreate);
|
|
48939
48856
|
this.on("update", this.options.onUpdate);
|
|
48940
48857
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -48945,6 +48862,10 @@
|
|
|
48945
48862
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
48946
48863
|
this.on("commentClick", this.options.onCommentClicked);
|
|
48947
48864
|
this.on("locked", this.options.onDocumentLocked);
|
|
48865
|
+
window.setTimeout(() => {
|
|
48866
|
+
if (this.isDestroyed) return;
|
|
48867
|
+
this.emit("create", { editor: this });
|
|
48868
|
+
}, 0);
|
|
48948
48869
|
};
|
|
48949
48870
|
onFocus_fn = function({ editor, event }) {
|
|
48950
48871
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -49065,15 +48986,14 @@
|
|
|
49065
48986
|
}
|
|
49066
48987
|
return DOMParser$1.fromSchema(this.schema).parse(parsedContent);
|
|
49067
48988
|
};
|
|
49068
|
-
createView_fn = function(
|
|
48989
|
+
createView_fn = function() {
|
|
49069
48990
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
49070
48991
|
const state2 = { schema: this.schema };
|
|
49071
48992
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
49072
|
-
this.view = new EditorView(element, {
|
|
48993
|
+
this.view = new EditorView(this.options.element, {
|
|
49073
48994
|
...this.options.editorProps,
|
|
49074
48995
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
49075
48996
|
state: EditorState.create(state2),
|
|
49076
|
-
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
49077
48997
|
handleDoubleClick: async (view, pos, event) => {
|
|
49078
48998
|
if (this.options.documentMode !== "editing") return;
|
|
49079
48999
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -49087,12 +49007,7 @@
|
|
|
49087
49007
|
event.stopPropagation();
|
|
49088
49008
|
if (!this.options.editable) {
|
|
49089
49009
|
this.setEditable(true, false);
|
|
49090
|
-
toggleHeaderFooterEditMode(
|
|
49091
|
-
editor: this,
|
|
49092
|
-
focusedSectionEditor: null,
|
|
49093
|
-
isEditMode: false,
|
|
49094
|
-
documentMode: this.options.documentMode
|
|
49095
|
-
});
|
|
49010
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
49096
49011
|
const pm = document.querySelector(".ProseMirror");
|
|
49097
49012
|
pm.classList.remove("header-footer-edit");
|
|
49098
49013
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -49105,6 +49020,8 @@
|
|
|
49105
49020
|
});
|
|
49106
49021
|
this.view.updateState(newState);
|
|
49107
49022
|
this.createNodeViews();
|
|
49023
|
+
const dom = this.view.dom;
|
|
49024
|
+
dom.editor = this;
|
|
49108
49025
|
this.options.telemetry?.sendReport();
|
|
49109
49026
|
};
|
|
49110
49027
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
@@ -49131,9 +49048,7 @@
|
|
|
49131
49048
|
}, 50);
|
|
49132
49049
|
};
|
|
49133
49050
|
initPagination_fn = async function() {
|
|
49134
|
-
if (this.options.isHeadless || !this.extensionService
|
|
49135
|
-
return;
|
|
49136
|
-
}
|
|
49051
|
+
if (this.options.isHeadless || !this.extensionService) return;
|
|
49137
49052
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
49138
49053
|
if (pagination && this.options.pagination) {
|
|
49139
49054
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -49145,7 +49060,7 @@
|
|
|
49145
49060
|
}
|
|
49146
49061
|
};
|
|
49147
49062
|
dispatchTransaction_fn = function(transaction) {
|
|
49148
|
-
if (this.isDestroyed) return;
|
|
49063
|
+
if (this.view.isDestroyed) return;
|
|
49149
49064
|
let state2;
|
|
49150
49065
|
try {
|
|
49151
49066
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -49197,11 +49112,6 @@
|
|
|
49197
49112
|
transaction
|
|
49198
49113
|
});
|
|
49199
49114
|
};
|
|
49200
|
-
handleNodeSelection_fn = function(view, pos) {
|
|
49201
|
-
if (this.options.isHeaderOrFooter) {
|
|
49202
|
-
return setImageNodeSelection(view, pos);
|
|
49203
|
-
}
|
|
49204
|
-
};
|
|
49205
49115
|
prepareDocumentForImport_fn = function(doc2) {
|
|
49206
49116
|
const newState = EditorState.create({
|
|
49207
49117
|
schema: this.schema,
|
|
@@ -51544,7 +51454,7 @@
|
|
|
51544
51454
|
},
|
|
51545
51455
|
addPmPlugins() {
|
|
51546
51456
|
const { view } = this.editor;
|
|
51547
|
-
new Plugin({
|
|
51457
|
+
const dropcapPlugin = new Plugin({
|
|
51548
51458
|
name: "dropcapPlugin",
|
|
51549
51459
|
key: new PluginKey("dropcapPlugin"),
|
|
51550
51460
|
state: {
|
|
@@ -51564,7 +51474,7 @@
|
|
|
51564
51474
|
}
|
|
51565
51475
|
}
|
|
51566
51476
|
});
|
|
51567
|
-
return [];
|
|
51477
|
+
return [dropcapPlugin];
|
|
51568
51478
|
}
|
|
51569
51479
|
});
|
|
51570
51480
|
const getDropcapDecorations = (state2, view) => {
|
|
@@ -51917,16 +51827,7 @@
|
|
|
51917
51827
|
};
|
|
51918
51828
|
},
|
|
51919
51829
|
parseDOM() {
|
|
51920
|
-
return [{
|
|
51921
|
-
tag: 'span[linebreaktype="page"]',
|
|
51922
|
-
getAttrs: (dom) => {
|
|
51923
|
-
if (!(dom instanceof HTMLElement)) return false;
|
|
51924
|
-
return {
|
|
51925
|
-
pageBreakSource: dom.getAttribute("pagebreaksource") || null,
|
|
51926
|
-
pageBreakType: dom.getAttribute("linebreaktype") || null
|
|
51927
|
-
};
|
|
51928
|
-
}
|
|
51929
|
-
}];
|
|
51830
|
+
return [{ tag: "span" }];
|
|
51930
51831
|
},
|
|
51931
51832
|
renderDOM({ htmlAttributes }) {
|
|
51932
51833
|
return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -54923,8 +54824,6 @@
|
|
|
54923
54824
|
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) {
|
|
54924
54825
|
return removedNodes;
|
|
54925
54826
|
}
|
|
54926
|
-
const hasDeletion = transactionDeletedAnything(tr);
|
|
54927
|
-
if (!hasDeletion) return removedNodes;
|
|
54928
54827
|
tr.steps.forEach((step, stepIndex) => {
|
|
54929
54828
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
54930
54829
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -54941,14 +54840,6 @@
|
|
|
54941
54840
|
});
|
|
54942
54841
|
return removedNodes;
|
|
54943
54842
|
}
|
|
54944
|
-
function transactionDeletedAnything(tr) {
|
|
54945
|
-
return tr.steps.some((step) => {
|
|
54946
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) {
|
|
54947
|
-
return step.from !== step.to;
|
|
54948
|
-
}
|
|
54949
|
-
return false;
|
|
54950
|
-
});
|
|
54951
|
-
}
|
|
54952
54843
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
54953
54844
|
let removedAnnotations = [];
|
|
54954
54845
|
try {
|
|
@@ -56474,16 +56365,12 @@
|
|
|
56474
56365
|
}
|
|
56475
56366
|
let id = {};
|
|
56476
56367
|
let { tr, schema } = view.state;
|
|
56477
|
-
|
|
56478
|
-
if (editor.options.isHeaderOrFooter) {
|
|
56479
|
-
selection = editor.options.lastSelection;
|
|
56480
|
-
}
|
|
56481
|
-
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
56368
|
+
if (!tr.selection.empty) {
|
|
56482
56369
|
tr.deleteSelection();
|
|
56483
56370
|
}
|
|
56484
56371
|
let imageMeta = {
|
|
56485
56372
|
type: "add",
|
|
56486
|
-
pos: selection.from,
|
|
56373
|
+
pos: tr.selection.from,
|
|
56487
56374
|
id
|
|
56488
56375
|
};
|
|
56489
56376
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -61732,8 +61619,7 @@
|
|
|
61732
61619
|
addStorage() {
|
|
61733
61620
|
return {
|
|
61734
61621
|
height: 0,
|
|
61735
|
-
sectionData: null
|
|
61736
|
-
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
61622
|
+
sectionData: null
|
|
61737
61623
|
};
|
|
61738
61624
|
},
|
|
61739
61625
|
addCommands() {
|
|
@@ -61776,14 +61662,13 @@
|
|
|
61776
61662
|
shouldUpdate = true;
|
|
61777
61663
|
shouldInitialize = meta.isReadyToInit;
|
|
61778
61664
|
}
|
|
61779
|
-
const syncMeta = tr.getMeta("y-sync$");
|
|
61780
|
-
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
61781
|
-
return { ...oldState };
|
|
61782
|
-
}
|
|
61783
61665
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
61784
61666
|
if (imagePluginTransaction) {
|
|
61785
61667
|
if (imagePluginTransaction.type === "remove") {
|
|
61786
|
-
|
|
61668
|
+
const imagePos = imagePluginTransaction.pos;
|
|
61669
|
+
const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
|
|
61670
|
+
if (domImage.complete) onImageLoad(editor);
|
|
61671
|
+
else domImage.onload = () => onImageLoad(editor);
|
|
61787
61672
|
}
|
|
61788
61673
|
return { ...oldState };
|
|
61789
61674
|
}
|
|
@@ -61810,7 +61695,6 @@
|
|
|
61810
61695
|
if (isForceUpdate) shouldUpdate = true;
|
|
61811
61696
|
return {
|
|
61812
61697
|
...oldState,
|
|
61813
|
-
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
61814
61698
|
isReadyToInit: shouldInitialize
|
|
61815
61699
|
};
|
|
61816
61700
|
}
|
|
@@ -61839,10 +61723,6 @@
|
|
|
61839
61723
|
},
|
|
61840
61724
|
onDestroy() {
|
|
61841
61725
|
cleanupFloatingSeparators();
|
|
61842
|
-
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
61843
|
-
if (headerFooterEditors) {
|
|
61844
|
-
headerFooterEditors.clear();
|
|
61845
|
-
}
|
|
61846
61726
|
}
|
|
61847
61727
|
});
|
|
61848
61728
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
|
|
@@ -61903,7 +61783,6 @@
|
|
|
61903
61783
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
61904
61784
|
if (!editor.converter) return DecorationSet.empty;
|
|
61905
61785
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
61906
|
-
if (!pageSize) return DecorationSet.empty;
|
|
61907
61786
|
const { width, height } = pageSize;
|
|
61908
61787
|
if (!width || !height) return DecorationSet.empty;
|
|
61909
61788
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -61942,13 +61821,11 @@
|
|
|
61942
61821
|
let pageHeightThreshold = pageHeight;
|
|
61943
61822
|
let footer = null, header = null;
|
|
61944
61823
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
61945
|
-
const
|
|
61946
|
-
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
61824
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
|
|
61947
61825
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
61948
61826
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
61949
61827
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
61950
|
-
const
|
|
61951
|
-
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
61828
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
|
|
61952
61829
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
61953
61830
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
61954
61831
|
if (!coords) return [];
|
|
@@ -61967,8 +61844,7 @@
|
|
|
61967
61844
|
if (currentPageNumber === 1) {
|
|
61968
61845
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
61969
61846
|
decorations.pop();
|
|
61970
|
-
const
|
|
61971
|
-
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
61847
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
|
|
61972
61848
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
61973
61849
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
61974
61850
|
}
|
|
@@ -62042,15 +61918,15 @@
|
|
|
62042
61918
|
div2.style.height = bufferHeight + "px";
|
|
62043
61919
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
62044
61920
|
}
|
|
62045
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber
|
|
62046
|
-
const headerDef = sectionData
|
|
61921
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
61922
|
+
const headerDef = sectionData.headers?.[headerId];
|
|
62047
61923
|
const minHeaderHeight = pageMargins.top * 96;
|
|
62048
61924
|
const headerMargin = pageMargins.header * 96;
|
|
62049
61925
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
62050
61926
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
62051
61927
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
62052
61928
|
const availableHeight = headerHeight - headerMargin;
|
|
62053
|
-
|
|
61929
|
+
const editorContainer = document.createElement("div");
|
|
62054
61930
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
62055
61931
|
headerId = "rId" + generateDocxRandomId();
|
|
62056
61932
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -62062,31 +61938,23 @@
|
|
|
62062
61938
|
};
|
|
62063
61939
|
}
|
|
62064
61940
|
const data = editor.converter.headers[headerId];
|
|
62065
|
-
const
|
|
62066
|
-
|
|
62067
|
-
|
|
62068
|
-
|
|
62069
|
-
|
|
62070
|
-
|
|
62071
|
-
|
|
62072
|
-
|
|
62073
|
-
|
|
62074
|
-
|
|
62075
|
-
|
|
62076
|
-
|
|
62077
|
-
|
|
62078
|
-
|
|
62079
|
-
sectionId: headerId,
|
|
62080
|
-
type: "header",
|
|
62081
|
-
availableHeight,
|
|
62082
|
-
currentPageNumber
|
|
62083
|
-
});
|
|
62084
|
-
editor.converter.headerEditors.push({ id: headerId, editor: editorSection });
|
|
62085
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
62086
|
-
broadcastEditorEvents(editor, editorSection);
|
|
62087
|
-
}
|
|
61941
|
+
const editorSection = createHeaderFooterEditor({
|
|
61942
|
+
editor,
|
|
61943
|
+
data,
|
|
61944
|
+
editorContainer,
|
|
61945
|
+
appendToBody: false,
|
|
61946
|
+
sectionId: headerId,
|
|
61947
|
+
type: "header",
|
|
61948
|
+
availableHeight,
|
|
61949
|
+
currentPageNumber
|
|
61950
|
+
});
|
|
61951
|
+
editor.converter.headerEditors.push({
|
|
61952
|
+
id: headerId,
|
|
61953
|
+
editor: editorSection
|
|
61954
|
+
});
|
|
62088
61955
|
editorSection.setEditable(false, false);
|
|
62089
|
-
|
|
61956
|
+
broadcastEditorEvents(editor, editorSection);
|
|
61957
|
+
editorContainer.className = "pagination-section-header";
|
|
62090
61958
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
62091
61959
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
62092
61960
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -62099,12 +61967,12 @@
|
|
|
62099
61967
|
headerHeight
|
|
62100
61968
|
};
|
|
62101
61969
|
}
|
|
62102
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber
|
|
62103
|
-
const footerDef = sectionData
|
|
61970
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
61971
|
+
const footerDef = sectionData.footers?.[footerId];
|
|
62104
61972
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
62105
61973
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
62106
61974
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
62107
|
-
|
|
61975
|
+
const editorContainer = document.createElement("div");
|
|
62108
61976
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
62109
61977
|
footerId = "rId" + generateDocxRandomId();
|
|
62110
61978
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -62116,31 +61984,23 @@
|
|
|
62116
61984
|
};
|
|
62117
61985
|
}
|
|
62118
61986
|
const data = editor.converter.footers[footerId];
|
|
62119
|
-
const
|
|
62120
|
-
|
|
62121
|
-
|
|
62122
|
-
|
|
62123
|
-
|
|
62124
|
-
|
|
62125
|
-
|
|
62126
|
-
|
|
62127
|
-
|
|
62128
|
-
|
|
62129
|
-
|
|
62130
|
-
|
|
62131
|
-
|
|
62132
|
-
|
|
62133
|
-
sectionId: footerId,
|
|
62134
|
-
type: "footer",
|
|
62135
|
-
availableHeight: footerHeight,
|
|
62136
|
-
currentPageNumber
|
|
62137
|
-
});
|
|
62138
|
-
editor.converter.footerEditors.push({ id: footerId, editor: editorSection });
|
|
62139
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
62140
|
-
broadcastEditorEvents(editor, editorSection);
|
|
62141
|
-
}
|
|
61987
|
+
const editorSection = createHeaderFooterEditor({
|
|
61988
|
+
editor,
|
|
61989
|
+
data,
|
|
61990
|
+
editorContainer,
|
|
61991
|
+
appendToBody: false,
|
|
61992
|
+
sectionId: footerId,
|
|
61993
|
+
type: "footer",
|
|
61994
|
+
availableHeight: footerHeight,
|
|
61995
|
+
currentPageNumber
|
|
61996
|
+
});
|
|
61997
|
+
editor.converter.footerEditors.push({
|
|
61998
|
+
id: footerId,
|
|
61999
|
+
editor: editorSection
|
|
62000
|
+
});
|
|
62142
62001
|
editorSection.setEditable(false, false);
|
|
62143
|
-
|
|
62002
|
+
broadcastEditorEvents(editor, editorSection);
|
|
62003
|
+
editorContainer.className = "pagination-section-footer";
|
|
62144
62004
|
editorContainer.style.height = footerHeight + "px";
|
|
62145
62005
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
62146
62006
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -62153,28 +62013,10 @@
|
|
|
62153
62013
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
62154
62014
|
};
|
|
62155
62015
|
}
|
|
62156
|
-
const getHeaderFooterEditorKey = ({
|
|
62157
|
-
pageNumber,
|
|
62158
|
-
isHeader,
|
|
62159
|
-
isFooter,
|
|
62160
|
-
isFirstHeader = false,
|
|
62161
|
-
isLastFooter = false
|
|
62162
|
-
}) => {
|
|
62163
|
-
if (isFirstHeader) return `first-header-${pageNumber}`;
|
|
62164
|
-
if (isLastFooter) return `last-footer-${pageNumber}`;
|
|
62165
|
-
if (isHeader) return `header-${pageNumber}`;
|
|
62166
|
-
if (isFooter) return `footer-${pageNumber}`;
|
|
62167
|
-
return void 0;
|
|
62168
|
-
};
|
|
62169
62016
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
62170
62017
|
if (editor.options.documentMode !== "editing") return;
|
|
62171
62018
|
editor.setEditable(false, false);
|
|
62172
|
-
toggleHeaderFooterEditMode(
|
|
62173
|
-
editor,
|
|
62174
|
-
focusedSectionEditor: currentFocusedSectionEditor,
|
|
62175
|
-
isEditMode: true,
|
|
62176
|
-
documentMode: editor.options.documentMode
|
|
62177
|
-
});
|
|
62019
|
+
toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
|
|
62178
62020
|
};
|
|
62179
62021
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
62180
62022
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -62729,7 +62571,7 @@
|
|
|
62729
62571
|
}
|
|
62730
62572
|
});
|
|
62731
62573
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
62732
|
-
const nodeResizer = (nodeNames = ["image"]
|
|
62574
|
+
const nodeResizer = (nodeNames = ["image"]) => {
|
|
62733
62575
|
let resizeState = {
|
|
62734
62576
|
dragging: false,
|
|
62735
62577
|
startX: 0,
|
|
@@ -62754,13 +62596,8 @@
|
|
|
62754
62596
|
if (tr.getMeta(NodeResizerKey)) {
|
|
62755
62597
|
return oldState;
|
|
62756
62598
|
}
|
|
62757
|
-
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
62758
|
-
const { selection } = newState;
|
|
62759
|
-
const node2 = selection.node;
|
|
62760
|
-
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
62761
|
-
return DecorationSet.empty;
|
|
62762
|
-
}
|
|
62763
62599
|
const decorations = [];
|
|
62600
|
+
const { selection } = newState;
|
|
62764
62601
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
62765
62602
|
decorations.push(
|
|
62766
62603
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -62963,7 +62800,7 @@
|
|
|
62963
62800
|
const NodeResizer = Extension.create({
|
|
62964
62801
|
name: "nodeResizer",
|
|
62965
62802
|
addPmPlugins() {
|
|
62966
|
-
return [nodeResizer(["image"]
|
|
62803
|
+
return [nodeResizer(["image"])];
|
|
62967
62804
|
}
|
|
62968
62805
|
});
|
|
62969
62806
|
const getRichTextExtensions = () => {
|
|
@@ -71639,6 +71476,7 @@ ${style2}
|
|
|
71639
71476
|
display: inline-block;
|
|
71640
71477
|
position: relative;
|
|
71641
71478
|
fill: currentColor;
|
|
71479
|
+
transform: translateZ(0);
|
|
71642
71480
|
`, [cM$1("color-transition", {
|
|
71643
71481
|
transition: "color .3s var(--n-bezier)"
|
|
71644
71482
|
}), cM$1("depth", {
|
|
@@ -89605,6 +89443,7 @@ ${style2}
|
|
|
89605
89443
|
display: inline-block;
|
|
89606
89444
|
position: relative;
|
|
89607
89445
|
fill: currentColor;
|
|
89446
|
+
transform: translateZ(0);
|
|
89608
89447
|
`, [cM("color-transition", {
|
|
89609
89448
|
transition: "color .3s var(--n-bezier)"
|
|
89610
89449
|
}), cM("depth", {
|
|
@@ -93477,7 +93316,7 @@ ${style2}
|
|
|
93477
93316
|
this.config.colors = shuffleArray(this.config.colors);
|
|
93478
93317
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
93479
93318
|
this.colorIndex = 0;
|
|
93480
|
-
this.version = "0.13.2
|
|
93319
|
+
this.version = "0.13.2";
|
|
93481
93320
|
console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
93482
93321
|
this.superdocId = config.superdocId || v4();
|
|
93483
93322
|
this.colors = this.config.colors;
|