|
|
|
|
@ -175,7 +175,11 @@ export class FileGroupPage extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
async displayEdit() {
|
|
|
|
|
const doc = await this.editorBuild.build()
|
|
|
|
|
const msg = ['srcdoc', doc]
|
|
|
|
|
const msg = [
|
|
|
|
|
'srcdoc',
|
|
|
|
|
doc,
|
|
|
|
|
{codeMirror: this.settings.codeMirror},
|
|
|
|
|
]
|
|
|
|
|
this.editFrame.contentWindow.postMessage(
|
|
|
|
|
msg, '*'
|
|
|
|
|
)
|
|
|
|
|
@ -203,7 +207,12 @@ export class FileGroupPage extends HTMLElement {
|
|
|
|
|
if (Array.isArray(event.data)) {
|
|
|
|
|
if (event.data[0] === 'ready') {
|
|
|
|
|
this.editFrame.contentWindow.postMessage(
|
|
|
|
|
['doc', this.body], '*'
|
|
|
|
|
[
|
|
|
|
|
'doc',
|
|
|
|
|
this.body,
|
|
|
|
|
{codeMirror: !!(this.settings.codeMirror)}
|
|
|
|
|
],
|
|
|
|
|
'*'
|
|
|
|
|
)
|
|
|
|
|
} else if (event.data[0] === 'html') {
|
|
|
|
|
const html = event.data[1]
|
|
|
|
|
@ -213,6 +222,18 @@ export class FileGroupPage extends HTMLElement {
|
|
|
|
|
this.body = doc
|
|
|
|
|
} else if (['get', 'put'].includes(event.data[0])) {
|
|
|
|
|
await this.handleRequestMessage('edit', event)
|
|
|
|
|
} else if (event.data[0] === 'load') {
|
|
|
|
|
if (event.data[1] === '/editor-lib-codemirror/codemirror-bundle.js') {
|
|
|
|
|
const url = event.data[1]
|
|
|
|
|
const resp = await fetch(url)
|
|
|
|
|
const text = await resp.text()
|
|
|
|
|
const port = event.ports[0]
|
|
|
|
|
port.postMessage({
|
|
|
|
|
status: 200,
|
|
|
|
|
body: text,
|
|
|
|
|
})
|
|
|
|
|
port.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|