Sandbox: Make `window.monaco` and `window.Prism` available for plugins inside the sandbox (#74977)

* Sandbox: Make `window.monaco` available for plugins inside the sandbox

* Add Prism as an endowment

* Fix typo
pull/74984/head
Esteban Beltran 2 years ago committed by GitHub
parent dfd6134ff1
commit c7b6ac065a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      public/app/features/plugins/sandbox/sandbox_plugin_loader.ts

@ -80,6 +80,15 @@ async function doImportPluginModuleInSandbox(meta: PluginMeta): Promise<System.M
// window.locationSandbox. In the future `window.location` could be a proxy if we
// want to intercept calls to it.
locationSandbox: window.location,
get monaco() {
// `window.monaco` may be undefined when invoked. However, plugins have long
// accessed it directly, aware of this possibility.
return Reflect.get(window, 'monaco');
},
get Prism() {
// Similar to `window.monaco`, `window.Prism` may be undefined when invoked.
return Reflect.get(window, 'Prism');
},
// Plugins builds use the AMD module system. Their code consists
// of a single function call to `define()` that internally contains all the plugin code.
// This is that `define` function the plugin will call.

Loading…
Cancel
Save