mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 07:18:49 +01:00
🎨 improve script in HTML block
* 🎨 improve script in HTML block
* style
* Update protyle-html.js
This commit is contained in:
parent
0476c8d48d
commit
41ef76ed74
1 changed files with 7 additions and 4 deletions
11
app/stage/protyle/js/protyle-html.js
vendored
11
app/stage/protyle/js/protyle-html.js
vendored
|
|
@ -20,13 +20,16 @@ class ProtyleHtml extends HTMLElement {
|
|||
el.innerHTML = dataContent
|
||||
const scripts = el.getElementsByTagName('script')
|
||||
let fatalHTML = ''
|
||||
for (let i = 0; i < scripts.length; i++) {
|
||||
if (scripts[i].textContent.indexOf('document.write') > -1) {
|
||||
for (const script of scripts) {
|
||||
if (script.textContent.indexOf('document.write') > -1) {
|
||||
fatalHTML += `<div style="color:var(--b3-theme-error);font-size: 12px">${window.siyuan.languages.htmlBlockError}</div>
|
||||
<textarea style="width: 100%;box-sizing: border-box;height: 120px"><script>${scripts[i].textContent}</script></textarea>`
|
||||
<textarea style="width: 100%;box-sizing: border-box;height: 120px"><script>${script.textContent}</script></textarea>`
|
||||
} else {
|
||||
const s = document.createElement('script')
|
||||
s.textContent = scripts[i].textContent
|
||||
for (const attr of script.attributes) {
|
||||
s.setAttribute(attr.name, attr.value);
|
||||
}
|
||||
s.textContent = script.textContent
|
||||
this.display.appendChild(s)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue