Skip to content

Commit 81147b3

Browse files
committed
Tweak line number service
1 parent 2fc6690 commit 81147b3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/app/public/ngx-gist-line-numbers.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export class NgxGistLineNumbersService {
99
private isLoaded = false;
1010

1111
public async load(): Promise<void> {
12-
if (this.isLoaded) {
12+
if (
13+
this.isLoaded ||
14+
typeof this.document.defaultView?.hljs?.initLineNumbersOnLoad ===
15+
'function'
16+
) {
1317
return;
1418
}
1519

@@ -24,7 +28,7 @@ export class NgxGistLineNumbersService {
2428
);
2529
}
2630

27-
firstValueFrom(this.loadHljsLineNumbersLibrary()).then(() => {
31+
await firstValueFrom(this.loadHljsLineNumbersLibrary()).then(() => {
2832
// The library `highlightjs-line-numbers.js` adds new functions to the
2933
// `highlight.js` scope on load, so we should now be able to call it
3034
// without failure.

0 commit comments

Comments
 (0)