plugins can be direct references or factory functions

master
Hakim El Hattab 2020-04-23 09:39:26 +02:00
parent c1b2e415db
commit 210fbb7646
8 changed files with 26 additions and 23 deletions

View File

@ -413,11 +413,11 @@ Reveal.on( 'customevent', function() {
<script type="module">
import Reveal from '/dist/reveal.js';
import zoom from '/plugin/zoom/zoom.js';
import notes from '/plugin/notes/notes.js';
import search from '/plugin/search/search.js';
import markdown from '/plugin/markdown/markdown.js';
import highlight from '/plugin/highlight/highlight.js';
import Zoom from '/plugin/zoom/zoom.js';
import Notes from '/plugin/notes/notes.js';
import Search from '/plugin/search/search.js';
import Markdown from '/plugin/markdown/markdown.js';
import Highlight from '/plugin/highlight/highlight.js';
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
@ -428,8 +428,8 @@ Reveal.on( 'customevent', function() {
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
plugins: [ zoom(), notes(), search(), markdown(), highlight() ]
// More info https://github.com/hakimel/reveal.js#plugins
plugins: [ Zoom, Notes, Search, Markdown, Highlight ]
});
</script>

2
dist/reveal.es5.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -39,16 +39,14 @@ const rollupConfig = {
babel({
exclude: 'node_modules/**',
compact: false,
presets: [
[
'@babel/preset-env',
{
corejs: 3,
useBuiltIns: 'entry',
modules: false
}
]
]
presets: [[
'@babel/preset-env',
{
corejs: 3,
useBuiltIns: 'entry',
modules: false
}
]]
}),
resolve(),
terser()

View File

@ -28,10 +28,10 @@
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
// - https://github.com/hakimel/reveal.js#plugins
Reveal.initialize({
hash: true,
plugins: [ RevealMarkdown(), RevealHighlight(), RevealNotes() ]
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
});
</script>
</body>

View File

@ -183,6 +183,11 @@ export default class Plugins {
plugin = arguments[1];
plugin.id = arguments[0];
}
// Plugin can optionally be a function which we call
// to create an instance of the plugin
else if( typeof plugin === 'function' ) {
plugin = plugin();
}
let id = plugin.id;