Merge pull request #78 from psrok1/fix/options-effects-order

Fix `readOnly` mode option check
This commit is contained in:
Suren Atoyan 2020-06-28 16:30:02 +04:00 committed by GitHub
commit d24bf693fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,11 @@ const Editor =
});
useUpdate(_ => {
if (options.readOnly) {
editorRef.current.updateOptions(options);
}, [options], isEditorReady);
useUpdate(_ => {
if (editorRef.current.getOption(monacoRef.current.editor.EditorOption.readOnly)) {
editorRef.current.setValue(value);
} else {
editorRef.current.executeEdits('', [{
@ -60,10 +64,6 @@ const Editor =
monacoRef.current.editor.setTheme(theme);
}, [theme], isEditorReady);
useUpdate(_ => {
editorRef.current.updateOptions(options);
}, [options], isEditorReady);
const createEditor = useCallback(_ => {
editorRef.current = monacoRef.current.editor.create(containerRef.current, {
value,