提交 1cdede1f 编写于 作者: J Johannes Rieken

use tt policy in cell renderer, fyi @roblourens, https://github.com/microsoft/vscode/issues/106396

上级 5fc41c15
......@@ -553,7 +553,11 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
class EditorTextRenderer {
getRichText(editor: ICodeEditor, modelRange: Range): string | null {
private _ttPolicy = window.trustedTypes!.createPolicy('cellRendererEditorText', {
createHTML(input) { return input; }
});
getRichText(editor: ICodeEditor, modelRange: Range): TrustedHTML | null {
const model = editor.getModel();
if (!model) {
return null;
......@@ -563,7 +567,7 @@ class EditorTextRenderer {
const fontInfo = editor.getOptions().get(EditorOption.fontInfo);
const fontFamily = fontInfo.fontFamily === EDITOR_FONT_DEFAULTS.fontFamily ? fontInfo.fontFamily : `'${fontInfo.fontFamily}', ${EDITOR_FONT_DEFAULTS.fontFamily}`;
return `<div style="`
const value = `<div style="`
+ `color: ${colorMap[modes.ColorId.DefaultForeground]};`
+ `background-color: ${colorMap[modes.ColorId.DefaultBackground]};`
+ `font-family: ${fontFamily};`
......@@ -574,6 +578,8 @@ class EditorTextRenderer {
+ `">`
+ this.getRichTextLines(model, modelRange, colorMap)
+ '</div>';
return this._ttPolicy.createHTML(value);
}
private getRichTextLines(model: ITextModel, modelRange: Range, colorMap: string[]): string {
......@@ -641,7 +647,7 @@ class CodeCellDragImageRenderer {
return null;
}
editorContainer.innerHTML = richEditorText;
editorContainer.innerHTML = String(richEditorText);
return dragImageContainer;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册