node-pptx icon indicating copy to clipboard operation
node-pptx copied to clipboard

Removing slide doesn't remove slides from [Content_Types].xml

Open jamieshield opened this issue 1 year ago • 0 comments

Removing slide doesn't remove the slide's relationships from [Content_Types].xml. That is, calling removeSlide to remove slide 2 does delete the following from [Content_Types].xml. <Override PartName="/ppt/slides/slide2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>

From my naive diagnosis, calling removeSlide calls the factory removeSlide. removeSlide(slide) { this.powerPointFactory.removeSlide(slide.name);

The factory removeSlide calls removeContentType(partName) factories/index.js: removeSlide(slideName) { ... this.contentTypeFactory.removeContentType(/ppt/slides/${slideName}.xml);

However, removeContentType is defined with two parameters partName and contentType. So the contentType never matches and the slides' relationship in ContentType.xml is not removed.

Adding a default parameter was a (hack) solution for me. node-pptx/lib/factories/content-types.js: removeContentType(partName, contentType = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml")

Time poor newbie reporting an issue - just trying to help. Apologies in advance for any inappropriateness in this issue report.

jamieshield avatar Feb 14 '24 00:02 jamieshield