Explorar el Código

enable defaultkeymap

reiji-h hace 2 años
padre
commit
8ce67b4ab0

+ 12 - 0
packages/editor/src/components/CodeMirrorEditor/CodeMirrorEditor.tsx

@@ -2,7 +2,9 @@ import {
   forwardRef, useMemo, useRef, useEffect,
   forwardRef, useMemo, useRef, useEffect,
 } from 'react';
 } from 'react';
 
 
+import { defaultKeymap } from '@codemirror/commands';
 import { indentUnit } from '@codemirror/language';
 import { indentUnit } from '@codemirror/language';
+import { keymap } from '@codemirror/view';
 import type { ReactCodeMirrorProps } from '@uiw/react-codemirror';
 import type { ReactCodeMirrorProps } from '@uiw/react-codemirror';
 
 
 import { GlobalCodeMirrorEditorKey } from '../../consts';
 import { GlobalCodeMirrorEditorKey } from '../../consts';
@@ -41,6 +43,16 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
   }, [onChange]);
   }, [onChange]);
   const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey, containerRef.current, cmProps);
   const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey, containerRef.current, cmProps);
 
 
+  useEffect(() => {
+    const extension = keymap.of([
+      ...defaultKeymap,
+    ]);
+
+    const cleanupFunction = codeMirrorEditor?.appendExtensions?.(extension);
+    return cleanupFunction;
+
+  }, [codeMirrorEditor]);
+
   useEffect(() => {
   useEffect(() => {
     if (indentSize == null) {
     if (indentSize == null) {
       return;
       return;