From ff7de5619dc93bc33ee39785e573d4022b9f6a78 Mon Sep 17 00:00:00 2001 From: psrok1 Date: Thu, 21 May 2020 15:57:04 +0200 Subject: [PATCH 1/2] Changed order of 'options' and 'value' effects --- src/Editor/Editor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Editor/Editor.js b/src/Editor/Editor.js index 2c90cce..8c3ddc8 100644 --- a/src/Editor/Editor.js +++ b/src/Editor/Editor.js @@ -27,6 +27,10 @@ const Editor = return _ => editorRef.current ? disposeEditor() : cancelable.cancel(); }); + useUpdate(_ => { + editorRef.current.updateOptions(options); + }, [options], isEditorReady); + useUpdate(_ => { if (options.readOnly) { editorRef.current.setValue(value); @@ -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, From da22f369e04b7a8b4cedd3edeacef19760429146 Mon Sep 17 00:00:00 2001 From: psrok1 Date: Mon, 22 Jun 2020 13:23:30 +0200 Subject: [PATCH 2/2] Check readOnly computed editor option instead of property --- src/Editor/Editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Editor/Editor.js b/src/Editor/Editor.js index 8c3ddc8..b953c46 100644 --- a/src/Editor/Editor.js +++ b/src/Editor/Editor.js @@ -32,7 +32,7 @@ const Editor = }, [options], isEditorReady); useUpdate(_ => { - if (options.readOnly) { + if (editorRef.current.getOption(monacoRef.current.editor.EditorOption.readOnly)) { editorRef.current.setValue(value); } else { editorRef.current.executeEdits('', [{