bundle html inside of notes.js, no more need for relatively locating external html

master
Hakim El Hattab 2020-05-18 15:59:18 +02:00
parent 8fc2ec9238
commit 3d2371f58c
10 changed files with 38 additions and 34 deletions

2
dist/reveal.esm.js vendored
View File

@ -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 * https://revealjs.com
* MIT licensed * MIT licensed
* *

2
dist/reveal.js vendored
View File

@ -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 * https://revealjs.com
* MIT licensed * MIT licensed
* *

View File

@ -38,6 +38,8 @@ process.setMaxListeners(20);
const babelConfig = { const babelConfig = {
exclude: 'node_modules/**', exclude: 'node_modules/**',
compact: false, compact: false,
extensions: ['.js', '.html'],
plugins: ['transform-html-import-to-string'],
presets: [[ presets: [[
'@babel/preset-env', '@babel/preset-env',
{ {

View File

@ -16,7 +16,7 @@ let Reveal = Deck;
/** /**
* The below is a thin shell that mimics the pre 4.0 * The below is a thin shell that mimics the pre 4.0
* reveal.js API and ensures backwards compatibility. * 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 * page, whereas the new API above lets you run many
* presentations on the same page. * presentations on the same page.
* *

6
package-lock.json generated
View File

@ -1425,6 +1425,12 @@
"object.assign": "^4.1.0" "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": { "bach": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz",

View File

@ -35,6 +35,7 @@
"@rollup/plugin-commonjs": "^11.1.0", "@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3", "@rollup/plugin-node-resolve": "^7.1.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-plugin-transform-html-import-to-string": "0.0.1",
"colors": "^1.4.0", "colors": "^1.4.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"glob": "^7.1.6", "glob": "^7.1.6",
@ -47,14 +48,14 @@
"gulp-sass": "^4.0.2", "gulp-sass": "^4.0.2",
"gulp-tap": "^2.0.0", "gulp-tap": "^2.0.0",
"gulp-zip": "^5.0.1", "gulp-zip": "^5.0.1",
"highlight.js": "^10.0.1",
"marked": "^1.0.0",
"node-qunit-puppeteer": "^2.0.1", "node-qunit-puppeteer": "^2.0.1",
"qunit": "^2.9.3", "qunit": "^2.9.3",
"rollup": "^2.6.1", "rollup": "^2.6.1",
"rollup-plugin-babel": "^4.4.0", "rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^5.3.0", "rollup-plugin-terser": "^5.3.0",
"yargs": "^15.1.0", "yargs": "^15.1.0"
"highlight.js": "^10.0.1",
"marked": "^1.0.0"
}, },
"browserslist": "> 0.5%, IE 11, not dead", "browserslist": "> 0.5%, IE 11, not dead",
"eslintConfig": { "eslintConfig": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,5 @@
import speakerViewHTML from './speaker-view.html';
/** /**
* Handles opening of and synchronization with the reveal.js * Handles opening of and synchronization with the reveal.js
* notes window. * notes window.
@ -11,27 +13,21 @@
*/ */
const Plugin = () => { const Plugin = () => {
var notesPopup = null; let popup = null;
var deck; let deck;
function openNotes( notesFilePath ) { function openNotes() {
if (notesPopup && !notesPopup.closed) { if (popup && !popup.closed) {
notesPopup.focus(); popup.focus();
return; return;
} }
if( !notesFilePath ) { popup = window.open( 'about:blank', 'reveal.js - Notes', 'width=1100,height=700' );
// var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path popup.document.write( speakerViewHTML );
// 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' ); if( !popup ) {
if( !notesPopup ) {
alert( 'Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.' ); alert( 'Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.' );
return; return;
} }
@ -44,8 +40,8 @@ const Plugin = () => {
*/ */
function connect() { function connect() {
// Keep trying to connect until we get a 'connected' message back // Keep trying to connect until we get a 'connected' message back
var connectInterval = setInterval( function() { let connectInterval = setInterval( function() {
notesPopup.postMessage( JSON.stringify( { popup.postMessage( JSON.stringify( {
namespace: 'reveal-notes', namespace: 'reveal-notes',
type: 'connect', type: 'connect',
url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search, url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search,
@ -54,7 +50,7 @@ const Plugin = () => {
}, 500 ); }, 500 );
window.addEventListener( 'message', function( event ) { window.addEventListener( 'message', function( event ) {
var data = JSON.parse( event.data ); let data = JSON.parse( event.data );
if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) { if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) {
clearInterval( connectInterval ); clearInterval( connectInterval );
onConnected(); onConnected();
@ -71,8 +67,8 @@ const Plugin = () => {
*/ */
function callRevealApi( methodName, methodArguments, callId ) { function callRevealApi( methodName, methodArguments, callId ) {
var result = deck[methodName].apply( deck, methodArguments ); let result = deck[methodName].apply( deck, methodArguments );
notesPopup.postMessage( JSON.stringify( { popup.postMessage( JSON.stringify( {
namespace: 'reveal-notes', namespace: 'reveal-notes',
type: 'return', type: 'return',
result: result, result: result,
@ -86,11 +82,11 @@ const Plugin = () => {
*/ */
function post( event ) { function post( event ) {
var slideElement = deck.getCurrentSlide(), let slideElement = deck.getCurrentSlide(),
notesElement = slideElement.querySelector( 'aside.notes' ), notesElement = slideElement.querySelector( 'aside.notes' ),
fragmentElement = slideElement.querySelector( '.current-fragment' ); fragmentElement = slideElement.querySelector( '.current-fragment' );
var messageData = { let messageData = {
namespace: 'reveal-notes', namespace: 'reveal-notes',
type: 'state', type: 'state',
notes: '', notes: '',
@ -107,7 +103,7 @@ const Plugin = () => {
// Look for notes defined in a fragment // Look for notes defined in a fragment
if( fragmentElement ) { if( fragmentElement ) {
var fragmentNotes = fragmentElement.querySelector( 'aside.notes' ); let fragmentNotes = fragmentElement.querySelector( 'aside.notes' );
if( fragmentNotes ) { if( fragmentNotes ) {
notesElement = fragmentNotes; notesElement = fragmentNotes;
} }
@ -126,7 +122,7 @@ const Plugin = () => {
messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string'; messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
} }
notesPopup.postMessage( JSON.stringify( messageData ), '*' ); popup.postMessage( JSON.stringify( messageData ), '*' );
} }

View File

@ -1,9 +1,8 @@
<!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>reveal.js - Slide Notes</title> <title>reveal.js - Speaker View</title>
<style> <style>
body { body {
@ -851,4 +850,4 @@
</script> </script>
</body> </body>
</html> </html>