From a3c1c6cccda4ad73f26c85280f5c1b9c0af092ce Mon Sep 17 00:00:00 2001 From: faruk-agentiqus Date: Tue, 3 Mar 2026 17:51:00 +0100 Subject: [PATCH] fix(editor): disable slash and emoji menus inside code blocks (#1897) The slash command menu (/) and emoji menu (:) were incorrectly triggering when typing inside code blocks, breaking keyboard navigation and confusing users who type paths like /work or symbols like := in their code. Added an `allow` function to both SlashCommand and EmojiCommand extensions that checks if the cursor is inside a code block and disables the menu accordingly. Closes #1730 --- .../src/features/editor/extensions/emoji-command.ts | 8 ++++++++ .../src/features/editor/extensions/slash-command.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/apps/client/src/features/editor/extensions/emoji-command.ts b/apps/client/src/features/editor/extensions/emoji-command.ts index 85a50f18..e2fc6b90 100644 --- a/apps/client/src/features/editor/extensions/emoji-command.ts +++ b/apps/client/src/features/editor/extensions/emoji-command.ts @@ -15,6 +15,14 @@ const Command = Extension.create({ command: ({ editor, range, props }) => { props.command({ editor, range, props }); }, + allow: ({ state, range }) => { + const $from = state.doc.resolve(range.from); + // Disable emoji menu inside code blocks + if ($from.parent.type.name === "codeBlock") { + return false; + } + return true; + }, } as Partial, }; }, diff --git a/apps/client/src/features/editor/extensions/slash-command.ts b/apps/client/src/features/editor/extensions/slash-command.ts index d11c3ae6..160cb924 100644 --- a/apps/client/src/features/editor/extensions/slash-command.ts +++ b/apps/client/src/features/editor/extensions/slash-command.ts @@ -17,6 +17,14 @@ const Command = Extension.create({ command: ({ editor, range, props }) => { props.command({ editor, range, props }); }, + allow: ({ state, range }) => { + const $from = state.doc.resolve(range.from); + // Disable slash menu inside code blocks + if ($from.parent.type.name === 'codeBlock') { + return false; + } + return true; + }, } as Partial, }; },