esm readme tweak

This commit is contained in:
Hakim El Hattab 2020-04-26 08:34:02 +02:00
parent b61a6a6f10
commit c7c09644f0
1 changed files with 10 additions and 5 deletions

View File

@ -189,10 +189,9 @@ Here's how to import and initialize the ES module version of reveal.js, includin
```html
<script type="module">
import Reveal from '/dist/reveal.js';
import markdown from '/plugin/markdown/markdown.js';
import Markdown from '/plugin/markdown/markdown.js';
Reveal.initialize({
keyboard: true,
plugins: [ markdown() ]
plugins: [ Markdown ]
});
</script>
```
@ -625,6 +624,8 @@ loaded when they become visible.
### Plugins
**Outdated, this will be rewritten to match the 4.0 plugin API**
Plugins should register themselves with reveal.js by calling `Reveal.registerPlugin( MyPlugin )`. Registered plugins _must_ expose a unique `id` property and can optionally expose an `init` function that reveal.js will call to initialize them.
When reveal.js is booted up via `initialize()`, it will go through all registered plugins and invoke their `init` methods. If the `init` method returns a Promise, reveal.js will wait for that promise to be fulfilled before finishing the startup sequence and firing the [ready](#ready-event) event. Heres an example of a plugin that does some asynchronous work before reveal.js can proceed:
@ -643,11 +644,15 @@ Reveal.initialize({
} );
```
Note that reveal.js will *not* wait for init Promise fulfillment if the plugin is loaded as an [async dependency](#dependencies). If the plugins init method does _not_ return a Promise, the plugin is considered ready right away and will not hold up the reveal.js startup sequence.
If the plugins init method does _not_ return a Promise, the plugin is considered ready right away and will not hold up the reveal.js startup sequence.
### Manually Registering Plugins
TBD. Describe how plugins can be registered after reveal.js is already initialized.
### Retrieving Plugins
If you want to check if a specific plugin is registered you can use the `Reveal.hasPlugin` method and pass in a plugin ID, for example: `Reveal.hasPlugin( myPlugin )`. If you want to retrieve a plugin instance you can use `Reveal.getPlugin( myPlugin )`.
If you want to check if a specific plugin is registered you can use the `Reveal.hasPlugin` method and pass in a plugin ID, for example: `Reveal.hasPlugin( my-plugin )`. If you want to retrieve a plugin instance you can use `Reveal.getPlugin( my-plugin )`.
### Dependencies