Skip to content

Commit

Permalink
Do not inherit presenter notes by default (gnab#574)
Browse files Browse the repository at this point in the history
But allow by setting inheritPresenterNote option
  • Loading branch information
gnab committed Jun 9, 2020
1 parent 10b7515 commit 92ed68d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/remark/models/slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var converter = require('../converter');

module.exports = Slide;

function Slide (slideIndex, slideNumber, slide, template) {
function Slide (slideIndex, slideNumber, slide, template, options) {
var self = this;

self.properties = slide.properties || {};
Expand All @@ -14,14 +14,14 @@ function Slide (slideIndex, slideNumber, slide, template) {
self.getSlideNumber = function () { return slideNumber; };

if (template) {
inherit(self, template);
inherit(self, template, options);
}
}

function inherit (slide, template) {
function inherit (slide, template, options) {
inheritProperties(slide, template);
inheritContent(slide, template);
inheritNotes(slide, template);
inheritNotes(slide, template, options);
}

function inheritProperties (slide, template) {
Expand Down Expand Up @@ -86,8 +86,8 @@ function deepCopyContent(target, content) {
}
}

function inheritNotes (slide, template) {
if (template.notes) {
function inheritNotes (slide, template, options) {
if (template.notes && options.inheritPresenterNotes) {
slide.notes = template.notes + '\n\n' + slide.notes;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/remark/models/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function createSlides (slideshowSource, options) {
slide.notes = '';
}

slideViewModel = new Slide(slides.length, slideNumber, slide, template);
slideViewModel = new Slide(slides.length, slideNumber, slide, template, options);

if (slide.properties.name) {
byName[slide.properties.name] = slideViewModel;
Expand Down
17 changes: 16 additions & 1 deletion test/remark/models/slide_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,29 @@ describe('Slide', function () {
content: ['More content.'],
properties: {prop2: 'val2'},
notes: 'slide notes'
}, template);
}, template, {inheritPresenterNotes: true});

slide.properties.should.have.property('prop1', 'val1');
slide.properties.should.have.property('prop2', 'val2');
slide.content.should.eql(['Some content.', 'More content.']);
slide.notes.should.equal('template notes\n\nslide notes');
});

it('should not inherit notes when inheritTemplateNotes is undefined', () => {
var template = new Slide(1, 1, {
content: [''],
properties: {},
notes: 'template notes'
})
, slide = new Slide(2, 2, {
content: [''],
properties: {},
notes: 'just slide notes'
}, template, {});

slide.notes.should.equal('just slide notes');
});

it('should not inherit name property', function () {
var template = new Slide(1, 1, {
content: ['Some content.'],
Expand Down

0 comments on commit 92ed68d

Please sign in to comment.