From 75ce696bdc4e972ac94755c837f963097e71f1eb Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 12 Oct 2022 09:36:45 +0800 Subject: [PATCH] :sparkles: fix https://github.com/siyuan-note/siyuan/issues/6143 --- app/src/util/assets.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts index 912dd0ab6..d55a42146 100644 --- a/app/src/util/assets.ts +++ b/app/src/util/assets.ts @@ -73,9 +73,13 @@ export const renderSnippet = () => { "content": string }) => { if (item.type === "css") { - document.head.insertAdjacentHTML("beforeend", ``); + document.head.insertAdjacentHTML("beforeend", ``); } else if (item.type === "js") { - document.head.insertAdjacentHTML("beforeend", ``); + const scriptElement = document.createElement("script"); + scriptElement.type = "text/javascript"; + scriptElement.text = `try{${item.content}}catch(e){console.error(e, 111)}`; + scriptElement.id = `snippetJS${item.name}`; + document.head.appendChild(scriptElement); } }) });