Skip to content

Commit

Permalink
fix(addon-doc): code glitch in ssr (#8705)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Aug 28, 2024
1 parent 9c501b2 commit 59712a2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions projects/addon-doc/components/code/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import {ClipboardModule} from '@angular/cdk/clipboard';
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
import {ChangeDetectionStrategy, Component, inject, Input} from '@angular/core';
import {AsyncPipe, isPlatformServer, NgForOf, NgIf} from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
inject,
Input,
PLATFORM_ID,
} from '@angular/core';
import {toSignal} from '@angular/core/rxjs-interop';
import {
TUI_DOC_EXAMPLE_MARKDOWN_CODE_PROCESSOR,
Expand All @@ -21,13 +27,16 @@ import {BehaviorSubject, map, startWith, Subject, switchMap, timer} from 'rxjs';
styleUrls: ['./index.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[style.visibility]': 'isServer ? "hidden" : "visible"',
'[class._has-filename]': 'hasFilename',
},
})
export class TuiDocCode {
private readonly icons = inject(TUI_DOC_ICONS);
private readonly rawLoader$$ = new BehaviorSubject<TuiRawLoaderContent>('');

protected readonly isServer = isPlatformServer(inject(PLATFORM_ID));

protected readonly markdownCodeProcessor = inject<TuiHandler<string, string[]>>(
TUI_DOC_EXAMPLE_MARKDOWN_CODE_PROCESSOR,
);
Expand Down

0 comments on commit 59712a2

Please sign in to comment.