@@ -10,7 +10,7 @@ import { IPresentationProps } from './interfaces/ipresentation-props';
1010import { PresTemplate } from './interfaces/pres-template' ;
1111import { RootPresTemplate } from './interfaces/root-pres-template' ;
1212import { Template } from './classes/template' ;
13- import { ModifyPresentationCallback , TemplateInfo } from './types/xml-types' ;
13+ import { ModifyXmlCallback , TemplateInfo } from './types/xml-types' ;
1414import { vd } from './helper/general-helper' ;
1515import { Master } from './classes/master' ;
1616import path from 'path' ;
@@ -41,7 +41,7 @@ export default class Automizer implements IPresentationProps {
4141 params : AutomizerParams ;
4242 status : StatusTracker ;
4343
44- modifyPresentation : ModifyPresentationCallback [ ] ;
44+ modifyPresentation : ModifyXmlCallback [ ] ;
4545
4646 /**
4747 * Creates an instance of `pptx-automizer`.
@@ -177,7 +177,7 @@ export default class Automizer implements IPresentationProps {
177177 return templateCreationId ;
178178 }
179179
180- public async modify ( cb : ModifyPresentationCallback ) : Promise < this> {
180+ public modify ( cb : ModifyXmlCallback ) : this {
181181 this . modifyPresentation . push ( cb ) ;
182182 return this ;
183183 }
@@ -284,23 +284,6 @@ export default class Automizer implements IPresentationProps {
284284 ) ;
285285 }
286286
287- async applyModifyPresentationCallbacks ( ) {
288- const presentationXml = await XmlHelper . getXmlFromArchive (
289- await this . rootTemplate . archive ,
290- `ppt/presentation.xml` ,
291- ) ;
292-
293- for ( const cb of this . modifyPresentation ) {
294- cb ( presentationXml ) ;
295- }
296-
297- await XmlHelper . writeXmlToArchive (
298- await this . rootTemplate . archive ,
299- `ppt/presentation.xml` ,
300- presentationXml ,
301- ) ;
302- }
303-
304287 /**
305288 * Write all slides into archive.
306289 */
@@ -317,6 +300,18 @@ export default class Automizer implements IPresentationProps {
317300 }
318301 }
319302
303+ /**
304+ * Applies all callbacks in this.modifyPresentation-array.
305+ * The callback array can be pushed by this.modify()
306+ */
307+ async applyModifyPresentationCallbacks ( ) : Promise < void > {
308+ await XmlHelper . modifyXmlInArchive (
309+ this . rootTemplate . archive ,
310+ `ppt/presentation.xml` ,
311+ this . modifyPresentation ,
312+ ) ;
313+ }
314+
320315 /**
321316 * Applies path prefix to given location string.
322317 * @param location path and/or filename
0 commit comments