mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-04 20:14:57 +08:00
Add importJS to the JS view client context (#1431)
This commit is contained in:
parent
12f77daa68
commit
1ffdf8bf6a
2 changed files with 17 additions and 2 deletions
|
@ -26,7 +26,7 @@ import { sha256Base64 } from "../../lib/utils";
|
|||
// (2): https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
|
||||
// (3): https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
|
||||
|
||||
const IFRAME_SHA256 = "Ogec/87xIEbz3xVctg9QCMqCPCTCf6vyL88bl41PR3I=";
|
||||
const IFRAME_SHA256 = "vd7g1B8fLBFZH6C6KNpG4H8B0SQ/oIuqKaTW6jD053A=";
|
||||
|
||||
export function initializeIframeSource(iframe, iframePort, iframeUrl) {
|
||||
const url = getIframeUrl(iframePort, iframeUrl);
|
||||
|
|
|
@ -78,11 +78,26 @@
|
|||
});
|
||||
},
|
||||
|
||||
importJS(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const scriptEl = document.createElement("script");
|
||||
scriptEl.addEventListener(
|
||||
"load",
|
||||
(event) => {
|
||||
resolve();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
scriptEl.src = url;
|
||||
document.head.appendChild(scriptEl);
|
||||
});
|
||||
},
|
||||
|
||||
handleSync(callback) {
|
||||
state.syncHandler = callback;
|
||||
},
|
||||
|
||||
selectSecret(callback, preselectName, options) {
|
||||
selectSecret(callback, preselectName, options = {}) {
|
||||
state.secretHandler = callback;
|
||||
postMessage({ type: "selectSecret", preselectName, options });
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue