From 9dfb0642da366cb072af672a29e503e323bced15 Mon Sep 17 00:00:00 2001 From: Caleb John Date: Wed, 22 Jul 2020 16:18:52 -0600 Subject: [PATCH] Desktop: Split Codemirror setOptions into different effects (#3522) --- .../NoteEditor/NoteBody/CodeMirror/Editor.tsx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx b/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx index 60086a2ad6..158e857740 100644 --- a/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx +++ b/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx @@ -252,13 +252,38 @@ function Editor(props: EditorProps, ref: any) { editor.clearHistory(); } editor.setOption('screenReaderLabel', props.value); + } + }, [props.value]); + + useEffect(() => { + if (editor) { editor.setOption('theme', props.theme); + } + }, [props.theme]); + + useEffect(() => { + if (editor) { editor.setOption('mode', props.mode); + } + }, [props.mode]); + + useEffect(() => { + if (editor) { editor.setOption('readOnly', props.readOnly); + } + }, [props.readOnly]); + + useEffect(() => { + if (editor) { editor.setOption('autoCloseBrackets', props.autoMatchBraces); + } + }, [props.autoMatchBraces]); + + useEffect(() => { + if (editor) { editor.setOption('keyMap', props.keyMap ? props.keyMap : 'default'); } - }, [props.value, props.theme, props.mode, props.readOnly, props.autoMatchBraces, props.keyMap]); + }, [props.keyMap]); return
; }