@pie-element/simple-cloze 0.1.4-next.15 → 0.1.4-next.16
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/author/index.js +200 -171
- package/dist/author/index.js.map +1 -1
- package/dist/browser/author/index.js +2585 -2562
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/delivery/index.js +1 -1
- package/dist/browser/editor-runtime/delivery/index.js +1 -1
- package/dist/browser/editor-runtime/{i18n-gsOjC7sf.js → i18n-C7YV9VIN.js} +291 -217
- package/dist/browser/editor-runtime/i18n-C7YV9VIN.js.map +1 -0
- package/dist/browser/editor-runtime/print/index.js +1 -1
- package/dist/browser/{i18n-gsOjC7sf.js → i18n-C7YV9VIN.js} +291 -217
- package/dist/browser/i18n-C7YV9VIN.js.map +1 -0
- package/dist/browser/print/index.js +1 -1
- package/dist/delivery/index.js +139 -58
- package/dist/delivery/index.js.map +1 -1
- package/dist/index.iife.js +2 -2
- package/dist/print/index.js +139 -58
- package/dist/print/index.js.map +1 -1
- package/module/print.js +265 -191
- package/module/print.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/editor-runtime/i18n-gsOjC7sf.js.map +0 -1
- package/dist/browser/i18n-gsOjC7sf.js.map +0 -1
package/dist/author/index.js
CHANGED
|
@@ -5486,7 +5486,7 @@ OrderedMap.from = function(value) {
|
|
|
5486
5486
|
return new OrderedMap(content);
|
|
5487
5487
|
};
|
|
5488
5488
|
//#endregion
|
|
5489
|
-
//#region ../../../node_modules/.bun/prosemirror-model@1.25.
|
|
5489
|
+
//#region ../../../node_modules/.bun/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js
|
|
5490
5490
|
function findDiffStart(a, b, pos) {
|
|
5491
5491
|
for (let i = 0;; i++) {
|
|
5492
5492
|
if (i == a.childCount || i == b.childCount) return a.childCount == b.childCount ? null : pos;
|
|
@@ -5932,9 +5932,7 @@ var Mark$1 = class Mark$1 {
|
|
|
5932
5932
|
if (!json) throw new RangeError("Invalid input for Mark.fromJSON");
|
|
5933
5933
|
let type = schema.marks[json.type];
|
|
5934
5934
|
if (!type) throw new RangeError(`There is no mark type ${json.type} in this schema`);
|
|
5935
|
-
|
|
5936
|
-
type.checkAttrs(mark.attrs);
|
|
5937
|
-
return mark;
|
|
5935
|
+
return type.create(json.attrs);
|
|
5938
5936
|
}
|
|
5939
5937
|
/**
|
|
5940
5938
|
Test whether two sets of marks are identical.
|
|
@@ -6831,11 +6829,11 @@ var Node$2 = class Node$2 {
|
|
|
6831
6829
|
*/
|
|
6832
6830
|
check() {
|
|
6833
6831
|
this.type.checkContent(this.content);
|
|
6834
|
-
this.type.
|
|
6832
|
+
checkAttrs(this.type.attrs, this.attrs, "node", this.type.name);
|
|
6835
6833
|
let copy = Mark$1.none;
|
|
6836
6834
|
for (let i = 0; i < this.marks.length; i++) {
|
|
6837
6835
|
let mark = this.marks[i];
|
|
6838
|
-
mark.type.
|
|
6836
|
+
checkAttrs(mark.type.attrs, mark.attrs, "mark", mark.type.name);
|
|
6839
6837
|
copy = mark.addToSet(copy);
|
|
6840
6838
|
}
|
|
6841
6839
|
if (!Mark$1.sameSet(copy, this.marks)) throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m) => m.type.name)}`);
|
|
@@ -6869,9 +6867,7 @@ var Node$2 = class Node$2 {
|
|
|
6869
6867
|
return schema.text(json.text, marks);
|
|
6870
6868
|
}
|
|
6871
6869
|
let content = Fragment.fromJSON(schema, json.content);
|
|
6872
|
-
|
|
6873
|
-
node.type.checkAttrs(node.attrs);
|
|
6874
|
-
return node;
|
|
6870
|
+
return schema.nodeType(json.type).create(json.attrs, content, marks);
|
|
6875
6871
|
}
|
|
6876
6872
|
};
|
|
6877
6873
|
Node$2.prototype.text = void 0;
|
|
@@ -6921,6 +6917,10 @@ function wrapMarks(marks, str) {
|
|
|
6921
6917
|
for (let i = marks.length - 1; i >= 0; i--) str = marks[i].type.name + "(" + str + ")";
|
|
6922
6918
|
return str;
|
|
6923
6919
|
}
|
|
6920
|
+
function checkAttrs(attrs, values, type, name) {
|
|
6921
|
+
for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
6922
|
+
for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
|
|
6923
|
+
}
|
|
6924
6924
|
/**
|
|
6925
6925
|
Instances of this class represent a match state of a node type's
|
|
6926
6926
|
[content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
|
|
@@ -7329,20 +7329,15 @@ function defaultAttrs(attrs) {
|
|
|
7329
7329
|
function computeAttrs(attrs, value) {
|
|
7330
7330
|
let built = Object.create(null);
|
|
7331
7331
|
for (let name in attrs) {
|
|
7332
|
+
let attr = attrs[name];
|
|
7332
7333
|
let given = value && value[name];
|
|
7333
|
-
if (given === void 0)
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
else throw new RangeError("No value supplied for attribute " + name);
|
|
7337
|
-
}
|
|
7334
|
+
if (given === void 0) if (attr.hasDefault) given = attr.default;
|
|
7335
|
+
else throw new RangeError("No value supplied for attribute " + name);
|
|
7336
|
+
else if (attr.validate) attr.validate(given);
|
|
7338
7337
|
built[name] = given;
|
|
7339
7338
|
}
|
|
7340
7339
|
return built;
|
|
7341
7340
|
}
|
|
7342
|
-
function checkAttrs(attrs, values, type, name) {
|
|
7343
|
-
for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
7344
|
-
for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
|
|
7345
|
-
}
|
|
7346
7341
|
function initAttrs(typeName, attrs) {
|
|
7347
7342
|
let result = Object.create(null);
|
|
7348
7343
|
if (attrs) for (let name in attrs) result[name] = new Attribute(typeName, name, attrs[name]);
|
|
@@ -7497,11 +7492,9 @@ var NodeType$1 = class NodeType$1 {
|
|
|
7497
7492
|
if (!this.validContent(content)) throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
|
|
7498
7493
|
}
|
|
7499
7494
|
/**
|
|
7500
|
-
@internal
|
|
7495
|
+
@internal no longer useful, but called by old prosemirror-view versions
|
|
7501
7496
|
*/
|
|
7502
|
-
checkAttrs(attrs) {
|
|
7503
|
-
checkAttrs(this.attrs, attrs, "node", this.name);
|
|
7504
|
-
}
|
|
7497
|
+
checkAttrs(attrs) {}
|
|
7505
7498
|
/**
|
|
7506
7499
|
Check whether the given mark type is allowed in this node.
|
|
7507
7500
|
*/
|
|
@@ -7612,12 +7605,6 @@ var MarkType = class MarkType {
|
|
|
7612
7605
|
for (let i = 0; i < set.length; i++) if (set[i].type == this) return set[i];
|
|
7613
7606
|
}
|
|
7614
7607
|
/**
|
|
7615
|
-
@internal
|
|
7616
|
-
*/
|
|
7617
|
-
checkAttrs(attrs) {
|
|
7618
|
-
checkAttrs(this.attrs, attrs, "mark", this.name);
|
|
7619
|
-
}
|
|
7620
|
-
/**
|
|
7621
7608
|
Queries whether a given mark type is
|
|
7622
7609
|
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
|
|
7623
7610
|
*/
|
|
@@ -8476,7 +8463,7 @@ function renderSpec(doc, structure, xmlNS, blockArraysIn) {
|
|
|
8476
8463
|
};
|
|
8477
8464
|
}
|
|
8478
8465
|
//#endregion
|
|
8479
|
-
//#region ../../../node_modules/.bun/prosemirror-transform@1.12.
|
|
8466
|
+
//#region ../../../node_modules/.bun/prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js
|
|
8480
8467
|
var lower16 = 65535;
|
|
8481
8468
|
var factor16 = Math.pow(2, 16);
|
|
8482
8469
|
function makeRecover(index, offset) {
|
|
@@ -8579,8 +8566,11 @@ var StepMap = class StepMap {
|
|
|
8579
8566
|
let result = start + diff + (side < 0 ? 0 : newSize);
|
|
8580
8567
|
if (simple) return result;
|
|
8581
8568
|
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
8582
|
-
let del =
|
|
8583
|
-
if (
|
|
8569
|
+
let del = 0;
|
|
8570
|
+
if (oldSize) {
|
|
8571
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
8572
|
+
if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
|
|
8573
|
+
}
|
|
8584
8574
|
return new MapResult(result, del, recover);
|
|
8585
8575
|
}
|
|
8586
8576
|
diff += newSize - oldSize;
|
|
@@ -9701,9 +9691,9 @@ var Fitter = class {
|
|
|
9701
9691
|
}
|
|
9702
9692
|
openMore() {
|
|
9703
9693
|
let { content, openStart, openEnd } = this.unplaced;
|
|
9704
|
-
|
|
9705
|
-
if (
|
|
9706
|
-
this.unplaced = new Slice(content, openStart + 1,
|
|
9694
|
+
if (maxOpen(content, -1) <= openStart) return false;
|
|
9695
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;
|
|
9696
|
+
this.unplaced = new Slice(content, openStart + 1, openEnd);
|
|
9707
9697
|
return true;
|
|
9708
9698
|
}
|
|
9709
9699
|
dropNode() {
|
|
@@ -9837,6 +9827,13 @@ function invalidMarks(type, fragment, start) {
|
|
|
9837
9827
|
function definesContent(type) {
|
|
9838
9828
|
return type.spec.defining || type.spec.definingForContent;
|
|
9839
9829
|
}
|
|
9830
|
+
function maxOpen(frag, side) {
|
|
9831
|
+
for (let count = 0;; count++) {
|
|
9832
|
+
let ch = side < 0 ? frag.firstChild : frag.lastChild;
|
|
9833
|
+
if (!ch || ch.isAtom) return count;
|
|
9834
|
+
frag = ch.content;
|
|
9835
|
+
}
|
|
9836
|
+
}
|
|
9840
9837
|
function replaceRange(tr, from, to, slice) {
|
|
9841
9838
|
if (!slice.size) return tr.deleteRange(from, to);
|
|
9842
9839
|
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
@@ -11282,7 +11279,7 @@ var PluginKey = class {
|
|
|
11282
11279
|
}
|
|
11283
11280
|
};
|
|
11284
11281
|
//#endregion
|
|
11285
|
-
//#region ../../../node_modules/.bun/prosemirror-commands@1.7.
|
|
11282
|
+
//#region ../../../node_modules/.bun/prosemirror-commands@1.7.2/node_modules/prosemirror-commands/dist/index.js
|
|
11286
11283
|
/**
|
|
11287
11284
|
Delete the selection, if there is one.
|
|
11288
11285
|
*/
|
|
@@ -11604,20 +11601,23 @@ a custom function to determine the type of the newly split off block.
|
|
|
11604
11601
|
*/
|
|
11605
11602
|
function splitBlockAs(splitNode) {
|
|
11606
11603
|
return (state, dispatch) => {
|
|
11607
|
-
let { $from, $to } = state.selection;
|
|
11608
11604
|
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
|
|
11605
|
+
let { $from } = state.selection;
|
|
11609
11606
|
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) return false;
|
|
11610
11607
|
if (dispatch) dispatch(state.tr.split($from.pos).scrollIntoView());
|
|
11611
11608
|
return true;
|
|
11612
11609
|
}
|
|
11613
|
-
if (
|
|
11610
|
+
if (!state.selection.$from.depth) return false;
|
|
11611
|
+
let tr = state.tr;
|
|
11612
|
+
if (!state.selection.empty && (state.selection instanceof TextSelection || state.selection instanceof AllSelection)) tr.deleteSelection();
|
|
11613
|
+
let { $from } = tr.selection, mapFrom = tr.steps.length;
|
|
11614
11614
|
let types = [];
|
|
11615
11615
|
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
11616
11616
|
for (let d = $from.depth;; d--) if ($from.node(d).isBlock) {
|
|
11617
11617
|
atEnd = $from.end(d) == $from.pos + ($from.depth - d);
|
|
11618
11618
|
atStart = $from.start(d) == $from.pos - ($from.depth - d);
|
|
11619
11619
|
deflt = defaultBlockAt$1($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));
|
|
11620
|
-
let splitType = splitNode && splitNode($
|
|
11620
|
+
let splitType = splitNode && splitNode($from.parent, atEnd, $from);
|
|
11621
11621
|
types.unshift(splitType || (atEnd && deflt ? { type: deflt } : null));
|
|
11622
11622
|
splitDepth = d;
|
|
11623
11623
|
break;
|
|
@@ -11625,9 +11625,7 @@ function splitBlockAs(splitNode) {
|
|
|
11625
11625
|
if (d == 1) return false;
|
|
11626
11626
|
types.unshift(null);
|
|
11627
11627
|
}
|
|
11628
|
-
let
|
|
11629
|
-
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) tr.deleteSelection();
|
|
11630
|
-
let splitPos = tr.mapping.map($from.pos);
|
|
11628
|
+
let splitPos = $from.pos;
|
|
11631
11629
|
let can = canSplit(tr.doc, splitPos, types.length, types);
|
|
11632
11630
|
if (!can) {
|
|
11633
11631
|
types[0] = deflt ? { type: deflt } : null;
|
|
@@ -11636,8 +11634,9 @@ function splitBlockAs(splitNode) {
|
|
|
11636
11634
|
if (!can) return false;
|
|
11637
11635
|
tr.split(splitPos, types.length, types);
|
|
11638
11636
|
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
11639
|
-
let
|
|
11640
|
-
|
|
11637
|
+
let mapping = tr.mapping.slice(mapFrom);
|
|
11638
|
+
let first = mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first);
|
|
11639
|
+
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(mapping.map($from.before(splitDepth)), deflt);
|
|
11641
11640
|
}
|
|
11642
11641
|
if (dispatch) dispatch(tr.scrollIntoView());
|
|
11643
11642
|
return true;
|
|
@@ -11963,7 +11962,7 @@ function sinkListItem(itemType) {
|
|
|
11963
11962
|
};
|
|
11964
11963
|
}
|
|
11965
11964
|
//#endregion
|
|
11966
|
-
//#region ../../../node_modules/.bun/prosemirror-view@1.42.
|
|
11965
|
+
//#region ../../../node_modules/.bun/prosemirror-view@1.42.6/node_modules/prosemirror-view/dist/index.js
|
|
11967
11966
|
var domIndex = function(node) {
|
|
11968
11967
|
for (var index = 0;; index++) {
|
|
11969
11968
|
node = node.previousSibling;
|
|
@@ -11994,12 +11993,12 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
11994
11993
|
if (node == targetNode && off == targetOff) return true;
|
|
11995
11994
|
if (off == (dir < 0 ? 0 : nodeSize(node))) {
|
|
11996
11995
|
let parent = node.parentNode;
|
|
11997
|
-
if (!parent || parent
|
|
11996
|
+
if (!parent || !isElt(parent) || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
|
|
11998
11997
|
off = domIndex(node) + (dir < 0 ? 0 : 1);
|
|
11999
11998
|
node = parent;
|
|
12000
|
-
} else if (node
|
|
11999
|
+
} else if (isElt(node)) {
|
|
12001
12000
|
let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
|
|
12002
|
-
if (child
|
|
12001
|
+
if (isElt(child) && child.contentEditable == "false") if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;
|
|
12003
12002
|
else return false;
|
|
12004
12003
|
else {
|
|
12005
12004
|
node = child;
|
|
@@ -12011,10 +12010,19 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
12011
12010
|
function nodeSize(node) {
|
|
12012
12011
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
12013
12012
|
}
|
|
12013
|
+
function isElt(node) {
|
|
12014
|
+
return node.nodeType == 1;
|
|
12015
|
+
}
|
|
12016
|
+
function isText(node) {
|
|
12017
|
+
return node.nodeType == 3;
|
|
12018
|
+
}
|
|
12019
|
+
function contains(parent, child) {
|
|
12020
|
+
return child ? parent.contains(isElt(child) ? child : child.parentNode) : false;
|
|
12021
|
+
}
|
|
12014
12022
|
function textNodeBefore$1(node, offset) {
|
|
12015
12023
|
for (;;) {
|
|
12016
|
-
if (node
|
|
12017
|
-
if (node
|
|
12024
|
+
if (isText(node) && offset) return node;
|
|
12025
|
+
if (isElt(node) && offset > 0) {
|
|
12018
12026
|
if (node.contentEditable == "false") return null;
|
|
12019
12027
|
node = node.childNodes[offset - 1];
|
|
12020
12028
|
offset = nodeSize(node);
|
|
@@ -12026,8 +12034,8 @@ function textNodeBefore$1(node, offset) {
|
|
|
12026
12034
|
}
|
|
12027
12035
|
function textNodeAfter$1(node, offset) {
|
|
12028
12036
|
for (;;) {
|
|
12029
|
-
if (node
|
|
12030
|
-
if (node
|
|
12037
|
+
if (isText(node) && offset < node.nodeValue.length) return node;
|
|
12038
|
+
if (isElt(node) && offset < node.childNodes.length) {
|
|
12031
12039
|
if (node.contentEditable == "false") return null;
|
|
12032
12040
|
node = node.childNodes[offset];
|
|
12033
12041
|
offset = 0;
|
|
@@ -12138,13 +12146,12 @@ function scrollRectIntoView(view, rect, startDOM) {
|
|
|
12138
12146
|
let doc = view.dom.ownerDocument;
|
|
12139
12147
|
for (let parent = startDOM || view.dom;;) {
|
|
12140
12148
|
if (!parent) break;
|
|
12141
|
-
if (parent
|
|
12149
|
+
if (!isElt(parent)) {
|
|
12142
12150
|
parent = parentNode(parent);
|
|
12143
12151
|
continue;
|
|
12144
12152
|
}
|
|
12145
|
-
let
|
|
12146
|
-
let
|
|
12147
|
-
let bounding = atTop ? windowRect(doc) : clientRect(elt);
|
|
12153
|
+
let atTop = parent == doc.body;
|
|
12154
|
+
let bounding = atTop ? windowRect(doc) : clientRect(parent);
|
|
12148
12155
|
let moveX = 0, moveY = 0;
|
|
12149
12156
|
if (rect.top < bounding.top + getSide(scrollThreshold, "top")) moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
|
|
12150
12157
|
else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom")) moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
|
|
@@ -12152,10 +12159,10 @@ function scrollRectIntoView(view, rect, startDOM) {
|
|
|
12152
12159
|
else if (rect.right > bounding.right - getSide(scrollThreshold, "right")) moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
|
|
12153
12160
|
if (moveX || moveY) if (atTop) doc.defaultView.scrollBy(moveX, moveY);
|
|
12154
12161
|
else {
|
|
12155
|
-
let startX =
|
|
12156
|
-
if (moveY)
|
|
12157
|
-
if (moveX)
|
|
12158
|
-
let dX =
|
|
12162
|
+
let startX = parent.scrollLeft, startY = parent.scrollTop;
|
|
12163
|
+
if (moveY) parent.scrollTop += moveY;
|
|
12164
|
+
if (moveX) parent.scrollLeft += moveX;
|
|
12165
|
+
let dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
|
|
12159
12166
|
rect = {
|
|
12160
12167
|
left: rect.left - dX,
|
|
12161
12168
|
top: rect.top - dY,
|
|
@@ -12225,13 +12232,14 @@ function focusPreventScroll(dom) {
|
|
|
12225
12232
|
}
|
|
12226
12233
|
}
|
|
12227
12234
|
function findOffsetInNode(node, coords) {
|
|
12228
|
-
let closest
|
|
12235
|
+
let closest;
|
|
12236
|
+
let dxClosest = 2e8, coordsClosest, offset = 0;
|
|
12229
12237
|
let rowBot = coords.top, rowTop = coords.top;
|
|
12230
12238
|
let firstBelow, coordsBelow;
|
|
12231
12239
|
for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
|
|
12232
12240
|
let rects;
|
|
12233
|
-
if (child
|
|
12234
|
-
else if (child
|
|
12241
|
+
if (isElt(child)) rects = child.getClientRects();
|
|
12242
|
+
else if (isText(child)) rects = textRange(child).getClientRects();
|
|
12235
12243
|
else continue;
|
|
12236
12244
|
for (let i = 0; i < rects.length; i++) {
|
|
12237
12245
|
let rect = rects[i];
|
|
@@ -12242,11 +12250,11 @@ function findOffsetInNode(node, coords) {
|
|
|
12242
12250
|
if (dx < dxClosest) {
|
|
12243
12251
|
closest = child;
|
|
12244
12252
|
dxClosest = dx;
|
|
12245
|
-
coordsClosest = dx && closest
|
|
12253
|
+
coordsClosest = dx && isText(closest) ? {
|
|
12246
12254
|
left: rect.right < coords.left ? rect.right : rect.left,
|
|
12247
12255
|
top: coords.top
|
|
12248
12256
|
} : coords;
|
|
12249
|
-
if (child
|
|
12257
|
+
if (isElt(child) && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
|
|
12250
12258
|
continue;
|
|
12251
12259
|
}
|
|
12252
12260
|
} else if (rect.top > coords.top && !firstBelow && rect.left <= coords.left && rect.right >= coords.left) {
|
|
@@ -12264,8 +12272,8 @@ function findOffsetInNode(node, coords) {
|
|
|
12264
12272
|
coordsClosest = coordsBelow;
|
|
12265
12273
|
dxClosest = 0;
|
|
12266
12274
|
}
|
|
12267
|
-
if (closest && closest
|
|
12268
|
-
if (!closest || dxClosest
|
|
12275
|
+
if (closest && isText(closest)) return findOffsetInText(closest, coordsClosest);
|
|
12276
|
+
if (!closest || dxClosest) return {
|
|
12269
12277
|
node,
|
|
12270
12278
|
offset
|
|
12271
12279
|
};
|
|
@@ -12303,7 +12311,7 @@ function targetKludge(dom, coords) {
|
|
|
12303
12311
|
}
|
|
12304
12312
|
function posFromElement(view, elt, coords) {
|
|
12305
12313
|
let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
|
|
12306
|
-
if (node
|
|
12314
|
+
if (isElt(node) && !node.firstChild) {
|
|
12307
12315
|
let rect = node.getBoundingClientRect();
|
|
12308
12316
|
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
|
|
12309
12317
|
}
|
|
@@ -12315,7 +12323,7 @@ function posFromCaret(view, node, offset, coords) {
|
|
|
12315
12323
|
if (cur == view.dom) break;
|
|
12316
12324
|
let desc = view.docView.nearestDesc(cur, true), rect;
|
|
12317
12325
|
if (!desc) return null;
|
|
12318
|
-
if (desc.dom
|
|
12326
|
+
if (isElt(desc.dom) && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
|
|
12319
12327
|
if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
|
|
12320
12328
|
if (!sawBlock && rect.left > coords.left || rect.top > coords.top) outsideBlock = desc.posBefore;
|
|
12321
12329
|
else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top) outsideBlock = desc.posAfter;
|
|
@@ -12331,7 +12339,7 @@ function elementFromPoint(element, coords, box) {
|
|
|
12331
12339
|
let len = element.childNodes.length;
|
|
12332
12340
|
if (len && box.top < box.bottom) for (let startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {
|
|
12333
12341
|
let child = element.childNodes[i];
|
|
12334
|
-
if (child
|
|
12342
|
+
if (isElt(child)) {
|
|
12335
12343
|
let rects = child.getClientRects();
|
|
12336
12344
|
for (let j = 0; j < rects.length; j++) {
|
|
12337
12345
|
let rect = rects[j];
|
|
@@ -12348,7 +12356,7 @@ function posAtCoords(view, coords) {
|
|
|
12348
12356
|
if (caret) ({node, offset} = caret);
|
|
12349
12357
|
let elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top);
|
|
12350
12358
|
let pos;
|
|
12351
|
-
if (!elt || !view.dom.contains(elt
|
|
12359
|
+
if (!elt || !view.dom.contains(elt)) {
|
|
12352
12360
|
let box = view.dom.getBoundingClientRect();
|
|
12353
12361
|
if (!inRect(coords, box)) return null;
|
|
12354
12362
|
elt = elementFromPoint(view.dom, coords, box);
|
|
@@ -12359,7 +12367,7 @@ function posAtCoords(view, coords) {
|
|
|
12359
12367
|
}
|
|
12360
12368
|
elt = targetKludge(elt, coords);
|
|
12361
12369
|
if (node) {
|
|
12362
|
-
if (gecko && node
|
|
12370
|
+
if (gecko && isElt(node)) {
|
|
12363
12371
|
offset = Math.min(offset, node.childNodes.length);
|
|
12364
12372
|
if (offset < node.childNodes.length) {
|
|
12365
12373
|
let next = node.childNodes[offset], box;
|
|
@@ -12367,9 +12375,9 @@ function posAtCoords(view, coords) {
|
|
|
12367
12375
|
}
|
|
12368
12376
|
}
|
|
12369
12377
|
let prev;
|
|
12370
|
-
if (webkit && offset && node
|
|
12371
|
-
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild
|
|
12372
|
-
else if (offset == 0 || node
|
|
12378
|
+
if (webkit && offset && isElt(node) && isElt(prev = node.childNodes[offset - 1]) && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
|
|
12379
|
+
if (node == view.dom && offset == node.childNodes.length - 1 && isElt(node.lastChild) && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;
|
|
12380
|
+
else if (offset == 0 || !isElt(node) || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
|
|
12373
12381
|
}
|
|
12374
12382
|
if (pos == null) pos = posFromElement(view, elt, coords);
|
|
12375
12383
|
let desc = view.docView.nearestDesc(elt, true);
|
|
@@ -12393,7 +12401,7 @@ var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
|
|
12393
12401
|
function coordsAtPos(view, pos, side) {
|
|
12394
12402
|
let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
|
|
12395
12403
|
let supportEmptyRange = webkit || gecko;
|
|
12396
|
-
if (node
|
|
12404
|
+
if (isText(node)) if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
|
|
12397
12405
|
let rect = singleRect(textRange(node, offset, offset), side);
|
|
12398
12406
|
if (gecko && offset && /\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {
|
|
12399
12407
|
let rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1);
|
|
@@ -12418,26 +12426,26 @@ function coordsAtPos(view, pos, side) {
|
|
|
12418
12426
|
if (!view.state.doc.resolve(pos - (atom || 0)).parent.inlineContent) {
|
|
12419
12427
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
12420
12428
|
let before = node.childNodes[offset - 1];
|
|
12421
|
-
if (before
|
|
12429
|
+
if (isElt(before)) return flattenH(before.getBoundingClientRect(), false);
|
|
12422
12430
|
}
|
|
12423
12431
|
if (atom == null && offset < nodeSize(node)) {
|
|
12424
12432
|
let after = node.childNodes[offset];
|
|
12425
|
-
if (after
|
|
12433
|
+
if (isElt(after)) return flattenH(after.getBoundingClientRect(), true);
|
|
12426
12434
|
}
|
|
12427
12435
|
return flattenH(node.getBoundingClientRect(), side >= 0);
|
|
12428
12436
|
}
|
|
12429
12437
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
12430
12438
|
let before = node.childNodes[offset - 1];
|
|
12431
|
-
let target = before
|
|
12439
|
+
let target = isText(before) ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : isElt(before) && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
|
|
12432
12440
|
if (target) return flattenV(singleRect(target, 1), false);
|
|
12433
12441
|
}
|
|
12434
12442
|
if (atom == null && offset < nodeSize(node)) {
|
|
12435
12443
|
let after = node.childNodes[offset];
|
|
12436
12444
|
while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords) after = after.nextSibling;
|
|
12437
|
-
let target = !after ? null : after
|
|
12445
|
+
let target = !after ? null : isText(after) ? textRange(after, 0, supportEmptyRange ? 0 : 1) : isElt(after) ? after : null;
|
|
12438
12446
|
if (target) return flattenV(singleRect(target, -1), true);
|
|
12439
12447
|
}
|
|
12440
|
-
return flattenV(singleRect(node
|
|
12448
|
+
return flattenV(singleRect(isText(node) ? textRange(node) : node, -side), side >= 0);
|
|
12441
12449
|
}
|
|
12442
12450
|
function flattenV(rect, left) {
|
|
12443
12451
|
if (rect.width == 0) return rect;
|
|
@@ -12487,8 +12495,8 @@ function endOfTextblockVertical(view, state, dir) {
|
|
|
12487
12495
|
let coords = coordsAtPos(view, $pos.pos, 1);
|
|
12488
12496
|
for (let child = dom.firstChild; child; child = child.nextSibling) {
|
|
12489
12497
|
let boxes;
|
|
12490
|
-
if (child
|
|
12491
|
-
else if (child
|
|
12498
|
+
if (isElt(child)) boxes = child.getClientRects();
|
|
12499
|
+
else if (isText(child)) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
|
|
12492
12500
|
else continue;
|
|
12493
12501
|
for (let i = 0; i < boxes.length; i++) {
|
|
12494
12502
|
let box = boxes[i];
|
|
@@ -12512,7 +12520,7 @@ function endOfTextblockHorizontal(view, state, dir) {
|
|
|
12512
12520
|
sel.modify("move", dir, "character");
|
|
12513
12521
|
let parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
|
|
12514
12522
|
let { focusNode: newNode, focusOffset: newOff } = view.domSelectionRange();
|
|
12515
|
-
let result = newNode && !
|
|
12523
|
+
let result = newNode && !contains(parentDOM, newNode) || oldNode == newNode && oldOff == newOff;
|
|
12516
12524
|
try {
|
|
12517
12525
|
sel.collapse(anchorNode, anchorOffset);
|
|
12518
12526
|
if (oldNode && (oldNode != anchorNode || oldOff != anchorOffset) && sel.extend) sel.extend(oldNode, oldOff);
|
|
@@ -12594,7 +12602,7 @@ var ViewDesc = class {
|
|
|
12594
12602
|
return this.posAtStart + this.size - 2 * this.border;
|
|
12595
12603
|
}
|
|
12596
12604
|
localPosFromDOM(dom, offset, bias) {
|
|
12597
|
-
if (this.contentDOM && this.contentDOM
|
|
12605
|
+
if (this.contentDOM && contains(this.contentDOM, dom)) if (bias < 0) {
|
|
12598
12606
|
let domBefore, desc;
|
|
12599
12607
|
if (dom == this.contentDOM) domBefore = dom.childNodes[offset - 1];
|
|
12600
12608
|
else {
|
|
@@ -12615,7 +12623,7 @@ var ViewDesc = class {
|
|
|
12615
12623
|
}
|
|
12616
12624
|
let atEnd;
|
|
12617
12625
|
if (dom == this.dom && this.contentDOM) atEnd = offset > domIndex(this.contentDOM);
|
|
12618
|
-
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = dom.compareDocumentPosition(this.contentDOM) &
|
|
12626
|
+
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = !!(dom.compareDocumentPosition(this.contentDOM) & 4);
|
|
12619
12627
|
else if (this.dom.firstChild) {
|
|
12620
12628
|
if (offset == 0) for (let search = dom;; search = search.parentNode) {
|
|
12621
12629
|
if (search == this.dom) {
|
|
@@ -12637,7 +12645,7 @@ var ViewDesc = class {
|
|
|
12637
12645
|
nearestDesc(dom, onlyNodes = false) {
|
|
12638
12646
|
for (let first = true, cur = dom; cur; cur = cur.parentNode) {
|
|
12639
12647
|
let desc = this.getDesc(cur), nodeDOM;
|
|
12640
|
-
if (desc && (!onlyNodes || desc.node)) if (first && (nodeDOM = desc.nodeDOM) && !(nodeDOM
|
|
12648
|
+
if (desc && (!onlyNodes || desc.node)) if (first && (nodeDOM = desc.nodeDOM) && !(isElt(nodeDOM) ? contains(nodeDOM, dom) : nodeDOM == dom)) first = false;
|
|
12641
12649
|
else return desc;
|
|
12642
12650
|
}
|
|
12643
12651
|
}
|
|
@@ -12678,14 +12686,17 @@ var ViewDesc = class {
|
|
|
12678
12686
|
let i = 0, offset = 0;
|
|
12679
12687
|
for (let curPos = 0; i < this.children.length; i++) {
|
|
12680
12688
|
let child = this.children[i], end = curPos + child.size;
|
|
12681
|
-
if (end > pos
|
|
12689
|
+
if (end > pos) {
|
|
12682
12690
|
offset = pos - curPos;
|
|
12683
12691
|
break;
|
|
12684
12692
|
}
|
|
12685
12693
|
curPos = end;
|
|
12686
12694
|
}
|
|
12687
12695
|
if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side);
|
|
12688
|
-
for (
|
|
12696
|
+
for (; i > 0; i--) {
|
|
12697
|
+
let prev = this.children[i - 1];
|
|
12698
|
+
if (prev.size || !(prev instanceof BufferHackViewDesc || prev instanceof WidgetViewDesc && prev.side >= 0)) break;
|
|
12699
|
+
}
|
|
12689
12700
|
if (side <= 0) {
|
|
12690
12701
|
let prev, enter = true;
|
|
12691
12702
|
for (;; i--, enter = false) {
|
|
@@ -12765,7 +12776,7 @@ var ViewDesc = class {
|
|
|
12765
12776
|
}
|
|
12766
12777
|
domAfterPos(pos) {
|
|
12767
12778
|
let { node, offset } = this.domFromPos(pos, 0);
|
|
12768
|
-
if (node
|
|
12779
|
+
if (!isElt(node) || offset == node.childNodes.length) throw new RangeError("No node after pos " + pos);
|
|
12769
12780
|
return node.childNodes[offset];
|
|
12770
12781
|
}
|
|
12771
12782
|
setSelection(anchor, head, view, force = false) {
|
|
@@ -12782,7 +12793,7 @@ var ViewDesc = class {
|
|
|
12782
12793
|
let brKludge = false;
|
|
12783
12794
|
if ((gecko || safari) && anchor == head) {
|
|
12784
12795
|
let { node, offset } = anchorDOM;
|
|
12785
|
-
if (node
|
|
12796
|
+
if (isText(node)) {
|
|
12786
12797
|
brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
|
|
12787
12798
|
if (brKludge && offset == node.nodeValue.length) for (let scan = node, after; scan; scan = scan.parentNode) {
|
|
12788
12799
|
if (after = scan.nextSibling) {
|
|
@@ -12800,7 +12811,7 @@ var ViewDesc = class {
|
|
|
12800
12811
|
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
|
|
12801
12812
|
}
|
|
12802
12813
|
}
|
|
12803
|
-
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode
|
|
12814
|
+
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && isElt(selRange.focusNode)) {
|
|
12804
12815
|
let after = selRange.focusNode.childNodes[selRange.focusOffset];
|
|
12805
12816
|
if (after && after.contentEditable == "false") force = true;
|
|
12806
12817
|
}
|
|
@@ -12876,13 +12887,10 @@ var WidgetViewDesc = class extends ViewDesc {
|
|
|
12876
12887
|
if (self.parent) return self.parent.posBeforeChild(self);
|
|
12877
12888
|
});
|
|
12878
12889
|
if (!widget.type.spec.raw) {
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
}
|
|
12884
|
-
if (!dom.hasAttribute("contenteditable")) dom.contentEditable = "false";
|
|
12885
|
-
dom.classList.add("ProseMirror-widget");
|
|
12890
|
+
let elt = isElt(dom) ? dom : document.createElement("span");
|
|
12891
|
+
if (elt != dom) elt.appendChild(dom);
|
|
12892
|
+
if (!elt.hasAttribute("contenteditable")) elt.contentEditable = "false";
|
|
12893
|
+
elt.classList.add("ProseMirror-widget");
|
|
12886
12894
|
}
|
|
12887
12895
|
super(parent, [], dom, null);
|
|
12888
12896
|
this.widget = widget;
|
|
@@ -13005,7 +13013,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
13005
13013
|
let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM;
|
|
13006
13014
|
if (node.isText) {
|
|
13007
13015
|
if (!dom) dom = document.createTextNode(node.text);
|
|
13008
|
-
else if (dom
|
|
13016
|
+
else if (!isText(dom)) throw new RangeError("Text must be rendered as a DOM text node");
|
|
13009
13017
|
} else if (!dom) {
|
|
13010
13018
|
let spec = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node), null, node.attrs);
|
|
13011
13019
|
({dom, contentDOM} = spec);
|
|
@@ -13038,7 +13046,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
13038
13046
|
}
|
|
13039
13047
|
}
|
|
13040
13048
|
if (!rule.contentElement) {
|
|
13041
|
-
let found = addedNodes && addedNodes.find((n) => n
|
|
13049
|
+
let found = addedNodes && addedNodes.find((n) => isElt(n) && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
|
|
13042
13050
|
if (found) rule.contentElement = found;
|
|
13043
13051
|
else rule.getContent = () => Fragment.empty;
|
|
13044
13052
|
}
|
|
@@ -13060,18 +13068,21 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
13060
13068
|
let localComposition = composition && composition.pos > -1 ? composition : null;
|
|
13061
13069
|
let compositionInChild = composition && composition.pos < 0;
|
|
13062
13070
|
let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
|
|
13071
|
+
let addBuffers = this.node.inlineContent, atBufferPos = addBuffers && this.node.isBlock;
|
|
13063
13072
|
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
|
|
13064
13073
|
if (widget.spec.marks) updater.syncToMarks(widget.spec.marks, inline, view, i);
|
|
13065
13074
|
else if (widget.type.side >= 0 && !insideNode) updater.syncToMarks(i == this.node.childCount ? Mark$1.none : this.node.child(i).marks, inline, view, i);
|
|
13066
13075
|
updater.placeWidget(widget, view, off);
|
|
13067
13076
|
}, (child, outerDeco, innerDeco, i) => {
|
|
13068
13077
|
updater.syncToMarks(child.marks, inline, view, i);
|
|
13078
|
+
if (atBufferPos && child.isAtom && !child.isText) updater.addHackNode("IMG", updater.top);
|
|
13069
13079
|
let compIndex;
|
|
13070
13080
|
if (updater.findNodeMatch(child, outerDeco, innerDeco, i));
|
|
13071
13081
|
else if (compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view));
|
|
13072
13082
|
else if (updater.updateNextNode(child, outerDeco, innerDeco, view, i, off));
|
|
13073
13083
|
else updater.addNode(child, outerDeco, innerDeco, view, off);
|
|
13074
13084
|
off += child.nodeSize;
|
|
13085
|
+
if (addBuffers) atBufferPos = child.isAtom && !child.isText;
|
|
13075
13086
|
});
|
|
13076
13087
|
updater.syncToMarks([], inline, view, 0);
|
|
13077
13088
|
if (this.node.isTextblock) updater.addTextblockHacks();
|
|
@@ -13128,7 +13139,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
13128
13139
|
}
|
|
13129
13140
|
updateOuterDeco(outerDeco) {
|
|
13130
13141
|
if (sameOuterDeco(outerDeco, this.outerDeco)) return;
|
|
13131
|
-
let needsWrap = this.nodeDOM
|
|
13142
|
+
let needsWrap = !isElt(this.nodeDOM);
|
|
13132
13143
|
let oldDOM = this.dom;
|
|
13133
13144
|
this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
|
|
13134
13145
|
if (this.dom != oldDOM) {
|
|
@@ -13138,13 +13149,13 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
13138
13149
|
this.outerDeco = outerDeco;
|
|
13139
13150
|
}
|
|
13140
13151
|
selectNode() {
|
|
13141
|
-
if (this.nodeDOM
|
|
13152
|
+
if (isElt(this.nodeDOM)) {
|
|
13142
13153
|
this.nodeDOM.classList.add("ProseMirror-selectednode");
|
|
13143
13154
|
if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.draggable = true;
|
|
13144
13155
|
}
|
|
13145
13156
|
}
|
|
13146
13157
|
deselectNode() {
|
|
13147
|
-
if (this.nodeDOM
|
|
13158
|
+
if (isElt(this.nodeDOM)) {
|
|
13148
13159
|
this.nodeDOM.classList.remove("ProseMirror-selectednode");
|
|
13149
13160
|
if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.removeAttribute("draggable");
|
|
13150
13161
|
}
|
|
@@ -13212,7 +13223,7 @@ var TextViewDesc = class TextViewDesc extends NodeViewDesc {
|
|
|
13212
13223
|
return this.node.text == text;
|
|
13213
13224
|
}
|
|
13214
13225
|
};
|
|
13215
|
-
var
|
|
13226
|
+
var BufferHackViewDesc = class extends ViewDesc {
|
|
13216
13227
|
parseRule() {
|
|
13217
13228
|
return { ignore: true };
|
|
13218
13229
|
}
|
|
@@ -13348,7 +13359,7 @@ function patchAttributes(dom, prev, cur) {
|
|
|
13348
13359
|
}
|
|
13349
13360
|
}
|
|
13350
13361
|
function applyOuterDeco(dom, deco, node) {
|
|
13351
|
-
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom
|
|
13362
|
+
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, !isElt(dom)));
|
|
13352
13363
|
}
|
|
13353
13364
|
function sameOuterDeco(a, b) {
|
|
13354
13365
|
if (a.length != b.length) return false;
|
|
@@ -13538,14 +13549,14 @@ var ViewTreeUpdater = class {
|
|
|
13538
13549
|
dom.alt = "";
|
|
13539
13550
|
}
|
|
13540
13551
|
if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak";
|
|
13541
|
-
let hack = new
|
|
13552
|
+
let hack = new BufferHackViewDesc(this.top, [], dom, null);
|
|
13542
13553
|
if (parent != this.top) parent.children.push(hack);
|
|
13543
13554
|
else parent.children.splice(this.index++, 0, hack);
|
|
13544
13555
|
this.changed = true;
|
|
13545
13556
|
}
|
|
13546
13557
|
}
|
|
13547
13558
|
isLocked(node) {
|
|
13548
|
-
return this.lock && (node == this.lock || node
|
|
13559
|
+
return this.lock && (node == this.lock || isElt(node) && node.contains(this.lock.parentNode));
|
|
13549
13560
|
}
|
|
13550
13561
|
};
|
|
13551
13562
|
function preMatch(frag, parentDesc) {
|
|
@@ -13689,10 +13700,15 @@ function selectionFromDOM(view, origin = null) {
|
|
|
13689
13700
|
if (selectionCollapsed(domSel)) {
|
|
13690
13701
|
anchor = head;
|
|
13691
13702
|
while (nearestDesc && !nearestDesc.node) nearestDesc = nearestDesc.parent;
|
|
13692
|
-
|
|
13693
|
-
if (nearestDesc && nearestDescNode.isAtom && NodeSelection.isSelectable(nearestDescNode) && nearestDesc.parent && !(nearestDescNode.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
|
|
13703
|
+
if (nearestDesc && nearestDesc.node.isAtom && NodeSelection.isSelectable(nearestDesc.node) && nearestDesc.parent && !(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
|
|
13694
13704
|
let pos = nearestDesc.posBefore;
|
|
13695
13705
|
selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
|
|
13706
|
+
} else if (gecko && origin == "key" && head > view.state.selection.to && isElt(domSel.focusNode) && domSel.focusOffset == domSel.focusNode.childNodes.length && nearestDesc && nearestDesc.posAtStart > view.state.selection.to) for (let scan = domSel.focusNode;; scan = scan.parentNode) {
|
|
13707
|
+
if (getComputedStyle(scan).overflow != "visible") {
|
|
13708
|
+
selection = Selection$1.findFrom(doc.resolve(nearestDesc.posAtStart), 1);
|
|
13709
|
+
break;
|
|
13710
|
+
}
|
|
13711
|
+
if (scan == nearestDesc.dom || scan.nextSibling || !scan.parentNode || !isElt(scan.parentNode)) break;
|
|
13696
13712
|
}
|
|
13697
13713
|
} else {
|
|
13698
13714
|
if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {
|
|
@@ -13830,7 +13846,7 @@ function hasSelection(view) {
|
|
|
13830
13846
|
let sel = view.domSelectionRange();
|
|
13831
13847
|
if (!sel.anchorNode) return false;
|
|
13832
13848
|
try {
|
|
13833
|
-
return view.dom
|
|
13849
|
+
return contains(view.dom, sel.anchorNode) && (view.editable || contains(view.dom, sel.focusNode));
|
|
13834
13850
|
} catch (_) {
|
|
13835
13851
|
return false;
|
|
13836
13852
|
}
|
|
@@ -13869,8 +13885,7 @@ function selectHorizontally(view, dir, mods) {
|
|
|
13869
13885
|
let nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;
|
|
13870
13886
|
if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;
|
|
13871
13887
|
if (NodeSelection.isSelectable(node)) return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));
|
|
13872
|
-
else
|
|
13873
|
-
else return false;
|
|
13888
|
+
else return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
|
|
13874
13889
|
}
|
|
13875
13890
|
} else if (sel instanceof NodeSelection && sel.node.isInline) return apply(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
|
|
13876
13891
|
else {
|
|
@@ -13879,12 +13894,9 @@ function selectHorizontally(view, dir, mods) {
|
|
|
13879
13894
|
return false;
|
|
13880
13895
|
}
|
|
13881
13896
|
}
|
|
13882
|
-
function nodeLen(node) {
|
|
13883
|
-
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
13884
|
-
}
|
|
13885
13897
|
function isIgnorable(dom, dir) {
|
|
13886
13898
|
let desc = dom.pmViewDesc;
|
|
13887
|
-
return desc
|
|
13899
|
+
return desc ? desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR") : isElt(dom) && dom.contentEditable == "false";
|
|
13888
13900
|
}
|
|
13889
13901
|
function skipIgnoredNodes(view, dir) {
|
|
13890
13902
|
return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);
|
|
@@ -13894,19 +13906,18 @@ function skipIgnoredNodesBefore(view) {
|
|
|
13894
13906
|
let node = sel.focusNode, offset = sel.focusOffset;
|
|
13895
13907
|
if (!node) return;
|
|
13896
13908
|
let moveNode, moveOffset, force = false;
|
|
13897
|
-
if (gecko && node
|
|
13898
|
-
for (;;) if (offset > 0)
|
|
13899
|
-
|
|
13909
|
+
if (gecko && isElt(node) && offset < nodeSize(node) && isIgnorable(node.childNodes[offset], -1)) force = true;
|
|
13910
|
+
for (;;) if (offset > 0) {
|
|
13911
|
+
if (!isElt(node)) break;
|
|
13900
13912
|
let before = node.childNodes[offset - 1];
|
|
13901
13913
|
if (isIgnorable(before, -1)) {
|
|
13902
13914
|
moveNode = node;
|
|
13903
13915
|
moveOffset = --offset;
|
|
13904
|
-
} else if (before
|
|
13916
|
+
} else if (isText(before)) {
|
|
13905
13917
|
node = before;
|
|
13906
13918
|
offset = node.nodeValue.length;
|
|
13907
13919
|
} else break;
|
|
13908
|
-
}
|
|
13909
|
-
else if (isBlockNode(node)) break;
|
|
13920
|
+
} else if (isBlockNode(node)) break;
|
|
13910
13921
|
else {
|
|
13911
13922
|
let prev = node.previousSibling;
|
|
13912
13923
|
while (prev && isIgnorable(prev, -1)) {
|
|
@@ -13920,7 +13931,7 @@ function skipIgnoredNodesBefore(view) {
|
|
|
13920
13931
|
offset = 0;
|
|
13921
13932
|
} else {
|
|
13922
13933
|
node = prev;
|
|
13923
|
-
offset =
|
|
13934
|
+
offset = nodeSize(node);
|
|
13924
13935
|
}
|
|
13925
13936
|
}
|
|
13926
13937
|
if (force) setSelFocus(view, node, offset);
|
|
@@ -13930,10 +13941,10 @@ function skipIgnoredNodesAfter(view) {
|
|
|
13930
13941
|
let sel = view.domSelectionRange();
|
|
13931
13942
|
let node = sel.focusNode, offset = sel.focusOffset;
|
|
13932
13943
|
if (!node) return;
|
|
13933
|
-
let len =
|
|
13944
|
+
let len = nodeSize(node);
|
|
13934
13945
|
let moveNode, moveOffset;
|
|
13935
13946
|
for (;;) if (offset < len) {
|
|
13936
|
-
if (node
|
|
13947
|
+
if (!isElt(node)) break;
|
|
13937
13948
|
let after = node.childNodes[offset];
|
|
13938
13949
|
if (isIgnorable(after, 1)) {
|
|
13939
13950
|
moveNode = node;
|
|
@@ -13954,7 +13965,7 @@ function skipIgnoredNodesAfter(view) {
|
|
|
13954
13965
|
} else {
|
|
13955
13966
|
node = next;
|
|
13956
13967
|
offset = 0;
|
|
13957
|
-
len =
|
|
13968
|
+
len = nodeSize(node);
|
|
13958
13969
|
}
|
|
13959
13970
|
}
|
|
13960
13971
|
if (moveNode) setSelFocus(view, moveNode, moveOffset);
|
|
@@ -13970,8 +13981,8 @@ function textNodeAfter(node, offset) {
|
|
|
13970
13981
|
}
|
|
13971
13982
|
while (node && offset < node.childNodes.length) {
|
|
13972
13983
|
let next = node.childNodes[offset];
|
|
13973
|
-
if (next
|
|
13974
|
-
if (next
|
|
13984
|
+
if (isText(next)) return next;
|
|
13985
|
+
if (isElt(next) && next.contentEditable == "false") break;
|
|
13975
13986
|
node = next;
|
|
13976
13987
|
offset = 0;
|
|
13977
13988
|
}
|
|
@@ -13983,14 +13994,14 @@ function textNodeBefore(node, offset) {
|
|
|
13983
13994
|
}
|
|
13984
13995
|
while (node && offset) {
|
|
13985
13996
|
let next = node.childNodes[offset - 1];
|
|
13986
|
-
if (next
|
|
13987
|
-
if (next
|
|
13997
|
+
if (isText(next)) return next;
|
|
13998
|
+
if (isElt(next) && next.contentEditable == "false") break;
|
|
13988
13999
|
node = next;
|
|
13989
14000
|
offset = node.childNodes.length;
|
|
13990
14001
|
}
|
|
13991
14002
|
}
|
|
13992
14003
|
function setSelFocus(view, node, offset) {
|
|
13993
|
-
if (node
|
|
14004
|
+
if (!isText(node)) {
|
|
13994
14005
|
let before, after;
|
|
13995
14006
|
if (after = textNodeAfter(node, offset)) {
|
|
13996
14007
|
node = after;
|
|
@@ -14072,7 +14083,7 @@ function switchEditable(view, node, state) {
|
|
|
14072
14083
|
function safariDownArrowBug(view) {
|
|
14073
14084
|
if (!safari || view.state.selection.$head.parentOffset > 0) return false;
|
|
14074
14085
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
14075
|
-
if (focusNode && focusNode
|
|
14086
|
+
if (focusNode && isElt(focusNode) && focusOffset == 0 && focusNode.firstChild && isElt(focusNode.firstChild) && focusNode.firstChild.contentEditable == "false") {
|
|
14076
14087
|
let child = focusNode.firstChild;
|
|
14077
14088
|
switchEditable(view, child, "true");
|
|
14078
14089
|
setTimeout(() => switchEditable(view, child, "false"), 20);
|
|
@@ -14119,7 +14130,7 @@ function serializeForClipboard(view, slice) {
|
|
|
14119
14130
|
let doc = detachedDoc(), wrap = doc.createElement("div");
|
|
14120
14131
|
wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
|
|
14121
14132
|
let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
|
|
14122
|
-
while (firstChild && firstChild
|
|
14133
|
+
while (firstChild && isElt(firstChild) && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
|
14123
14134
|
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
|
14124
14135
|
let wrapper = doc.createElement(needsWrap[i]);
|
|
14125
14136
|
while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
|
|
@@ -14128,7 +14139,7 @@ function serializeForClipboard(view, slice) {
|
|
|
14128
14139
|
}
|
|
14129
14140
|
firstChild = wrap.firstChild;
|
|
14130
14141
|
}
|
|
14131
|
-
if (firstChild && firstChild
|
|
14142
|
+
if (firstChild && isElt(firstChild)) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
|
|
14132
14143
|
return {
|
|
14133
14144
|
dom: wrap,
|
|
14134
14145
|
text: view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n"),
|
|
@@ -14173,7 +14184,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
14173
14184
|
let sliceData = contextNode && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(contextNode.getAttribute("data-pm-slice") || "");
|
|
14174
14185
|
if (sliceData && sliceData[3]) for (let i = +sliceData[3]; i > 0; i--) {
|
|
14175
14186
|
let child = dom.firstChild;
|
|
14176
|
-
while (child && child
|
|
14187
|
+
while (child && !isElt(child)) child = child.nextSibling;
|
|
14177
14188
|
if (!child) break;
|
|
14178
14189
|
dom = child;
|
|
14179
14190
|
}
|
|
@@ -14326,11 +14337,10 @@ function addContext(slice, context) {
|
|
|
14326
14337
|
let type = schema.nodes[array[i]];
|
|
14327
14338
|
if (!type || type.hasRequiredAttrs()) break;
|
|
14328
14339
|
try {
|
|
14329
|
-
type.
|
|
14340
|
+
content = Fragment.from(type.create(array[i + 1], content));
|
|
14330
14341
|
} catch (e) {
|
|
14331
14342
|
break;
|
|
14332
14343
|
}
|
|
14333
|
-
content = Fragment.from(type.create(array[i + 1], content));
|
|
14334
14344
|
openStart++;
|
|
14335
14345
|
openEnd++;
|
|
14336
14346
|
}
|
|
@@ -14474,14 +14484,14 @@ function updateSelection(view, selection, origin) {
|
|
|
14474
14484
|
if (!view.focused) view.focus();
|
|
14475
14485
|
if (view.state.selection.eq(selection)) return;
|
|
14476
14486
|
let tr = view.state.tr.setSelection(selection);
|
|
14477
|
-
|
|
14487
|
+
tr.setMeta("pointer", true);
|
|
14478
14488
|
view.dispatch(tr);
|
|
14479
14489
|
}
|
|
14480
14490
|
function selectClickedLeaf(view, inside) {
|
|
14481
14491
|
if (inside == -1) return false;
|
|
14482
14492
|
let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
|
|
14483
14493
|
if (node && node.isAtom && NodeSelection.isSelectable(node)) {
|
|
14484
|
-
updateSelection(view, new NodeSelection($pos)
|
|
14494
|
+
updateSelection(view, new NodeSelection($pos));
|
|
14485
14495
|
return true;
|
|
14486
14496
|
}
|
|
14487
14497
|
return false;
|
|
@@ -14500,7 +14510,7 @@ function selectClickedNode(view, inside) {
|
|
|
14500
14510
|
}
|
|
14501
14511
|
}
|
|
14502
14512
|
if (selectAt != null) {
|
|
14503
|
-
updateSelection(view, NodeSelection.create(view.state.doc, selectAt)
|
|
14513
|
+
updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
|
|
14504
14514
|
return true;
|
|
14505
14515
|
} else return false;
|
|
14506
14516
|
}
|
|
@@ -14517,7 +14527,7 @@ function defaultTripleClick(view, inside, event) {
|
|
|
14517
14527
|
if (event.button != 0) return false;
|
|
14518
14528
|
let selection = selectionForTripleClick(view, inside, true), doc = view.state.doc;
|
|
14519
14529
|
if (!selection) return false;
|
|
14520
|
-
updateSelection(view, selection
|
|
14530
|
+
updateSelection(view, selection);
|
|
14521
14531
|
if (selection instanceof TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);
|
|
14522
14532
|
return true;
|
|
14523
14533
|
}
|
|
@@ -14603,7 +14613,7 @@ var LeftMouseDown = class extends MouseDown {
|
|
|
14603
14613
|
}
|
|
14604
14614
|
const target = flushed ? null : event.target;
|
|
14605
14615
|
const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
14606
|
-
this.target = targetDesc && targetDesc.nodeDOM
|
|
14616
|
+
this.target = targetDesc && isElt(targetDesc.nodeDOM) ? targetDesc.nodeDOM : null;
|
|
14607
14617
|
let { selection } = view.state;
|
|
14608
14618
|
if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)) this.mightDrag = {
|
|
14609
14619
|
node: targetNode,
|
|
@@ -14642,7 +14652,7 @@ var LeftMouseDown = class extends MouseDown {
|
|
|
14642
14652
|
if (this.allowDefault || !pos) setSelectionOrigin(this.view, "pointer");
|
|
14643
14653
|
else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) event.preventDefault();
|
|
14644
14654
|
else if (event.button == 0 && (this.flushed || safari && this.mightDrag && !this.mightDrag.node.isAtom || chrome && !this.view.state.selection.visible && Math.min(Math.abs(pos.pos - this.view.state.selection.from), Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
|
|
14645
|
-
updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos))
|
|
14655
|
+
updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
|
|
14646
14656
|
event.preventDefault();
|
|
14647
14657
|
} else setSelectionOrigin(this.view, "pointer");
|
|
14648
14658
|
}
|
|
@@ -14678,7 +14688,7 @@ var TripleClickDrag = class extends MouseDown {
|
|
|
14678
14688
|
if (!target) return;
|
|
14679
14689
|
let { doc } = this.view.state, start = this.startSelection;
|
|
14680
14690
|
let [anchor, head] = target.from < start.from ? [start.to, target.from] : [start.from, target.to];
|
|
14681
|
-
updateSelection(this.view, TextSelection.create(doc, anchor, head)
|
|
14691
|
+
updateSelection(this.view, TextSelection.create(doc, anchor, head));
|
|
14682
14692
|
}
|
|
14683
14693
|
};
|
|
14684
14694
|
handlers.touchstart = (view) => {
|
|
@@ -14704,7 +14714,7 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
14704
14714
|
if (!view.composing) {
|
|
14705
14715
|
view.domObserver.flush();
|
|
14706
14716
|
let { state } = view, $pos = state.selection.$to;
|
|
14707
|
-
if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
|
|
14717
|
+
if (state.selection instanceof TextSelection && state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
|
|
14708
14718
|
view.markCursor = view.state.storedMarks || $pos.marks();
|
|
14709
14719
|
endComposition(view, true);
|
|
14710
14720
|
view.markCursor = null;
|
|
@@ -14712,10 +14722,10 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
14712
14722
|
endComposition(view, !state.selection.empty);
|
|
14713
14723
|
if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
|
|
14714
14724
|
let sel = view.domSelectionRange();
|
|
14715
|
-
for (let node = sel.focusNode, offset = sel.focusOffset; node && node
|
|
14725
|
+
for (let node = sel.focusNode, offset = sel.focusOffset; node && isElt(node) && offset != 0;) {
|
|
14716
14726
|
let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
|
|
14717
14727
|
if (!before) break;
|
|
14718
|
-
if (before
|
|
14728
|
+
if (isText(before)) {
|
|
14719
14729
|
let sel = view.domSelection();
|
|
14720
14730
|
if (sel) sel.collapse(before, before.nodeValue.length);
|
|
14721
14731
|
break;
|
|
@@ -14732,9 +14742,9 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
14732
14742
|
};
|
|
14733
14743
|
function selectionBeforeUneditable(view) {
|
|
14734
14744
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
14735
|
-
if (!focusNode || focusNode
|
|
14745
|
+
if (!focusNode || !isElt(focusNode) || focusOffset >= focusNode.childNodes.length) return false;
|
|
14736
14746
|
let next = focusNode.childNodes[focusOffset];
|
|
14737
|
-
return next
|
|
14747
|
+
return isElt(next) && next.contentEditable == "false";
|
|
14738
14748
|
}
|
|
14739
14749
|
editHandlers.compositionend = (view, event) => {
|
|
14740
14750
|
if (view.composing) {
|
|
@@ -14887,7 +14897,7 @@ handlers.dragstart = (view, _event) => {
|
|
|
14887
14897
|
let node;
|
|
14888
14898
|
if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof NodeSelection ? sel.to - 1 : sel.to));
|
|
14889
14899
|
else if (mouseDown && mouseDown.mightDrag) node = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
|
|
14890
|
-
else if (event.target && event.target
|
|
14900
|
+
else if (event.target && isElt(event.target)) {
|
|
14891
14901
|
let desc = view.docView.nearestDesc(event.target, true);
|
|
14892
14902
|
if (desc && desc.node.type.spec.draggable && desc != view.docView) node = NodeSelection.create(view.state.doc, desc.posBefore);
|
|
14893
14903
|
}
|
|
@@ -15660,7 +15670,7 @@ var DOMObserver = class {
|
|
|
15660
15670
|
let desc = container && this.view.docView.nearestDesc(container);
|
|
15661
15671
|
if (desc && desc.ignoreMutation({
|
|
15662
15672
|
type: "selection",
|
|
15663
|
-
target: container
|
|
15673
|
+
target: isText(container) ? container.parentNode : container
|
|
15664
15674
|
})) {
|
|
15665
15675
|
this.setCurSelection();
|
|
15666
15676
|
return true;
|
|
@@ -15689,7 +15699,7 @@ var DOMObserver = class {
|
|
|
15689
15699
|
if (added.some((n) => n.nodeName == "BR") && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some((m) => m.type == "childList" && m.removedNodes.length))) {
|
|
15690
15700
|
for (let node of added) if (node.nodeName == "BR" && node.parentNode) {
|
|
15691
15701
|
let after = node.nextSibling;
|
|
15692
|
-
while (after && after
|
|
15702
|
+
while (after && isElt(after)) {
|
|
15693
15703
|
if (after.contentEditable == "false") {
|
|
15694
15704
|
node.parentNode.removeChild(node);
|
|
15695
15705
|
break;
|
|
@@ -15741,7 +15751,7 @@ var DOMObserver = class {
|
|
|
15741
15751
|
for (let i = 0; i < mut.addedNodes.length; i++) {
|
|
15742
15752
|
let node = mut.addedNodes[i];
|
|
15743
15753
|
added.push(node);
|
|
15744
|
-
if (node
|
|
15754
|
+
if (isText(node)) this.lastChangedTextNode = node;
|
|
15745
15755
|
}
|
|
15746
15756
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return {
|
|
15747
15757
|
from: desc.posBefore,
|
|
@@ -15840,7 +15850,7 @@ function fixUpBadSafariComposition(view, addedNodes) {
|
|
|
15840
15850
|
let parent = nextCell;
|
|
15841
15851
|
for (;;) {
|
|
15842
15852
|
let first = parent.firstChild;
|
|
15843
|
-
if (!first || first
|
|
15853
|
+
if (!first || !isElt(first) || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName)) break;
|
|
15844
15854
|
parent = first;
|
|
15845
15855
|
}
|
|
15846
15856
|
parent.insertBefore(node, parent.firstChild);
|
|
@@ -15853,7 +15863,7 @@ function parseBetween(view, from_, to_, addedNodes) {
|
|
|
15853
15863
|
let domSel = view.domSelectionRange();
|
|
15854
15864
|
let find;
|
|
15855
15865
|
let anchor = domSel.anchorNode;
|
|
15856
|
-
if (anchor && view.dom
|
|
15866
|
+
if (anchor && contains(view.dom, anchor)) {
|
|
15857
15867
|
find = [{
|
|
15858
15868
|
node: anchor,
|
|
15859
15869
|
offset: domSel.anchorOffset
|
|
@@ -15947,7 +15957,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
15947
15957
|
view.input.lastKeyCode = null;
|
|
15948
15958
|
let change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
|
|
15949
15959
|
if (change) view.input.domChangeCount++;
|
|
15950
|
-
if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => n
|
|
15960
|
+
if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => isElt(n) && !isInline.test(n.nodeName)) && (!change || change.endA >= change.endB) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
15951
15961
|
view.input.lastIOSEnter = 0;
|
|
15952
15962
|
return;
|
|
15953
15963
|
}
|
|
@@ -15983,7 +15993,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
15983
15993
|
let $to = parse.doc.resolveNoCache(change.endB - parse.from);
|
|
15984
15994
|
let $fromA = doc.resolve(change.start);
|
|
15985
15995
|
let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
|
|
15986
|
-
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange &&
|
|
15996
|
+
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos)) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
15987
15997
|
view.input.lastIOSEnter = 0;
|
|
15988
15998
|
return;
|
|
15989
15999
|
}
|
|
@@ -16070,6 +16080,14 @@ function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
|
|
|
16070
16080
|
if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) return false;
|
|
16071
16081
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
|
|
16072
16082
|
}
|
|
16083
|
+
function looksLikeEnter(content, from, to) {
|
|
16084
|
+
let newTextlines = 0, newLeaves = 0;
|
|
16085
|
+
content.nodesBetween(from, to, (node, pos) => {
|
|
16086
|
+
if (node.isTextblock && pos >= from && pos < to) newTextlines++;
|
|
16087
|
+
else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf) newLeaves++;
|
|
16088
|
+
});
|
|
16089
|
+
return newLeaves == 0 && newTextlines == 1;
|
|
16090
|
+
}
|
|
16073
16091
|
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
16074
16092
|
let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
|
|
16075
16093
|
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
|
|
@@ -16294,11 +16312,11 @@ var EditorView = class {
|
|
|
16294
16312
|
*/
|
|
16295
16313
|
scrollToSelection() {
|
|
16296
16314
|
let startDOM = this.domSelectionRange().focusNode;
|
|
16297
|
-
if (!startDOM || !this.dom
|
|
16315
|
+
if (!startDOM || !contains(this.dom, startDOM));
|
|
16298
16316
|
else if (this.someProp("handleScrollToSelection", (f) => f(this)));
|
|
16299
16317
|
else if (this.state.selection instanceof NodeSelection) {
|
|
16300
16318
|
let target = this.docView.domAfterPos(this.state.selection.from);
|
|
16301
|
-
if (target
|
|
16319
|
+
if (isElt(target)) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
|
|
16302
16320
|
} else scrollRectIntoView(this, this.coordsAtPos(this.state.selection.head, 1), startDOM);
|
|
16303
16321
|
}
|
|
16304
16322
|
destroyPluginViews() {
|
|
@@ -16527,7 +16545,7 @@ var EditorView = class {
|
|
|
16527
16545
|
@internal
|
|
16528
16546
|
*/
|
|
16529
16547
|
domSelectionRange() {
|
|
16530
|
-
let sel = this.domSelection();
|
|
16548
|
+
let sel = this.dom.isConnected !== false && this.domSelection();
|
|
16531
16549
|
if (!sel) return {
|
|
16532
16550
|
focusNode: null,
|
|
16533
16551
|
focusOffset: 0,
|
|
@@ -27105,7 +27123,7 @@ var Underline = Mark.create({
|
|
|
27105
27123
|
}
|
|
27106
27124
|
});
|
|
27107
27125
|
//#endregion
|
|
27108
|
-
//#region ../../../node_modules/.bun/prosemirror-dropcursor@1.8.
|
|
27126
|
+
//#region ../../../node_modules/.bun/prosemirror-dropcursor@1.8.4/node_modules/prosemirror-dropcursor/dist/index.js
|
|
27109
27127
|
/**
|
|
27110
27128
|
Create a plugin that, when added to a ProseMirror instance,
|
|
27111
27129
|
causes a decoration to show up at the drop position when something
|
|
@@ -27128,6 +27146,7 @@ var DropCursorView = class {
|
|
|
27128
27146
|
this.cursorPos = null;
|
|
27129
27147
|
this.element = null;
|
|
27130
27148
|
this.timeout = -1;
|
|
27149
|
+
this.lastDragEvent = null;
|
|
27131
27150
|
this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
|
|
27132
27151
|
this.color = options.color === false ? void 0 : options.color || "black";
|
|
27133
27152
|
this.class = options.class;
|
|
@@ -27148,11 +27167,15 @@ var DropCursorView = class {
|
|
|
27148
27167
|
});
|
|
27149
27168
|
}
|
|
27150
27169
|
destroy() {
|
|
27170
|
+
this.setCursor(null);
|
|
27151
27171
|
this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
|
|
27152
27172
|
}
|
|
27153
27173
|
update(editorView, prevState) {
|
|
27154
|
-
if (this.cursorPos != null && prevState.doc != editorView.state.doc) if (this.
|
|
27155
|
-
|
|
27174
|
+
if (this.cursorPos != null && prevState.doc != editorView.state.doc) if (this.lastDragEvent) {
|
|
27175
|
+
let target = this.computeTarget(this.lastDragEvent);
|
|
27176
|
+
if (target == this.cursorPos) this.updateOverlay();
|
|
27177
|
+
else this.setCursor(target);
|
|
27178
|
+
} else this.updateOverlay();
|
|
27156
27179
|
}
|
|
27157
27180
|
setCursor(pos) {
|
|
27158
27181
|
if (pos == this.cursorPos) return;
|
|
@@ -27223,8 +27246,7 @@ var DropCursorView = class {
|
|
|
27223
27246
|
clearTimeout(this.timeout);
|
|
27224
27247
|
this.timeout = setTimeout(() => this.setCursor(null), timeout);
|
|
27225
27248
|
}
|
|
27226
|
-
|
|
27227
|
-
if (!this.editorView.editable) return;
|
|
27249
|
+
computeTarget(event) {
|
|
27228
27250
|
let pos = this.editorView.posAtCoords({
|
|
27229
27251
|
left: event.clientX,
|
|
27230
27252
|
top: event.clientY
|
|
@@ -27232,12 +27254,19 @@ var DropCursorView = class {
|
|
|
27232
27254
|
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
|
|
27233
27255
|
let disableDropCursor = node && node.type.spec.disableDropCursor;
|
|
27234
27256
|
let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;
|
|
27235
|
-
if (pos
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27257
|
+
if (!pos || disabled) return null;
|
|
27258
|
+
let target = pos.pos;
|
|
27259
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
27260
|
+
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
|
|
27261
|
+
if (point != null) target = point;
|
|
27262
|
+
}
|
|
27263
|
+
return target;
|
|
27264
|
+
}
|
|
27265
|
+
dragover(event) {
|
|
27266
|
+
if (!this.editorView.editable) return;
|
|
27267
|
+
this.lastDragEvent = event;
|
|
27268
|
+
let target = this.computeTarget(event);
|
|
27269
|
+
if (target != null) {
|
|
27241
27270
|
this.setCursor(target);
|
|
27242
27271
|
this.scheduleRemoval(5e3);
|
|
27243
27272
|
}
|