diff --git a/src/Editor/Editor.js b/src/Editor/Editor.js index 47ed161..9770737 100644 --- a/src/Editor/Editor.js +++ b/src/Editor/Editor.js @@ -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,