prosemirror-view 1.18.7 → 1.18.8
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 +12 -0
- package/dist/index.es.js +42 -19
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +42 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/input.js +7 -5
- package/src/viewdesc.js +33 -12
package/dist/index.js
CHANGED
|
@@ -698,7 +698,7 @@ var prototypeAccessors = { beforePosition: { configurable: true },size: { config
|
|
|
698
698
|
ViewDesc.prototype.matchesWidget = function matchesWidget () { return false };
|
|
699
699
|
ViewDesc.prototype.matchesMark = function matchesMark () { return false };
|
|
700
700
|
ViewDesc.prototype.matchesNode = function matchesNode () { return false };
|
|
701
|
-
ViewDesc.prototype.matchesHack = function matchesHack () { return false };
|
|
701
|
+
ViewDesc.prototype.matchesHack = function matchesHack (_nodeName) { return false };
|
|
702
702
|
|
|
703
703
|
prototypeAccessors.beforePosition.get = function () { return false };
|
|
704
704
|
|
|
@@ -964,9 +964,17 @@ ViewDesc.prototype.setSelection = function setSelection (anchor, head, root, for
|
|
|
964
964
|
if (node.nodeType == 3) {
|
|
965
965
|
brKludge = offset$1 && node.nodeValue[offset$1 - 1] == "\n";
|
|
966
966
|
// Issue #1128
|
|
967
|
-
if (brKludge && offset$1 == node.nodeValue.length
|
|
968
|
-
|
|
969
|
-
|
|
967
|
+
if (brKludge && offset$1 == node.nodeValue.length) {
|
|
968
|
+
for (var scan = node, after = (void 0); scan; scan = scan.parentNode) {
|
|
969
|
+
if (after = scan.nextSibling) {
|
|
970
|
+
if (after.nodeName == "BR")
|
|
971
|
+
{ anchorDOM = headDOM = {node: after.parentNode, offset: domIndex(after) + 1}; }
|
|
972
|
+
break
|
|
973
|
+
}
|
|
974
|
+
var desc = scan.pmViewDesc;
|
|
975
|
+
if (desc && desc.node && desc.node.isBlock) { break }
|
|
976
|
+
}
|
|
977
|
+
}
|
|
970
978
|
} else {
|
|
971
979
|
var prev = node.childNodes[offset$1 - 1];
|
|
972
980
|
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
|
|
@@ -975,8 +983,8 @@ ViewDesc.prototype.setSelection = function setSelection (anchor, head, root, for
|
|
|
975
983
|
// Firefox can act strangely when the selection is in front of an
|
|
976
984
|
// uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536
|
|
977
985
|
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; }
|
|
986
|
+
var after$1 = domSel.focusNode.childNodes[domSel.focusOffset];
|
|
987
|
+
if (after$1 && after$1.contentEditable == "false") { force = true; }
|
|
980
988
|
}
|
|
981
989
|
|
|
982
990
|
if (!(force || brKludge && result.safari) &&
|
|
@@ -1486,6 +1494,12 @@ var TextViewDesc = /*@__PURE__*/(function (NodeViewDesc) {
|
|
|
1486
1494
|
return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom, view)
|
|
1487
1495
|
};
|
|
1488
1496
|
|
|
1497
|
+
TextViewDesc.prototype.markDirty = function markDirty (from, to) {
|
|
1498
|
+
NodeViewDesc.prototype.markDirty.call(this, from, to);
|
|
1499
|
+
if (this.dom != this.nodeDOM && (from == 0 || to == this.nodeDOM.nodeValue.length))
|
|
1500
|
+
{ this.dirty = NODE_DIRTY; }
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1489
1503
|
prototypeAccessors$4.domAtom.get = function () { return false };
|
|
1490
1504
|
|
|
1491
1505
|
Object.defineProperties( TextViewDesc.prototype, prototypeAccessors$4 );
|
|
@@ -1507,7 +1521,7 @@ var TrailingHackViewDesc = /*@__PURE__*/(function (ViewDesc) {
|
|
|
1507
1521
|
var prototypeAccessors$5 = { domAtom: { configurable: true } };
|
|
1508
1522
|
|
|
1509
1523
|
TrailingHackViewDesc.prototype.parseRule = function parseRule () { return {ignore: true} };
|
|
1510
|
-
TrailingHackViewDesc.prototype.matchesHack = function matchesHack () { return this.dirty == NOT_DIRTY };
|
|
1524
|
+
TrailingHackViewDesc.prototype.matchesHack = function matchesHack (nodeName) { return this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName };
|
|
1511
1525
|
prototypeAccessors$5.domAtom.get = function () { return true };
|
|
1512
1526
|
|
|
1513
1527
|
Object.defineProperties( TrailingHackViewDesc.prototype, prototypeAccessors$5 );
|
|
@@ -1851,13 +1865,20 @@ ViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks () {
|
|
|
1851
1865
|
if (!lastChild || // Empty textblock
|
|
1852
1866
|
!(lastChild instanceof TextViewDesc) ||
|
|
1853
1867
|
/\n$/.test(lastChild.node.text)) {
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1868
|
+
// Avoid a bug in Safari's cursor drawing (#1165)
|
|
1869
|
+
if (result.safari && lastChild && lastChild.dom.contentEditable == "false")
|
|
1870
|
+
{ this.addHackNode("IMG"); }
|
|
1871
|
+
this.addHackNode("BR");
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
|
|
1876
|
+
if (this.index < this.top.children.length && this.top.children[this.index].matchesHack(nodeName)) {
|
|
1877
|
+
this.index++;
|
|
1878
|
+
} else {
|
|
1879
|
+
var dom = document.createElement(nodeName);
|
|
1880
|
+
this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));
|
|
1881
|
+
this.changed = true;
|
|
1861
1882
|
}
|
|
1862
1883
|
};
|
|
1863
1884
|
|
|
@@ -3368,7 +3389,7 @@ function dispatchEvent(view, event) {
|
|
|
3368
3389
|
editHandlers.keydown = function (view, event) {
|
|
3369
3390
|
view.shiftKey = event.keyCode == 16 || event.shiftKey;
|
|
3370
3391
|
if (inOrNearComposition(view, event)) { return }
|
|
3371
|
-
view.domObserver.forceFlush();
|
|
3392
|
+
if (event.keyCode != 229) { view.domObserver.forceFlush(); }
|
|
3372
3393
|
view.lastKeyCode = event.keyCode;
|
|
3373
3394
|
view.lastKeyCodeTime = Date.now();
|
|
3374
3395
|
// On iOS, if we preventDefault enter key presses, the virtual
|
|
@@ -3494,10 +3515,11 @@ function handleDoubleClick(view, pos, inside, event) {
|
|
|
3494
3515
|
function handleTripleClick(view, pos, inside, event) {
|
|
3495
3516
|
return runHandlerOnContext(view, "handleTripleClickOn", pos, inside, event) ||
|
|
3496
3517
|
view.someProp("handleTripleClick", function (f) { return f(view, pos, event); }) ||
|
|
3497
|
-
defaultTripleClick(view, inside)
|
|
3518
|
+
defaultTripleClick(view, inside, event)
|
|
3498
3519
|
}
|
|
3499
3520
|
|
|
3500
|
-
function defaultTripleClick(view, inside) {
|
|
3521
|
+
function defaultTripleClick(view, inside, event) {
|
|
3522
|
+
if (event.button != 0) { return false }
|
|
3501
3523
|
var doc = view.state.doc;
|
|
3502
3524
|
if (inside == -1) {
|
|
3503
3525
|
if (doc.inlineContent) {
|
|
@@ -3559,7 +3581,7 @@ var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
|
3559
3581
|
this.event = event;
|
|
3560
3582
|
this.flushed = flushed;
|
|
3561
3583
|
this.selectNode = event[selectNodeModifier];
|
|
3562
|
-
this.allowDefault = event.shiftKey;
|
|
3584
|
+
this.allowDefault = event.shiftKey || event.button != 0;
|
|
3563
3585
|
|
|
3564
3586
|
var targetNode, targetPos;
|
|
3565
3587
|
if (pos.inside > -1) {
|
|
@@ -3579,7 +3601,8 @@ var MouseDown = function MouseDown(view, pos, event, flushed) {
|
|
|
3579
3601
|
|
|
3580
3602
|
var ref = view.state;
|
|
3581
3603
|
var selection = ref.selection;
|
|
3582
|
-
if (
|
|
3604
|
+
if (event.button == 0 &&
|
|
3605
|
+
targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
3583
3606
|
selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos)
|
|
3584
3607
|
{ this.mightDrag = {node: targetNode,
|
|
3585
3608
|
pos: targetPos,
|