-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to go:embed, at the cost of 10MB extra binary size..
- Loading branch information
Showing
12 changed files
with
48 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package static | ||
|
||
import ( | ||
"embed" | ||
) | ||
|
||
//go:embed * | ||
var FS embed.FS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,7 @@ | |
</div> | ||
</r-cell> | ||
</r-grid> | ||
<iframe | ||
title="Starboard Notebook Sandbox iFrame" | ||
id="notebook-iframe" | ||
class="full-page-width" | ||
src="{{.iframeHost}}/static/vendor/[email protected]/dist/index.html" | ||
sandbox="allow-scripts allow-modals allow-same-origin allow-pointer-lock allow-top-navigation-by-user-activation allow-forms allow-downloads" | ||
frameborder="0" | ||
></iframe> | ||
<div id="notebook-mount"></div> | ||
<hr style="margin-bottom: 0;"> | ||
<details> | ||
<summary><span style="font-weight: 700; font-size: 0.8em; color: #333" >Current notebook content</span></summary> | ||
|
@@ -30,8 +23,8 @@ | |
|
||
{{template "footer"}} | ||
|
||
<script src="/static/vendor/[email protected]/js/iframeResizer.min.js"></script> | ||
<script type="module"> | ||
import {StarboardNotebookIFrame} from "/static/vendor/[email protected]/dist/index.js" | ||
const initialNotebookContent = {{.notebookContent}}; | ||
|
||
let currentNotebookContent; | ||
|
@@ -74,34 +67,19 @@ | |
updateDirtyIndicators(false); | ||
} | ||
|
||
window.iFrameComponent = window.iFrameResize({ // Check the iframeResizer docs&code for the options here | ||
autoResize: true, | ||
checkOrigin: [ | ||
"{{.iframeHost}}", | ||
], | ||
onMessage: (messageData) => { | ||
// This message is sent when the notebook is ready | ||
// Respond to this message with the initial content of the notebook. | ||
// | ||
// The iFrame will send this message multiple times until you set the content. | ||
// Note that you don't have to reply synchronously: you can wait for the content to be loaded from say a remote server | ||
if (messageData.message.type === "SIGNAL_READY") { | ||
window.iFrameComponent[0].iFrameResizer.sendMessage({ | ||
type: "SET_NOTEBOOK_CONTENT", data: initialNotebookContent | ||
}) | ||
|
||
// Whenever the notebook content gets changed (e.g. a character is typed) | ||
// the entire content is sent to the parent website. | ||
} else if (messageData.message.type === "NOTEBOOK_CONTENT_UPDATE") { | ||
updateContent(messageData.message.data); | ||
|
||
// This signal is sent when a save shortcut (e.g. cmd+s on mac) is pressed. | ||
} else if (messageData.message.type === "SAVE") { | ||
updateContent(messageData.message.data); | ||
save(messageData.message.data); // Implement your own save function.. | ||
} | ||
const mount = document.querySelector("#notebook-mount"); | ||
const el = new StarboardNotebookIFrame({ | ||
notebookContent: currentNotebookContent, | ||
src: "{{.iframeHost}}/static/vendor/[email protected]/dist/index.html", | ||
onSaveMessage(payload) { | ||
updateContent(payload.content); | ||
save(payload.content); // Implement your own save function.. | ||
}, | ||
onReady: () => {}, | ||
inPageLinks: true, | ||
}, document.querySelector("#notebook-iframe")); | ||
onContentUpdateMessage(payload) { | ||
updateContent(payload.content); | ||
}, | ||
|
||
}); | ||
el.style.width = "100%"; | ||
mount.appendChild(el); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package templates | ||
|
||
import ( | ||
"embed" | ||
) | ||
|
||
//go:embed * | ||
var FS embed.FS |