@@ -15,25 +15,21 @@ declare const ngDevMode: boolean;
1515 exportAs : 'highlightJs' ,
1616} )
1717export class HighlightJsDirective implements AfterViewInit , OnDestroy {
18- readonly options = input < Partial < HLJSOptions > > ( ) ;
19- readonly l = input < string > ( 'html' , { alias : 'lang' } ) ;
18+ private cog = inject ( HIGHLIGHTJS_CONFIG , { optional : true } ) ;
19+ readonly options = input < Partial < HLJSOptions > > ( this . cog ?. options ?? { } ) ;
20+ readonly lang = input < string > ( this . cog ?. lang ?? 'html' ) ;
2021 readonly code = model < string > ( ) ;
21- readonly mode = input < 'default' | 'simple' > ( 'simple' ) ;
22+ readonly mode = input < 'default' | 'simple' > ( this . cog ?. mode ?? 'simple' ) ;
2223
2324 protected codeEl ?: HTMLElement ;
2425 protected parentEl ?: HTMLElement ;
2526 private modelValue$ ?: Subscription ;
2627 private observer ?: MutationObserver ;
2728 private el = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
28- private ngModel = inject < NgModel > ( NgModel , { optional : true } ) ;
29+ private ngModel = inject < NgModel > ( NgModel , { optional : true } ) ;
2930 private doc = inject ( DOCUMENT ) ;
30- private cog = inject ( HIGHLIGHTJS_CONFIG , { optional : true } ) ;
3131 private ngZone = inject ( NgZone ) ;
3232
33- constructor ( ) {
34- Object . assign ( this , this . cog ) ;
35- }
36-
3733 private escapeHTML ( str : string ) : string {
3834 return ( str || '' ) . replace ( / & / g, '&' ) . replace ( / < / g, '<' ) . replace ( / > / g, '>' ) . replace ( / " / g, '"' ) . replace ( / ' / g, ''' ) ;
3935 }
@@ -49,7 +45,7 @@ export class HighlightJsDirective implements AfterViewInit, OnDestroy {
4945
5046 const isSimple = this . mode ( ) === 'simple' ;
5147 if ( isSimple ) {
52- const lang = this . l ( ) ;
48+ const lang = this . lang ( ) ;
5349 if ( lang ) {
5450 this . codeEl . className = lang ;
5551 }
0 commit comments