From f25dbbb86f44d28781ea106f66bbdd6809985bee Mon Sep 17 00:00:00 2001 From: Tom Moor <380914+tommoor@users.noreply.github.com> Date: Sun, 4 Oct 2026 12:45:10 +0000 Subject: [PATCH] Revert unapproved ProseMirror dependency patch Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com> --- app/editor/selectionOnFocus.test.ts | 59 --------------------------- patches/prosemirror-view+1.41.8.patch | 34 --------------- 2 files changed, 93 deletions(-) delete mode 100644 app/editor/selectionOnFocus.test.ts delete mode 100644 patches/prosemirror-view+1.41.8.patch diff --git a/app/editor/selectionOnFocus.test.ts b/app/editor/selectionOnFocus.test.ts deleted file mode 100644 index 964c467a67..0000000000 --- a/app/editor/selectionOnFocus.test.ts +++ /dev/null @@ -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(); - } - }); -}); diff --git a/patches/prosemirror-view+1.41.8.patch b/patches/prosemirror-view+1.41.8.patch deleted file mode 100644 index 87c6b1efb5..0000000000 --- a/patches/prosemirror-view+1.41.8.patch +++ /dev/null @@ -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)