plugins can be direct references or factory functions

This commit is contained in:
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"> <script type="module">
import Reveal from '/dist/reveal.js'; import Reveal from '/dist/reveal.js';
import zoom from '/plugin/zoom/zoom.js'; import Zoom from '/plugin/zoom/zoom.js';
import notes from '/plugin/notes/notes.js'; import Notes from '/plugin/notes/notes.js';
import search from '/plugin/search/search.js'; import Search from '/plugin/search/search.js';
import markdown from '/plugin/markdown/markdown.js'; import Markdown from '/plugin/markdown/markdown.js';
import highlight from '/plugin/highlight/highlight.js'; import Highlight from '/plugin/highlight/highlight.js';
// More info https://github.com/hakimel/reveal.js#configuration // More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({ Reveal.initialize({
@ -428,8 +428,8 @@ Reveal.on( 'customevent', function() {
transition: 'slide', // none/fade/slide/convex/concave/zoom transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies // More info https://github.com/hakimel/reveal.js#plugins
plugins: [ zoom(), notes(), search(), markdown(), highlight() ] plugins: [ Zoom, Notes, Search, Markdown, Highlight ]
}); });
</script> </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({ babel({
exclude: 'node_modules/**', exclude: 'node_modules/**',
compact: false, compact: false,
presets: [ presets: [[
[
'@babel/preset-env', '@babel/preset-env',
{ {
corejs: 3, corejs: 3,
useBuiltIns: 'entry', useBuiltIns: 'entry',
modules: false modules: false
} }
] ]]
]
}), }),
resolve(), resolve(),
terser() terser()

View File

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

View File

@ -183,6 +183,11 @@ export default class Plugins {
plugin = arguments[1]; plugin = arguments[1];
plugin.id = arguments[0]; 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; let id = plugin.id;