/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
adev/src/app/features/home/components/code-block/code-block.ts
43 строки
1 KB
Kam
refactor(docs-infra): correct misspelled `CodeHighlighter` class name
01 июн 2026, 19:34
01 июн 2026, 19:34
032fae8
Код
Авторство
О чём код?
/*! * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {AsyncPipe} from '@angular/common'; import {Component, computed, inject, input} from '@angular/core'; import {DomSanitizer} from '@angular/platform-browser'; import {ThemeManager} from '../../../../core/services/theme-manager.service'; import {CodeHighlighter} from '../../code-highlighting/code-highlighter'; @Component({ selector: 'adev-code-block', template: `<pre><code [innerHTML]="highlightedCode() | async"></code></pre>`, imports: [AsyncPipe], styles: ` ::ng-deep pre { margin: 0; } `, }) export class CodeBlock { codeHighlighter = inject(CodeHighlighter); code = input.required<string>(); language = input<'angular-html' | 'angular-ts'>('angular-ts'); sanitizer = inject(DomSanitizer); theme = inject(ThemeManager); highlightedCode = computed(() => { return this.codeHighlighter .codeToHtml(this.code(), { cssVariablePrefix: '--shiki-', lang: this.language(), theme: this.theme.theme() === 'light' ? 'github-light' : 'github-dark', }) .then((hightlightedHtml) => { return this.sanitizer.bypassSecurityTrustHtml(hightlightedHtml); }); }); }