Skip to content

Commit

Permalink
fix: correct render editor-socket (#1389)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Sep 16, 2024
1 parent 4890065 commit f0c86b8
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
inject,
Input,
SecurityContext,
signal,
ViewEncapsulation,
} from '@angular/core';
import type {SafeHtml} from '@angular/platform-browser';
Expand All @@ -24,7 +25,7 @@ import {TUI_EDITOR_SANITIZER} from '../../tokens/editor-sanitizer';
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class.tui-editor-socket]': 'options.enableDefaultStyles',
'[innerHTML]': 'innerHtml',
'[innerHTML]': 'html()',
'(click)': 'click($event)',
},
})
Expand All @@ -34,19 +35,19 @@ export class TuiEditorSocket {
private readonly sanitizer = inject(DomSanitizer);
private readonly document = inject(DOCUMENT);
protected readonly options = inject(TUI_EDITOR_OPTIONS);
protected readonly html = signal<SafeHtml | string | null>(null);

@Input()
public content: string | null = null;

public get innerHtml(): SafeHtml | null {
if (!this.content) {
return null;
public set content(content: string | null) {
if (!content) {
return;
}

return (
this.customSanitizer?.sanitize(SecurityContext.HTML, this.content) ??
this.sanitizer.bypassSecurityTrustHtml(this.content)
);
const safety =
this.customSanitizer?.sanitize(SecurityContext.HTML, content) ??
this.sanitizer.bypassSecurityTrustHtml(content ?? '');

this.html.set(safety);
}

/**
Expand Down

0 comments on commit f0c86b8

Please sign in to comment.