diff --git a/src/useCodeMirror.ts b/src/useCodeMirror.ts index 3604ed9f4..15eb78b40 100644 --- a/src/useCodeMirror.ts +++ b/src/useCodeMirror.ts @@ -57,6 +57,26 @@ export function useCodeMirror(props: UseCodeMirror) { getExtensions.unshift(keymap.of([indentWithTab])); } if (defaultBasicSetup) { + if (Array.isArray(basicSetup)) { + /** + * 🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧 + * This is not a solution. + * https://github.com/uiwjs/react-codemirror/issues/280 + */ + basicSetup.map((item) => { + if (item.value && Array.isArray(item.value)) { + item.value = item.value + .map((keymap: any) => { + if ('Mod-f' === keymap.key) { + return undefined; + } + return keymap; + }) + .filter(Boolean); + } + return item; + }); + } getExtensions.unshift(basicSetup); } @@ -102,6 +122,11 @@ export function useCodeMirror(props: UseCodeMirror) { setView(viewCurrent); } } + return () => { + if (view) { + setView(undefined); + } + }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [container, state]); diff --git a/website/App.tsx b/website/App.tsx index 0a149fe53..36744a8f2 100644 --- a/website/App.tsx +++ b/website/App.tsx @@ -127,7 +127,6 @@ let count = 0; export default function App() { const dark = document.documentElement.getAttribute('data-color-mode'); - console.log('>>', document.documentElement.getAttribute('data-color-mode')); const [mode, setMode] = useState('javascript'); const [placeholder, setPlaceholder] = useState('Please enter the code.'); const [autofocus, setAutofocus] = useState(false);