Skip to content

Commit 7749b8f

Browse files
committed
fix(slide): remove unsupported xml tags from ppt-addons (e.g. thinkcell)
1 parent bf892d9 commit 7749b8f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/classes/slide.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export class Slide implements ISlide {
9898
*/
9999
targetRelsPath: string;
100100
status: StatusTracker;
101+
/**
102+
* List of unsupported tags in slide xml
103+
* @internal
104+
*/
105+
unsupportedTags = ['p:custDataLst', 'mc:AlternateContent'];
101106

102107
constructor(params: {
103108
presentation: IPresentationProps;
@@ -186,6 +191,7 @@ export class Slide implements ISlide {
186191
}
187192

188193
await this.applyModifications();
194+
await this.cleanSlide();
189195

190196
this.status.increment();
191197
}
@@ -444,6 +450,30 @@ export class Slide implements ISlide {
444450
}
445451
}
446452

453+
/**
454+
* Removes all unsupported tags from slide xml.
455+
* E.g. added relations & tags by Thinkcell cannot
456+
* be processed by pptx-automizer at the moment.
457+
* @internal
458+
*/
459+
async cleanSlide(): Promise<void> {
460+
const xml = await XmlHelper.getXmlFromArchive(
461+
this.targetArchive,
462+
this.targetPath,
463+
);
464+
465+
this.unsupportedTags.forEach((tag) => {
466+
const drop = xml.getElementsByTagName(tag);
467+
if (drop.length) {
468+
XmlHelper.sliceCollection(drop, 0);
469+
console.log(
470+
'Removed ' + drop.length + ' unsupported ' + tag + ' elements.',
471+
);
472+
}
473+
});
474+
await XmlHelper.writeXmlToArchive(this.targetArchive, this.targetPath, xml);
475+
}
476+
447477
/**
448478
* Copys slide files
449479
* @internal

0 commit comments

Comments
 (0)