diff --git a/components/file-group-page.js b/components/file-group-page.js index 4895c5d..bc325d1 100644 --- a/components/file-group-page.js +++ b/components/file-group-page.js @@ -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() + } } } } diff --git a/sw.js b/sw.js index 272f9c0..7175251 100644 --- a/sw.js +++ b/sw.js @@ -13,6 +13,8 @@ async function initCache() { '/editor/file-group.js', '/editor/file-view.js', '/editor/text-edit.js', + '/editor/code-edit.js', + '/editor/header.js', '/forms/button-group.js', '/index.html', '/loader/builder.js', @@ -22,7 +24,8 @@ async function initCache() { '/settings/network-settings.js', '/settings/connections.js', '/settings/connection-edit.js', - ]) //1 + '/editor-lib-codemirror/codemirror-bundle.js', + ]) } self.addEventListener("install", event => {