diff --git a/public/app.js b/public/app.js index fd3e1b1..9739746 100644 --- a/public/app.js +++ b/public/app.js @@ -65,8 +65,16 @@ createApp({ }, { console: ` - ` - } + `, + }, + { + console_hiddne: ` + + + + +`, + }, ], highlightedCode: { html: "", @@ -167,44 +175,47 @@ createApp({ methods: { loadPrismTheme() { - const existingTheme = document.querySelector('link[data-prism-theme]'); + const existingTheme = document.querySelector("link[data-prism-theme]"); if (existingTheme) { existingTheme.remove(); } - - const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; - - const link = document.createElement('link'); - link.rel = 'stylesheet'; - link.setAttribute('data-prism-theme', ''); - + + const isDarkMode = window.matchMedia( + "(prefers-color-scheme: dark)" + ).matches; + + const link = document.createElement("link"); + link.rel = "stylesheet"; + link.setAttribute("data-prism-theme", ""); + if (isDarkMode) { - link.href = './libraries/prism/theme/prism-vsc-dark-plus.min.css'; + link.href = "./libraries/prism/theme/prism-vsc-dark-plus.min.css"; } else { - link.href = './libraries/prism/theme/prism.min.css'; + link.href = "./libraries/prism/theme/prism.min.css"; } - + document.head.appendChild(link); this.rehighlightCode(); }, - rehighlightCode() { - this.highlightCode(this.html, 'html'); - this.highlightCode(this.css, 'css'); - this.highlightCode(this.js, 'js'); - }, + rehighlightCode() { + this.highlightCode(this.html, "html"); + this.highlightCode(this.css, "css"); + this.highlightCode(this.js, "js"); + }, initThemeListener() { - window.matchMedia('(prefers-color-scheme: dark)') - .addEventListener('change', () => { + window + .matchMedia("(prefers-color-scheme: dark)") + .addEventListener("change", () => { this.loadPrismTheme(); }); - }, + }, handleScroll(event) { const textarea = event.target; const pre = textarea.nextElementSibling; if (pre) { pre.scrollTop = textarea.scrollTop; - pre.scrollLeft = textarea.scrollLeft + pre.scrollLeft = textarea.scrollLeft; } }, toggleConsole() { @@ -343,21 +354,21 @@ createApp({ updatePreview() { if (this.isExecutionPaused) return; - + const preview = document.getElementById("preview-frame"); if (!preview) return; - + // create a new iframe to replace the existing one const newFrame = document.createElement("iframe"); newFrame.id = "preview-frame"; - + // replace the old frame with the new one preview.parentNode.replaceChild(newFrame, preview); - + // write content to the new frame const doc = newFrame.contentDocument; doc.open(); - + const content = ` @@ -368,7 +379,9 @@ createApp({ ${this.html || ""} - ${this.showConsole ? `` : ''} + ` + : "" + } `; - + try { doc.write(content); doc.close(); diff --git a/public/index.html b/public/index.html index 61ded63..428a4d5 100644 --- a/public/index.html +++ b/public/index.html @@ -33,7 +33,7 @@ @@ -43,7 +43,7 @@ :class="{ 'toggle-active': isExecutionPaused }" > - {{ isExecutionPaused ? 'Resume' : 'Pause' }} + {{ isExecutionPaused ? 'live' : 'pause' }}