Commit 3d2371f5 authored by Hakim El Hattab's avatar Hakim El Hattab
Browse files

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

parent 8fc2ec92
/*!
* 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
*
......
/*!
* 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
*
......
......@@ -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',
{
......
......@@ -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.
*
......
......@@ -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",
......
......@@ -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": {
......
This diff is collapsed.
This diff is collapsed.
import speakerViewHTML from './speaker-view.html';
/**
* Handles opening of and synchronization with the reveal.js
* notes window.
......@@ -11,27 +13,21 @@
*/
const Plugin = () => {
var notesPopup = null;
let popup = null;
var deck;
let deck;
function openNotes( notesFilePath ) {
function openNotes() {
if (notesPopup && !notesPopup.closed) {
notesPopup.focus();
if (popup && !popup.closed) {
popup.focus();
return;
}
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';
notesFilePath = 'plugin/notes/notes.html'
}
notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' );
popup = window.open( 'about:blank', 'reveal.js - Notes', 'width=1100,height=700' );
popup.document.write( speakerViewHTML );
if( !notesPopup ) {
if( !popup ) {
alert( 'Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.' );
return;
}
......@@ -44,8 +40,8 @@ const Plugin = () => {
*/
function connect() {
// Keep trying to connect until we get a 'connected' message back
var connectInterval = setInterval( function() {
notesPopup.postMessage( JSON.stringify( {
let connectInterval = setInterval( function() {
popup.postMessage( JSON.stringify( {
namespace: 'reveal-notes',
type: 'connect',
url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search,
......@@ -54,7 +50,7 @@ const Plugin = () => {
}, 500 );
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' ) {
clearInterval( connectInterval );
onConnected();
......@@ -71,8 +67,8 @@ const Plugin = () => {
*/
function callRevealApi( methodName, methodArguments, callId ) {
var result = deck[methodName].apply( deck, methodArguments );
notesPopup.postMessage( JSON.stringify( {
let result = deck[methodName].apply( deck, methodArguments );
popup.postMessage( JSON.stringify( {
namespace: 'reveal-notes',
type: 'return',
result: result,
......@@ -86,11 +82,11 @@ const Plugin = () => {
*/
function post( event ) {
var slideElement = deck.getCurrentSlide(),
let slideElement = deck.getCurrentSlide(),
notesElement = slideElement.querySelector( 'aside.notes' ),
fragmentElement = slideElement.querySelector( '.current-fragment' );
var messageData = {
let messageData = {
namespace: 'reveal-notes',
type: 'state',
notes: '',
......@@ -107,7 +103,7 @@ const Plugin = () => {
// Look for notes defined in a fragment
if( fragmentElement ) {
var fragmentNotes = fragmentElement.querySelector( 'aside.notes' );
let fragmentNotes = fragmentElement.querySelector( 'aside.notes' );
if( fragmentNotes ) {
notesElement = fragmentNotes;
}
......@@ -126,7 +122,7 @@ const Plugin = () => {
messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
}
notesPopup.postMessage( JSON.stringify( messageData ), '*' );
popup.postMessage( JSON.stringify( messageData ), '*' );
}
......
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reveal.js - Slide Notes</title>
<title>reveal.js - Speaker View</title>
<style>
body {
......@@ -851,4 +850,4 @@
</script>
</body>
</html>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment