From e4df6ed0365069bd4d981fab4b58b5d97beb3362 Mon Sep 17 00:00:00 2001 From: RTa-technology Date: Wed, 1 Nov 2023 15:18:04 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script/eventHandlers.ts | 1 - src/script/worker.ts | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/script/eventHandlers.ts b/src/script/eventHandlers.ts index 5e9faf9..c447503 100644 --- a/src/script/eventHandlers.ts +++ b/src/script/eventHandlers.ts @@ -147,7 +147,6 @@ const handleEditpageInput = debounce((event) => { const { target } = event; if (!(target instanceof HTMLTextAreaElement)) return; - const value = target.value; const type = "page"; const shortid = getCurrentPageShortId(); diff --git a/src/script/worker.ts b/src/script/worker.ts index 282d528..5b92d42 100644 --- a/src/script/worker.ts +++ b/src/script/worker.ts @@ -14,16 +14,16 @@ const handleMessage = (event) => { }; const targetContent = document.getElementById(contentMapping[type]) || document.getElementById('page-content'); const cleanedHtml = html.replace(//g, '').replace(/<\/wj-body>/g, ''); - - setInnerHtml(targetContent, cleanedHtml); - const pageStyles = document.getElementById('page-styles'); - if (pageStyles) { - setInnerHtml( - pageStyles, - styles.map((v) => ``).join('\n\n') - ); + if (styles.length > 0 && pageStyles) { + styles.forEach((style: string) => { + const styleEl = document.createElement('style'); + styleEl.textContent = style; + pageStyles.appendChild(styleEl); + }); } + + setInnerHtml(targetContent, cleanedHtml); }; ftml.onmessage = handleMessage; \ No newline at end of file