Skip to content

Commit 8f4d1a9

Browse files
authored
Clean up HtmlRenderingHook (microsoft#154961)
- Pass `HtmlRenderingHook` to hook - Rename register function to make it clear it is experimental - Add docs
1 parent f86174b commit 8f4d1a9

File tree

1 file changed

+8
-3
lines changed
  • extensions/notebook-renderers/src

1 file changed

+8
-3
lines changed

extensions/notebook-renderers/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ interface IDisposable {
1111
}
1212

1313
interface HtmlRenderingHook {
14-
postRender(element: HTMLElement): HTMLElement | undefined;
14+
/**
15+
* Invoked after the output item has been rendered but before it has been appended to the document.
16+
*
17+
* @return A new `HTMLElement` or `undefined` to continue using the provided element.
18+
*/
19+
postRender(outputItem: OutputItem, element: HTMLElement): HTMLElement | undefined;
1520
}
1621

1722
function clearContainer(container: HTMLElement) {
@@ -75,7 +80,7 @@ function renderHTML(outputInfo: OutputItem, container: HTMLElement, hooks: Itera
7580
element.innerHTML = trustedHtml as string;
7681

7782
for (const hook of hooks) {
78-
element = hook.postRender(element) ?? element;
83+
element = hook.postRender(outputInfo, element) ?? element;
7984
}
8085

8186
container.appendChild(element);
@@ -286,7 +291,7 @@ export const activate: ActivationFunction<void> = (ctx) => {
286291
disposables.forEach(d => d.dispose());
287292
}
288293
},
289-
registerHtmlRenderingHook: (hook: HtmlRenderingHook): IDisposable => {
294+
experimental_registerHtmlRenderingHook: (hook: HtmlRenderingHook): IDisposable => {
290295
htmlHooks.add(hook);
291296
return {
292297
dispose: () => {

0 commit comments

Comments
 (0)