From 116d4173aa171aa6478a13a903fab9f7bccc3535 Mon Sep 17 00:00:00 2001 From: Minhyeok Park Date: Tue, 15 Oct 2024 17:31:00 +0900 Subject: [PATCH] feat: preserve undo-stack when pull from output --- index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 077ca6a..3a73b5d 100644 --- a/index.html +++ b/index.html @@ -145,12 +145,16 @@ try { document.getElementById('base64e').value = btoa(value) } catch { document.getElementById('base64e').value ='(err)' } try { document.getElementById('urid').value = document.getElementById('uridcmp').checked ? decodeURIComponent(value) : decodeURI(value) } catch { document.getElementById('urid').value = '(err)' } try { document.getElementById('urie').value = document.getElementById('uriecmp').checked ? encodeURIComponent(value) : encodeURI(value) } catch { document.getElementById('urie').value = '(err)' } - try { document.getElementById('jsonbtf').value = JSON.stringify(JSON.parse(value), null, parseInt(document.getElementById('jsonbtfsp').value)) } catch { document.getElementById('jsonbtf').value ='(err)' } + try { document.getElementById('jsonbtf').value = value.split('\n').map((v) => JSON.stringify(JSON.parse(v), null, parseInt(document.getElementById('jsonbtfsp').value))).join('\n') } catch { document.getElementById('jsonbtf').value ='(err)' } try { document.getElementById('jsonsmp').value = JSON.stringify(JSON.parse(value)) } catch { document.getElementById('jsonsmp').value ='(err)' } } - window.btn = (id) => - editor.setValue(document.getElementById(id).value) + window.btn = (id) => { + const text = document.getElementById(id).value + + editor.executeEdits('ptools', [{ identifier: 'delete', range: new monaco.Range(1, 1, 1000000000, 1), text: '', forceMoveMarkers: true }]); + editor.executeEdits('ptools', [{ identifier: 'insert', range: new monaco.Range(1, 1, 1, 1), text, forceMoveMarkers: true }]); + } try { document.getElementById('uridcmp').onchange = () => render()