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