Actualizar 'components/page.js'

file-group-page
bat 3 years ago
parent cd0c47b2d3
commit 9db892198e

@ -36,11 +36,9 @@ export class Page extends HTMLElement {
super() super()
const shadow = this.attachShadow({mode: 'open'}) const shadow = this.attachShadow({mode: 'open'})
this.textArea = document.createElement('textarea') this.textArea = document.createElement('textarea')
this.header = document.createElement('h1')
this.textArea.addEventListener('input', e => { this.textArea.addEventListener('input', e => {
const path = this.getAttribute('path')
localStorage.setItem( localStorage.setItem(
path, this.path,
e.target.value e.target.value
) )
}) })
@ -51,10 +49,9 @@ export class Page extends HTMLElement {
} }
connectedCallback() { connectedCallback() {
const path = this.getAttribute('path')
this.header.innerText = path this.header.innerText = path
this.textArea.value = localStorage.getItem( this.textArea.value = localStorage.getItem(
path this.path
) ?? '' ) ?? ''
const style = document.createElement('style') const style = document.createElement('style')
style.textContent = ` style.textContent = `
@ -64,8 +61,11 @@ export class Page extends HTMLElement {
font-family: sans-serif; font-family: sans-serif;
} }
textarea { textarea {
width: 94vw; width: 100%;
height: 45vh; margin: 0 5px;
padding: 5px;
height: 50vh;
} }
iframe { iframe {
border: none; border: none;
@ -74,7 +74,7 @@ export class Page extends HTMLElement {
} }
` `
this.shadowRoot.append(style) this.shadowRoot.append(style)
if (path.startsWith('/sandbox/')) { if (this.path.startsWith('/sandbox/')) {
this.initFrame() this.initFrame()
} }
} }

Loading…
Cancel
Save