From 0c5266429db223a3b72be7a83f823d3ab155a5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Sat, 4 Apr 2026 18:52:55 +0200 Subject: [PATCH] make shortcut editor tab dependent --- client/components/codeEditor/codeEditor.jsx | 5 +++-- client/components/codeEditor/customKeyMap.js | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/components/codeEditor/codeEditor.jsx b/client/components/codeEditor/codeEditor.jsx index 835b3c160..d027583b6 100644 --- a/client/components/codeEditor/codeEditor.jsx +++ b/client/components/codeEditor/codeEditor.jsx @@ -36,7 +36,7 @@ const themes = { default: defaultCM5Theme, darkbrewery, ...themesImport }; const themeCompartment = new Compartment(); const highlightCompartment = new Compartment(); -import customKeymap from './customKeyMap.js'; +import { generalKeymap, markdownKeymap } from './customKeyMaps.js'; import pageFoldExtension from './customFolding.js'; import { customHighlightStyle, tokenizeCustomMarkdown, tokenizeCustomCSS } from './customHighlight.js'; import { legacyCustomHighlightStyle, legacyTokenizeCustomMarkdown } from './legacyCustomHighlight.js'; @@ -168,7 +168,8 @@ const CodeEditor = forwardRef( ...(tab !== 'brewStyles' ? [autocompleteEmoji] : []), search(), keymap.of([...defaultKeymap, foldKeymap, ...searchKeymap]), - customKeymap, + generalKeymap, + ...(tab !== 'brewStyles' ? [markdownKeymap] : []), drawSelection(), EditorState.allowMultipleSelections.of(true), customClose, diff --git a/client/components/codeEditor/customKeyMap.js b/client/components/codeEditor/customKeyMap.js index 60a0bb60d..dca6dded1 100644 --- a/client/components/codeEditor/customKeyMap.js +++ b/client/components/codeEditor/customKeyMap.js @@ -207,8 +207,13 @@ const newPage = (view)=>{ return true; }; -export default keymap.of([ +export const generalKeymap = keymap.of([ { key: 'Tab', run: insertTabAtCursor }, + { key: 'Mod-z', run: undo }, //i think it may be unnecessary + { key: 'Mod-Shift-z', run: redo }, +]); + +export const markdownKeymap = keymap.of([ //{ key: 'Shift-Tab', run: indentMore }, { key: 'Shift-Tab', run: indentLess }, { key: 'Mod-b', run: makeBold }, @@ -233,6 +238,4 @@ export default keymap.of([ { key: 'Shift-Mod-6', run: makeHeader(6) }, { key: 'Shift-Mod-Enter', run: newColumn }, { key: 'Mod-Enter', run: newPage }, - { key: 'Mod-z', run: undo }, //i think it may be unnecessary - { key: 'Mod-Shift-z', run: redo }, ]);