Skip to content

Commit

Permalink
Fix dynamic notebook widgets resizing (#13289)
Browse files Browse the repository at this point in the history
* fix resizing of dynamic widgets

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>

* Update output-webview-internal.ts

removed forgotten debug changes

---------

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
  • Loading branch information
jonah-iden authored Jan 22, 2024
1 parent 56cf3db commit 1a56ba9
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,17 @@ export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {
// we need to check for all images are loaded. Otherwise we can't determine the correct height of the output
const images = Array.from(document.images);
if (images.length > 0) {
Promise.all(images.filter(img => !img.complete).map(img => new Promise(resolve => { img.onload = img.onerror = resolve; }))).then(() =>
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight }));
Promise.all(images.filter(img => !img.complete).map(img => new Promise(resolve => { img.onload = img.onerror = resolve; }))).then(() => {
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight });
new ResizeObserver(() =>
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight }))
.observe(document.body);
});
} else {
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight });
new ResizeObserver(() =>
theia.postMessage(<webviewCommunication.OnDidRenderOutput>{ type: 'didRenderOutput', contentHeight: document.body.clientHeight }))
.observe(document.body);
}

}
Expand Down

0 comments on commit 1a56ba9

Please sign in to comment.