1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Desktop: Split Codemirror setOptions into different effects (#3522)

This commit is contained in:
Caleb John 2020-07-22 16:18:52 -06:00 committed by GitHub
parent 0fa8dfa063
commit 9dfb0642da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 <div style={props.style} ref={editorParent} />;
}