From ed628dd3e4cf4558780139a293ecc77a10f70405 Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Tue, 12 Nov 2024 10:44:49 -0800 Subject: [PATCH] chore(docs): Fix pressing `/` in an example editor starts a search --- .../src/browser/editor/addCodeMirrorEditor.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/typedoc-extensions/src/browser/editor/addCodeMirrorEditor.ts b/packages/typedoc-extensions/src/browser/editor/addCodeMirrorEditor.ts index 9e570ff5f..8a8931164 100644 --- a/packages/typedoc-extensions/src/browser/editor/addCodeMirrorEditor.ts +++ b/packages/typedoc-extensions/src/browser/editor/addCodeMirrorEditor.ts @@ -110,6 +110,15 @@ const addCodeMirrorEditor = ( changes: { from: 0, insert: initialText }, }); + // Overrides the Typedoc search shortcut. Because the upstream shortcut uses the "keypress" event, + // we override the same event: + editor.dom.addEventListener('keypress', (event) => { + if (event.key === '/') { + // Prevent other event listeners from handling the event. + event.stopPropagation(); + } + }); + return { getText() { return editor.state.doc.toString();