From 3d2371f58c350453045b76084165219a6f8d063c Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 18 May 2020 15:59:18 +0200 Subject: [PATCH] bundle html inside of notes.js, no more need for relatively locating external html --- dist/reveal.esm.js | 2 +- dist/reveal.js | 2 +- gulpfile.js | 2 + js/index.js | 2 +- package-lock.json | 6 +++ package.json | 7 ++-- plugin/notes/notes.esm.js | 2 +- plugin/notes/notes.js | 2 +- plugin/notes/plugin.js | 42 +++++++++---------- .../notes/{notes.html => speaker-view.html} | 5 +-- 10 files changed, 38 insertions(+), 34 deletions(-) rename plugin/notes/{notes.html => speaker-view.html} (99%) diff --git a/dist/reveal.esm.js b/dist/reveal.esm.js index 9622b42..7a89603 100644 --- a/dist/reveal.esm.js +++ b/dist/reveal.esm.js @@ -1,5 +1,5 @@ /*! -* reveal.js 4.0.0-dev (Tue May 12 2020) +* reveal.js 4.0.0-dev (Mon May 18 2020) * https://revealjs.com * MIT licensed * diff --git a/dist/reveal.js b/dist/reveal.js index a48c859..34056eb 100644 --- a/dist/reveal.js +++ b/dist/reveal.js @@ -1,5 +1,5 @@ /*! -* reveal.js 4.0.0-dev (Tue May 12 2020) +* reveal.js 4.0.0-dev (Mon May 18 2020) * https://revealjs.com * MIT licensed * diff --git a/gulpfile.js b/gulpfile.js index 575173d..2812f3a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,6 +38,8 @@ process.setMaxListeners(20); const babelConfig = { exclude: 'node_modules/**', compact: false, + extensions: ['.js', '.html'], + plugins: ['transform-html-import-to-string'], presets: [[ '@babel/preset-env', { diff --git a/js/index.js b/js/index.js index ff6f633..db5577d 100644 --- a/js/index.js +++ b/js/index.js @@ -16,7 +16,7 @@ let Reveal = Deck; /** * The below is a thin shell that mimics the pre 4.0 * reveal.js API and ensures backwards compatibility. - * This API only allows for once Reveal instance per + * This API only allows for one Reveal instance per * page, whereas the new API above lets you run many * presentations on the same page. * diff --git a/package-lock.json b/package-lock.json index e2a6128..7277c18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1425,6 +1425,12 @@ "object.assign": "^4.1.0" } }, + "babel-plugin-transform-html-import-to-string": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-html-import-to-string/-/babel-plugin-transform-html-import-to-string-0.0.1.tgz", + "integrity": "sha1-lJFSUV2q12TPVcUasXh9IG3s+J0=", + "dev": true + }, "bach": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", diff --git a/package.json b/package.json index 5917e44..8c758c8 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@rollup/plugin-commonjs": "^11.1.0", "@rollup/plugin-node-resolve": "^7.1.3", "babel-eslint": "^10.1.0", + "babel-plugin-transform-html-import-to-string": "0.0.1", "colors": "^1.4.0", "core-js": "^3.6.5", "glob": "^7.1.6", @@ -47,14 +48,14 @@ "gulp-sass": "^4.0.2", "gulp-tap": "^2.0.0", "gulp-zip": "^5.0.1", + "highlight.js": "^10.0.1", + "marked": "^1.0.0", "node-qunit-puppeteer": "^2.0.1", "qunit": "^2.9.3", "rollup": "^2.6.1", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-terser": "^5.3.0", - "yargs": "^15.1.0", - "highlight.js": "^10.0.1", - "marked": "^1.0.0" + "yargs": "^15.1.0" }, "browserslist": "> 0.5%, IE 11, not dead", "eslintConfig": { diff --git a/plugin/notes/notes.esm.js b/plugin/notes/notes.esm.js index 1e5f340..bb34fdd 100644 --- a/plugin/notes/notes.esm.js +++ b/plugin/notes/notes.esm.js @@ -1 +1 @@ -export default function(){var e,t=null;function n(n){var a;!t||t.closed?(n||(n="plugin/notes/notes.html"),(t=window.open(n,"reveal.js - Notes","width=1100,height=700"))?(a=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 s,r,i,d,l=JSON.parse(n.data);l&&"reveal-notes"===l.namespace&&"connected"===l.type&&(clearInterval(a),e.on("slidechanged",o),e.on("fragmentshown",o),e.on("fragmenthidden",o),e.on("overviewhidden",o),e.on("overviewshown",o),e.on("paused",o),e.on("resumed",o),o()),l&&"reveal-notes"===l.namespace&&"call"===l.type&&(s=l.methodName,r=l.arguments,i=l.callId,d=e[s].apply(e,r),t.postMessage(JSON.stringify({namespace:"reveal-notes",type:"return",result:d,callId:i}),"*"))}))):alert("Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.")):t.focus();function o(n){var a=e.getCurrentSlide(),o=a.querySelector("aside.notes"),s=a.querySelector(".current-fragment"),r={namespace:"reveal-notes",type:"state",notes:"",markdown:!1,whitespace:"normal",state:e.getState()};if(a.hasAttribute("data-notes")&&(r.notes=a.getAttribute("data-notes"),r.whitespace="pre-wrap"),s){var i=s.querySelector("aside.notes");i?o=i:s.hasAttribute("data-notes")&&(r.notes=s.getAttribute("data-notes"),r.whitespace="pre-wrap",o=null)}o&&(r.notes=o.innerHTML,r.markdown="string"==typeof o.getAttribute("data-markdown")),t.postMessage(JSON.stringify(r),"*")}}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}} +export default function(){var t,n=null;function e(){var e;!n||n.closed?((n=window.open("about:blank","reveal.js - Notes","width=1100,height=700")).document.write("\n\t\n\t\t\n\n\t\treveal.js - Speaker View\n\n\t\t\n\t\n\n\t\n\n\t\t
Loading speaker view...
\n\n\t\t
\n\t\t
Upcoming
\n\t\t
\n\t\t\t
\n\t\t\t\t

Time Click to Reset

\n\t\t\t\t
\n\t\t\t\t\t0:00 AM\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t00:00:00\n\t\t\t\t
\n\t\t\t\t
\n\n\t\t\t\t

Pacing – Time to finish current slide

\n\t\t\t\t
\n\t\t\t\t\t00:00:00\n\t\t\t\t
\n\t\t\t
\n\n\t\t\t
\n\t\t\t\t

Notes

\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\n\t\t - + \ No newline at end of file