fix: undo redo key mapping

+ fix hidden line number style
This commit is contained in:
Felix Roos
2023-11-03 10:20:07 +01:00
parent 76ee9485f4
commit 7cc17fefcb
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
import { defaultKeymap } from '@codemirror/commands';
import { javascript } from '@codemirror/lang-javascript';
import { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';
import { EditorState, Compartment } from '@codemirror/state';
import { history } from '@codemirror/commands';
import { EditorView, highlightActiveLineGutter, keymap, lineNumbers } from '@codemirror/view';
import { Drawer, repl } from '@strudel.cycles/core';
import { isFlashEnabled, flash } from './flash.mjs';
@@ -12,7 +12,7 @@ import { keybindings } from './keybindings.mjs';
const extensions = {
isLineWrappingEnabled: (on) => (on ? EditorView.lineWrapping : []),
isLineNumbersDisplayed: (on) => (on ? lineNumbers() : lineNumbers({ formatNumber: () => '' })),
isLineNumbersDisplayed: (on) => (on ? lineNumbers() : []),
theme,
isAutoCompletionEnabled,
isPatternHighlightingEnabled,
@@ -34,7 +34,7 @@ export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, set
javascript(),
highlightActiveLineGutter(),
syntaxHighlighting(defaultHighlightStyle),
keymap.of(defaultKeymap),
history(),
EditorView.updateListener.of((v) => onChange(v)),
keymap.of([
{
+3 -3
View File
@@ -3,6 +3,7 @@ import { keymap, ViewPlugin } from '@codemirror/view';
import { emacs } from '@replit/codemirror-emacs';
import { vim } from '@replit/codemirror-vim';
import { vscodeKeymap } from '@replit/codemirror-vscode-keymap';
import { defaultKeymap, historyKeymap } from '@codemirror/commands';
const vscodePlugin = ViewPlugin.fromClass(
class {
@@ -14,7 +15,6 @@ const vscodePlugin = ViewPlugin.fromClass(
},
},
);
const vscodeExtension = (options) => [vscodePlugin].concat(options ?? []);
const keymaps = {
@@ -24,6 +24,6 @@ const keymaps = {
};
export function keybindings(name) {
const keymap = keymaps[name];
return keymap ? keymap() : [];
const active = keymaps[name];
return [keymap.of(defaultKeymap), keymap.of(historyKeymap), active ? active() : []];
}