convert plugins to ES modules, transpile es5 versions backwards compatibility

This commit is contained in:
Hakim El Hattab 2020-04-15 10:23:51 +02:00
parent 9522357349
commit a55cd813be
36 changed files with 3018 additions and 886 deletions

View file

@ -410,11 +410,17 @@ Reveal.on( 'customevent', function() {
</div>
<script type="module" src="js/index.js"></script>
<script type="module">
import Reveal from '/js/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';
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
let deck = new Reveal( document.querySelector( '.reveal' ), {
controls: true,
progress: true,
center: true,
@ -423,16 +429,11 @@ Reveal.on( 'customevent', function() {
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
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' },
{ src: 'plugin/search/search.js', async: true },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
dependencies: [ Zoom, Notes, Search, Markdown, Highlight ]
});
deck.initialize();
</script>
</body>

5
dist/plugin/highlight.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/plugin/markdown.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/plugin/math.js vendored Normal file
View file

@ -0,0 +1 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}({7:function(e,t,n){"use strict";n.r(t);var r=function(){var e=Reveal.getConfig().math||{},t=(e.mathjax||"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js")+"?config="+(e.config||"TeX-AMS_HTML-full"),n={messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]],skipTags:["script","noscript","style","textarea","pre"]},skipStartupTypeset:!0};function r(e,t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}return{id:"math",init:function(a){r(e,n),r(e.tex2jax,n.tex2jax),e.mathjax=e.config=null,function(e,t){var n=document.querySelector("head"),r=document.createElement("script");r.type="text/javascript",r.src=e;var a=function(){"function"==typeof t&&(t.call(),t=null)};r.onload=a,r.onreadystatechange=function(){"loaded"===this.readyState&&a()},n.appendChild(r)}(t,(function(){MathJax.Hub.Config(e),MathJax.Hub.Queue(["Typeset",MathJax.Hub]),MathJax.Hub.Queue(a.layout),a.on("slidechanged",(function(e){MathJax.Hub.Queue(["Typeset",MathJax.Hub,e.currentSlide])}))}))}}}();Reveal.registerPlugin(r)}});

1
dist/plugin/notes.js vendored Normal file
View file

@ -0,0 +1 @@
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}({5:function(e,t,n){"use strict";n.r(t);var o=function(){var e,t=null;function n(n){var o;!t||t.closed?(n||(n="plugin/notes/notes.html"),(t=window.open(n,"reveal.js - Notes","width=1100,height=700"))?(o=setInterval((function(){t.postMessage(JSON.stringify({namespace:"reveal-notes",type:"connect",url:window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,state:e.getState()}),"*")}),500),window.addEventListener("message",(function(n){var a,i,s,l,u=JSON.parse(n.data);u&&"reveal-notes"===u.namespace&&"connected"===u.type&&(clearInterval(o),e.on("slidechanged",r),e.on("fragmentshown",r),e.on("fragmenthidden",r),e.on("overviewhidden",r),e.on("overviewshown",r),e.on("paused",r),e.on("resumed",r),r()),u&&"reveal-notes"===u.namespace&&"call"===u.type&&(a=u.methodName,i=u.arguments,s=u.callId,l=e[a].apply(e,i),t.postMessage(JSON.stringify({namespace:"reveal-notes",type:"return",result:l,callId:s}),"*"))}))):alert("Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.")):t.focus();function r(n){var o=e.getCurrentSlide(),r=o.querySelector("aside.notes"),a=o.querySelector(".current-fragment"),i={namespace:"reveal-notes",type:"state",notes:"",markdown:!1,whitespace:"normal",state:e.getState()};if(o.hasAttribute("data-notes")&&(i.notes=o.getAttribute("data-notes"),i.whitespace="pre-wrap"),a){var s=a.querySelector("aside.notes");s?r=s:a.hasAttribute("data-notes")&&(i.notes=a.getAttribute("data-notes"),i.whitespace="pre-wrap",r=null)}r&&(i.notes=r.innerHTML,i.markdown="string"==typeof r.getAttribute("data-markdown")),t.postMessage(JSON.stringify(i),"*")}}return{id:"notes",init:function(t){e=t,/receiver/i.test(window.location.search)||(null!==window.location.search.match(/(\?|\&)notes/gi)&&n(),e.addKeyBinding({keyCode:83,key:"S",description:"Speaker notes view"},(function(){n()})))},open:n}}();Reveal.registerPlugin(o)}});

1
dist/plugin/search.js vendored Normal file
View file

@ -0,0 +1 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}({4:function(e,t,n){"use strict";n.r(t);var r=function(){var e,t,n,r;function i(e,t){var n=document.getElementById(e)||document.body,r=t||"EM",i=new RegExp("^(?:"+r+"|SCRIPT|FORM)$"),o=["#ff6","#a0ffff","#9f9","#f99","#f6f"],l=[],a=0,c="",d=[];this.setRegex=function(e){e=e.replace(/^[^\w]+|[^\w]+$/g,"").replace(/[^\w'-]+/g,"|"),c=new RegExp("("+e+")","i")},this.getRegex=function(){return c.toString().replace(/^\/\\b\(|\)\\b\/i$/g,"").replace(/\|/g," ")},this.hiliteWords=function(e){if(null!=e&&e&&c&&!i.test(e.nodeName)){if(e.hasChildNodes())for(var t=0;t<e.childNodes.length;t++)this.hiliteWords(e.childNodes[t]);if(3==e.nodeType&&(nv=e.nodeValue)&&(regs=c.exec(nv))){for(var n=e;null!=n&&"SECTION"!=n.nodeName;)n=n.parentNode;var u=Reveal.getIndices(n),s=d.length,p=!1;for(t=0;t<s;t++)d[t].h===u.h&&d[t].v===u.v&&(p=!0);p||d.push(u),l[regs[0].toLowerCase()]||(l[regs[0].toLowerCase()]=o[a++%o.length]);var f=document.createElement(r);f.appendChild(document.createTextNode(regs[0])),f.style.backgroundColor=l[regs[0].toLowerCase()],f.style.fontStyle="inherit",f.style.color="#000";var g=e.splitText(regs.index);g.nodeValue=g.nodeValue.substring(regs[0].length),e.parentNode.insertBefore(f,g)}}},this.remove=function(){for(var e=document.getElementsByTagName(r);e.length&&(el=e[0]);)el.parentNode.replaceChild(el.firstChild,el)},this.apply=function(e){if(null!=e&&e)return this.remove(),this.setRegex(e),this.hiliteWords(n),d}}function o(){var e=document.getElementById("searchinputdiv"),t=document.getElementById("searchinput");e.style.display="inline",t.focus(),t.select()}function l(){document.getElementById("searchinputdiv").style.display="none",r&&r.remove()}function a(){if(n){var o=document.getElementById("searchinput").value;""===o?(r&&r.remove(),e=null):(r=new i("slidecontent"),e=r.apply(o),t=0)}e&&(e.length&&e.length<=t&&(t=0),e.length>t&&(Reveal.slide(e[t].h,e[t].v),t++))}var c={};if(c.wrapper=document.querySelector(".reveal"),!c.wrapper.querySelector(".searchbox")){var d=document.createElement("div");d.id="searchinputdiv",d.classList.add("searchdiv"),d.style.position="absolute",d.style.top="10px",d.style.right="10px",d.style.zIndex=10,d.innerHTML='<span><input type="search" id="searchinput" class="searchinput" style="vertical-align: top;"/><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJiSURBVHjatFZNaxNBGH5md+Mmu92NVdKDRipSAyqCghgQD4L4cRe86UUtAQ+eFCxoa4/25EXBFi8eBE+eRPoDhB6KgiiixdAPCEkx2pjvTXadd9yNsflwuyUDD/O+u8PzzDPvzOwyx3EwyCZhwG3gAkp7MnpjgbopjsltcD4gjuXZZKeAR348MYLYTm3LzOs/y3j3JTfZxgXWXmTuwPHIc4VmoOmv5IrI53+AO2DdHLjkDWQ3GoEEVFXtXQOvkSnPWcyUceviLhwbDYv8/XIVj97kse7TodLvZXxYxrPUHkQ1ufXs3FEdybEIxucySOesoNvUgWU1cP3MkCBfTFdw9fGaAMVmRELq7LBw2Q3/FaAxxWIRpw+ZIr/7IouPqzUBiqmdHAv7EuhRAwf1er2Vy4x1jW3b2d5Jfvu5IPp7l2LYbcgCFFNb+FoJ7oBqEAqFMPNqFcmEgVMJDfMT+1tvN0pNjERlMS6QA5pFOKxiKVPFhakPeL3It+WGJUDxt2wFR+JhzI7v5ctkd8DXOZAkCYYxhO+lKm4+Xfqz/rIixBuNBl7eOYzkQQNzqX249mRl6zUgEcYkaJrGhUwBinVdh6IouPzwE6/DL5w4oLkH8y981aDf+uq6hlKpJESiUdNfDZi7/ehG9K6KfiA3pml0PLcsq+cSMTj2NL9ukc4UOmz7AZ3+crkC4mHujFvXNaMFB3bEr8xPS6p5O+jXxq4VZtaen7/PwzrntjcLUE0iHPS1Ud1cdiEJl/8WivZk0wXd7zWOMkeF8s0CcAmkNrC2nvXZDbbbN73ccYnZoH9bfgswAFzAe9/h3dbKAAAAAElFTkSuQmCC" id="searchbutton" class="searchicon" style="vertical-align: top; margin-top: -1px;"/></span>',c.wrapper.appendChild(d)}return document.getElementById("searchbutton").addEventListener("click",(function(e){a()}),!1),document.getElementById("searchinput").addEventListener("keyup",(function(e){switch(e.keyCode){case 13:e.preventDefault(),a(),n=!1;break;default:n=!0}}),!1),document.addEventListener("keydown",(function(e){"F"==e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),"inline"!==document.getElementById("searchinputdiv").style.display?o():l())}),!1),l(),{id:"search",init:function(e){e.registerKeyboardShortcut("CTRL + Shift + F","Search")},open:o}}();Reveal.registerPlugin(r)}});

11
dist/plugin/zoom.js vendored Normal file
View file

@ -0,0 +1,11 @@
!function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=6)}({6:function(e,t,o){"use strict";o.r(t);
/*!
* reveal.js Zoom plugin
*/var n={id:"zoom",init:function(e){e.getRevealElement().addEventListener("mousedown",(function(t){var o=/Linux/.test(window.navigator.platform)?"ctrl":"alt",n=(e.getConfig().zoomKey?e.getConfig().zoomKey:o)+"Key",r=e.getConfig().zoomLevel?e.getConfig().zoomLevel:2;t[n]&&!e.isOverview()&&(t.preventDefault(),i.to({x:t.clientX,y:t.clientY,scale:r,pan:!1}))}))}},i=function(){var e=1,t=0,o=0,n=-1,r=-1,d="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style;function s(t,o){var n=u();if(t.width=t.width||1,t.height=t.height||1,t.x-=(window.innerWidth-t.width*o)/2,t.y-=(window.innerHeight-t.height*o)/2,d)if(1===o)document.body.style.transform="",document.body.style.OTransform="",document.body.style.msTransform="",document.body.style.MozTransform="",document.body.style.WebkitTransform="";else{var i=n.x+"px "+n.y+"px",r="translate("+-t.x+"px,"+-t.y+"px) scale("+o+")";document.body.style.transformOrigin=i,document.body.style.OTransformOrigin=i,document.body.style.msTransformOrigin=i,document.body.style.MozTransformOrigin=i,document.body.style.WebkitTransformOrigin=i,document.body.style.transform=r,document.body.style.OTransform=r,document.body.style.msTransform=r,document.body.style.MozTransform=r,document.body.style.WebkitTransform=r}else 1===o?(document.body.style.position="",document.body.style.left="",document.body.style.top="",document.body.style.width="",document.body.style.height="",document.body.style.zoom=""):(document.body.style.position="relative",document.body.style.left=-(n.x+t.x)/o+"px",document.body.style.top=-(n.y+t.y)/o+"px",document.body.style.width=100*o+"%",document.body.style.height=100*o+"%",document.body.style.zoom=o);e=o,document.documentElement.classList&&(1!==e?document.documentElement.classList.add("zoomed"):document.documentElement.classList.remove("zoomed"))}function l(){var n=.12*window.innerWidth,i=.12*window.innerHeight,r=u();o<i?window.scroll(r.x,r.y-14/e*(1-o/i)):o>window.innerHeight-i&&window.scroll(r.x,r.y+(1-(window.innerHeight-o)/i)*(14/e)),t<n?window.scroll(r.x-14/e*(1-t/n),r.y):t>window.innerWidth-n&&window.scroll(r.x+(1-(window.innerWidth-t)/n)*(14/e),r.y)}function u(){return{x:void 0!==window.scrollX?window.scrollX:window.pageXOffset,y:void 0!==window.scrollY?window.scrollY:window.pageYOffset}}return d&&(document.body.style.transition="transform 0.8s ease",document.body.style.OTransition="-o-transform 0.8s ease",document.body.style.msTransition="-ms-transform 0.8s ease",document.body.style.MozTransition="-moz-transform 0.8s ease",document.body.style.WebkitTransition="-webkit-transform 0.8s ease"),document.addEventListener("keyup",(function(t){1!==e&&27===t.keyCode&&i.out()})),document.addEventListener("mousemove",(function(n){1!==e&&(t=n.clientX,o=n.clientY)})),{to:function(t){if(1!==e)i.out();else{if(t.x=t.x||0,t.y=t.y||0,t.element){var o=t.element.getBoundingClientRect();t.x=o.left-20,t.y=o.top-20,t.width=o.width+40,t.height=o.height+40}void 0!==t.width&&void 0!==t.height&&(t.scale=Math.max(Math.min(window.innerWidth/t.width,window.innerHeight/t.height),1)),t.scale>1&&(t.x*=t.scale,t.y*=t.scale,s(t,t.scale),!1!==t.pan&&(n=setTimeout((function(){r=setInterval(l,1e3/60)}),800)))}},out:function(){clearTimeout(n),clearInterval(r),s({x:0,y:0},1),e=1},magnify:function(e){this.to(e)},reset:function(){this.out()},zoomLevel:function(){return e}}}();
/*!
* zoom.js 0.3 (modified for use with reveal.js)
* http://lab.hakim.se/zoom-js
* MIT licensed
*
* Copyright (C) 2011-2014 Hakim El Hattab, http://hakim.se
*/Reveal.registerPlugin(n)}});

4
dist/reveal.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -42,6 +42,24 @@ gulp.task('js', () => gulp.src(['./js/index.js'])
.pipe(rename('reveal.min.js'))
.pipe(gulp.dest('./dist')))
gulp.task('plugins', () => gulp.src(['./js/index.js'])
.pipe(webpack({
...require('./webpack.config.js'),
entry: {
'highlight': './plugin/highlight/highlight.es5',
'markdown': './plugin/markdown/markdown.es5',
'search': './plugin/search/search.es5',
'notes': './plugin/notes/notes.es5',
'zoom': './plugin/zoom/zoom.es5',
'math': './plugin/math/math.es5'
},
output: {
filename: '[name].js'
}
}))
.on('error', swallowError)
.pipe(gulp.dest('./dist/plugin')))
gulp.task('css-themes', () => gulp.src(['./css/theme/source/*.{sass,scss}'])
.pipe(sass())
.pipe(gulp.dest('./dist/theme')))

View file

@ -22,7 +22,6 @@
</div>
<script src="dist/reveal.min.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
@ -30,10 +29,9 @@
Reveal.initialize({
hash: true,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/highlight/highlight.js' },
{ src: 'plugin/notes/notes.js', async: true }
{ src: 'dist/plugin/markdown.js' },
{ src: 'dist/plugin/highlight.js' },
{ src: 'dist/plugin/notes.js' }
]
});
</script>

View file

@ -60,8 +60,8 @@ export default class Plugins {
// Load synchronous scripts
scripts.forEach( s => {
if( s.plugin ) {
this.registerPlugin( s.plugin );
if( typeof s.id === 'string' ) {
this.registerPlugin( s );
scriptLoadedCallback( s );
}
else {

View file

@ -28,7 +28,6 @@ import {
deserialize,
transformElement,
createSingletonNode,
closestParent,
getQueryHash,
getRemainingHeight
} from './utils/util.js'

5
package-lock.json generated
View file

@ -5205,6 +5205,11 @@
"minimalistic-assert": "^1.0.1"
}
},
"highlight.js": {
"version": "9.18.1",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.1.tgz",
"integrity": "sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg=="
},
"hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",

View file

@ -87,5 +87,8 @@
"no-eq-null": 2,
"no-unused-expressions": 0
}
},
"dependencies": {
"highlight.js": "^9.18.1"
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
/* highlightjs-line-numbers.js 2.6.0 | (C) 2018 Yauheni Pakala | MIT License | github.com/wcoder/highlightjs-line-numbers.js */
/* Edited by Hakim for reveal.js; removed async timeout */
!function(n,e){"use strict";function t(){var n=e.createElement("style");n.type="text/css",n.innerHTML=g(".{0}{border-collapse:collapse}.{0} td{padding:0}.{1}:before{content:attr({2})}",[v,L,b]),e.getElementsByTagName("head")[0].appendChild(n)}function r(t){"interactive"===e.readyState||"complete"===e.readyState?i(t):n.addEventListener("DOMContentLoaded",function(){i(t)})}function i(t){try{var r=e.querySelectorAll("code.hljs,code.nohighlight");for(var i in r)r.hasOwnProperty(i)&&l(r[i],t)}catch(o){n.console.error("LineNumbers error: ",o)}}function l(n,e){"object"==typeof n&&f(function(){n.innerHTML=s(n,e)})}function o(n,e){if("string"==typeof n){var t=document.createElement("code");return t.innerHTML=n,s(t,e)}}function s(n,e){e=e||{singleLine:!1};var t=e.singleLine?0:1;return c(n),a(n.innerHTML,t)}function a(n,e){var t=u(n);if(""===t[t.length-1].trim()&&t.pop(),t.length>e){for(var r="",i=0,l=t.length;i<l;i++)r+=g('<tr><td class="{0}"><div class="{1} {2}" {3}="{5}"></div></td><td class="{4}"><div class="{1}">{6}</div></td></tr>',[j,m,L,b,p,i+1,t[i].length>0?t[i]:" "]);return g('<table class="{0}">{1}</table>',[v,r])}return n}function c(n){var e=n.childNodes;for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];h(r.textContent)>0&&(r.childNodes.length>0?c(r):d(r.parentNode))}}function d(n){var e=n.className;if(/hljs-/.test(e)){for(var t=u(n.innerHTML),r=0,i="";r<t.length;r++){var l=t[r].length>0?t[r]:" ";i+=g('<span class="{0}">{1}</span>\n',[e,l])}n.innerHTML=i.trim()}}function u(n){return 0===n.length?[]:n.split(y)}function h(n){return(n.trim().match(y)||[]).length}function f(e){e()}function g(n,e){return n.replace(/\{(\d+)\}/g,function(n,t){return e[t]?e[t]:n})}var v="hljs-ln",m="hljs-ln-line",p="hljs-ln-code",j="hljs-ln-numbers",L="hljs-ln-n",b="data-line-number",y=/\r\n|\r|\n/g;n.hljs?(n.hljs.initLineNumbersOnLoad=r,n.hljs.lineNumbersBlock=l,n.hljs.lineNumbersValue=o,t()):n.console.error("highlight.js not detected!")}(window,document);

View file

@ -0,0 +1,7 @@
/**
* This is used to compile a self-registering
* es5 compatible version of the plugin.
*/
import plugin from './highlight.js'
Reveal.registerPlugin( plugin );

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
/**
* This is used to compile a self-registering
* es5 compatible version of the plugin.
*/
import plugin from './markdown.js'
Reveal.registerPlugin( plugin );

View file

@ -1,19 +1,46 @@
/**
/*!
* The reveal.js markdown plugin. Handles parsing of
* markdown inside of presentations as well as loading
* of external markdown documents.
*/
(function( root, factory ) {
if (typeof define === 'function' && define.amd) {
root.marked = require( './marked' );
root.RevealMarkdown = factory( root.marked );
} else if( typeof exports === 'object' ) {
module.exports = factory( require( './marked' ) );
} else {
// Browser globals (root is window)
root.RevealMarkdown = factory( root.marked );
import marked from './marked.js'
export default {
id: 'markdown',
/**
* Starts processing and converting Markdown within the
* current reveal.js deck.
*/
init: function( deck ) {
if( typeof hljs !== 'undefined' ) {
marked.setOptions({
highlight: function( code, lang ) {
return hljs.highlightAuto( code, [lang] ).value;
}
}( this, function( marked ) {
});
}
// marked can be configured via reveal.js config options
var options = deck.getConfig().markdown;
if( options ) {
marked.setOptions( options );
}
return processSlides( deck.getRevealElement() ).then( convertSlides );
},
// TODO: Do these belong in the API?
processSlides: processSlides,
convertSlides: convertSlides,
slidify: slidify,
marked: marked
};
var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$',
DEFAULT_NOTES_SEPARATOR = 'notes?:',
@ -138,7 +165,7 @@
// iterate until all blocks between separators are stacked up
while( matches = separatorRegex.exec( markdown ) ) {
notes = null;
var notes = null;
// determine direction (horizontal by default)
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
@ -195,13 +222,13 @@
* multi-slide markdown into separate sections and
* handles loading of external markdown.
*/
function processSlides() {
function processSlides( scope ) {
return new Promise( function( resolve ) {
var externalPromises = [];
[].slice.call( document.querySelectorAll( '[data-markdown]') ).forEach( function( section, i ) {
[].slice.call( scope.querySelectorAll( '[data-markdown]:not([data-markdown-parsed])') ).forEach( function( section, i ) {
if( section.getAttribute( 'data-markdown' ).length ) {
@ -258,7 +285,7 @@
var xhr = new XMLHttpRequest(),
url = section.getAttribute( 'data-markdown' );
datacharset = section.getAttribute( 'data-charset' );
var datacharset = section.getAttribute( 'data-charset' );
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
if( datacharset != null && datacharset != '' ) {
@ -287,7 +314,7 @@
xhr.send();
}
catch ( e ) {
alert( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e );
console.warn( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e );
resolve( xhr, url );
}
@ -309,6 +336,8 @@
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"]+?)\"|(data-[^\"= ]+?)(?=[\" ])", 'mg' );
var nodeValue = node.nodeValue;
var matches,
matchesClass;
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
var classes = matches[1];
@ -333,13 +362,13 @@
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
previousParentElement = element;
var previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) {
childElement = element.childNodes[i];
var childElement = element.childNodes[i];
if ( i > 0 ) {
j = i - 1;
var j = i - 1;
while ( j >= 0 ) {
aPreviousChildElement = element.childNodes[j];
var aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
previousParentElement = aPreviousChildElement;
break;
@ -347,7 +376,7 @@
j = j - 1;
}
}
parentSection = section;
var parentSection = section;
if( childElement.nodeName == "section" ) {
parentSection = childElement ;
previousParentElement = childElement ;
@ -399,51 +428,3 @@
return Promise.resolve();
}
// API
var RevealMarkdown = {
id: 'markdown',
/**
* Starts processing and converting Markdown within the
* current reveal.js deck.
*/
init: function( deck ) {
if( typeof marked === 'undefined' ) {
throw 'The reveal.js Markdown plugin requires marked to be loaded';
}
if( typeof hljs !== 'undefined' ) {
marked.setOptions({
highlight: function( code, lang ) {
return hljs.highlightAuto( code, [lang] ).value;
}
});
}
// marked can be configured via reveal.js config options
var options = deck.getConfig().markdown;
if( options ) {
marked.setOptions( options );
}
return processSlides().then( convertSlides );
},
// TODO: Do these belong in the API?
processSlides: processSlides,
convertSlides: convertSlides,
slidify: slidify
};
// Register our plugin so that reveal.js will call our
// plugin 'init' method as part of the initialization
Reveal.registerPlugin( RevealMarkdown );
return RevealMarkdown;
}));

File diff suppressed because one or more lines are too long

7
plugin/math/math.es5 Normal file
View file

@ -0,0 +1,7 @@
/**
* This is used to compile a self-registering
* es5 compatible version of the plugin.
*/
import plugin from './math.js'
Reveal.registerPlugin( plugin );

View file

@ -4,7 +4,7 @@
*
* @author Hakim El Hattab
*/
var RevealMath = window.RevealMath || (function(){
var RevealMath = (function(){
var options = Reveal.getConfig().math || {};
var mathjax = options.mathjax || 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
@ -91,4 +91,4 @@ var RevealMath = window.RevealMath || (function(){
})();
Reveal.registerPlugin( RevealMath );
export default RevealMath;

7
plugin/notes/notes.es5 Normal file
View file

@ -0,0 +1,7 @@
/**
* This is used to compile a self-registering
* es5 compatible version of the plugin.
*/
import plugin from './notes.js'
Reveal.registerPlugin( plugin );

View file

@ -23,9 +23,10 @@ var RevealNotes = (function() {
}
if( !notesFilePath ) {
var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path
jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path
notesFilePath = jsFileLocation + 'notes.html';
// var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path
// jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path
// notesFilePath = jsFileLocation + 'notes.html';
notesFilePath = 'plugin/notes/notes.html'
}
notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' );
@ -156,9 +157,9 @@ var RevealNotes = (function() {
return {
id: 'notes',
init: function( revealInstance ) {
init: function( reveal ) {
deck = revealInstance;
deck = reveal;
if( !/receiver/i.test( window.location.search ) ) {
@ -181,4 +182,4 @@ var RevealNotes = (function() {
})();
Reveal.registerPlugin( RevealNotes );
export default RevealNotes;

7
plugin/search/search.es5 Normal file
View file

@ -0,0 +1,7 @@
/**
* This is used to compile a self-registering
* es5 compatible version of the plugin.
*/
import plugin from './search.js'
Reveal.registerPlugin( plugin );

View file

@ -200,7 +200,22 @@ function Hilitor(id, tag)
toggleSearch();
}
}, false );
if( window.Reveal ) Reveal.registerKeyboardShortcut( 'CTRL + Shift + F', 'Search' );
closeSearch();
return { open: openSearch };
return {
id: 'search',
init: reveal => {
reveal.registerKeyboardShortcut( 'CTRL + Shift + F', 'Search' );
},
open: openSearch
}
})();
export default RevealSearch;

7
plugin/zoom/zoom.es5 Normal file
View file

@ -0,0 +1,7 @@
/**
* This is used to compile a self-registering
* es5 compatible version of the plugin.
*/
import plugin from './zoom.js'
Reveal.registerPlugin( plugin );

View file

@ -1,7 +1,8 @@
// Custom reveal.js integration
var RevealZoom = (function(){
/*!
* reveal.js Zoom plugin
*/
export default {
return {
id: 'zoom',
init: function( reveal ) {
@ -25,11 +26,8 @@ var RevealZoom = (function(){
} );
}
}
})();
Reveal.registerPlugin( RevealZoom );
};
/*!
* zoom.js 0.3 (modified for use with reveal.js)

View file

@ -195,7 +195,7 @@
},
dependencies: [
{ src: '../../plugin/math/math.js', async: true }
{ src: '../../dist/plugin/math.js', async: true }
]
});

View file

@ -17,7 +17,11 @@
<div style="display: flex; flex-direction: row;">
<div class="reveal deck1" style="width: 100%; height: 50vh; margin: 10px;">
<div class="slides">
<section>1.1</section>
<section data-markdown>
<script type="text/template">
## Slide attributes
</script>
</section>
<section>1.2</section>
<section>1.3</section>
</div>
@ -25,7 +29,11 @@
<div class="reveal deck2" style="width: 100%; height: 50vh; margin: 10px;">
<div class="slides">
<section>2.1</section>
<section data-markdown>
<script type="text/template">
## Slide attributes
</script>
</section>
<section>2.2</section>
<section>2.3</section>
</div>
@ -34,20 +42,25 @@
<script src="../../dist/reveal.min.js"></script>
<script>
<script type="module">
import Markdown from '../../plugin/markdown/markdown.js';
let r1 = new Reveal( document.querySelector( '.deck1' ), {
embedded: true,
keyboard: false
} );
r1.initialize();
r1.initialize().then( () => {
let r2 = new Reveal( document.querySelector( '.deck2' ), {
embedded: true,
keyboard: false
keyboard: false,
dependencies: [{plugin: Markdown}]
} );
r2.initialize();
} );
</script>
</body>

View file

@ -122,13 +122,12 @@
</div>
<script src="../dist/reveal.min.js"></script>
<script>
<script type="module">
import '../js/index.js'
import Markdown from '../plugin/markdown/markdown.js'
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
dependencies: [ Markdown ]
}).then( function() {
QUnit.module( 'Markdown' );

View file

@ -24,14 +24,12 @@
</div>
<script src="qunit-2.5.0.js"></script>
<script src="../dist/reveal.min.js"></script>
<script>
<script type="module">
import '../js/index.js'
import Markdown from '../plugin/markdown/markdown.js'
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
dependencies: [ Markdown ]
}).then( function() {
QUnit.module( 'Markdown' );

View file

@ -32,15 +32,13 @@
</div>
<script src="qunit-2.5.0.js"></script>
<script src="../dist/reveal.min.js"></script>
<script>
<script type="module">
import '../js/index.js'
import Markdown from '../plugin/markdown/markdown.js'
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
// Test loading JS files with query strings
{ src: '../plugin/markdown/markdown.js?query=string' },
],
dependencies: [ Markdown ],
markdown: {
smartypants: true
}
@ -49,7 +47,7 @@
QUnit.module( 'Markdown' );
QUnit.test( 'Options are set', function( assert ) {
assert.strictEqual( marked.defaults.smartypants, true );
assert.strictEqual( Reveal.getPlugin( 'markdown' ).marked.defaults.smartypants, true );
});
QUnit.test( 'Smart quotes are activated', function( assert ) {

View file

@ -117,14 +117,13 @@
</div>
<script src="qunit-2.5.0.js"></script>
<script src="../dist/reveal.min.js"></script>
<script>
<script type="module">
import '../js/index.js'
import Markdown from '../plugin/markdown/markdown.js'
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
dependencies: [ Markdown ]
}).then( function() {
QUnit.module( 'Markdown' );

View file

@ -41,13 +41,12 @@
</div>
<script src="../dist/reveal.min.js"></script>
<script>
<script type="module">
import '../js/index.js'
import Markdown from '../plugin/markdown/markdown.js'
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
dependencies: [ Markdown ]
}).then( function() {
QUnit.module( 'Markdown' );