UNPKG

@ng-doc/app

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

34 lines (30 loc) 2.1 kB
import * as i0 from '@angular/core'; import { input, inject, ElementRef, computed, Directive } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { NgDocHighlighterService } from '@ng-doc/app/services'; class NgDocCodeHighlighterDirective { constructor() { this.code = input.required({ ...(ngDevMode ? { debugName: "code" } : {}), alias: 'ngDocHighlighter' }); this.element = inject((ElementRef)).nativeElement; this.highlighter = inject(NgDocHighlighterService); this.sanitizer = inject(DomSanitizer); this.highlightedCode = computed(() => this.sanitizer.bypassSecurityTrustHtml(this.highlighter.highlight(this.code())), ...(ngDevMode ? [{ debugName: "highlightedCode" }] : [])); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgDocCodeHighlighterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: NgDocCodeHighlighterDirective, isStandalone: true, selector: "[ngDocHighlighter]", inputs: { code: { classPropertyName: "code", publicName: "ngDocHighlighter", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "innerHTML": "highlightedCode()" } }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgDocCodeHighlighterDirective, decorators: [{ type: Directive, args: [{ selector: '[ngDocHighlighter]', standalone: true, host: { '[innerHTML]': 'highlightedCode()', }, }] }], ctorParameters: () => [], propDecorators: { code: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngDocHighlighter", required: true }] }] } }); /** * Generated bundle index. Do not edit. */ export { NgDocCodeHighlighterDirective }; //# sourceMappingURL=ng-doc-app-directives-code-highlighter.mjs.map