From 5300236e213960f4d33b457e1b6f45daa57a7fdb Mon Sep 17 00:00:00 2001 From: sallyx Date: Sat, 11 Feb 2023 19:16:02 +0100 Subject: [PATCH] Fixed updating editor with another editor value If you had two editors on one page with the same value, changing values in one ditor did not work. This update fixed it. I don't know how it affects the previous fix, please test before merge. --- src/main/component/Editor.svelte | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/component/Editor.svelte b/src/main/component/Editor.svelte index 41ea2c4..c960883 100644 --- a/src/main/component/Editor.svelte +++ b/src/main/component/Editor.svelte @@ -62,13 +62,13 @@ let element: HTMLElement; let editorRef: any; - let lastVal = value; + let lastVal : { [key:string] : string} = {}; let disablindCache = disabled; const dispatch = createEventDispatcher(); $: { - if (editorRef && lastVal !== value) { + if (editorRef && (!lastVal[id] || lastVal[id] !== value)) { editorRef.setContent(value); text = editorRef.getContent({format: 'text'}); } @@ -103,9 +103,9 @@ editor.setContent(value); // bind model events editor.on(modelEvents, () => { - lastVal = editor.getContent(); - if (lastVal !== value) { - value = lastVal; + lastVal[id] = editor.getContent(); + if (lastVal[id] !== value) { + value = lastVal[id]; text = editor.getContent({format: 'text'}); } }); @@ -144,4 +144,4 @@ onDestroy(() => { {:else} {/if} - \ No newline at end of file +