@@ -30,8 +30,16 @@ export default defineComponent({
3030 type : String ,
3131 default : '#636E7B' ,
3232 } ,
33+ lineHighlightingColor : {
34+ type : String ,
35+ default : 'rgba(101, 117, 133, .16)' ,
36+ } ,
37+ highlightedLines : {
38+ type : Array as PropType < number [ ] > ,
39+ default : ( ) => [ ] ,
40+ } ,
3341 } ,
34- async setup ( { code, lang, theme, showLineNumbers, lineNumberColor } ) {
42+ async setup ( { code, lang, theme, showLineNumbers, lineNumberColor, highlightedLines , lineHighlightingColor } ) {
3543 const shiki = await getHighlighter ( {
3644 langs : [ lang ] ,
3745 themes : [ theme ] ,
@@ -42,6 +50,11 @@ export default defineComponent({
4250 lang,
4351 theme,
4452 transformers : [
53+ {
54+ code ( node ) {
55+ node . properties . style = 'display: table; width: 100%;'
56+ } ,
57+ } ,
4558 {
4659 line ( node , line ) {
4760 node . properties . style = 'display: table-row; line-height: 1.5; height: 1.5em;'
@@ -52,7 +65,7 @@ export default defineComponent({
5265 tagName : 'span' ,
5366 properties : {
5467 className : [ 'line-number' ] ,
55- style : `padding-right: 15px; color: ${ lineNumberColor } ` ,
68+ style : `padding-left: 5px; padding- right: 15px; color: ${ lineNumberColor } ; user-select: none; ` ,
5669 } ,
5770 children : [
5871 {
@@ -62,6 +75,9 @@ export default defineComponent({
6275 ] ,
6376 } )
6477 }
78+
79+ if ( highlightedLines . includes ( line ) )
80+ node . properties . style += `background-color: ${ lineHighlightingColor } ;`
6581 } ,
6682 } ,
6783 ] ,
0 commit comments