Issue
I'm using pptxgenjs 2.3.0. I create two PPTX files using the same shared slide master configuration, which contains a placeholder:
const PptxGenJS = require('pptxgenjs');
const SLIDE_MASTER = {
title: 'SLIDE_MASTER',
objects: [
{
placeholder: {
options: {
name: 'name',
type: 'body',
x: '20%',
y: 2,
},
},
},
]
};
function createPptx(name) {
const pptx = new PptxGenJS();
pptx.defineSlideMaster(SLIDE_MASTER);
const slide = pptx.addNewSlide('SLIDE_MASTER');
slide.addText('Hello World1!', { placeholder: 'name' });
pptx.save(name);
}
createPptx('Presentation1');
createPptx('Presentation2');
For the first run, the slide is correct:

For the second run, the slide lost its formatting:

Elements in the master slides without placeholders are not effected by this.
Workaround
Create a deep copy of the slide master configuration before passing it to defineSlideMaster:
pptx.defineSlideMaster(JSON.parse(JSON.stringify(SLIDE_MASTER)));