aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Berezin <berezinant@gmail.com>2024-05-07 16:11:42 +0200
committerGitHub <noreply@github.com>2024-05-07 16:11:42 +0200
commit2d45e27b1e727e0cb3fe0a456a5c04de7d249af5 (patch)
tree5064a2bd0656cf2195055baec546de34a8e6077d
parentbf056d64fca71627938457478c214be2afc4b167 (diff)
downloaddokka-upstream-master.tar.gz
fix: made code samples runnable (#3535) (#3596)upstream-master
-rw-r--r--dokka-subprojects/plugin-base/src/main/resources/dokka/scripts/platform-content-handler.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/dokka-subprojects/plugin-base/src/main/resources/dokka/scripts/platform-content-handler.js b/dokka-subprojects/plugin-base/src/main/resources/dokka/scripts/platform-content-handler.js
index b40ee62b0..8235caed8 100644
--- a/dokka-subprojects/plugin-base/src/main/resources/dokka/scripts/platform-content-handler.js
+++ b/dokka-subprojects/plugin-base/src/main/resources/dokka/scripts/platform-content-handler.js
@@ -104,6 +104,11 @@ const initPlayground = (theme) => {
// As an alternative we could extract this samples-specific script to new js file but then we would handle dark mode in 2 separate files which is not ideal
const samplesAreEnabled = () => {
try {
+ if (typeof KotlinPlayground === 'undefined') {
+ // KotlinPlayground is exported universally as a global variable or as a module
+ // Due to possible interaction with other js scripts KotlinPlayground may not be accessible directly from `window`, so we need an additional check
+ KotlinPlayground = exports.KotlinPlayground;
+ }
KotlinPlayground
return true
} catch (e) {