Files
orca/config/patches/prosemirror-view@1.42.3.patch
Brennan Benson 9eb930173e Keep rich Markdown in place when focus returns from Find (#36781)
* Preserve rich Markdown viewport through bare focus returns

* Retire viewport ownership on editor remount

* Complete no-op navigation and body Tab coverage

* Keep patch metadata keys separate from dependency snapshots

* Retire the viewport before root detach callbacks

* Give the engine writer fixture its native selection

* Keep native focus navigation current in Markdown

* fix: leave smooth Markdown scrolling to native focus cancellation

* Cover focus wrapper removal and routed Markdown writers

* Type the viewport scroll spy and mark the focus-recovery wait as deliberate

* Scope Markdown viewport wheel and touch guards to the editor scroller
2026-11-01 11:46:13 -08:00

114 lines
4.8 KiB
Diff

diff --git a/src/domobserver.ts b/src/domobserver.ts
--- a/src/domobserver.ts
+++ b/src/domobserver.ts
@@ -235,7 +235,7 @@
view.input.lastFocus = 0
selectionToDOM(view)
this.currentSelection.set(sel)
- view.scrollToSelection()
+ view.scrollToSelection("focus")
} else if (from > -1 || newSel) {
if (from > -1) {
view.docView.markDirty(from, to)
diff --git a/src/index.ts b/src/index.ts
--- a/src/index.ts
+++ b/src/index.ts
@@ -234,11 +234,11 @@
}
/// @internal
- scrollToSelection() {
+ scrollToSelection(reason?: "focus") {
let startDOM = this.domSelectionRange().focusNode
if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode)) {
// Ignore selections outside the editor
- } else if (this.someProp("handleScrollToSelection", f => f(this))) {
+ } else if (this.someProp("handleScrollToSelection", f => f(this, reason))) {
// Handled
} else if (this.state.selection instanceof NodeSelection) {
let target = this.docView.domAfterPos(this.state.selection.from)
@@ -675,7 +675,7 @@
/// the selection into view. A handler function may return false to
/// indicate that it did not handle the scrolling and further
/// handlers or the default behavior should be tried.
- handleScrollToSelection?: (this: P, view: EditorView) => boolean
+ handleScrollToSelection?: (this: P, view: EditorView, reason?: "focus") => boolean
/// Determines whether an in-editor drag event should copy or move
/// the selection. When not given, the event's `altKey` property is
diff --git a/dist/index.js b/dist/index.js
--- a/dist/index.js
+++ b/dist/index.js
@@ -4864,7 +4864,7 @@
view.input.lastFocus = 0;
selectionToDOM(view);
this.currentSelection.set(sel);
- view.scrollToSelection();
+ view.scrollToSelection("focus");
}
else if (from > -1 || newSel) {
if (from > -1) {
@@ -5626,10 +5626,10 @@
/**
@internal
*/
- scrollToSelection() {
+ scrollToSelection(reason) {
let startDOM = this.domSelectionRange().focusNode;
if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode)) ;
- else if (this.someProp("handleScrollToSelection", f => f(this))) ;
+ else if (this.someProp("handleScrollToSelection", f => f(this, reason))) ;
else if (this.state.selection instanceof NodeSelection) {
let target = this.docView.domAfterPos(this.state.selection.from);
if (target.nodeType == 1)
diff --git a/dist/index.cjs b/dist/index.cjs
--- a/dist/index.cjs
+++ b/dist/index.cjs
@@ -4565,7 +4565,7 @@
view.input.lastFocus = 0;
selectionToDOM(view);
this.currentSelection.set(sel);
- view.scrollToSelection();
+ view.scrollToSelection("focus");
} else if (from > -1 || newSel) {
if (from > -1) {
view.docView.markDirty(from, to);
@@ -5195,11 +5195,11 @@
}
}, {
key: "scrollToSelection",
- value: function scrollToSelection() {
+ value: function scrollToSelection(reason) {
var _this17 = this;
var startDOM = this.domSelectionRange().focusNode;
if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode)) ;else if (this.someProp("handleScrollToSelection", function (f) {
- return f(_this17);
+ return f(_this17, reason);
})) ;else if (this.state.selection instanceof prosemirrorState.NodeSelection) {
var target = this.docView.domAfterPos(this.state.selection.from);
if (target.nodeType == 1) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
diff --git a/dist/index.d.ts b/dist/index.d.ts
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -718,7 +718,7 @@
indicate that it did not handle the scrolling and further
handlers or the default behavior should be tried.
*/
- handleScrollToSelection?: (this: P, view: EditorView) => boolean;
+ handleScrollToSelection?: (this: P, view: EditorView, reason?: "focus") => boolean;
/**
Determines whether an in-editor drag event should copy or move
the selection. When not given, the event's `altKey` property is
diff --git a/dist/index.d.cts b/dist/index.d.cts
--- a/dist/index.d.cts
+++ b/dist/index.d.cts
@@ -718,7 +718,7 @@
indicate that it did not handle the scrolling and further
handlers or the default behavior should be tried.
*/
- handleScrollToSelection?: (this: P, view: EditorView) => boolean;
+ handleScrollToSelection?: (this: P, view: EditorView, reason?: "focus") => boolean;
/**
Determines whether an in-editor drag event should copy or move
the selection. When not given, the event's `altKey` property is