From 1f7035970ec649206ba725a0031648a97ee93b49 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Tue, 19 May 2020 17:15:46 +0800 Subject: [PATCH] fix: make props original reactive (#110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 唐宗超 --- src/MonacoEditor.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/MonacoEditor.js b/src/MonacoEditor.js index 9afd834..b942bbf 100644 --- a/src/MonacoEditor.js +++ b/src/MonacoEditor.js @@ -48,6 +48,15 @@ export default { } }, + original(newValue) { + if (this.editor && this.diffEditor) { + const editor = this.getOriginalEditor() + if (newValue !== editor.getValue()) { + editor.setValue(newValue) + } + } + }, + language(newVal) { if (this.editor) { const editor = this.getModifiedEditor() @@ -137,6 +146,10 @@ export default { return this.diffEditor ? this.editor.getModifiedEditor() : this.editor }, + getOriginalEditor() { + return this.diffEditor ? this.editor.getOriginalEditor() : this.editor + }, + focus() { this.editor.focus() }