Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the current fragment's notes when showNotes: true #3491

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion js/controllers/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,27 @@ export default class Notes {
return slide.getAttribute( 'data-notes' );
}

if ( Reveal.getConfig().fragments ) {
let fragmentElement = slide.querySelector( '.current-fragment' );
if( fragmentElement ) {
let fragmentNotes = fragmentElement.querySelector( 'aside.notes' );
if( fragmentNotes ) {
return fragmentNotes.innerHTML;
}
else if( fragmentElement.hasAttribute( 'data-notes' ) ) {
return fragmentElement.getAttribute( 'data-notes' );
}
}
}
// ... or using <aside class="notes"> elements
let notesElements = slide.querySelectorAll( 'aside.notes' );
if( notesElements ) {
return Array.from(notesElements).map( notesElement => notesElement.innerHTML ).join( '\n' );
// ignore notes inside of fragments since those are shown individually when stepping through fragments
let notes = Array.from(notesElements);
if ( Reveal.getConfig().fragments ) {
notes = notes.filter( notesElement => notesElement.closest( '.fragment' ) === null );
}
return notes.map( notesElement => notesElement.innerHTML ).join('\n');
}

return null;
Expand Down
9 changes: 9 additions & 0 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ export default function( revealElement, options ) {
// Register plugins and load dependencies, then move on to #start()
plugins.load( config.plugins, config.dependencies ).then( start );

if ( config.fragments ) {
Reveal.on( 'fragmentshown', () => { notes.update(); } );
Reveal.on( 'fragmenthidden', () => { notes.update(); } );
Reveal.on( 'slidechanged', () => {
fragments.update();
notes.update();
} );
}

return new Promise( resolve => Reveal.on( 'ready', resolve ) );

}
Expand Down