Files
notesnook/packages/editor/patches/prosemirror-view+1.42.2.patch
Ammar Ahmed 07205a897b editor: fix android backspace stopped working after prosemirror-view update
The bug: Select 2 text blocks fully and pressing backspace removes the conent and adds it back again. The editor thinks enter is pressed and adds the content to dom back from state.

Guard the whitespace heuristic to only fire on net insertion so backspace keeps working properly.
2026-08-25 12:05:31 +05:00

65 lines
4.0 KiB
Diff

diff --git a/node_modules/prosemirror-view/dist/index.cjs b/node_modules/prosemirror-view/dist/index.cjs
index a615cb7..c9b1f46 100644
--- a/node_modules/prosemirror-view/dist/index.cjs
+++ b/node_modules/prosemirror-view/dist/index.cjs
@@ -1005,8 +1005,8 @@ var ViewDesc = function () {
if (!(force || brKludge && safari) && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, selRange.anchorNode, selRange.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, selRange.focusNode, selRange.focusOffset)) return;
var domSelExtended = false;
if ((domSel.extend || anchor == head) && !(brKludge && gecko)) {
- domSel.collapse(anchorDOM.node, anchorDOM.offset);
try {
+ domSel.collapse(anchorDOM.node, anchorDOM.offset);
if (anchor != head) domSel.extend(headDOM.node, headDOM.offset);
domSelExtended = true;
} catch (_) {}
@@ -3647,7 +3647,7 @@ function handleDrop(view, event, dragging) {
});
tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end)));
}
- view.focus();
+ if (!dragging || !dragging.nodeView) view.focus();
view.dispatch(tr.setMeta("uiEvent", "drop"));
}
handlers.focus = function (view) {
@@ -4881,7 +4881,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
var inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function (n) {
return n.nodeName == "DIV" || n.nodeName == "P";
- })) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", function (f) {
+ })) || change.endB > change.endA && !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", function (f) {
return f(view, keyEvent(13, "Enter"));
})) {
view.input.lastIOSEnter = 0;
diff --git a/node_modules/prosemirror-view/dist/index.js b/node_modules/prosemirror-view/dist/index.js
index 61118ee..c8c510b 100644
--- a/node_modules/prosemirror-view/dist/index.js
+++ b/node_modules/prosemirror-view/dist/index.js
@@ -1079,8 +1079,8 @@ class ViewDesc {
// browsers support it yet.
let domSelExtended = false;
if ((domSel.extend || anchor == head) && !(brKludge && gecko)) {
- domSel.collapse(anchorDOM.node, anchorDOM.offset);
try {
+ domSel.collapse(anchorDOM.node, anchorDOM.offset);
if (anchor != head)
domSel.extend(headDOM.node, headDOM.offset);
domSelExtended = true;
@@ -3885,7 +3885,7 @@ function handleDrop(view, event, dragging) {
tr.mapping.maps[tr.mapping.maps.length - 1].forEach((_from, _to, _newFrom, newTo) => end = newTo);
tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end)));
}
- view.focus();
+ if (!dragging || !dragging.nodeView) view.focus();
view.dispatch(tr.setMeta("uiEvent", "drop"));
}
handlers.focus = view => {
@@ -5193,7 +5193,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
// as being an iOS enter press), just dispatch an Enter key instead.
if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
- (!inlineChange && $from.pos < parse.doc.content.size &&
+ (change.endB > change.endA && !inlineChange && $from.pos < parse.doc.content.size &&
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
$from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")))) &&
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {