mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 03:12:35 +02:00
fix(theme): Restore former globalThis.Prism (#10618)
This commit is contained in:
parent
d723a1ee46
commit
52e50d29bc
1 changed files with 6 additions and 0 deletions
|
@ -23,6 +23,8 @@ export default function prismIncludeLanguages(
|
|||
// avoid polluting global namespace.
|
||||
// You can mutate PrismObject: registering plugins, deleting languages... As
|
||||
// long as you don't re-assign it
|
||||
|
||||
const PrismBefore = globalThis.Prism;
|
||||
globalThis.Prism = PrismObject;
|
||||
|
||||
additionalLanguages.forEach((lang) => {
|
||||
|
@ -34,5 +36,9 @@ export default function prismIncludeLanguages(
|
|||
require(`prismjs/components/prism-${lang}`);
|
||||
});
|
||||
|
||||
// Clean up and eventually restore former globalThis.Prism object (if any)
|
||||
delete (globalThis as Optional<typeof globalThis, 'Prism'>).Prism;
|
||||
if (typeof PrismBefore !== 'undefined') {
|
||||
globalThis.Prism = PrismObject;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue