mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-12 15:17:32 -06:00
For #125269 - Rename `CellInfo` - >`OutputItem` (only internally, we also need to update the published types) - Move `id` into `OutputItem` - Move `element` out of `OutputItem` - Rename `renderCell` to `renderOutputItem` - Rename `destoryCell` to `disposeOutputItem` (`dispose` is the term we generally use in our APIs)
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
const MarkdownIt = require('markdown-it');
|
|
|
|
export function activate() {
|
|
let markdownIt = new MarkdownIt({
|
|
html: true
|
|
});
|
|
|
|
return {
|
|
renderOutputItem: (outputInfo: { text(): string }, element: HTMLElement) => {
|
|
const rendered = markdownIt.render(outputInfo.text());
|
|
element.innerHTML = rendered;
|
|
|
|
// Insert styles into markdown preview shadow dom so that they are applied
|
|
for (const markdownStyleNode of document.getElementsByClassName('markdown-style')) {
|
|
element.insertAdjacentElement('beforebegin', markdownStyleNode.cloneNode(true) as Element);
|
|
}
|
|
},
|
|
extendMarkdownIt: (f: (md: typeof markdownIt) => void) => {
|
|
f(markdownIt);
|
|
}
|
|
};
|
|
}
|