Revert unapproved ProseMirror dependency patch

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
This commit is contained in:
Tom Moorandlinear-code[bot] committed 2026-10-04 12:45:10 +00:00
1 parent ab908c68bf
commit f25dbbb86f
2 files changed
-93

No files matched your search

-59
View File
@@ -1,59 +0,0 @@
import { Schema } from "prosemirror-model";
import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
describe("editor selection after focus", () => {
it("selects from the current document when focus replaces the editor state during a click", () => {
const schema = new Schema({
nodes: {
doc: { content: "block+" },
paragraph: { content: "text*", group: "block", toDOM: () => ["p", 0] },
atom: { group: "block", atom: true, toDOM: () => ["hr"] },
text: { group: "inline" },
},
});
const container = document.createElement("div");
document.body.appendChild(container);
const view = new EditorView(container, {
state: EditorState.create({
schema,
doc: schema.node("doc", null, [schema.node("atom")]),
}),
handleDOMEvents: {
focus: (editorView) => {
editorView.updateState(
EditorState.create({
schema,
doc: schema.node("doc", null, [schema.node("paragraph")]),
})
);
return false;
},
},
dispatchTransaction: (transaction) => {
view.updateState(view.state.apply(transaction));
},
});
vi.spyOn(view, "posAtCoords").mockReturnValue({ pos: 0, inside: 0 });
let caughtError: Error | undefined;
const handleError = (event: ErrorEvent) => {
caughtError = event.error;
event.preventDefault();
};
window.addEventListener("error", handleError);
try {
view.dom.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
view.dom.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
expect(view.state.doc.firstChild?.type.name).toBe("paragraph");
expect(view.state.selection.$from.doc).toBe(view.state.doc);
expect(caughtError).toBeUndefined();
} finally {
window.removeEventListener("error", handleError);
view.destroy();
container.remove();
}
});
});
-34
View File
@@ -1,34 +0,0 @@
diff --git a/node_modules/prosemirror-view/dist/index.cjs b/node_modules/prosemirror-view/dist/index.cjs
--- a/node_modules/prosemirror-view/dist/index.cjs
+++ b/node_modules/prosemirror-view/dist/index.cjs
@@ -3058,6 +3058,7 @@ function selectClickedNode(view, inside) {
}
function updateSelection(view, selection, origin) {
if (!view.focused) view.focus();
+ if (selection.$from.doc != view.state.doc) selection = prosemirrorState.Selection.near(view.state.doc.resolve(Math.min(selection.from, view.state.doc.content.size)));
if (view.state.selection.eq(selection)) return;
var tr = view.state.tr.setSelection(selection);
if (origin == "pointer") tr.setMeta("pointer", true);
diff --git a/node_modules/prosemirror-view/dist/index.js b/node_modules/prosemirror-view/dist/index.js
--- a/node_modules/prosemirror-view/dist/index.js
+++ b/node_modules/prosemirror-view/dist/index.js
@@ -3214,6 +3214,8 @@ function runHandlerOnContext(view, propName, pos, inside, event) {
function updateSelection(view, selection, origin) {
if (!view.focused)
view.focus();
+ if (selection.$from.doc != view.state.doc)
+ selection = Selection.near(view.state.doc.resolve(Math.min(selection.from, view.state.doc.content.size)));
if (view.state.selection.eq(selection))
return;
let tr = view.state.tr.setSelection(selection);
diff --git a/node_modules/prosemirror-view/src/input.ts b/node_modules/prosemirror-view/src/input.ts
--- a/node_modules/prosemirror-view/src/input.ts
+++ b/node_modules/prosemirror-view/src/input.ts
@@ -186,5 +186,7 @@ function updateSelection(view: EditorView, selection: Selection, origin: string) {
function updateSelection(view: EditorView, selection: Selection, origin: string) {
if (!view.focused) view.focus()
+ if (selection.$from.doc != view.state.doc)
+ selection = Selection.near(view.state.doc.resolve(Math.min(selection.from, view.state.doc.content.size)))
if (view.state.selection.eq(selection)) return
let tr = view.state.tr.setSelection(selection)
if (origin == "pointer") tr.setMeta("pointer", true)