@@ -3,6 +3,8 @@ import snackbar from 'mods/snackbar/js/index.ts';
3
3
import i18n from './i18n' ;
4
4
5
5
export default class Panel {
6
+ private highlight : HTMLElement
7
+
6
8
private pre : HTMLElement
7
9
8
10
private wrapper : HTMLElement
@@ -21,6 +23,7 @@ export default class Panel {
21
23
}
22
24
23
25
this . pre = this . code . parentElement as HTMLElement
26
+ this . highlight = this . pre . parentElement as HTMLElement
24
27
25
28
this . ele = document . createElement ( 'div' )
26
29
this . ele . className = 'code-block-panel'
@@ -30,7 +33,7 @@ export default class Panel {
30
33
this . wrapper . appendChild ( this . ele )
31
34
32
35
this . maxLines ( )
33
- this . language ( )
36
+ this . title ( )
34
37
this . lineNoButton ( )
35
38
this . wrapButton ( )
36
39
this . expandButton ( )
@@ -57,17 +60,14 @@ export default class Panel {
57
60
}
58
61
}
59
62
60
- // Show the code language.
61
- private language ( ) {
62
- const lang = this . code . getAttribute ( 'data-lang ' )
63
- if ( ! lang || lang === 'fallback' ) {
63
+ // Display the title
64
+ private title ( ) {
65
+ const title = this . highlight . getAttribute ( 'title ' )
66
+ if ( title === null ) {
64
67
return
65
68
}
66
69
67
- const e = document . createElement ( 'span' )
68
- e . className = 'code-block-lang'
69
- e . innerText = lang
70
- this . pre . appendChild ( e )
70
+ this . code . setAttribute ( 'title' , title )
71
71
}
72
72
73
73
private button ( name : string , callback : CallableFunction ) : HTMLButtonElement {
0 commit comments