From 6d00018d3dd38a404e3542481ca4b6c5c243f9b2 Mon Sep 17 00:00:00 2001 From: pearmini Date: Sat, 8 Nov 2025 15:52:09 -0500 Subject: [PATCH] Fix open link stop running --- editor/commentLink.js | 2 ++ editor/index.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/editor/commentLink.js b/editor/commentLink.js index 6038ba4..5bd7170 100644 --- a/editor/commentLink.js +++ b/editor/commentLink.js @@ -75,6 +75,8 @@ export const commentLinkClickHandler = EditorView.domEventHandlers({ if (!url) return false; if (event.metaKey || event.ctrlKey) { event.preventDefault(); + // Notify the runtime to resume running. + window.dispatchEvent(new Event("openlink")); window.open(url, "_blank", "noopener,noreferrer"); return true; } diff --git a/editor/index.js b/editor/index.js index e41b842..26275ff 100644 --- a/editor/index.js +++ b/editor/index.js @@ -88,6 +88,7 @@ export function createEditor(container, options) { runtimeRef.current.onChanges(dispatch); window.addEventListener("keydown", onKeyDown); window.addEventListener("keyup", onKeyUp); + window.addEventListener("openlink", onOpenLink); } function dispatch(changes) { @@ -131,6 +132,12 @@ export function createEditor(container, options) { } } + function onOpenLink() { + if (!isStopByMetaKey) return; + isStopByMetaKey = false; + runtimeRef.current?.setIsRunning(true); + } + return { run: () => { try { @@ -146,12 +153,14 @@ export function createEditor(container, options) { runtimeRef.current = null; window.removeEventListener("keydown", onKeyDown); window.removeEventListener("keyup", onKeyUp); + window.removeEventListener("openlink", onOpenLink); }, on: (event, callback) => dispatcher.on(event, callback), destroy: () => { runtimeRef.current?.destroy(); window.removeEventListener("keydown", onKeyDown); window.removeEventListener("keyup", onKeyUp); + window.removeEventListener("openlink", onOpenLink); view.destroy(); }, };