소스 검색

initialize plugins serially

Hakim El Hattab 5 년 전
부모
커밋
08f29f08a2
5개의 변경된 파일390개의 추가작업 그리고 342개의 파일을 삭제
  1. 0 0
      dist/plugin/markdown.js
  2. 0 0
      dist/reveal.min.js
  3. 17 6
      js/controllers/plugins.js
  4. 364 329
      package-lock.json
  5. 9 7
      plugin/markdown/markdown.js

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/plugin/markdown.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/reveal.min.js


+ 17 - 6
js/controllers/plugins.js

@@ -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();
+
 			}
 
 		} )

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 364 - 329
package-lock.json


+ 9 - 7
plugin/markdown/markdown.js

@@ -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;

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.