@harbour-enterprises/superdoc 0.13.2-rev9 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{eventemitter3-KKY27oz-.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
- package/dist/chunks/{eventemitter3-CHxWXmuK.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
- package/dist/chunks/{index-CweAXNfB.cjs → index-B4J7wgs6.cjs} +2 -2
- package/dist/chunks/{index-kOMfCfBT.cjs → index-Cdsq63Xq.cjs} +4 -4
- package/dist/chunks/{index-DS3W0eVB.es.js → index-Diu6UKHt.es.js} +4 -4
- package/dist/chunks/{index-BqLFjUHn.es.js → index-Hr3Um-Bg.es.js} +2 -2
- package/dist/chunks/{jszip-9bCX1h2W.cjs → jszip-BTAcmbVg.cjs} +1 -1
- package/dist/chunks/{jszip-Cl3s9njw.es.js → jszip-DckFs3A7.es.js} +1 -1
- package/dist/chunks/{super-editor.es-TaswSSDL.cjs → super-editor.es-BM89AzsN.cjs} +811 -1088
- package/dist/chunks/{super-editor.es-BE0HKCoV.es.js → super-editor.es-BNyzbCw0.es.js} +811 -1088
- package/dist/chunks/{url-B8LY3nwf.cjs → url-BIzg4y2i.cjs} +2 -2
- package/dist/chunks/{url-Bq00tGvm.es.js → url-CHayXMZH.es.js} +2 -2
- package/dist/chunks/{vue-BBJVqxjL.es.js → vue-Bi1uWinj.es.js} +3 -10
- package/dist/chunks/{vue-BBjMeYfo.cjs → vue-HIY1g7dm.cjs} +3 -10
- package/dist/chunks/{xml-js-BuAdLsHD.cjs → xml-js-BjqmFOSP.cjs} +102 -81
- package/dist/chunks/{xml-js-1F0lia4t.es.js → xml-js-CfClL-1b.es.js} +102 -81
- package/dist/style.css +1 -2
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BvRopd2F.js → converter-CsK9KCaL.js} +55 -637
- package/dist/super-editor/chunks/{docx-zipper-CZ8M74hv.js → docx-zipper-6iKmmME2.js} +1 -1
- package/dist/super-editor/chunks/{editor-D1rD0fdS.js → editor-Cxb-Zwyu.js} +685 -387
- package/dist/super-editor/chunks/{toolbar-CvP4K1yD.js → toolbar-QHIHaeEf.js} +3 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/core/Editor.d.ts +0 -7
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/InputRule.d.ts +0 -7
- package/dist/super-editor/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/annotator.d.ts +0 -4
- package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
- package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
- package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.d.ts.map +1 -1
- package/dist/super-editor/extensions/image/imageHelpers/startImageUpload.d.ts.map +1 -1
- package/dist/super-editor/extensions/line-break/line-break.d.ts.map +1 -1
- package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +1 -6
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +1 -2
- package/dist/super-editor/super-editor.es.js +7 -7
- package/dist/super-editor/tests/e2e/test-app/vite.config.d.ts +1 -1
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +9 -8
- package/dist/superdoc.es.js +10 -9
- package/dist/superdoc.umd.js +815 -1098
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts +0 -2
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts.map +0 -1
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +0 -3
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +0 -1
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;
|
|
@@ -45676,111 +45247,514 @@
|
|
|
45676
45247
|
221: "}",
|
|
45677
45248
|
222: '"'
|
|
45678
45249
|
};
|
|
45679
|
-
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
45680
|
-
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
45681
|
-
for (var i$1 = 0; i$1 < 10; i$1++) base$2[48 + i$1] = base$2[96 + i$1] = String(i$1);
|
|
45682
|
-
for (var i$1 = 1; i$1 <= 24; i$1++) base$2[i$1 + 111] = "F" + i$1;
|
|
45683
|
-
for (var i$1 = 65; i$1 <= 90; i$1++) {
|
|
45684
|
-
base$2[i$1] = String.fromCharCode(i$1 + 32);
|
|
45685
|
-
shift[i$1] = String.fromCharCode(i$1);
|
|
45686
|
-
}
|
|
45687
|
-
for (var code in base$2) if (!shift.hasOwnProperty(code)) shift[code] = base$2[code];
|
|
45688
|
-
function keyName(event) {
|
|
45689
|
-
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
45690
|
-
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$2)[event.keyCode] || event.key || "Unidentified";
|
|
45691
|
-
if (name == "Esc") name = "Escape";
|
|
45692
|
-
if (name == "Del") name = "Delete";
|
|
45693
|
-
if (name == "Left") name = "ArrowLeft";
|
|
45694
|
-
if (name == "Up") name = "ArrowUp";
|
|
45695
|
-
if (name == "Right") name = "ArrowRight";
|
|
45696
|
-
if (name == "Down") name = "ArrowDown";
|
|
45697
|
-
return name;
|
|
45698
|
-
}
|
|
45699
|
-
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
45700
|
-
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
45701
|
-
function normalizeKeyName(name) {
|
|
45702
|
-
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
45703
|
-
if (result == "Space")
|
|
45704
|
-
result = " ";
|
|
45705
|
-
let alt, ctrl, shift2, meta;
|
|
45706
|
-
for (let i2 = 0; i2 < parts.length - 1; i2++) {
|
|
45707
|
-
let mod = parts[i2];
|
|
45708
|
-
if (/^(cmd|meta|m)$/i.test(mod))
|
|
45709
|
-
meta = true;
|
|
45710
|
-
else if (/^a(lt)?$/i.test(mod))
|
|
45711
|
-
alt = true;
|
|
45712
|
-
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
45713
|
-
ctrl = true;
|
|
45714
|
-
else if (/^s(hift)?$/i.test(mod))
|
|
45715
|
-
shift2 = true;
|
|
45716
|
-
else if (/^mod$/i.test(mod)) {
|
|
45717
|
-
if (mac)
|
|
45718
|
-
meta = true;
|
|
45719
|
-
else
|
|
45720
|
-
ctrl = true;
|
|
45721
|
-
} else
|
|
45722
|
-
throw new Error("Unrecognized modifier name: " + mod);
|
|
45250
|
+
var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
45251
|
+
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
45252
|
+
for (var i$1 = 0; i$1 < 10; i$1++) base$2[48 + i$1] = base$2[96 + i$1] = String(i$1);
|
|
45253
|
+
for (var i$1 = 1; i$1 <= 24; i$1++) base$2[i$1 + 111] = "F" + i$1;
|
|
45254
|
+
for (var i$1 = 65; i$1 <= 90; i$1++) {
|
|
45255
|
+
base$2[i$1] = String.fromCharCode(i$1 + 32);
|
|
45256
|
+
shift[i$1] = String.fromCharCode(i$1);
|
|
45257
|
+
}
|
|
45258
|
+
for (var code in base$2) if (!shift.hasOwnProperty(code)) shift[code] = base$2[code];
|
|
45259
|
+
function keyName(event) {
|
|
45260
|
+
var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
45261
|
+
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base$2)[event.keyCode] || event.key || "Unidentified";
|
|
45262
|
+
if (name == "Esc") name = "Escape";
|
|
45263
|
+
if (name == "Del") name = "Delete";
|
|
45264
|
+
if (name == "Left") name = "ArrowLeft";
|
|
45265
|
+
if (name == "Up") name = "ArrowUp";
|
|
45266
|
+
if (name == "Right") name = "ArrowRight";
|
|
45267
|
+
if (name == "Down") name = "ArrowDown";
|
|
45268
|
+
return name;
|
|
45269
|
+
}
|
|
45270
|
+
const mac = typeof navigator != "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
45271
|
+
const windows = typeof navigator != "undefined" && /Win/.test(navigator.platform);
|
|
45272
|
+
function normalizeKeyName(name) {
|
|
45273
|
+
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
45274
|
+
if (result == "Space")
|
|
45275
|
+
result = " ";
|
|
45276
|
+
let alt, ctrl, shift2, meta;
|
|
45277
|
+
for (let i2 = 0; i2 < parts.length - 1; i2++) {
|
|
45278
|
+
let mod = parts[i2];
|
|
45279
|
+
if (/^(cmd|meta|m)$/i.test(mod))
|
|
45280
|
+
meta = true;
|
|
45281
|
+
else if (/^a(lt)?$/i.test(mod))
|
|
45282
|
+
alt = true;
|
|
45283
|
+
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
45284
|
+
ctrl = true;
|
|
45285
|
+
else if (/^s(hift)?$/i.test(mod))
|
|
45286
|
+
shift2 = true;
|
|
45287
|
+
else if (/^mod$/i.test(mod)) {
|
|
45288
|
+
if (mac)
|
|
45289
|
+
meta = true;
|
|
45290
|
+
else
|
|
45291
|
+
ctrl = true;
|
|
45292
|
+
} else
|
|
45293
|
+
throw new Error("Unrecognized modifier name: " + mod);
|
|
45294
|
+
}
|
|
45295
|
+
if (alt)
|
|
45296
|
+
result = "Alt-" + result;
|
|
45297
|
+
if (ctrl)
|
|
45298
|
+
result = "Ctrl-" + result;
|
|
45299
|
+
if (meta)
|
|
45300
|
+
result = "Meta-" + result;
|
|
45301
|
+
if (shift2)
|
|
45302
|
+
result = "Shift-" + result;
|
|
45303
|
+
return result;
|
|
45304
|
+
}
|
|
45305
|
+
function normalize(map2) {
|
|
45306
|
+
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
45307
|
+
for (let prop in map2)
|
|
45308
|
+
copy2[normalizeKeyName(prop)] = map2[prop];
|
|
45309
|
+
return copy2;
|
|
45310
|
+
}
|
|
45311
|
+
function modifiers(name, event, shift2 = true) {
|
|
45312
|
+
if (event.altKey)
|
|
45313
|
+
name = "Alt-" + name;
|
|
45314
|
+
if (event.ctrlKey)
|
|
45315
|
+
name = "Ctrl-" + name;
|
|
45316
|
+
if (event.metaKey)
|
|
45317
|
+
name = "Meta-" + name;
|
|
45318
|
+
if (shift2 && event.shiftKey)
|
|
45319
|
+
name = "Shift-" + name;
|
|
45320
|
+
return name;
|
|
45321
|
+
}
|
|
45322
|
+
function keymap(bindings) {
|
|
45323
|
+
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
45324
|
+
}
|
|
45325
|
+
function keydownHandler(bindings) {
|
|
45326
|
+
let map2 = normalize(bindings);
|
|
45327
|
+
return function(view, event) {
|
|
45328
|
+
let name = keyName(event), baseName, direct = map2[modifiers(name, event)];
|
|
45329
|
+
if (direct && direct(view.state, view.dispatch, view))
|
|
45330
|
+
return true;
|
|
45331
|
+
if (name.length == 1 && name != " ") {
|
|
45332
|
+
if (event.shiftKey) {
|
|
45333
|
+
let noShift = map2[modifiers(name, event, false)];
|
|
45334
|
+
if (noShift && noShift(view.state, view.dispatch, view))
|
|
45335
|
+
return true;
|
|
45336
|
+
}
|
|
45337
|
+
if ((event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
45338
|
+
!(windows && event.ctrlKey && event.altKey) && (baseName = base$2[event.keyCode]) && baseName != name) {
|
|
45339
|
+
let fromCode = map2[modifiers(baseName, event)];
|
|
45340
|
+
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
45341
|
+
return true;
|
|
45342
|
+
}
|
|
45343
|
+
}
|
|
45344
|
+
return false;
|
|
45345
|
+
};
|
|
45346
|
+
}
|
|
45347
|
+
function isExtensionRulesEnabled(extension, enabled) {
|
|
45348
|
+
if (Array.isArray(enabled)) {
|
|
45349
|
+
return enabled.some((enabledExtension) => {
|
|
45350
|
+
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
45351
|
+
return name === extension.name;
|
|
45352
|
+
});
|
|
45353
|
+
}
|
|
45354
|
+
return enabled;
|
|
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
|
+
}
|
|
45723
45512
|
}
|
|
45724
|
-
|
|
45725
|
-
|
|
45726
|
-
if (ctrl)
|
|
45727
|
-
result = "Ctrl-" + result;
|
|
45728
|
-
if (meta)
|
|
45729
|
-
result = "Meta-" + result;
|
|
45730
|
-
if (shift2)
|
|
45731
|
-
result = "Shift-" + result;
|
|
45732
|
-
return result;
|
|
45733
|
-
}
|
|
45734
|
-
function normalize(map2) {
|
|
45735
|
-
let copy2 = /* @__PURE__ */ Object.create(null);
|
|
45736
|
-
for (let prop in map2)
|
|
45737
|
-
copy2[normalizeKeyName(prop)] = map2[prop];
|
|
45738
|
-
return copy2;
|
|
45513
|
+
levelState.prevLevel = currentLevel;
|
|
45514
|
+
return [...levelState.stack];
|
|
45739
45515
|
}
|
|
45740
|
-
function
|
|
45741
|
-
|
|
45742
|
-
|
|
45743
|
-
|
|
45744
|
-
|
|
45745
|
-
|
|
45746
|
-
|
|
45747
|
-
|
|
45748
|
-
|
|
45749
|
-
|
|
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
|
+
}
|
|
45750
45543
|
}
|
|
45751
|
-
|
|
45752
|
-
|
|
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
|
+
}
|
|
45753
45551
|
}
|
|
45754
|
-
|
|
45755
|
-
|
|
45756
|
-
|
|
45757
|
-
|
|
45758
|
-
|
|
45759
|
-
|
|
45760
|
-
|
|
45761
|
-
|
|
45762
|
-
|
|
45763
|
-
|
|
45764
|
-
|
|
45765
|
-
|
|
45766
|
-
|
|
45767
|
-
|
|
45768
|
-
|
|
45769
|
-
|
|
45770
|
-
|
|
45771
|
-
}
|
|
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
|
+
);
|
|
45772
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) {
|
|
45773
45585
|
return false;
|
|
45774
|
-
};
|
|
45775
|
-
}
|
|
45776
|
-
function isExtensionRulesEnabled(extension, enabled) {
|
|
45777
|
-
if (Array.isArray(enabled)) {
|
|
45778
|
-
return enabled.some((enabledExtension) => {
|
|
45779
|
-
const name = typeof enabledExtension === "string" ? enabledExtension : enabledExtension.name;
|
|
45780
|
-
return name === extension.name;
|
|
45781
|
-
});
|
|
45782
45586
|
}
|
|
45783
|
-
|
|
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();
|
|
45784
45758
|
}
|
|
45785
45759
|
const _ExtensionService = class _ExtensionService2 {
|
|
45786
45760
|
constructor(extensions, userExtensions, editor) {
|
|
@@ -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");
|
|
@@ -47745,19 +47714,6 @@
|
|
|
47745
47714
|
);
|
|
47746
47715
|
});
|
|
47747
47716
|
};
|
|
47748
|
-
const resetHeaderFooterFieldAnnotations = ({ editor }) => {
|
|
47749
|
-
if (!editor) return;
|
|
47750
|
-
const sectionEditors = getAllHeaderFooterEditors(editor);
|
|
47751
|
-
sectionEditors.forEach(({ editor: sectionEditor, sectionId, type: type2 }) => {
|
|
47752
|
-
sectionEditor.commands.resetFieldAnnotations();
|
|
47753
|
-
onHeaderFooterDataUpdate(
|
|
47754
|
-
{ editor: sectionEditor },
|
|
47755
|
-
editor,
|
|
47756
|
-
sectionId,
|
|
47757
|
-
type2
|
|
47758
|
-
);
|
|
47759
|
-
});
|
|
47760
|
-
};
|
|
47761
47717
|
const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
|
|
47762
47718
|
if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
|
|
47763
47719
|
const { doc: doc2 } = editor.state;
|
|
@@ -47828,7 +47784,6 @@
|
|
|
47828
47784
|
getAllHeaderFooterEditors,
|
|
47829
47785
|
updateHeaderFooterFieldAnnotations,
|
|
47830
47786
|
deleteHeaderFooterFieldAnnotations,
|
|
47831
|
-
resetHeaderFooterFieldAnnotations,
|
|
47832
47787
|
cleanUpListsWithAnnotations
|
|
47833
47788
|
};
|
|
47834
47789
|
const CollaborationPluginKey = new PluginKey("collaboration");
|
|
@@ -48008,16 +47963,6 @@
|
|
|
48008
47963
|
const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
|
|
48009
47964
|
dispatch(tr);
|
|
48010
47965
|
};
|
|
48011
|
-
const setImageNodeSelection = (view, pos) => {
|
|
48012
|
-
const { doc: doc2 } = view.state;
|
|
48013
|
-
const node2 = doc2.nodeAt(pos);
|
|
48014
|
-
if (node2 && node2.type.name === "image") {
|
|
48015
|
-
const tr = view.state.tr.setSelection(NodeSelection.create(doc2, pos));
|
|
48016
|
-
view.dispatch(tr);
|
|
48017
|
-
return true;
|
|
48018
|
-
}
|
|
48019
|
-
return false;
|
|
48020
|
-
};
|
|
48021
47966
|
const _Editor = class _Editor2 extends EventEmitter$2 {
|
|
48022
47967
|
/**
|
|
48023
47968
|
* Create a new Editor instance
|
|
@@ -48116,19 +48061,6 @@
|
|
|
48116
48061
|
this.setHighContrastMode = setHighContrastMode;
|
|
48117
48062
|
initMode();
|
|
48118
48063
|
}
|
|
48119
|
-
mount(el) {
|
|
48120
|
-
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
48121
|
-
window.setTimeout(() => {
|
|
48122
|
-
if (this.isDestroyed) return;
|
|
48123
|
-
this.emit("create", { editor: this });
|
|
48124
|
-
}, 0);
|
|
48125
|
-
}
|
|
48126
|
-
unmount() {
|
|
48127
|
-
if (this.view) {
|
|
48128
|
-
this.view.destroy();
|
|
48129
|
-
}
|
|
48130
|
-
this.view = null;
|
|
48131
|
-
}
|
|
48132
48064
|
/**
|
|
48133
48065
|
* Set the toolbar for this editor
|
|
48134
48066
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -48177,7 +48109,7 @@
|
|
|
48177
48109
|
* @returns {boolean}
|
|
48178
48110
|
*/
|
|
48179
48111
|
get isDestroyed() {
|
|
48180
|
-
return this.view
|
|
48112
|
+
return this.view.isDestroyed;
|
|
48181
48113
|
}
|
|
48182
48114
|
/**
|
|
48183
48115
|
* Get the editor element
|
|
@@ -48220,12 +48152,7 @@
|
|
|
48220
48152
|
this.commands.toggleTrackChangesShowOriginal();
|
|
48221
48153
|
this.setEditable(false, false);
|
|
48222
48154
|
this.setOptions({ documentMode: "viewing" });
|
|
48223
|
-
toggleHeaderFooterEditMode(
|
|
48224
|
-
editor: this,
|
|
48225
|
-
focusedSectionEditor: null,
|
|
48226
|
-
isEditMode: false,
|
|
48227
|
-
documentMode: cleanedMode
|
|
48228
|
-
});
|
|
48155
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
48229
48156
|
} else if (cleanedMode === "suggesting") {
|
|
48230
48157
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
48231
48158
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -48238,12 +48165,7 @@
|
|
|
48238
48165
|
this.commands.disableTrackChanges();
|
|
48239
48166
|
this.setEditable(true, false);
|
|
48240
48167
|
this.setOptions({ documentMode: "editing" });
|
|
48241
|
-
toggleHeaderFooterEditMode(
|
|
48242
|
-
editor: this,
|
|
48243
|
-
focusedSectionEditor: null,
|
|
48244
|
-
isEditMode: false,
|
|
48245
|
-
documentMode: cleanedMode
|
|
48246
|
-
});
|
|
48168
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
48247
48169
|
}
|
|
48248
48170
|
}
|
|
48249
48171
|
/**
|
|
@@ -48420,26 +48342,29 @@
|
|
|
48420
48342
|
};
|
|
48421
48343
|
}
|
|
48422
48344
|
/**
|
|
48423
|
-
|
|
48424
|
-
|
|
48425
|
-
|
|
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");
|
|
48426
48355
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
48427
|
-
if (!proseMirror || !
|
|
48356
|
+
if (!proseMirror || !pageSize || !pageMargins) {
|
|
48428
48357
|
return;
|
|
48429
48358
|
}
|
|
48430
48359
|
proseMirror.setAttribute("role", "document");
|
|
48431
48360
|
proseMirror.setAttribute("aria-multiline", true);
|
|
48432
48361
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
48433
48362
|
proseMirror.setAttribute("aria-description", "");
|
|
48434
|
-
|
|
48435
|
-
|
|
48436
|
-
|
|
48437
|
-
|
|
48438
|
-
|
|
48439
|
-
if (pageMargins) {
|
|
48440
|
-
element.style.paddingLeft = pageMargins.left + "in";
|
|
48441
|
-
element.style.paddingRight = pageMargins.right + "in";
|
|
48442
|
-
}
|
|
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";
|
|
48443
48368
|
element.style.boxSizing = "border-box";
|
|
48444
48369
|
element.style.isolation = "isolate";
|
|
48445
48370
|
proseMirror.style.outline = "none";
|
|
@@ -48460,19 +48385,6 @@
|
|
|
48460
48385
|
proseMirror.style.paddingTop = "1in";
|
|
48461
48386
|
proseMirror.style.paddingBottom = "1in";
|
|
48462
48387
|
}
|
|
48463
|
-
}
|
|
48464
|
-
/**
|
|
48465
|
-
* Initialize default styles for the editor container and ProseMirror.
|
|
48466
|
-
* Get page size and margins from the converter.
|
|
48467
|
-
* Set document default font and font size.
|
|
48468
|
-
*
|
|
48469
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
48470
|
-
* @returns {void}
|
|
48471
|
-
*/
|
|
48472
|
-
initDefaultStyles(element = this.element) {
|
|
48473
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
48474
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
48475
|
-
this.updateEditorStyles(element, proseMirror);
|
|
48476
48388
|
this.initMobileStyles(element);
|
|
48477
48389
|
}
|
|
48478
48390
|
/**
|
|
@@ -48684,25 +48596,10 @@
|
|
|
48684
48596
|
*/
|
|
48685
48597
|
destroy() {
|
|
48686
48598
|
this.emit("destroy");
|
|
48687
|
-
this.
|
|
48688
|
-
this.destroyHeaderFooterEditors();
|
|
48599
|
+
if (this.view) this.view.destroy();
|
|
48689
48600
|
__privateMethod$1(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
48690
48601
|
this.removeAllListeners();
|
|
48691
48602
|
}
|
|
48692
|
-
destroyHeaderFooterEditors() {
|
|
48693
|
-
try {
|
|
48694
|
-
const editors = [
|
|
48695
|
-
...this.converter.headerEditors,
|
|
48696
|
-
...this.converter.footerEditors
|
|
48697
|
-
];
|
|
48698
|
-
for (let editorData of editors) {
|
|
48699
|
-
editorData.editor.destroy();
|
|
48700
|
-
}
|
|
48701
|
-
this.converter.headerEditors.length = 0;
|
|
48702
|
-
this.converter.footerEditors.length = 0;
|
|
48703
|
-
} catch (error) {
|
|
48704
|
-
}
|
|
48705
|
-
}
|
|
48706
48603
|
/**
|
|
48707
48604
|
* Check if migrations are needed for the data
|
|
48708
48605
|
* @static
|
|
@@ -48720,7 +48617,7 @@
|
|
|
48720
48617
|
* @returns {Object | void} Migration results
|
|
48721
48618
|
*/
|
|
48722
48619
|
processCollaborationMigrations() {
|
|
48723
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.2
|
|
48620
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2");
|
|
48724
48621
|
if (!this.options.ydoc) return;
|
|
48725
48622
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
48726
48623
|
let docVersion = metaMap.get("version");
|
|
@@ -48764,7 +48661,6 @@
|
|
|
48764
48661
|
__privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
|
|
48765
48662
|
this.initDefaultStyles();
|
|
48766
48663
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
48767
|
-
updateYdocDocxData(this);
|
|
48768
48664
|
this.initializeCollaborationData(true);
|
|
48769
48665
|
} else {
|
|
48770
48666
|
__privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -48916,7 +48812,7 @@
|
|
|
48916
48812
|
this.emit("beforeCreate", { editor: this });
|
|
48917
48813
|
this.on("contentError", this.options.onContentError);
|
|
48918
48814
|
this.on("exception", this.options.onException);
|
|
48919
|
-
this.
|
|
48815
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
48920
48816
|
this.initDefaultStyles();
|
|
48921
48817
|
this.setDocumentMode(options2.documentMode);
|
|
48922
48818
|
if (this.options.isHeadless) return;
|
|
@@ -48940,6 +48836,10 @@
|
|
|
48940
48836
|
__privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
|
|
48941
48837
|
__privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
|
|
48942
48838
|
}
|
|
48839
|
+
window.setTimeout(() => {
|
|
48840
|
+
if (this.isDestroyed) return;
|
|
48841
|
+
this.emit("create", { editor: this });
|
|
48842
|
+
}, 0);
|
|
48943
48843
|
};
|
|
48944
48844
|
initRichText_fn = function(options2) {
|
|
48945
48845
|
if (!options2.extensions || !options2.extensions.length) {
|
|
@@ -48951,7 +48851,7 @@
|
|
|
48951
48851
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
48952
48852
|
this.emit("beforeCreate", { editor: this });
|
|
48953
48853
|
this.on("contentError", this.options.onContentError);
|
|
48954
|
-
this.
|
|
48854
|
+
__privateMethod$1(this, _Editor_instances, createView_fn).call(this);
|
|
48955
48855
|
this.on("create", this.options.onCreate);
|
|
48956
48856
|
this.on("update", this.options.onUpdate);
|
|
48957
48857
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -48962,6 +48862,10 @@
|
|
|
48962
48862
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
48963
48863
|
this.on("commentClick", this.options.onCommentClicked);
|
|
48964
48864
|
this.on("locked", this.options.onDocumentLocked);
|
|
48865
|
+
window.setTimeout(() => {
|
|
48866
|
+
if (this.isDestroyed) return;
|
|
48867
|
+
this.emit("create", { editor: this });
|
|
48868
|
+
}, 0);
|
|
48965
48869
|
};
|
|
48966
48870
|
onFocus_fn = function({ editor, event }) {
|
|
48967
48871
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -49082,15 +48986,14 @@
|
|
|
49082
48986
|
}
|
|
49083
48987
|
return DOMParser$1.fromSchema(this.schema).parse(parsedContent);
|
|
49084
48988
|
};
|
|
49085
|
-
createView_fn = function(
|
|
48989
|
+
createView_fn = function() {
|
|
49086
48990
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
49087
48991
|
const state2 = { schema: this.schema };
|
|
49088
48992
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
49089
|
-
this.view = new EditorView(element, {
|
|
48993
|
+
this.view = new EditorView(this.options.element, {
|
|
49090
48994
|
...this.options.editorProps,
|
|
49091
48995
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
49092
48996
|
state: EditorState.create(state2),
|
|
49093
|
-
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
49094
48997
|
handleDoubleClick: async (view, pos, event) => {
|
|
49095
48998
|
if (this.options.documentMode !== "editing") return;
|
|
49096
48999
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -49104,12 +49007,7 @@
|
|
|
49104
49007
|
event.stopPropagation();
|
|
49105
49008
|
if (!this.options.editable) {
|
|
49106
49009
|
this.setEditable(true, false);
|
|
49107
|
-
toggleHeaderFooterEditMode(
|
|
49108
|
-
editor: this,
|
|
49109
|
-
focusedSectionEditor: null,
|
|
49110
|
-
isEditMode: false,
|
|
49111
|
-
documentMode: this.options.documentMode
|
|
49112
|
-
});
|
|
49010
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
49113
49011
|
const pm = document.querySelector(".ProseMirror");
|
|
49114
49012
|
pm.classList.remove("header-footer-edit");
|
|
49115
49013
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -49122,6 +49020,8 @@
|
|
|
49122
49020
|
});
|
|
49123
49021
|
this.view.updateState(newState);
|
|
49124
49022
|
this.createNodeViews();
|
|
49023
|
+
const dom = this.view.dom;
|
|
49024
|
+
dom.editor = this;
|
|
49125
49025
|
this.options.telemetry?.sendReport();
|
|
49126
49026
|
};
|
|
49127
49027
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
@@ -49148,9 +49048,7 @@
|
|
|
49148
49048
|
}, 50);
|
|
49149
49049
|
};
|
|
49150
49050
|
initPagination_fn = async function() {
|
|
49151
|
-
if (this.options.isHeadless || !this.extensionService
|
|
49152
|
-
return;
|
|
49153
|
-
}
|
|
49051
|
+
if (this.options.isHeadless || !this.extensionService) return;
|
|
49154
49052
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
49155
49053
|
if (pagination && this.options.pagination) {
|
|
49156
49054
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -49162,7 +49060,7 @@
|
|
|
49162
49060
|
}
|
|
49163
49061
|
};
|
|
49164
49062
|
dispatchTransaction_fn = function(transaction) {
|
|
49165
|
-
if (this.isDestroyed) return;
|
|
49063
|
+
if (this.view.isDestroyed) return;
|
|
49166
49064
|
let state2;
|
|
49167
49065
|
try {
|
|
49168
49066
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -49214,11 +49112,6 @@
|
|
|
49214
49112
|
transaction
|
|
49215
49113
|
});
|
|
49216
49114
|
};
|
|
49217
|
-
handleNodeSelection_fn = function(view, pos) {
|
|
49218
|
-
if (this.options.isHeaderOrFooter) {
|
|
49219
|
-
return setImageNodeSelection(view, pos);
|
|
49220
|
-
}
|
|
49221
|
-
};
|
|
49222
49115
|
prepareDocumentForImport_fn = function(doc2) {
|
|
49223
49116
|
const newState = EditorState.create({
|
|
49224
49117
|
schema: this.schema,
|
|
@@ -51561,7 +51454,7 @@
|
|
|
51561
51454
|
},
|
|
51562
51455
|
addPmPlugins() {
|
|
51563
51456
|
const { view } = this.editor;
|
|
51564
|
-
new Plugin({
|
|
51457
|
+
const dropcapPlugin = new Plugin({
|
|
51565
51458
|
name: "dropcapPlugin",
|
|
51566
51459
|
key: new PluginKey("dropcapPlugin"),
|
|
51567
51460
|
state: {
|
|
@@ -51581,7 +51474,7 @@
|
|
|
51581
51474
|
}
|
|
51582
51475
|
}
|
|
51583
51476
|
});
|
|
51584
|
-
return [];
|
|
51477
|
+
return [dropcapPlugin];
|
|
51585
51478
|
}
|
|
51586
51479
|
});
|
|
51587
51480
|
const getDropcapDecorations = (state2, view) => {
|
|
@@ -51934,16 +51827,7 @@
|
|
|
51934
51827
|
};
|
|
51935
51828
|
},
|
|
51936
51829
|
parseDOM() {
|
|
51937
|
-
return [{
|
|
51938
|
-
tag: 'span[linebreaktype="page"]',
|
|
51939
|
-
getAttrs: (dom) => {
|
|
51940
|
-
if (!(dom instanceof HTMLElement)) return false;
|
|
51941
|
-
return {
|
|
51942
|
-
pageBreakSource: dom.getAttribute("pagebreaksource") || null,
|
|
51943
|
-
pageBreakType: dom.getAttribute("linebreaktype") || null
|
|
51944
|
-
};
|
|
51945
|
-
}
|
|
51946
|
-
}];
|
|
51830
|
+
return [{ tag: "span" }];
|
|
51947
51831
|
},
|
|
51948
51832
|
renderDOM({ htmlAttributes }) {
|
|
51949
51833
|
return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -54940,8 +54824,6 @@
|
|
|
54940
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) {
|
|
54941
54825
|
return removedNodes;
|
|
54942
54826
|
}
|
|
54943
|
-
const hasDeletion = transactionDeletedAnything(tr);
|
|
54944
|
-
if (!hasDeletion) return removedNodes;
|
|
54945
54827
|
tr.steps.forEach((step, stepIndex) => {
|
|
54946
54828
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
54947
54829
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -54958,14 +54840,6 @@
|
|
|
54958
54840
|
});
|
|
54959
54841
|
return removedNodes;
|
|
54960
54842
|
}
|
|
54961
|
-
function transactionDeletedAnything(tr) {
|
|
54962
|
-
return tr.steps.some((step) => {
|
|
54963
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) {
|
|
54964
|
-
return step.from !== step.to;
|
|
54965
|
-
}
|
|
54966
|
-
return false;
|
|
54967
|
-
});
|
|
54968
|
-
}
|
|
54969
54843
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
54970
54844
|
let removedAnnotations = [];
|
|
54971
54845
|
try {
|
|
@@ -55361,18 +55235,8 @@
|
|
|
55361
55235
|
};
|
|
55362
55236
|
}
|
|
55363
55237
|
},
|
|
55364
|
-
defaultDisplayLabel: {
|
|
55365
|
-
default: "",
|
|
55366
|
-
parseDOM: (elem) => elem.getAttribute("data-default-display-label"),
|
|
55367
|
-
renderDOM: (attrs) => {
|
|
55368
|
-
if (!attrs.defaultDisplayLabel) return {};
|
|
55369
|
-
return {
|
|
55370
|
-
"data-default-display-label": attrs.defaultDisplayLabel
|
|
55371
|
-
};
|
|
55372
|
-
}
|
|
55373
|
-
},
|
|
55374
55238
|
displayLabel: {
|
|
55375
|
-
default: "",
|
|
55239
|
+
default: "Text field",
|
|
55376
55240
|
parseDOM: (elem) => elem.getAttribute("data-display-label"),
|
|
55377
55241
|
renderDOM: (attrs) => {
|
|
55378
55242
|
if (!attrs.displayLabel) return {};
|
|
@@ -55688,7 +55552,6 @@
|
|
|
55688
55552
|
return renderer2();
|
|
55689
55553
|
},
|
|
55690
55554
|
addCommands() {
|
|
55691
|
-
const annotationTypes = this.options.types;
|
|
55692
55555
|
return {
|
|
55693
55556
|
/**
|
|
55694
55557
|
* Add field annotation.
|
|
@@ -55710,12 +55573,7 @@
|
|
|
55710
55573
|
let currentMarks = $pos.marks();
|
|
55711
55574
|
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
55712
55575
|
let formatAttrs = getFormatAttrsFromMarks(currentMarks);
|
|
55713
|
-
let
|
|
55714
|
-
let node2 = schema.nodes[this.name].create({
|
|
55715
|
-
...attrs,
|
|
55716
|
-
...formatAttrs,
|
|
55717
|
-
defaultDisplayLabel
|
|
55718
|
-
}, null, null);
|
|
55576
|
+
let node2 = schema.nodes[this.name].create({ ...attrs, ...formatAttrs }, null, null);
|
|
55719
55577
|
state2.tr.insert(newPos, node2).setSelection(Selection.near(tr.doc.resolve(newPos + node2.nodeSize)));
|
|
55720
55578
|
if (editorFocus) {
|
|
55721
55579
|
this.editor.view.focus();
|
|
@@ -55723,9 +55581,9 @@
|
|
|
55723
55581
|
}
|
|
55724
55582
|
return true;
|
|
55725
55583
|
},
|
|
55726
|
-
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state: state2, commands: commands2 }) => {
|
|
55584
|
+
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ editor, dispatch, state: state2, tr, commands: commands2 }) => {
|
|
55727
55585
|
const { from: from2 } = state2.selection;
|
|
55728
|
-
|
|
55586
|
+
commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
55729
55587
|
},
|
|
55730
55588
|
/**
|
|
55731
55589
|
* Replace field annotation.
|
|
@@ -55735,113 +55593,24 @@
|
|
|
55735
55593
|
* from: 20,
|
|
55736
55594
|
* to: 45,
|
|
55737
55595
|
* attrs: {
|
|
55738
|
-
*
|
|
55739
|
-
*
|
|
55596
|
+
* fieldType: 'TEXTINPUT'
|
|
55597
|
+
* fieldColor: '#980043'
|
|
55740
55598
|
* }
|
|
55741
55599
|
* ])
|
|
55742
55600
|
*/
|
|
55743
|
-
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => {
|
|
55601
|
+
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, state: state2, tr }) => {
|
|
55744
55602
|
if (!dispatch) return true;
|
|
55603
|
+
tr.setMeta("fieldAnnotationReplace", true);
|
|
55745
55604
|
fieldsArray.forEach((annotation) => {
|
|
55746
55605
|
let { from: from2, to, attrs } = annotation;
|
|
55747
55606
|
let { schema } = editor;
|
|
55748
55607
|
let newPosFrom = tr.mapping.map(from2);
|
|
55749
55608
|
let newPosTo = tr.mapping.map(to);
|
|
55750
|
-
let
|
|
55751
|
-
let node2 = schema.nodes[this.name].create({
|
|
55752
|
-
...attrs,
|
|
55753
|
-
defaultDisplayLabel
|
|
55754
|
-
}, null, null);
|
|
55609
|
+
let node2 = schema.nodes[this.name].create({ ...attrs }, null, null);
|
|
55755
55610
|
tr.replaceWith(newPosFrom, newPosTo, node2);
|
|
55756
55611
|
});
|
|
55757
55612
|
return true;
|
|
55758
55613
|
},
|
|
55759
|
-
/**
|
|
55760
|
-
* Replace annotations with a label (as text node) in selection.
|
|
55761
|
-
* @param options Additional options.
|
|
55762
|
-
* @example
|
|
55763
|
-
* editor.commands.replaceFieldAnnotationsWithLabelInSelection()
|
|
55764
|
-
*/
|
|
55765
|
-
replaceFieldAnnotationsWithLabelInSelection: (options2 = {}) => ({ commands: commands2 }) => {
|
|
55766
|
-
return commands2.replaceFieldAnnotationsWithLabel(null, {
|
|
55767
|
-
...options2,
|
|
55768
|
-
isInSelection: true
|
|
55769
|
-
});
|
|
55770
|
-
},
|
|
55771
|
-
/**
|
|
55772
|
-
* Replace annotations with a label (as text node).
|
|
55773
|
-
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
55774
|
-
* @param options.isInSelection Find in selection instead of field IDs.
|
|
55775
|
-
* @param options.addToHistory Add to history or not.
|
|
55776
|
-
* @param options.types Annotation types to replace.
|
|
55777
|
-
* @example
|
|
55778
|
-
* editor.commands.replaceFieldAnnotationsWithLabel(['1', '2'])
|
|
55779
|
-
*/
|
|
55780
|
-
replaceFieldAnnotationsWithLabel: (fieldIdOrArray, {
|
|
55781
|
-
isInSelection = false,
|
|
55782
|
-
addToHistory = false,
|
|
55783
|
-
types: types2 = annotationTypes
|
|
55784
|
-
} = {}) => ({ dispatch, state: state2, tr }) => {
|
|
55785
|
-
let { from: from2, to } = state2.selection;
|
|
55786
|
-
let annotations = isInSelection ? findFieldAnnotationsBetween(from2, to, state2.doc) : findFieldAnnotationsByFieldId(fieldIdOrArray, state2);
|
|
55787
|
-
annotations = types2.length ? annotations.filter(({ node: node2 }) => types2.includes(node2.attrs.type)) : annotations;
|
|
55788
|
-
if (!annotations.length) {
|
|
55789
|
-
return true;
|
|
55790
|
-
}
|
|
55791
|
-
if (!addToHistory) {
|
|
55792
|
-
tr.setMeta("addToHistory", false);
|
|
55793
|
-
}
|
|
55794
|
-
if (dispatch) {
|
|
55795
|
-
annotations.forEach((annotation) => {
|
|
55796
|
-
let { pos, node: node2 } = annotation;
|
|
55797
|
-
let newPosFrom = tr.mapping.map(pos);
|
|
55798
|
-
let newPosTo = tr.mapping.map(pos + node2.nodeSize);
|
|
55799
|
-
let currentNode = tr.doc.nodeAt(newPosFrom);
|
|
55800
|
-
let nodeEqual = node2.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
55801
|
-
let $newPosFrom = tr.doc.resolve(newPosFrom);
|
|
55802
|
-
let currentMarks = $newPosFrom.marks();
|
|
55803
|
-
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
55804
|
-
if (nodeEqual) {
|
|
55805
|
-
let label = node2.attrs.displayLabel || " ";
|
|
55806
|
-
let textNode = state2.schema.text(label, currentMarks);
|
|
55807
|
-
tr.replaceWith(newPosFrom, newPosTo, textNode);
|
|
55808
|
-
}
|
|
55809
|
-
});
|
|
55810
|
-
}
|
|
55811
|
-
return true;
|
|
55812
|
-
},
|
|
55813
|
-
/**
|
|
55814
|
-
* Resets all annotations to default values.
|
|
55815
|
-
* @example
|
|
55816
|
-
* editor.commands.resetFieldAnnotations()
|
|
55817
|
-
*/
|
|
55818
|
-
resetFieldAnnotations: () => ({ dispatch, state: state2, tr }) => {
|
|
55819
|
-
let annotations = getAllFieldAnnotations(state2);
|
|
55820
|
-
if (!annotations.length) {
|
|
55821
|
-
return true;
|
|
55822
|
-
}
|
|
55823
|
-
tr.setMeta("fieldAnnotationUpdate", true);
|
|
55824
|
-
if (dispatch) {
|
|
55825
|
-
annotations.forEach(({ pos, node: node2 }) => {
|
|
55826
|
-
let newPos = tr.mapping.map(pos);
|
|
55827
|
-
let currentNode = tr.doc.nodeAt(newPos);
|
|
55828
|
-
let nodeEqual = node2.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
55829
|
-
if (nodeEqual) {
|
|
55830
|
-
let displayLabel = node2.attrs.defaultDisplayLabel || node2.attrs.displayLabel || "";
|
|
55831
|
-
tr.setNodeMarkup(newPos, void 0, {
|
|
55832
|
-
...node2.attrs,
|
|
55833
|
-
// reset displayLabel to default.
|
|
55834
|
-
displayLabel,
|
|
55835
|
-
// reset attrs for specific types.
|
|
55836
|
-
imageSrc: null,
|
|
55837
|
-
rawHtml: null,
|
|
55838
|
-
linkUrl: null
|
|
55839
|
-
});
|
|
55840
|
-
}
|
|
55841
|
-
});
|
|
55842
|
-
}
|
|
55843
|
-
return true;
|
|
55844
|
-
},
|
|
55845
55614
|
/**
|
|
55846
55615
|
* Update annotations associated with a field.
|
|
55847
55616
|
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
@@ -56596,16 +56365,12 @@
|
|
|
56596
56365
|
}
|
|
56597
56366
|
let id = {};
|
|
56598
56367
|
let { tr, schema } = view.state;
|
|
56599
|
-
|
|
56600
|
-
if (editor.options.isHeaderOrFooter) {
|
|
56601
|
-
selection = editor.options.lastSelection;
|
|
56602
|
-
}
|
|
56603
|
-
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
56368
|
+
if (!tr.selection.empty) {
|
|
56604
56369
|
tr.deleteSelection();
|
|
56605
56370
|
}
|
|
56606
56371
|
let imageMeta = {
|
|
56607
56372
|
type: "add",
|
|
56608
|
-
pos: selection.from,
|
|
56373
|
+
pos: tr.selection.from,
|
|
56609
56374
|
id
|
|
56610
56375
|
};
|
|
56611
56376
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -61854,8 +61619,7 @@
|
|
|
61854
61619
|
addStorage() {
|
|
61855
61620
|
return {
|
|
61856
61621
|
height: 0,
|
|
61857
|
-
sectionData: null
|
|
61858
|
-
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
61622
|
+
sectionData: null
|
|
61859
61623
|
};
|
|
61860
61624
|
},
|
|
61861
61625
|
addCommands() {
|
|
@@ -61898,14 +61662,13 @@
|
|
|
61898
61662
|
shouldUpdate = true;
|
|
61899
61663
|
shouldInitialize = meta.isReadyToInit;
|
|
61900
61664
|
}
|
|
61901
|
-
const syncMeta = tr.getMeta("y-sync$");
|
|
61902
|
-
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
61903
|
-
return { ...oldState };
|
|
61904
|
-
}
|
|
61905
61665
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
61906
61666
|
if (imagePluginTransaction) {
|
|
61907
61667
|
if (imagePluginTransaction.type === "remove") {
|
|
61908
|
-
|
|
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);
|
|
61909
61672
|
}
|
|
61910
61673
|
return { ...oldState };
|
|
61911
61674
|
}
|
|
@@ -61932,7 +61695,6 @@
|
|
|
61932
61695
|
if (isForceUpdate) shouldUpdate = true;
|
|
61933
61696
|
return {
|
|
61934
61697
|
...oldState,
|
|
61935
|
-
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
61936
61698
|
isReadyToInit: shouldInitialize
|
|
61937
61699
|
};
|
|
61938
61700
|
}
|
|
@@ -61961,10 +61723,6 @@
|
|
|
61961
61723
|
},
|
|
61962
61724
|
onDestroy() {
|
|
61963
61725
|
cleanupFloatingSeparators();
|
|
61964
|
-
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
61965
|
-
if (headerFooterEditors) {
|
|
61966
|
-
headerFooterEditors.clear();
|
|
61967
|
-
}
|
|
61968
61726
|
}
|
|
61969
61727
|
});
|
|
61970
61728
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
|
|
@@ -62025,7 +61783,6 @@
|
|
|
62025
61783
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
62026
61784
|
if (!editor.converter) return DecorationSet.empty;
|
|
62027
61785
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
62028
|
-
if (!pageSize) return DecorationSet.empty;
|
|
62029
61786
|
const { width, height } = pageSize;
|
|
62030
61787
|
if (!width || !height) return DecorationSet.empty;
|
|
62031
61788
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -62064,13 +61821,11 @@
|
|
|
62064
61821
|
let pageHeightThreshold = pageHeight;
|
|
62065
61822
|
let footer = null, header = null;
|
|
62066
61823
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
62067
|
-
const
|
|
62068
|
-
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
61824
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
|
|
62069
61825
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
62070
61826
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
62071
61827
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
62072
|
-
const
|
|
62073
|
-
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
61828
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
|
|
62074
61829
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
62075
61830
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
62076
61831
|
if (!coords) return [];
|
|
@@ -62089,8 +61844,7 @@
|
|
|
62089
61844
|
if (currentPageNumber === 1) {
|
|
62090
61845
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
62091
61846
|
decorations.pop();
|
|
62092
|
-
const
|
|
62093
|
-
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
61847
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
|
|
62094
61848
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
62095
61849
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
62096
61850
|
}
|
|
@@ -62164,15 +61918,15 @@
|
|
|
62164
61918
|
div2.style.height = bufferHeight + "px";
|
|
62165
61919
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
62166
61920
|
}
|
|
62167
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber
|
|
62168
|
-
const headerDef = sectionData
|
|
61921
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
61922
|
+
const headerDef = sectionData.headers?.[headerId];
|
|
62169
61923
|
const minHeaderHeight = pageMargins.top * 96;
|
|
62170
61924
|
const headerMargin = pageMargins.header * 96;
|
|
62171
61925
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
62172
61926
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
62173
61927
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
62174
61928
|
const availableHeight = headerHeight - headerMargin;
|
|
62175
|
-
|
|
61929
|
+
const editorContainer = document.createElement("div");
|
|
62176
61930
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
62177
61931
|
headerId = "rId" + generateDocxRandomId();
|
|
62178
61932
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -62184,31 +61938,23 @@
|
|
|
62184
61938
|
};
|
|
62185
61939
|
}
|
|
62186
61940
|
const data = editor.converter.headers[headerId];
|
|
62187
|
-
const
|
|
62188
|
-
|
|
62189
|
-
|
|
62190
|
-
|
|
62191
|
-
|
|
62192
|
-
|
|
62193
|
-
|
|
62194
|
-
|
|
62195
|
-
|
|
62196
|
-
|
|
62197
|
-
|
|
62198
|
-
|
|
62199
|
-
|
|
62200
|
-
|
|
62201
|
-
sectionId: headerId,
|
|
62202
|
-
type: "header",
|
|
62203
|
-
availableHeight,
|
|
62204
|
-
currentPageNumber
|
|
62205
|
-
});
|
|
62206
|
-
editor.converter.headerEditors.push({ id: headerId, editor: editorSection });
|
|
62207
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
62208
|
-
broadcastEditorEvents(editor, editorSection);
|
|
62209
|
-
}
|
|
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
|
+
});
|
|
62210
61955
|
editorSection.setEditable(false, false);
|
|
62211
|
-
|
|
61956
|
+
broadcastEditorEvents(editor, editorSection);
|
|
61957
|
+
editorContainer.className = "pagination-section-header";
|
|
62212
61958
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
62213
61959
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
62214
61960
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -62221,12 +61967,12 @@
|
|
|
62221
61967
|
headerHeight
|
|
62222
61968
|
};
|
|
62223
61969
|
}
|
|
62224
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber
|
|
62225
|
-
const footerDef = sectionData
|
|
61970
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
61971
|
+
const footerDef = sectionData.footers?.[footerId];
|
|
62226
61972
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
62227
61973
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
62228
61974
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
62229
|
-
|
|
61975
|
+
const editorContainer = document.createElement("div");
|
|
62230
61976
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
62231
61977
|
footerId = "rId" + generateDocxRandomId();
|
|
62232
61978
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -62238,31 +61984,23 @@
|
|
|
62238
61984
|
};
|
|
62239
61985
|
}
|
|
62240
61986
|
const data = editor.converter.footers[footerId];
|
|
62241
|
-
const
|
|
62242
|
-
|
|
62243
|
-
|
|
62244
|
-
|
|
62245
|
-
|
|
62246
|
-
|
|
62247
|
-
|
|
62248
|
-
|
|
62249
|
-
|
|
62250
|
-
|
|
62251
|
-
|
|
62252
|
-
|
|
62253
|
-
|
|
62254
|
-
|
|
62255
|
-
sectionId: footerId,
|
|
62256
|
-
type: "footer",
|
|
62257
|
-
availableHeight: footerHeight,
|
|
62258
|
-
currentPageNumber
|
|
62259
|
-
});
|
|
62260
|
-
editor.converter.footerEditors.push({ id: footerId, editor: editorSection });
|
|
62261
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
62262
|
-
broadcastEditorEvents(editor, editorSection);
|
|
62263
|
-
}
|
|
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
|
+
});
|
|
62264
62001
|
editorSection.setEditable(false, false);
|
|
62265
|
-
|
|
62002
|
+
broadcastEditorEvents(editor, editorSection);
|
|
62003
|
+
editorContainer.className = "pagination-section-footer";
|
|
62266
62004
|
editorContainer.style.height = footerHeight + "px";
|
|
62267
62005
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
62268
62006
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -62275,28 +62013,10 @@
|
|
|
62275
62013
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
62276
62014
|
};
|
|
62277
62015
|
}
|
|
62278
|
-
const getHeaderFooterEditorKey = ({
|
|
62279
|
-
pageNumber,
|
|
62280
|
-
isHeader,
|
|
62281
|
-
isFooter,
|
|
62282
|
-
isFirstHeader = false,
|
|
62283
|
-
isLastFooter = false
|
|
62284
|
-
}) => {
|
|
62285
|
-
if (isFirstHeader) return `first-header-${pageNumber}`;
|
|
62286
|
-
if (isLastFooter) return `last-footer-${pageNumber}`;
|
|
62287
|
-
if (isHeader) return `header-${pageNumber}`;
|
|
62288
|
-
if (isFooter) return `footer-${pageNumber}`;
|
|
62289
|
-
return void 0;
|
|
62290
|
-
};
|
|
62291
62016
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
62292
62017
|
if (editor.options.documentMode !== "editing") return;
|
|
62293
62018
|
editor.setEditable(false, false);
|
|
62294
|
-
toggleHeaderFooterEditMode(
|
|
62295
|
-
editor,
|
|
62296
|
-
focusedSectionEditor: currentFocusedSectionEditor,
|
|
62297
|
-
isEditMode: true,
|
|
62298
|
-
documentMode: editor.options.documentMode
|
|
62299
|
-
});
|
|
62019
|
+
toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
|
|
62300
62020
|
};
|
|
62301
62021
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
62302
62022
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -62851,7 +62571,7 @@
|
|
|
62851
62571
|
}
|
|
62852
62572
|
});
|
|
62853
62573
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
62854
|
-
const nodeResizer = (nodeNames = ["image"]
|
|
62574
|
+
const nodeResizer = (nodeNames = ["image"]) => {
|
|
62855
62575
|
let resizeState = {
|
|
62856
62576
|
dragging: false,
|
|
62857
62577
|
startX: 0,
|
|
@@ -62876,13 +62596,8 @@
|
|
|
62876
62596
|
if (tr.getMeta(NodeResizerKey)) {
|
|
62877
62597
|
return oldState;
|
|
62878
62598
|
}
|
|
62879
|
-
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
62880
|
-
const { selection } = newState;
|
|
62881
|
-
const node2 = selection.node;
|
|
62882
|
-
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
62883
|
-
return DecorationSet.empty;
|
|
62884
|
-
}
|
|
62885
62599
|
const decorations = [];
|
|
62600
|
+
const { selection } = newState;
|
|
62886
62601
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
62887
62602
|
decorations.push(
|
|
62888
62603
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -63085,7 +62800,7 @@
|
|
|
63085
62800
|
const NodeResizer = Extension.create({
|
|
63086
62801
|
name: "nodeResizer",
|
|
63087
62802
|
addPmPlugins() {
|
|
63088
|
-
return [nodeResizer(["image"]
|
|
62803
|
+
return [nodeResizer(["image"])];
|
|
63089
62804
|
}
|
|
63090
62805
|
});
|
|
63091
62806
|
const getRichTextExtensions = () => {
|
|
@@ -71761,6 +71476,7 @@ ${style2}
|
|
|
71761
71476
|
display: inline-block;
|
|
71762
71477
|
position: relative;
|
|
71763
71478
|
fill: currentColor;
|
|
71479
|
+
transform: translateZ(0);
|
|
71764
71480
|
`, [cM$1("color-transition", {
|
|
71765
71481
|
transition: "color .3s var(--n-bezier)"
|
|
71766
71482
|
}), cM$1("depth", {
|
|
@@ -89727,6 +89443,7 @@ ${style2}
|
|
|
89727
89443
|
display: inline-block;
|
|
89728
89444
|
position: relative;
|
|
89729
89445
|
fill: currentColor;
|
|
89446
|
+
transform: translateZ(0);
|
|
89730
89447
|
`, [cM("color-transition", {
|
|
89731
89448
|
transition: "color .3s var(--n-bezier)"
|
|
89732
89449
|
}), cM("depth", {
|
|
@@ -93599,7 +93316,7 @@ ${style2}
|
|
|
93599
93316
|
this.config.colors = shuffleArray(this.config.colors);
|
|
93600
93317
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
93601
93318
|
this.colorIndex = 0;
|
|
93602
|
-
this.version = "0.13.2
|
|
93319
|
+
this.version = "0.13.2";
|
|
93603
93320
|
console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
93604
93321
|
this.superdocId = config.superdocId || v4();
|
|
93605
93322
|
this.colors = this.config.colors;
|