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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
## 1.18.7 (2021-05-20)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug where clicking on a textblock that had a node-selected parent didn't set a cursor selection.
|
|
6
|
+
|
|
7
|
+
Fix a bug that caused a workaround for a Chrome Android issue to not work correctly, leading to bad cursor placement after some types of text input.
|
|
8
|
+
|
|
9
|
+
## 1.18.6 (2021-05-17)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Fix a crash in mouse click handling introduced in the previous version.
|
|
14
|
+
|
|
15
|
+
## 1.18.5 (2021-05-17)
|
|
16
|
+
|
|
17
|
+
### Bug fixes
|
|
18
|
+
|
|
19
|
+
Work around a Firefox bug where backspace sometimes deletes the node after the cursor.
|
|
20
|
+
|
|
21
|
+
Fix a bug that prevented `transformPasted` hooks from being called on content dragged within the editor.
|
|
22
|
+
|
|
23
|
+
Fixes an issue where clicking near a node or other special selection on Chrome would in some cases do nothing.
|
|
24
|
+
|
|
25
|
+
## 1.18.4 (2021-04-27)
|
|
26
|
+
|
|
27
|
+
### Bug fixes
|
|
28
|
+
|
|
29
|
+
Fix incorrect drag cursor in Chrome on some platforms.
|
|
30
|
+
|
|
31
|
+
Fix an issue where a race condition could leave a node uneditable when clicked.
|
|
32
|
+
|
|
33
|
+
Fix scroll handling when the editor is placed through a DOM component slot.
|
|
34
|
+
|
|
35
|
+
Fix a typo in the Chrome backspace workaround.
|
|
36
|
+
|
|
37
|
+
Fixes an issue where, when mouseup events weren't being delivered, the editor could leak event handlers.
|
|
38
|
+
|
|
1
39
|
## 1.18.3 (2021-04-13)
|
|
2
40
|
|
|
3
41
|
### Bug fixes
|
package/dist/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ var domIndex = function(node) {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
var parentNode = function(node) {
|
|
36
|
-
var parent = node.parentNode;
|
|
36
|
+
var parent = node.assignedSlot || node.parentNode;
|
|
37
37
|
return parent && parent.nodeType == 11 ? parent.host : parent
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -377,7 +377,10 @@ function posAtCoords(view, coords) {
|
|
|
377
377
|
if (!elt) { return null }
|
|
378
378
|
}
|
|
379
379
|
// Safari's caretRangeFromPoint returns nonsense when on a draggable element
|
|
380
|
-
if (result.safari
|
|
380
|
+
if (result.safari) {
|
|
381
|
+
for (var p = elt; node && p; p = parentNode(p))
|
|
382
|
+
{ if (p.draggable) { node = offset = null; } }
|
|
383
|
+
}
|
|
381
384
|
elt = targetKludge(elt, coords);
|
|
382
385
|
if (node) {
|
|
383
386
|
if (result.gecko && node.nodeType == 1) {
|
|
@@ -965,6 +968,12 @@ ViewDesc.prototype.setSelection = function setSelection (anchor, head, root, for
|
|
|
965
968
|
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
|
|
966
969
|
}
|
|
967
970
|
}
|
|
971
|
+
// Firefox can act strangely when the selection is in front of an
|
|
972
|
+
// uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536
|
|
973
|
+
if (result.gecko && domSel.focusNode && domSel.focusNode != headDOM.node && domSel.focusNode.nodeType == 1) {
|
|
974
|
+
var after = domSel.focusNode.childNodes[domSel.focusOffset];
|
|
975
|
+
if (after && after.contentEditable == "false") { force = true; }
|
|
976
|
+
}
|
|
968
977
|
|
|
969
978
|
if (!(force || brKludge && result.safari) &&
|
|
970
979
|
isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) &&
|
|
@@ -1480,26 +1489,26 @@ var TextViewDesc = /*@__PURE__*/(function (NodeViewDesc) {
|
|
|
1480
1489
|
return TextViewDesc;
|
|
1481
1490
|
}(NodeViewDesc));
|
|
1482
1491
|
|
|
1483
|
-
// A dummy desc used to tag trailing BR or
|
|
1492
|
+
// A dummy desc used to tag trailing BR or IMG nodes created to work
|
|
1484
1493
|
// around contentEditable terribleness.
|
|
1485
|
-
var
|
|
1486
|
-
function
|
|
1494
|
+
var TrailingHackViewDesc = /*@__PURE__*/(function (ViewDesc) {
|
|
1495
|
+
function TrailingHackViewDesc () {
|
|
1487
1496
|
ViewDesc.apply(this, arguments);
|
|
1488
1497
|
}
|
|
1489
1498
|
|
|
1490
|
-
if ( ViewDesc )
|
|
1491
|
-
|
|
1492
|
-
|
|
1499
|
+
if ( ViewDesc ) TrailingHackViewDesc.__proto__ = ViewDesc;
|
|
1500
|
+
TrailingHackViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );
|
|
1501
|
+
TrailingHackViewDesc.prototype.constructor = TrailingHackViewDesc;
|
|
1493
1502
|
|
|
1494
1503
|
var prototypeAccessors$5 = { domAtom: { configurable: true } };
|
|
1495
1504
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1505
|
+
TrailingHackViewDesc.prototype.parseRule = function parseRule () { return {ignore: true} };
|
|
1506
|
+
TrailingHackViewDesc.prototype.matchesHack = function matchesHack () { return this.dirty == NOT_DIRTY };
|
|
1498
1507
|
prototypeAccessors$5.domAtom.get = function () { return true };
|
|
1499
1508
|
|
|
1500
|
-
Object.defineProperties(
|
|
1509
|
+
Object.defineProperties( TrailingHackViewDesc.prototype, prototypeAccessors$5 );
|
|
1501
1510
|
|
|
1502
|
-
return
|
|
1511
|
+
return TrailingHackViewDesc;
|
|
1503
1512
|
}(ViewDesc));
|
|
1504
1513
|
|
|
1505
1514
|
// A separate subclass is used for customized node views, so that the
|
|
@@ -1842,7 +1851,7 @@ ViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks () {
|
|
|
1842
1851
|
this.index++;
|
|
1843
1852
|
} else {
|
|
1844
1853
|
var dom = document.createElement("br");
|
|
1845
|
-
this.top.children.splice(this.index++, 0, new
|
|
1854
|
+
this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));
|
|
1846
1855
|
this.changed = true;
|
|
1847
1856
|
}
|
|
1848
1857
|
}
|
|
@@ -2496,7 +2505,7 @@ function parseBetween(view, from_, to_) {
|
|
|
2496
2505
|
if (result.chrome && view.lastKeyCode === 8) {
|
|
2497
2506
|
for (var off = toOffset; off > fromOffset; off--) {
|
|
2498
2507
|
var node = parent.childNodes[off - 1], desc = node.pmViewDesc;
|
|
2499
|
-
if (node.
|
|
2508
|
+
if (node.nodeName == "BR" && !desc) { toOffset = off; break }
|
|
2500
2509
|
if (!desc || desc.size) { break }
|
|
2501
2510
|
}
|
|
2502
2511
|
}
|
|
@@ -2713,7 +2722,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
2713
2722
|
// Edge just doesn't move the cursor forward when you start typing
|
|
2714
2723
|
// in an empty block or between br nodes.
|
|
2715
2724
|
if (sel$2 && !(result.chrome && result.android && view.composing && sel$2.empty &&
|
|
2716
|
-
(change.
|
|
2725
|
+
(change.start != change.endB || view.lastAndroidDelete < Date.now() - 100) &&
|
|
2717
2726
|
(sel$2.head == chFrom || sel$2.head == tr.mapping.map(chTo) - 1) ||
|
|
2718
2727
|
result.ie && sel$2.empty && sel$2.head == chFrom))
|
|
2719
2728
|
{ tr.setSelection(sel$2); }
|
|
@@ -3527,12 +3536,14 @@ handlers.mousedown = function (view, event) {
|
|
|
3527
3536
|
var pos = view.posAtCoords(eventCoords(event));
|
|
3528
3537
|
if (!pos) { return }
|
|
3529
3538
|
|
|
3530
|
-
if (type == "singleClick")
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3539
|
+
if (type == "singleClick") {
|
|
3540
|
+
if (view.mouseDown) { view.mouseDown.done(); }
|
|
3541
|
+
view.mouseDown = new MouseDown(view, pos, event, flushed);
|
|
3542
|
+
} else if ((type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
|
|
3543
|
+
event.preventDefault();
|
|
3544
|
+
} else {
|
|
3545
|
+
setSelectionOrigin(view, "pointer");
|
|
3546
|
+
}
|
|
3536
3547
|
};
|
|
3537
3548
|
|
|
3538
3549
|
var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
@@ -3562,8 +3573,10 @@ var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
|
3562
3573
|
var targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3563
3574
|
this.target = targetDesc ? targetDesc.dom : null;
|
|
3564
3575
|
|
|
3576
|
+
var ref = view.state;
|
|
3577
|
+
var selection = ref.selection;
|
|
3565
3578
|
if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
3566
|
-
|
|
3579
|
+
selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
|
|
3567
3580
|
{ this.mightDrag = {node: targetNode,
|
|
3568
3581
|
pos: targetPos,
|
|
3569
3582
|
addAttr: this.target && !this.target.draggable,
|
|
@@ -3573,7 +3586,9 @@ var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
|
3573
3586
|
this.view.domObserver.stop();
|
|
3574
3587
|
if (this.mightDrag.addAttr) { this.target.draggable = true; }
|
|
3575
3588
|
if (this.mightDrag.setUneditable)
|
|
3576
|
-
{ setTimeout(function () {
|
|
3589
|
+
{ setTimeout(function () {
|
|
3590
|
+
if (this$1.view.mouseDown == this$1) { this$1.target.setAttribute("contentEditable", "false"); }
|
|
3591
|
+
}, 20); }
|
|
3577
3592
|
this.view.domObserver.start();
|
|
3578
3593
|
}
|
|
3579
3594
|
|
|
@@ -3618,7 +3633,8 @@ MouseDown.prototype.up = function up (event) {
|
|
|
3618
3633
|
// thus doesn't get a reaction from ProseMirror. This
|
|
3619
3634
|
// works around that.
|
|
3620
3635
|
(result.chrome && !(this.view.state.selection instanceof TextSelection) &&
|
|
3621
|
-
(pos.pos
|
|
3636
|
+
Math.min(Math.abs(pos.pos - this.view.state.selection.from),
|
|
3637
|
+
Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
|
|
3622
3638
|
updateSelection(this.view, Selection.near(this.view.state.doc.resolve(pos.pos)), "pointer");
|
|
3623
3639
|
event.preventDefault();
|
|
3624
3640
|
} else {
|
|
@@ -3631,6 +3647,7 @@ MouseDown.prototype.move = function move (event) {
|
|
|
3631
3647
|
Math.abs(this.event.y - event.clientY) > 4))
|
|
3632
3648
|
{ this.allowDefault = true; }
|
|
3633
3649
|
setSelectionOrigin(this.view, "pointer");
|
|
3650
|
+
if (event.buttons == 0) { this.done(); }
|
|
3634
3651
|
};
|
|
3635
3652
|
|
|
3636
3653
|
handlers.touchdown = function (view) {
|
|
@@ -3840,6 +3857,8 @@ handlers.dragstart = function (view, e) {
|
|
|
3840
3857
|
var text = ref.text;
|
|
3841
3858
|
e.dataTransfer.clearData();
|
|
3842
3859
|
e.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
|
|
3860
|
+
// See https://github.com/ProseMirror/prosemirror/issues/1156
|
|
3861
|
+
e.dataTransfer.effectAllowed = "copyMove";
|
|
3843
3862
|
if (!brokenClipboardAPI) { e.dataTransfer.setData("text/plain", text); }
|
|
3844
3863
|
view.dragging = new Dragging(slice, !e[dragCopyModifier]);
|
|
3845
3864
|
};
|
|
@@ -3863,9 +3882,13 @@ editHandlers.drop = function (view, e) {
|
|
|
3863
3882
|
if (!eventPos) { return }
|
|
3864
3883
|
var $mouse = view.state.doc.resolve(eventPos.pos);
|
|
3865
3884
|
if (!$mouse) { return }
|
|
3866
|
-
var slice = dragging && dragging.slice
|
|
3867
|
-
|
|
3868
|
-
|
|
3885
|
+
var slice = dragging && dragging.slice;
|
|
3886
|
+
if (slice) {
|
|
3887
|
+
view.someProp("transformPasted", function (f) { slice = f(slice); });
|
|
3888
|
+
} else {
|
|
3889
|
+
slice = parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? "Text" : "text/plain"),
|
|
3890
|
+
brokenClipboardAPI ? null : e.dataTransfer.getData("text/html"), false, $mouse);
|
|
3891
|
+
}
|
|
3869
3892
|
var move = dragging && !e[dragCopyModifier];
|
|
3870
3893
|
if (view.someProp("handleDrop", function (f) { return f(view, e, slice || Slice.empty, move); })) {
|
|
3871
3894
|
e.preventDefault();
|