From 6bcee73c29c5424ba27872d667d86ec05b484c02 Mon Sep 17 00:00:00 2001 From: Belem Zhang Date: Fri, 21 Jun 2024 10:15:51 +0800 Subject: [PATCH 1/2] Fix #255 call refresh() when editor changes by typing, pasting, or deleting --- nnotepad/js/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nnotepad/js/index.js b/nnotepad/js/index.js index 6f1c8685..04345728 100644 --- a/nnotepad/js/index.js +++ b/nnotepad/js/index.js @@ -24,6 +24,10 @@ document.addEventListener('DOMContentLoaded', async (e) => { disableMonospaceOptimizations: true, }); + editor.onDidChangeModelContent(() => { + refresh(); + }); + async function refresh(e) { const code = editor.getValue(); $('#output').innerText = ''; From 1829d16cb475d54cb0852fe8bc4d47478d5aa4c5 Mon Sep 17 00:00:00 2001 From: Belem Zhang Date: Fri, 21 Jun 2024 12:35:54 +0800 Subject: [PATCH 2/2] Remove original input event in editor --- nnotepad/js/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/nnotepad/js/index.js b/nnotepad/js/index.js index 04345728..dbc7c77e 100644 --- a/nnotepad/js/index.js +++ b/nnotepad/js/index.js @@ -63,7 +63,6 @@ document.addEventListener('DOMContentLoaded', async (e) => { } } - $('#input').addEventListener('input', Util.debounce(refresh, 500)); $('#device').addEventListener('change', refresh); refresh();