Skip to content

Commit

Permalink
fix iframe height
Browse files Browse the repository at this point in the history
Signed-off-by: Jonah Iden <[email protected]>
  • Loading branch information
jonah-iden committed Oct 8, 2024
1 parent 6c03afa commit f8e8401
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,18 @@ export class CellOutputWebviewImpl implements CellOutputWebview, Disposable {
if (selectedCell) {
this.notebook.setSelectedCell(selectedCell);
}
break;
case 'cellHeightRequest':
const cellHeight = this.notebook.getCellByHandle(message.cellHandle)?.cellHeight ?? 0;
this.webviewWidget.sendMessage({
type: 'cellHeightUpdate',
cellHandle: message.cellHandle,
height: cellHeight
});
break;
case 'bodyHeightChange':
this.webviewWidget.setIframeHeight(message.height);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,5 +789,12 @@ export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {

window.addEventListener('focusout', (event: FocusEvent) => focusChange(event, false));

new ResizeObserver(() => {
theia.postMessage({
type: 'bodyHeightChange',
height: document.body.clientHeight
} as webviewCommunication.BodyHeightChange);
}).observe(document.body);

theia.postMessage(<webviewCommunication.WebviewInitialized>{ type: 'initialized' });
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,20 @@ export interface CellHeightRequest {
readonly cellHandle: number;
}

export interface BodyHeightChange {
readonly type: 'bodyHeightChange';
readonly height: number;
}

export type FromWebviewMessage = WebviewInitialized
| OnDidRenderOutput
| WheelMessage
| CustomRendererMessage
| KernelMessage
| InputFocusChange
| CellOuputFocus
| CellHeightRequest;
| CellHeightRequest
| BodyHeightChange;

export interface Output {
id: string
Expand Down

0 comments on commit f8e8401

Please sign in to comment.