From 878938d58d228842d0b10905a39b2159a63cd68f Mon Sep 17 00:00:00 2001 From: "openai-code-agent[bot]" <242516109+Codex@users.noreply.github.com> Date: Sat, 21 Feb 2026 18:14:34 +0000 Subject: [PATCH 1/2] Initial plan From 708c36353963e2b9fbe68938c4e7c337d21f7356 Mon Sep 17 00:00:00 2001 From: "openai-code-agent[bot]" <242516109+Codex@users.noreply.github.com> Date: Sat, 21 Feb 2026 18:16:05 +0000 Subject: [PATCH 2/2] Handle caret plugin multiple instances --- apps/desktop/src/editor/plugins/caret.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/desktop/src/editor/plugins/caret.ts b/apps/desktop/src/editor/plugins/caret.ts index ca82e79..c942a98 100644 --- a/apps/desktop/src/editor/plugins/caret.ts +++ b/apps/desktop/src/editor/plugins/caret.ts @@ -4,12 +4,11 @@ import type { EditorView } from "prosemirror-view"; export type CaretStyle = "line" | "underline"; let caretStyle: CaretStyle = (localStorage.getItem("cursor") as CaretStyle) ?? "line"; -let activeView: EditorView | null = null; -let activeEl: HTMLElement | null = null; +const caretInstances = new Set<{ view: EditorView; el: HTMLElement }>(); export function setCaretStyle(style: CaretStyle) { caretStyle = style; - if (activeView && activeEl) updateCaret(activeView, activeEl); + caretInstances.forEach(({ view, el }) => updateCaret(view, el)); } function getCursorRect(view: EditorView) { @@ -48,12 +47,18 @@ function updateCaret(view: EditorView, el: HTMLElement) { export const caretPlugin = new Plugin({ view(view) { + const parent = view.dom.parentElement; + if (!parent) { + console.warn("caretPlugin: editor has no parent element; skipping custom caret"); + return {}; + } + const el = document.createElement("div"); el.className = "pm-caret"; el.setAttribute("data-style", caretStyle); - view.dom.parentElement?.appendChild(el); - activeView = view; - activeEl = el; + parent.appendChild(el); + const instance = { view, el }; + caretInstances.add(instance); updateCaret(view, el); return { @@ -62,8 +67,7 @@ export const caretPlugin = new Plugin({ }, destroy() { el.remove(); - activeView = null; - activeEl = null; + caretInstances.delete(instance); }, }; },