prosemirror-view 1.18.3 → 1.18.7
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/CHANGELOG.md +38 -0
- package/dist/index.es.js +50 -27
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +50 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/dom.js +1 -1
- package/src/domchange.js +2 -2
- package/src/domcoords.js +4 -1
- package/src/input.js +22 -9
- package/src/viewdesc.js +9 -3
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var domIndex = function(node) {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
var parentNode = function(node) {
|
|
40
|
-
var parent = node.parentNode;
|
|
40
|
+
var parent = node.assignedSlot || node.parentNode;
|
|
41
41
|
return parent && parent.nodeType == 11 ? parent.host : parent
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -381,7 +381,10 @@ function posAtCoords(view, coords) {
|
|
|
381
381
|
if (!elt) { return null }
|
|
382
382
|
}
|
|
383
383
|
// Safari's caretRangeFromPoint returns nonsense when on a draggable element
|
|
384
|
-
if (result.safari
|
|
384
|
+
if (result.safari) {
|
|
385
|
+
for (var p = elt; node && p; p = parentNode(p))
|
|
386
|
+
{ if (p.draggable) { node = offset = null; } }
|
|
387
|
+
}
|
|
385
388
|
elt = targetKludge(elt, coords);
|
|
386
389
|
if (node) {
|
|
387
390
|
if (result.gecko && node.nodeType == 1) {
|
|
@@ -969,6 +972,12 @@ ViewDesc.prototype.setSelection = function setSelection (anchor, head, root, for
|
|
|
969
972
|
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
|
|
970
973
|
}
|
|
971
974
|
}
|
|
975
|
+
// Firefox can act strangely when the selection is in front of an
|
|
976
|
+
// uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536
|
|
977
|
+
if (result.gecko && domSel.focusNode && domSel.focusNode != headDOM.node && domSel.focusNode.nodeType == 1) {
|
|
978
|
+
var after = domSel.focusNode.childNodes[domSel.focusOffset];
|
|
979
|
+
if (after && after.contentEditable == "false") { force = true; }
|
|
980
|
+
}
|
|
972
981
|
|
|
973
982
|
if (!(force || brKludge && result.safari) &&
|
|
974
983
|
isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) &&
|
|
@@ -1484,26 +1493,26 @@ var TextViewDesc = /*@__PURE__*/(function (NodeViewDesc) {
|
|
|
1484
1493
|
return TextViewDesc;
|
|
1485
1494
|
}(NodeViewDesc));
|
|
1486
1495
|
|
|
1487
|
-
// A dummy desc used to tag trailing BR or
|
|
1496
|
+
// A dummy desc used to tag trailing BR or IMG nodes created to work
|
|
1488
1497
|
// around contentEditable terribleness.
|
|
1489
|
-
var
|
|
1490
|
-
function
|
|
1498
|
+
var TrailingHackViewDesc = /*@__PURE__*/(function (ViewDesc) {
|
|
1499
|
+
function TrailingHackViewDesc () {
|
|
1491
1500
|
ViewDesc.apply(this, arguments);
|
|
1492
1501
|
}
|
|
1493
1502
|
|
|
1494
|
-
if ( ViewDesc )
|
|
1495
|
-
|
|
1496
|
-
|
|
1503
|
+
if ( ViewDesc ) TrailingHackViewDesc.__proto__ = ViewDesc;
|
|
1504
|
+
TrailingHackViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );
|
|
1505
|
+
TrailingHackViewDesc.prototype.constructor = TrailingHackViewDesc;
|
|
1497
1506
|
|
|
1498
1507
|
var prototypeAccessors$5 = { domAtom: { configurable: true } };
|
|
1499
1508
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1509
|
+
TrailingHackViewDesc.prototype.parseRule = function parseRule () { return {ignore: true} };
|
|
1510
|
+
TrailingHackViewDesc.prototype.matchesHack = function matchesHack () { return this.dirty == NOT_DIRTY };
|
|
1502
1511
|
prototypeAccessors$5.domAtom.get = function () { return true };
|
|
1503
1512
|
|
|
1504
|
-
Object.defineProperties(
|
|
1513
|
+
Object.defineProperties( TrailingHackViewDesc.prototype, prototypeAccessors$5 );
|
|
1505
1514
|
|
|
1506
|
-
return
|
|
1515
|
+
return TrailingHackViewDesc;
|
|
1507
1516
|
}(ViewDesc));
|
|
1508
1517
|
|
|
1509
1518
|
// A separate subclass is used for customized node views, so that the
|
|
@@ -1846,7 +1855,7 @@ ViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks () {
|
|
|
1846
1855
|
this.index++;
|
|
1847
1856
|
} else {
|
|
1848
1857
|
var dom = document.createElement("br");
|
|
1849
|
-
this.top.children.splice(this.index++, 0, new
|
|
1858
|
+
this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));
|
|
1850
1859
|
this.changed = true;
|
|
1851
1860
|
}
|
|
1852
1861
|
}
|
|
@@ -2500,7 +2509,7 @@ function parseBetween(view, from_, to_) {
|
|
|
2500
2509
|
if (result.chrome && view.lastKeyCode === 8) {
|
|
2501
2510
|
for (var off = toOffset; off > fromOffset; off--) {
|
|
2502
2511
|
var node = parent.childNodes[off - 1], desc = node.pmViewDesc;
|
|
2503
|
-
if (node.
|
|
2512
|
+
if (node.nodeName == "BR" && !desc) { toOffset = off; break }
|
|
2504
2513
|
if (!desc || desc.size) { break }
|
|
2505
2514
|
}
|
|
2506
2515
|
}
|
|
@@ -2717,7 +2726,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
2717
2726
|
// Edge just doesn't move the cursor forward when you start typing
|
|
2718
2727
|
// in an empty block or between br nodes.
|
|
2719
2728
|
if (sel$2 && !(result.chrome && result.android && view.composing && sel$2.empty &&
|
|
2720
|
-
(change.
|
|
2729
|
+
(change.start != change.endB || view.lastAndroidDelete < Date.now() - 100) &&
|
|
2721
2730
|
(sel$2.head == chFrom || sel$2.head == tr.mapping.map(chTo) - 1) ||
|
|
2722
2731
|
result.ie && sel$2.empty && sel$2.head == chFrom))
|
|
2723
2732
|
{ tr.setSelection(sel$2); }
|
|
@@ -3531,12 +3540,14 @@ handlers.mousedown = function (view, event) {
|
|
|
3531
3540
|
var pos = view.posAtCoords(eventCoords(event));
|
|
3532
3541
|
if (!pos) { return }
|
|
3533
3542
|
|
|
3534
|
-
if (type == "singleClick")
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3543
|
+
if (type == "singleClick") {
|
|
3544
|
+
if (view.mouseDown) { view.mouseDown.done(); }
|
|
3545
|
+
view.mouseDown = new MouseDown(view, pos, event, flushed);
|
|
3546
|
+
} else if ((type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
|
|
3547
|
+
event.preventDefault();
|
|
3548
|
+
} else {
|
|
3549
|
+
setSelectionOrigin(view, "pointer");
|
|
3550
|
+
}
|
|
3540
3551
|
};
|
|
3541
3552
|
|
|
3542
3553
|
var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
@@ -3566,8 +3577,10 @@ var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
|
3566
3577
|
var targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3567
3578
|
this.target = targetDesc ? targetDesc.dom : null;
|
|
3568
3579
|
|
|
3580
|
+
var ref = view.state;
|
|
3581
|
+
var selection = ref.selection;
|
|
3569
3582
|
if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
3570
|
-
|
|
3583
|
+
selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos)
|
|
3571
3584
|
{ this.mightDrag = {node: targetNode,
|
|
3572
3585
|
pos: targetPos,
|
|
3573
3586
|
addAttr: this.target && !this.target.draggable,
|
|
@@ -3577,7 +3590,9 @@ var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
|
3577
3590
|
this.view.domObserver.stop();
|
|
3578
3591
|
if (this.mightDrag.addAttr) { this.target.draggable = true; }
|
|
3579
3592
|
if (this.mightDrag.setUneditable)
|
|
3580
|
-
{ setTimeout(function () {
|
|
3593
|
+
{ setTimeout(function () {
|
|
3594
|
+
if (this$1.view.mouseDown == this$1) { this$1.target.setAttribute("contentEditable", "false"); }
|
|
3595
|
+
}, 20); }
|
|
3581
3596
|
this.view.domObserver.start();
|
|
3582
3597
|
}
|
|
3583
3598
|
|
|
@@ -3622,7 +3637,8 @@ MouseDown.prototype.up = function up (event) {
|
|
|
3622
3637
|
// thus doesn't get a reaction from ProseMirror. This
|
|
3623
3638
|
// works around that.
|
|
3624
3639
|
(result.chrome && !(this.view.state.selection instanceof prosemirrorState.TextSelection) &&
|
|
3625
|
-
(pos.pos
|
|
3640
|
+
Math.min(Math.abs(pos.pos - this.view.state.selection.from),
|
|
3641
|
+
Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
|
|
3626
3642
|
updateSelection(this.view, prosemirrorState.Selection.near(this.view.state.doc.resolve(pos.pos)), "pointer");
|
|
3627
3643
|
event.preventDefault();
|
|
3628
3644
|
} else {
|
|
@@ -3635,6 +3651,7 @@ MouseDown.prototype.move = function move (event) {
|
|
|
3635
3651
|
Math.abs(this.event.y - event.clientY) > 4))
|
|
3636
3652
|
{ this.allowDefault = true; }
|
|
3637
3653
|
setSelectionOrigin(this.view, "pointer");
|
|
3654
|
+
if (event.buttons == 0) { this.done(); }
|
|
3638
3655
|
};
|
|
3639
3656
|
|
|
3640
3657
|
handlers.touchdown = function (view) {
|
|
@@ -3844,6 +3861,8 @@ handlers.dragstart = function (view, e) {
|
|
|
3844
3861
|
var text = ref.text;
|
|
3845
3862
|
e.dataTransfer.clearData();
|
|
3846
3863
|
e.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
|
|
3864
|
+
// See https://github.com/ProseMirror/prosemirror/issues/1156
|
|
3865
|
+
e.dataTransfer.effectAllowed = "copyMove";
|
|
3847
3866
|
if (!brokenClipboardAPI) { e.dataTransfer.setData("text/plain", text); }
|
|
3848
3867
|
view.dragging = new Dragging(slice, !e[dragCopyModifier]);
|
|
3849
3868
|
};
|
|
@@ -3867,9 +3886,13 @@ editHandlers.drop = function (view, e) {
|
|
|
3867
3886
|
if (!eventPos) { return }
|
|
3868
3887
|
var $mouse = view.state.doc.resolve(eventPos.pos);
|
|
3869
3888
|
if (!$mouse) { return }
|
|
3870
|
-
var slice = dragging && dragging.slice
|
|
3871
|
-
|
|
3872
|
-
|
|
3889
|
+
var slice = dragging && dragging.slice;
|
|
3890
|
+
if (slice) {
|
|
3891
|
+
view.someProp("transformPasted", function (f) { slice = f(slice); });
|
|
3892
|
+
} else {
|
|
3893
|
+
slice = parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? "Text" : "text/plain"),
|
|
3894
|
+
brokenClipboardAPI ? null : e.dataTransfer.getData("text/html"), false, $mouse);
|
|
3895
|
+
}
|
|
3873
3896
|
var move = dragging && !e[dragCopyModifier];
|
|
3874
3897
|
if (view.someProp("handleDrop", function (f) { return f(view, e, slice || prosemirrorModel.Slice.empty, move); })) {
|
|
3875
3898
|
e.preventDefault();
|