gzuidhof / starboard-wrap

🌯A small library that wraps a Starboard Notebook iframe in the parent webpage
Mozilla Public License 2.0
14 stars 10 forks source link

How to register plugin? #10

Open stefaneidelloth opened 3 years ago

stefaneidelloth commented 3 years ago

I would like to use the starboard-observable plugin with starboard-wrap. => How can I do so?

Suggestion: allow to pass some urls to be included as plugin to the constructor:

let starboardUrl = "https://cdn.starboard.gg/npm/starboard-notebook@0.13.2/dist/index.html"; let pluginUrl = "../../../../node_modules/starboard-observable/dist/starboard-observable.js"; let starBoard = new StarboardEmbed({ notebookContent: initialValue, src: starboardUrl, pluginSrc: [pluginUrl] });

If I try to directly import the plugin in the file where I create StarboardEmbed, I get

image

image

=> In order to import a plugin, the runtime needs to exist in the current scope.

stefaneidelloth commented 3 years ago

As a workaround I could specify some initial esm notebook content that registers the plugin from within the notebook:

# %%--- [esm]
# properties:
#   run_on_load: true
#   collapsed: false
# ---%%
import {plugin} from "https://cdn.skypack.dev/starboard-observable@0.1.6";
runtime.controls.registerPlugin(plugin);

image

However, I would prefer to do it in the background (not show that part to the users of the notebook at all).