1
0
Fork 0

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

This commit is contained in:
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
* 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
* MIT licensed
*

View File

@ -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',
{

View File

@ -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.
*

6
package-lock.json generated
View File

@ -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",

View File

@ -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": {

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
* 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'
}
popup = window.open( 'about:blank', 'reveal.js - Notes', 'width=1100,height=700' );
popup.document.write( speakerViewHTML );
notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' );
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 ), '*' );
}

View File

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