Skip to content

Commit

Permalink
fix(vision): fixes bug where codemirror would insert a new line on cm…
Browse files Browse the repository at this point in the history
…d-return
  • Loading branch information
sgulseth committed Mar 26, 2024
1 parent e4f28e5 commit 17098dc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/@sanity/vision/src/codemirror/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
syntaxHighlighting,
} from '@codemirror/language'
import {highlightSelectionMatches} from '@codemirror/search'
import {Extension} from '@codemirror/state'
import {type Extension} from '@codemirror/state'
import {
drawSelection,
highlightActiveLine,
Expand All @@ -31,5 +31,16 @@ export const codemirrorExtensions: Extension[] = [
history(),
drawSelection(),
syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
keymap.of([defaultKeymap, historyKeymap].flat().filter(Boolean)),
keymap.of(
[
// Override the default keymap for Mod-Enter to not insert a new line, we have a custom event handler for executing queries
{key: 'Mod-Enter', run: () => true},

// Add the default keymap and history keymap
defaultKeymap,
historyKeymap,
]
.flat()
.filter(Boolean),
),
]

0 comments on commit 17098dc

Please sign in to comment.