initialize plugins serially
This commit is contained in:
parent
561c3ff443
commit
08f29f08a2
2
dist/plugin/markdown.js
vendored
2
dist/plugin/markdown.js
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.min.js
vendored
2
dist/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -85,7 +85,8 @@ export default class Plugins {
|
|||
|
||||
return new Promise( resolve => {
|
||||
|
||||
let pluginsToInitialize = Object.keys( this.registeredPlugins ).length;
|
||||
let pluginValues = Object.values( this.registeredPlugins );
|
||||
let pluginsToInitialize = pluginValues.length;
|
||||
|
||||
// If there are no plugins, skip this step
|
||||
if( pluginsToInitialize === 0 ) {
|
||||
|
@ -94,23 +95,31 @@ export default class Plugins {
|
|||
// ... otherwise initialize plugins
|
||||
else {
|
||||
|
||||
let initNextPlugin;
|
||||
|
||||
let afterPlugInitialized = () => {
|
||||
if( --pluginsToInitialize === 0 ) {
|
||||
this.loadAsync().then( resolve );
|
||||
}
|
||||
else {
|
||||
initNextPlugin();
|
||||
}
|
||||
};
|
||||
|
||||
for( let i in this.registeredPlugins ) {
|
||||
let i = 0;
|
||||
|
||||
let plugin = this.registeredPlugins[i];
|
||||
// Initialize plugins serially
|
||||
initNextPlugin = () => {
|
||||
|
||||
let plugin = pluginValues[i++];
|
||||
|
||||
// If the plugin has an 'init' method, invoke it
|
||||
if( typeof plugin.init === 'function' ) {
|
||||
let callback = plugin.init( this.Reveal );
|
||||
let promise = plugin.init( this.Reveal );
|
||||
|
||||
// If the plugin returned a Promise, wait for it
|
||||
if( callback && typeof callback.then === 'function' ) {
|
||||
callback.then( afterPlugInitialized );
|
||||
if( promise && typeof promise.then === 'function' ) {
|
||||
promise.then( afterPlugInitialized );
|
||||
}
|
||||
else {
|
||||
afterPlugInitialized();
|
||||
|
@ -122,6 +131,8 @@ export default class Plugins {
|
|||
|
||||
}
|
||||
|
||||
initNextPlugin();
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
|
|
2096
package-lock.json
generated
2096
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -15,13 +15,15 @@ export default {
|
|||
* current reveal.js deck.
|
||||
*/
|
||||
init: function( deck ) {
|
||||
if( typeof window.hljs !== 'undefined' ) {
|
||||
marked.setOptions({
|
||||
highlight: function( code, lang ) {
|
||||
return window.hljs.highlightAuto( code, lang ? [lang] : null ).value;
|
||||
}
|
||||
});
|
||||
}
|
||||
// This should no longer be needed, as long as the highlight.js
|
||||
// plugin is included after the markdown plugin
|
||||
// if( typeof window.hljs !== 'undefined' ) {
|
||||
// marked.setOptions({
|
||||
// highlight: function( code, lang ) {
|
||||
// return window.hljs.highlightAuto( code, lang ? [lang] : null ).value;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// marked can be configured via reveal.js config options
|
||||
var options = deck.getConfig().markdown;
|
||||
|
|
Loading…
Reference in New Issue
Block a user