From eff426550b471a558b04730d9ea0cdc7c183be9f Mon Sep 17 00:00:00 2001 From: Josh Creek Date: Sat, 8 Oct 2022 17:17:41 +0100 Subject: [PATCH] feat(#1): Add state to localstorage --- src/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index.ts b/src/index.ts index 84b19ad..f8b7015 100644 --- a/src/index.ts +++ b/src/index.ts @@ -228,6 +228,15 @@ function startSpinning() { const button = document.getElementById('startSpinning'); button.onclick = startSpinning; +const textArea = document.getElementById('input-lines'); +if (window.localStorage.TextEditorData) { + textArea.value = window.localStorage.TextEditorData; +} + +textArea.addEventListener('keyup', () => { + window.localStorage.TextEditorData = textArea.value; +}); + if (process.env.NODE_ENV === 'production') { loadServiceWorker(); }