Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit afb830a

Browse files
fix: switch between slot types and reload of the code
1 parent 5207605 commit afb830a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

studio/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents/highlight-code/src/components/highlight-code/deckdeckgo-highlight-code.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ export class DeckdeckgoHighlightCode {
3333
private anchorOffsetTop: number = 0;
3434

3535
async componentDidLoad() {
36+
const languageWasLoaded: boolean = await this.languageDidLoad();
37+
3638
await this.loadLanguage();
3739

38-
if (this.language === 'javascript') {
40+
if (languageWasLoaded) {
3941
await this.fetchOrParse();
4042
}
4143
}
@@ -59,6 +61,27 @@ export class DeckdeckgoHighlightCode {
5961
}
6062
}
6163

64+
private languageDidLoad(): Promise<boolean> {
65+
return new Promise<boolean>((resolve) => {
66+
if (!document || !this.language || this.language === '') {
67+
resolve(false);
68+
return;
69+
}
70+
71+
if (this.language === 'javascript') {
72+
resolve(true);
73+
return;
74+
}
75+
76+
const scripts = document.querySelector('[deckdeckgo-prism-loaded=\'' + this.language + '\']');
77+
if (scripts) {
78+
resolve(true);
79+
} else {
80+
resolve(false);
81+
}
82+
});
83+
}
84+
6285
@Watch('language')
6386
loadLanguage(): Promise<void> {
6487
return new Promise<void>(async (resolve) => {

0 commit comments

Comments
 (0)