mirror of
https://github.com/storybookjs/storybook.git
synced 2026-09-28 18:03:02 +08:00
28 lines
794 B
TypeScript
28 lines
794 B
TypeScript
import { Component, Input } from '@angular/core';
|
|
// DomSanitizer must be a regular import, not a type-only import, because it's used in dependency injection.
|
|
// Type-only imports are stripped during compilation, causing runtime errors like "DomSanitizer is not defined".
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
@Component({
|
|
standalone: false,
|
|
selector: 'storybook-html',
|
|
template: `
|
|
<div [innerHTML]="safeContent"></div>
|
|
`,
|
|
})
|
|
export default class HtmlComponent {
|
|
/**
|
|
* The HTML to render
|
|
*
|
|
* @required
|
|
*/
|
|
@Input()
|
|
content = '';
|
|
|
|
constructor(private sanitizer: DomSanitizer) {}
|
|
|
|
get safeContent() {
|
|
return this.sanitizer.bypassSecurityTrustHtml(this.content);
|
|
}
|
|
}
|