Milde optimizations
This commit is contained in:
parent
5b81185afa
commit
1af5e022a0
@ -1,8 +1,9 @@
|
|||||||
/* Reset SB styles */
|
/* Reset SB styles */
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
height: initial !important;
|
/*height: initial !important;
|
||||||
overflow: initial !important;
|
overflow-x: initial !important;
|
||||||
|
overflow-y: hidden !important;*/
|
||||||
background-color: var(--root-background-color) !important;
|
background-color: var(--root-background-color) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ ol {
|
|||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
padding-left: 1ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul li::before {
|
ul li::before {
|
||||||
|
@ -47,7 +47,7 @@ async function init() {
|
|||||||
const messageData = e.data;
|
const messageData = e.data;
|
||||||
switch (messageData.type) {
|
switch (messageData.type) {
|
||||||
case "setHeight":
|
case "setHeight":
|
||||||
iframe.style.height = messageData.height + "px";
|
iframe.height = messageData.height + "px";
|
||||||
// Propagate height setting to parent
|
// Propagate height setting to parent
|
||||||
updateHeight();
|
updateHeight();
|
||||||
break;
|
break;
|
||||||
|
@ -55,7 +55,8 @@ class IFrameWidget extends WidgetType {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
iframe.style.height = `${this.estimatedHeight}px`;
|
const estimatedHeight = this.estimatedHeight;
|
||||||
|
iframe.height = `${estimatedHeight}px`;
|
||||||
|
|
||||||
return iframe;
|
return iframe;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,8 @@ function loadJsByUrl(url) {
|
|||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
height: initial !important;
|
height: initial !important;
|
||||||
overflow: initial !important;
|
overflow-x: initial !important;
|
||||||
|
overflow-y: hidden !important;
|
||||||
background-color: var(--root-background-color);
|
background-color: var(--root-background-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -32,7 +32,7 @@ function updatePool(exclude?: PreloadedIFrame) {
|
|||||||
preloadedIframe.used && !document.body.contains(preloadedIframe.iframe)
|
preloadedIframe.used && !document.body.contains(preloadedIframe.iframe)
|
||||||
) {
|
) {
|
||||||
// Ditch it
|
// Ditch it
|
||||||
console.log("Garbage collecting iframe", preloadedIframe);
|
// console.log("Garbage collecting iframe", preloadedIframe);
|
||||||
iframePool.delete(preloadedIframe);
|
iframePool.delete(preloadedIframe);
|
||||||
}
|
}
|
||||||
if (!preloadedIframe.used) {
|
if (!preloadedIframe.used) {
|
||||||
@ -46,7 +46,7 @@ function updatePool(exclude?: PreloadedIFrame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function prepareSandboxIFrame(): PreloadedIFrame {
|
export function prepareSandboxIFrame(): PreloadedIFrame {
|
||||||
console.log("Preloading iframe");
|
// console.log("Preloading iframe");
|
||||||
const iframe = document.createElement("iframe");
|
const iframe = document.createElement("iframe");
|
||||||
|
|
||||||
// Empty page with current origin. Handled this differently before, but "dock apps" in Safari (PWA implementation) seem to have various restrictions
|
// Empty page with current origin. Handled this differently before, but "dock apps" in Safari (PWA implementation) seem to have various restrictions
|
||||||
@ -70,7 +70,7 @@ export function prepareSandboxIFrame(): PreloadedIFrame {
|
|||||||
function claimIFrame(): PreloadedIFrame {
|
function claimIFrame(): PreloadedIFrame {
|
||||||
for (const preloadedIframe of iframePool) {
|
for (const preloadedIframe of iframePool) {
|
||||||
if (!preloadedIframe.used) {
|
if (!preloadedIframe.used) {
|
||||||
console.log("Took iframe from pool");
|
// console.log("Took iframe from pool");
|
||||||
preloadedIframe.used = true;
|
preloadedIframe.used = true;
|
||||||
updatePool(preloadedIframe);
|
updatePool(preloadedIframe);
|
||||||
return preloadedIframe;
|
return preloadedIframe;
|
||||||
@ -108,6 +108,7 @@ export function mountIFrame(
|
|||||||
onMessage?: (message: any) => void,
|
onMessage?: (message: any) => void,
|
||||||
) {
|
) {
|
||||||
const iframe = preloadedIFrame.iframe;
|
const iframe = preloadedIFrame.iframe;
|
||||||
|
|
||||||
preloadedIFrame.ready.then(async () => {
|
preloadedIFrame.ready.then(async () => {
|
||||||
const messageListener = (evt: any) => {
|
const messageListener = (evt: any) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -146,7 +147,7 @@ export function mountIFrame(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setHeight":
|
case "setHeight":
|
||||||
iframe.style.height = data.height + "px";
|
iframe.height = data.height + "px";
|
||||||
if (widgetHeightCacheKey) {
|
if (widgetHeightCacheKey) {
|
||||||
client.space.setCachedWidgetHeight(
|
client.space.setCachedWidgetHeight(
|
||||||
widgetHeightCacheKey,
|
widgetHeightCacheKey,
|
||||||
@ -183,10 +184,10 @@ export function mountIFrame(
|
|||||||
} else if (resolvedContent.url) {
|
} else if (resolvedContent.url) {
|
||||||
iframe.contentWindow!.location.href = resolvedContent.url;
|
iframe.contentWindow!.location.href = resolvedContent.url;
|
||||||
if (resolvedContent.height) {
|
if (resolvedContent.height) {
|
||||||
iframe.style.height = resolvedContent.height + "px";
|
iframe.height = resolvedContent.height + "px";
|
||||||
}
|
}
|
||||||
if (resolvedContent.width) {
|
if (resolvedContent.width) {
|
||||||
iframe.style.width = resolvedContent.width + "px";
|
iframe.width = resolvedContent.width + "px";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
|
@ -35,7 +35,7 @@ export class Space {
|
|||||||
.catch(
|
.catch(
|
||||||
console.error,
|
console.error,
|
||||||
);
|
);
|
||||||
console.log("Flushed widget height cache to store");
|
// console.log("Flushed widget height cache to store");
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
setCachedWidgetHeight(bodyText: string, height: number) {
|
setCachedWidgetHeight(bodyText: string, height: number) {
|
||||||
|
@ -437,7 +437,7 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this seems to not be used anymore
|
// Allow for cursor movement into a code widget fenced code block from bottom-up
|
||||||
.sb-fenced-code-hide {
|
.sb-fenced-code-hide {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user