Skip to content

Commit a57ed9f

Browse files
committed
chore: prettier code formatting
1 parent 398caa7 commit a57ed9f

File tree

11 files changed

+182
-138
lines changed

11 files changed

+182
-138
lines changed

src/classes/slide.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class Slide implements ISlide {
9999

100100
/**
101101
* Select and modify a single element on an added slide.
102-
* @param {string} selector - Element's name on the slide.
102+
* @param {string} selector - Element's name on the slide.
103103
* Should be a unique string defined on the "Selection"-pane within ppt.
104104
* @param {ShapeModificationCallback | ShapeModificationCallback[]} callback - One or more callback functions to apply.
105105
* Depending on the shape type (e.g. chart or table), different arguments will be passed to the callback.
@@ -122,9 +122,9 @@ export class Slide implements ISlide {
122122

123123
/**
124124
* Select, insert and (optionally) modify a single element to a slide.
125-
* @param {string} presName - Filename or alias name of the template presentation.
125+
* @param {string} presName - Filename or alias name of the template presentation.
126126
* Must have been importet with Automizer.load().
127-
* @param {number} slideNumber - Slide number within the specified template to search for the required element.
127+
* @param {number} slideNumber - Slide number within the specified template to search for the required element.
128128
* @param {ShapeModificationCallback | ShapeModificationCallback[]} callback - One or more callback functions to apply.
129129
* Depending on the shape type (e.g. chart or table), different arguments will be passed to the callback.
130130
*/

src/dev.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,19 @@ const data1 = {
1313
body: [
1414
{ label: 'item test r1', values: [10, 16, 12] },
1515
{ label: 'item test r2', values: [12, 18, 15] },
16-
{ label: 'item test r3', values: [14, 12, 11 ] },
16+
{ label: 'item test r3', values: [14, 12, 11] },
1717
],
1818
};
1919

2020
const data2 = [
2121
[10, 16, 12],
2222
[12, 18, 15],
2323
[14, 12, 11],
24-
]
24+
];
2525

2626
pres
2727
.addSlide('table', 1, (slide) => {
28-
slide.modifyElement('TableWithHeader', [
29-
modify.setTableData(data2)
30-
]);
28+
slide.modifyElement('TableWithHeader', [modify.setTableData(data2)]);
3129
})
3230
.write(`modify-table.test.pptx`)
3331

src/helper/cell-id-helper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class CellIdHelper {
4444
}
4545

4646
static increment(letterNumber: number): string {
47-
const Generator = new this('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
47+
const Generator = new this('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
4848
return Generator.start(letterNumber).next();
4949
}
5050

@@ -63,7 +63,7 @@ export default class CellIdHelper {
6363
}
6464

6565
const newRange = `${info[0]}!$${colLetter}$${start[2]}${endCell}`;
66-
return newRange
66+
return newRange;
6767
}
6868

6969
static getSpanString(
@@ -73,7 +73,7 @@ export default class CellIdHelper {
7373
rows: number,
7474
): string {
7575
const startColLetter = CellIdHelper.increment(startColNumber);
76-
const endColLetter = CellIdHelper.increment(startColNumber + cols);
76+
const endColLetter = CellIdHelper.increment(startColNumber + cols);
7777
const endRowNumber = startRowNumber + rows;
7878
return `${startColLetter}${startRowNumber}:${endColLetter}${endRowNumber}`;
7979
}

src/helper/modify-helper.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { XmlHelper } from './xml-helper';
22
import { ModifyChart } from '../modify/modify-chart';
33
import { Workbook } from '../types/types';
4-
import { ChartData, ChartBubble, ChartSlot, ChartCategory, ChartSeries } from '../types/chart-types';
4+
import {
5+
ChartData,
6+
ChartBubble,
7+
ChartSlot,
8+
ChartCategory,
9+
ChartSeries,
10+
} from '../types/chart-types';
511
import { TableData } from '../types/table-types';
612
import { ShapeCoordinates } from '../types/shape-types';
713

@@ -53,19 +59,18 @@ export const setChartData = (data: ChartData) => (
5359
chart: Document,
5460
workbook: Workbook,
5561
): void => {
56-
57-
const slots = [] as ChartSlot[]
62+
const slots = [] as ChartSlot[];
5863
data.series.forEach((series: ChartSeries, s: number) => {
5964
slots.push({
6065
index: s,
6166
series: series,
6267
targetCol: s + 1,
6368
type: 'defaultSeries',
64-
})
69+
});
6570
});
6671

6772
new ModifyChart(chart, workbook, data, slots).modify();
68-
73+
6974
// XmlHelper.dump(chart)
7075
};
7176

@@ -74,7 +79,7 @@ export const setChartVerticalLines = (data: ChartData) => (
7479
chart: Document,
7580
workbook: Workbook,
7681
): void => {
77-
const slots = [] as ChartSlot[]
82+
const slots = [] as ChartSlot[];
7883

7984
slots.push({
8085
label: `Y-Values`,
@@ -88,7 +93,7 @@ export const setChartVerticalLines = (data: ChartData) => (
8893
series: series,
8994
targetCol: s + 2,
9095
type: 'xySeries',
91-
})
96+
});
9297
});
9398

9499
new ModifyChart(chart, workbook, data, slots).modify();
@@ -99,7 +104,7 @@ export const setChartBubbles = (data: ChartData) => (
99104
chart: Document,
100105
workbook: Workbook,
101106
): void => {
102-
const slots = [] as ChartSlot[]
107+
const slots = [] as ChartSlot[];
103108

104109
data.series.forEach((series: ChartSeries, s: number) => {
105110
const colId = s * 3;
@@ -110,7 +115,7 @@ export const setChartBubbles = (data: ChartData) => (
110115
type: 'customSeries',
111116
tag: 'c:xVal',
112117
mapData: (point: ChartBubble): number => point.x,
113-
})
118+
});
114119
slots.push({
115120
label: `${series.label}-Y-Value`,
116121
index: s,
@@ -119,8 +124,8 @@ export const setChartBubbles = (data: ChartData) => (
119124
type: 'customSeries',
120125
tag: 'c:yVal',
121126
mapData: (point: ChartBubble): number => point.y,
122-
isStrRef: false
123-
})
127+
isStrRef: false,
128+
});
124129
slots.push({
125130
label: `${series.label}-Size`,
126131
index: s,
@@ -129,15 +134,15 @@ export const setChartBubbles = (data: ChartData) => (
129134
type: 'customSeries',
130135
tag: 'c:bubbleSize',
131136
mapData: (point: ChartBubble): number => point.size,
132-
isStrRef: false
133-
})
137+
isStrRef: false,
138+
});
134139
});
135140

136141
new ModifyChart(chart, workbook, data, slots).modify();
137142
};
138143

139144
export const setTableData = (data: TableData) => (
140-
element: XMLDocument | Document | Element
145+
element: XMLDocument | Document | Element,
141146
): void => {
142147
XmlHelper.dump(element);
143148
};

src/helper/modify-xml-helper.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
Modification,
3-
ModificationTags,
4-
} from '../types/modify-types';
1+
import { Modification, ModificationTags } from '../types/modify-types';
52

63
import StringIdGenerator from './cell-id-helper';
74
import { GeneralHelper } from './general-helper';
@@ -14,10 +11,7 @@ export default class ModifyXmlHelper {
1411
this.root = root;
1512
}
1613

17-
modify(
18-
tags: ModificationTags,
19-
root?: XMLDocument | Element,
20-
): void {
14+
modify(tags: ModificationTags, root?: XMLDocument | Element): void {
2115
root = root || this.root;
2216

2317
for (const tag in tags) {
@@ -59,16 +53,27 @@ export default class ModifyXmlHelper {
5953
element.setAttribute(attribute, String(value));
6054
};
6155

62-
static range = (series: number, length?: number) => (element: Element): void => {
63-
const range = element.firstChild.textContent
64-
element.firstChild.textContent = StringIdGenerator.setRange(range, series, length);;
56+
static range = (series: number, length?: number) => (
57+
element: Element,
58+
): void => {
59+
const range = element.firstChild.textContent;
60+
element.firstChild.textContent = StringIdGenerator.setRange(
61+
range,
62+
series,
63+
length,
64+
);
6565
};
6666

67-
assertNode(collection: HTMLCollectionOf<Element>, index: number, tag?: string, info?): void {
67+
assertNode(
68+
collection: HTMLCollectionOf<Element>,
69+
index: number,
70+
tag?: string,
71+
info?,
72+
): void {
6873
if (!collection[index]) {
69-
if(collection[collection.length - 1] === undefined) {
70-
console.log(info)
71-
throw new Error(`Index ${index} not found at "${tag}"`)
74+
if (collection[collection.length - 1] === undefined) {
75+
console.log(info);
76+
throw new Error(`Index ${index} not found at "${tag}"`);
7277
}
7378
const tplNode = collection[collection.length - 1];
7479
const newChild = tplNode.cloneNode(true);

src/helper/xml-helper.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,10 @@ export class XmlHelper {
296296
};
297297
}
298298

299-
300-
static appendSharedString(sharedStrings: Document, stringValue: string): number {
299+
static appendSharedString(
300+
sharedStrings: Document,
301+
stringValue: string,
302+
): number {
301303
const strings = sharedStrings.getElementsByTagName('sst')[0];
302304
const newLabel = sharedStrings.createTextNode(stringValue);
303305
const newText = sharedStrings.createElement('t');

0 commit comments

Comments
 (0)