@@ -553,11 +553,11 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
553553
554554class EditorTextRenderer {
555555
556- private _ttPolicy = window . trustedTypes ! . createPolicy ( 'cellRendererEditorText' , {
556+ private _ttPolicy = window . trustedTypes ? .createPolicy ( 'cellRendererEditorText' , {
557557 createHTML ( input ) { return input ; }
558558 } ) ;
559559
560- getRichText ( editor : ICodeEditor , modelRange : Range ) : TrustedHTML | null {
560+ getRichText ( editor : ICodeEditor , modelRange : Range ) : HTMLElement | null {
561561 const model = editor . getModel ( ) ;
562562 if ( ! model ) {
563563 return null ;
@@ -567,22 +567,24 @@ class EditorTextRenderer {
567567 const fontInfo = editor . getOptions ( ) . get ( EditorOption . fontInfo ) ;
568568 const fontFamily = fontInfo . fontFamily === EDITOR_FONT_DEFAULTS . fontFamily ? fontInfo . fontFamily : `'${ fontInfo . fontFamily } ', ${ EDITOR_FONT_DEFAULTS . fontFamily } ` ;
569569
570- const value = `<div style="`
570+
571+ const style = ``
571572 + `color: ${ colorMap [ modes . ColorId . DefaultForeground ] } ;`
572573 + `background-color: ${ colorMap [ modes . ColorId . DefaultBackground ] } ;`
573574 + `font-family: ${ fontFamily } ;`
574575 + `font-weight: ${ fontInfo . fontWeight } ;`
575576 + `font-size: ${ fontInfo . fontSize } px;`
576577 + `line-height: ${ fontInfo . lineHeight } px;`
577- + `white-space: pre;`
578- + `">`
579- + this . getRichTextLines ( model , modelRange , colorMap )
580- + '</div>' ;
578+ + `white-space: pre;` ;
579+
580+ const element = DOM . $ ( 'div' , { style } ) ;
581581
582- return this . _ttPolicy . createHTML ( value ) ;
582+ const linesHtml = this . getRichTextLinesAsHtml ( model , modelRange , colorMap ) ;
583+ element . innerHTML = linesHtml as unknown as string ;
584+ return element ;
583585 }
584586
585- private getRichTextLines ( model : ITextModel , modelRange : Range , colorMap : string [ ] ) : string {
587+ private getRichTextLinesAsHtml ( model : ITextModel , modelRange : Range , colorMap : string [ ] ) : string | TrustedHTML {
586588 const startLineNumber = modelRange . startLineNumber ;
587589 const startColumn = modelRange . startColumn ;
588590 const endLineNumber = modelRange . endLineNumber ;
@@ -605,7 +607,9 @@ class EditorTextRenderer {
605607 }
606608 }
607609
608- return result ;
610+ return this . _ttPolicy
611+ ? this . _ttPolicy . createHTML ( result )
612+ : result ;
609613 }
610614
611615 private getDefaultColorMap ( ) : string [ ] {
@@ -637,7 +641,7 @@ class CodeCellDragImageRenderer {
637641 dragImageContainer . classList . forEach ( c => dragImageContainer . classList . remove ( c ) ) ;
638642 dragImageContainer . classList . add ( 'cell-drag-image' , 'monaco-list-row' , 'focused' , `${ type } -cell-row` ) ;
639643
640- const editorContainer = dragImageContainer . querySelector ( '.cell-editor-container' ) ;
644+ const editorContainer : HTMLElement | null = dragImageContainer . querySelector ( '.cell-editor-container' ) ;
641645 if ( ! editorContainer ) {
642646 return null ;
643647 }
@@ -646,8 +650,7 @@ class CodeCellDragImageRenderer {
646650 if ( ! richEditorText ) {
647651 return null ;
648652 }
649-
650- DOM . trustedInnerHTML ( editorContainer , richEditorText ) ;
653+ DOM . reset ( editorContainer , richEditorText ) ;
651654
652655 return dragImageContainer ;
653656 }
0 commit comments