Fix #132143. Softer image update on rerun. (#170917)

* Fix #132143. Softer image update on rerun.

* Output raw data update required.
This commit is contained in:
Peng Lyu
2023-01-10 10:16:59 -08:00
committed by GitHub
parent 5b8361bc71
commit 7ab8a39a89
4 changed files with 60 additions and 19 deletions

View File

@@ -48,6 +48,14 @@ function renderImage(outputInfo: OutputItem, element: HTMLElement): IDisposable
}
};
if (element.firstChild) {
const display = element.firstChild as HTMLElement;
if (display.firstChild && display.firstChild.nodeName === 'IMG' && display.firstChild instanceof HTMLImageElement) {
display.firstChild.src = src;
return disposable;
}
}
const image = document.createElement('img');
image.src = src;
const display = document.createElement('div');
@@ -301,6 +309,7 @@ export const activate: ActivationFunction<void> = (ctx) => {
case 'image/jpeg':
case 'image/git':
{
disposables.get(outputInfo.id)?.dispose();
const disposable = renderImage(outputInfo, element);
disposables.set(outputInfo.id, disposable);
}