Skip to content

Commit

Permalink
Update generated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Potherca committed May 24, 2024
1 parent cbaba77 commit 3089782
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions generated.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/* Routes */
routes: {
"/" : function (params) {
editor.pageData.page = 'home'
editor.pageData.page = 'hello'
}

}
Expand Down Expand Up @@ -83,7 +83,20 @@ <h1>This is an App</h1>
<!-- /Page HTML templates -->
</div>
<script src="js/simply.everything.js"></script>
<script src="js/simply-edit.js" data-api-key="muze"></script>
<script>
window.waitForImport = {
init : () => true,
save : () => true,
load : function(callback) {
window.addEventListener("simply-import-fired", () => {
callback("{}");
})
},
connect: () => true,
disconnect: () => true
}
</script>
<script src="js/simply-edit.js" data-api-key="muze" data-simply-storage="waitForImport"></script>
<script>
/* Transformers */
editor.transformers = {
Expand All @@ -106,6 +119,36 @@ <h1>This is an App</h1>
});
</script>
<!-- Foot HTML -->
<!-- importFoot -->
<script type="module">
import dc from 'https://cdn.jsdelivr.net/gh/potherca-blog/[email protected]/index.js'

document.body.insertAdjacentHTML('beforeend', dc.componentTemplates)
document.body.querySelector("[data-simply-field=page]").insertAdjacentHTML('beforeend', dc.pageTemplates);

// We need to make sure that both simplyApp _and_ dc[...] are loaded.
// Race conditions caused by network transport need to be mitigated...

/**
* @CHECKME: De we want routes? This is a new APP, do components even have routes?
*/
function importActionsAndCommands(simplyApp, dc) {
Object.entries(dc.simplyApp.actions).forEach(([index,action]) => {
simplyApp.actions[index] = action
})

Object.entries(dc.simplyApp.commands).forEach(([index,command]) => {
simplyApp.commands[index] = command
})
}

window.addEventListener("simply-content-loaded", () => {
importActionsAndCommands(simplyApp, dc)
})

// @CHECKME: Should we fire at the window or at the document? Why?
editor.fireEvent('simply-import-fired', window)
</script>

<!-- /Foot HTML -->
</body>
Expand Down

0 comments on commit 3089782

Please sign in to comment.