Skip to content

Commit 0986dd5

Browse files
committed
chore(xml): bump xmldom version; add dLbl-template
1 parent 72fd901 commit 0986dd5

File tree

7 files changed

+58
-470
lines changed

7 files changed

+58
-470
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@
5454
"eslint-config-prettier": "^8.1.0",
5555
"eslint-plugin-prettier": "^3.3.1",
5656
"jest": "^26.6.3",
57-
"nodemon": "^2.0.7",
57+
"nodemon": "^2.0.20",
5858
"prettier": "^2.2.1",
5959
"ts-jest": "^26.5.2",
6060
"ts-node": "^9.1.1",
6161
"typedoc": "^0.22.15",
6262
"typescript": "^4.2.3"
6363
},
6464
"dependencies": {
65-
"jszip": "^3.6.0",
66-
"regexp.escape": "^1.1.0",
67-
"xmldom": "^0.6.0"
65+
"@xmldom/xmldom": "^0.8.2",
66+
"jszip": "^3.10.1",
67+
"regexp.escape": "^1.1.0"
6868
}
6969
}

src/dev.ts

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,15 @@ const automizer = new Automizer({
99

1010
const run = async () => {
1111
const pres = automizer
12-
.loadRoot(`ChartLinesVerticalImageMarkers.pptx`)
13-
.load(`ChartLinesVerticalImageMarkers.pptx`, 'charts');
14-
15-
const data = {
16-
series: [
17-
{ label: 'series s1' },
18-
{ label: 'series s2' },
19-
{ label: 'series s3' },
20-
],
21-
categories: [
22-
{ label: 'item test r1', y: 10, values: [10, 16, 12] },
23-
{ label: 'item test r2', y: 9, values: [12, 18, 15] },
24-
{ label: 'item test r3', y: 8, values: [14, 12, 11] },
25-
{ label: 'item test r4', y: 7, values: [8, 11, 9] },
26-
{ label: 'item test r5', y: 6, values: [6, 15, 7] },
27-
{ label: 'item test r6', y: 5, values: [16, 16, 9] },
28-
{ label: 'item test r7', y: 4, values: [10, 13, 12] },
29-
{ label: 'item test r8', y: 3, values: [11, 12, 14] },
30-
{ label: 'item test r9', y: 2, values: [9, 7, 11] },
31-
{ label: 'item test r10', y: 1, values: [7, 5, 17] },
32-
],
33-
};
34-
35-
const dataSmaller = {
36-
series: [{ label: 'series s1' }],
37-
categories: [
38-
{ label: 'item test r1', y: 10, values: [10] },
39-
{ label: 'item test r2', y: 9, values: [12] },
40-
{ label: 'item test r3', y: 8, values: [14] },
41-
],
42-
};
12+
.loadRoot(`bug/RootTemplate.pptx`)
13+
.load(`bug/Slides.pptx`, 'slides')
14+
.load(`bug/Library - Icons.pptx`, 'image');
4315

4416
const result = await pres
45-
.addSlide('charts', 1, (slide) => {
46-
slide.modifyElement('DotMatrixImageMarkers', [
47-
modify.setChartVerticalLines(dataSmaller),
48-
]);
17+
.addSlide('slides', 6, (slide) => {
18+
slide.addElement('image', 1, 'Tschechien');
4919
})
50-
.write(`modify-chart-vertical-lines-marker.test.pptx`);
20+
.write(`add-image-bug.test.pptx`);
5121
};
5222

5323
run().catch((error) => {

src/helper/xml-elements.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Color } from '../types/modify-types';
22
import { XmlHelper } from './xml-helper';
33
import { vd } from './general-helper';
44
import * as fs from 'fs';
5-
import { DOMParser } from 'xmldom';
5+
import { DOMParser } from '@xmldom/xmldom';
6+
import { dLblXml } from './xml/dLbl';
67

78
export type XmlElementParams = {
89
color?: Color;
@@ -152,8 +153,7 @@ export default class XmlElements {
152153
}
153154

154155
dataPointLabel() {
155-
const xml = fs.readFileSync(__dirname + '/xml/dLbl.xml');
156-
const doc = new DOMParser().parseFromString(xml.toString());
156+
const doc = new DOMParser().parseFromString(dLblXml);
157157
const ele = doc.getElementsByTagName('c:dLbl')[0];
158158
const firstChild = this.element.firstChild;
159159
this.element.insertBefore(ele.cloneNode(true), firstChild);

src/helper/xml-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import JSZip from 'jszip';
22

3-
import { DOMParser, XMLSerializer } from 'xmldom';
3+
import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
44
import { FileHelper } from './file-helper';
55
import {
66
DefaultAttribute,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1+
export const dLblXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:c16r2="http://schemas.microsoft.com/office/drawing/2015/06/chart">
33
<c:chart>
44
<c:plotArea>
@@ -51,3 +51,4 @@
5151
</c:plotArea>
5252
</c:chart>
5353
</c:chartSpace>
54+
`;

src/helper/xml/test.xml

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)