Skip to content

Commit

Permalink
merge support for multiple notes on same slide
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Sep 5, 2022
2 parents b23d15c + 62a85d5 commit 01efcf2
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 32 deletions.
4 changes: 4 additions & 0 deletions dist/reveal.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
<div class="reveal">
<div class="slides">
<section>Slide 1</section>
<section>Slide 2</section>
<section>Slide 2
<aside class="notes">
<p>Some notes</p>
</aside>
<p>Some slide text</p>
<aside class="notes">
<p>and some more notes</p>
</aside>
</section>
</div>
</div>

Expand Down
16 changes: 10 additions & 6 deletions js/controllers/notes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Handles the showing and
* Handles the showing of speaker notes
*/
export default class Notes {

Expand Down Expand Up @@ -89,7 +89,7 @@ export default class Notes {
* Retrieves the speaker notes from a slide. Notes can be
* defined in two ways:
* 1. As a data-notes attribute on the slide <section>
* 2. As an <aside class="notes"> inside of the slide
* 2. With <aside class="notes"> elements inside the slide
*
* @param {HTMLElement} [slide=currentSlide]
* @return {(string|null)}
Expand All @@ -101,10 +101,14 @@ export default class Notes {
return slide.getAttribute( 'data-notes' );
}

// ... or using an <aside class="notes"> element
let notesElement = slide.querySelector( 'aside.notes' );
if( notesElement ) {
return notesElement.innerHTML;
// ... or using <aside class="notes"> elements
let notesElements = slide.querySelectorAll( 'aside.notes' );
if( notesElements ) {
let notes = "";
for (let i = 0; i < notesElements.length; i++) {
notes += notesElements[i].innerHTML + "\n";
}
return notes;
}

return null;
Expand Down
4 changes: 2 additions & 2 deletions plugin/highlight/highlight.esm.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugin/highlight/highlight.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugin/markdown/markdown.esm.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugin/markdown/markdown.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin/math/math.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/notes/notes.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin/notes/notes.js

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions plugin/notes/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const Plugin = () => {
function post( event ) {

let slideElement = deck.getCurrentSlide(),
notesElement = slideElement.querySelector( 'aside.notes' ),
notesElements = slideElement.querySelectorAll( 'aside.notes' ),
fragmentElement = slideElement.querySelector( '.current-fragment' );

let messageData = {
Expand All @@ -130,21 +130,25 @@ const Plugin = () => {
if( fragmentElement ) {
let fragmentNotes = fragmentElement.querySelector( 'aside.notes' );
if( fragmentNotes ) {
notesElement = fragmentNotes;
messageData.notes = fragmentNotes.innerHTML;
messageData.markdown = typeof fragmentNotes.getAttribute( 'data-markdown' ) === 'string';

// Ignore other slide notes
notesElements = null;
}
else if( fragmentElement.hasAttribute( 'data-notes' ) ) {
messageData.notes = fragmentElement.getAttribute( 'data-notes' );
messageData.whitespace = 'pre-wrap';

// In case there are slide notes
notesElement = null;
notesElements = null;
}
}

// Look for notes defined in an aside element
if( notesElement ) {
messageData.notes = notesElement.innerHTML;
messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
if( notesElements ) {
messageData.notes = Array.from(notesElements).map( notesElement => notesElement.innerHTML ).join( '\n' );
messageData.markdown = typeof notesElements[0].getAttribute( 'data-markdown' ) === 'string';
}

speakerWindow.postMessage( JSON.stringify( messageData ), '*' );
Expand Down
2 changes: 1 addition & 1 deletion plugin/search/search.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/search/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 01efcf2

Please sign in to comment.