highlight, math, notes and zoom plugins now register via Reveal.registerPlugin

edit
Hakim El Hattab 2019-03-04 14:32:38 +01:00
parent d780352b7f
commit c40e9819a2
5 changed files with 92 additions and 61 deletions

View File

@ -402,7 +402,7 @@ Reveal.addEventListener( 'customevent', function() {
dependencies: [
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/highlight/highlight.js', async: true },
{ src: 'plugin/search/search.js', async: true },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }

File diff suppressed because one or more lines are too long

View File

@ -20,28 +20,6 @@ var RevealMath = window.RevealMath || (function(){
skipStartupTypeset: true
};
defaults( options, defaultOptions );
defaults( options.tex2jax, defaultOptions.tex2jax );
options.mathjax = options.config = null;
loadScript( url, function() {
MathJax.Hub.Config( options );
// Typeset followed by an immediate reveal.js layout since
// the typesetting process could affect slide height
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
MathJax.Hub.Queue( Reveal.layout );
// Reprocess equations in slides when they turn visible
Reveal.addEventListener( 'slidechanged', function( event ) {
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );
} );
} );
function defaults( options, defaultOptions ) {
for ( var i in defaultOptions ) {
@ -81,4 +59,37 @@ var RevealMath = window.RevealMath || (function(){
}
return {
init: function() {
defaults( options, defaultOptions );
defaults( options.tex2jax, defaultOptions.tex2jax );
options.mathjax = options.config = null;
loadScript( url, function() {
MathJax.Hub.Config( options );
// Typeset followed by an immediate reveal.js layout since
// the typesetting process could affect slide height
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
MathJax.Hub.Queue( Reveal.layout );
// Reprocess equations in slides when they turn visible
Reveal.addEventListener( 'slidechanged', function( event ) {
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );
} );
} );
// lofi xbrowser Promise.resolve()
return { then: function( resolve ) { resolve(); }};
}
}
})();
Reveal.registerPlugin( 'math', RevealMath );

View File

@ -168,7 +168,8 @@ var RevealNotes = (function() {
}
return Promise.resolve();
// lofi xbrowser Promise.resolve()
return { then: function( resolve ) { resolve(); }};
},

View File

@ -1,9 +1,10 @@
// Custom reveal.js integration
(function(){
var revealElement = document.querySelector( '.reveal' );
if( revealElement ) {
var RevealZoom = (function(){
revealElement.addEventListener( 'mousedown', function( event ) {
return {
init: function() {
Reveal.getRevealElement().addEventListener( 'mousedown', function( event ) {
var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt';
var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key';
@ -21,9 +22,16 @@
}
} );
// lofi xbrowser Promise.resolve()
return { then: function( resolve ) { resolve(); }};
}
}
})();
Reveal.registerPlugin( 'zoom', RevealZoom );
/*!
* zoom.js 0.3 (modified for use with reveal.js)
* http://lab.hakim.se/zoom-js