More iframe height fixing
parent
852b07c7a7
commit
371932e085
|
@ -23,6 +23,7 @@ class IFrameWidget extends WidgetType {
|
|||
}
|
||||
|
||||
toDOM(): HTMLElement {
|
||||
const from = this.from;
|
||||
const iframe = createWidgetSandboxIFrame(
|
||||
this.editor,
|
||||
this.bodyText,
|
||||
|
@ -31,7 +32,7 @@ class IFrameWidget extends WidgetType {
|
|||
switch (message.type) {
|
||||
case "blur":
|
||||
this.editor.editorView.dispatch({
|
||||
selection: { anchor: this.from },
|
||||
selection: { anchor: from },
|
||||
});
|
||||
this.editor.focus();
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ self.syscall = async (name, ...args) => {
|
|||
});
|
||||
};
|
||||
|
||||
let oldHeight = undefined;
|
||||
let heightChecks = 0;
|
||||
|
||||
window.addEventListener("message", (message) => {
|
||||
const data = message.data;
|
||||
switch (data.type) {
|
||||
|
@ -35,6 +38,11 @@ window.addEventListener("message", (message) => {
|
|||
console.error("Error evaling script", e);
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
oldHeight = undefined;
|
||||
heightChecks = 0;
|
||||
updateHeight();
|
||||
});
|
||||
break;
|
||||
case "syscall-response":
|
||||
{
|
||||
|
@ -65,8 +73,6 @@ function api(obj) {
|
|||
window.parent.postMessage(obj, "*");
|
||||
}
|
||||
|
||||
let oldHeight = undefined;
|
||||
let heightChecks = 0;
|
||||
function updateHeight() {
|
||||
const body = document.body, html = document.documentElement;
|
||||
let height = Math.max(body.offsetHeight, html.offsetHeight);
|
||||
|
@ -82,9 +88,6 @@ function updateHeight() {
|
|||
setTimeout(updateHeight, 100);
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
updateHeight();
|
||||
});
|
||||
|
||||
function loadJsByUrl(url) {
|
||||
const script = document.createElement("script");
|
||||
|
|
|
@ -10,7 +10,6 @@ export function createWidgetSandboxIFrame(
|
|||
) {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.srcdoc = panelHtml;
|
||||
// iframe.style.height = "150px";
|
||||
|
||||
const messageListener = (evt: any) => {
|
||||
(async () => {
|
||||
|
|
Loading…
Reference in New Issue