Skip to content

Commit 6c86585

Browse files
committed
chore(slide): add placeholder params to ElementInfo
1 parent 5c1472e commit 6c86585

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/helper/xml-slide-helper.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export class XmlSlideHelper {
118118
id: XmlSlideHelper.getElementCreationId(slideElement),
119119
type: XmlSlideHelper.getElementType(slideElement),
120120
position: XmlSlideHelper.parseShapeCoordinates(slideElement),
121+
placeholder: XmlSlideHelper.parsePlaceholderInfo(slideElement),
121122
hasTextBody: !!XmlSlideHelper.getTextBody(slideElement),
122123
getXmlElement: () => slideElement,
123124
getText: () => XmlSlideHelper.parseTextFragments(slideElement),
@@ -433,6 +434,22 @@ export class XmlSlideHelper {
433434
return parseInt(element.getAttribute(attributeName), 10);
434435
};
435436

437+
static parsePlaceholderInfo = (
438+
element: XmlElement,
439+
): ElementInfo['placeholder'] => {
440+
const info = element.getElementsByTagName('p:ph').item(0)
441+
442+
if(!info) {
443+
return
444+
}
445+
446+
return {
447+
type: info.getAttribute('type'),
448+
sz: info.getAttribute('sz'),
449+
idx: parseInt(info.getAttribute('idx')),
450+
};
451+
};
452+
436453
/**
437454
* Asynchronously retrieves the dimensions of a slide.
438455
* Tries to find the dimensions from the slide XML, then from the layout, master, and presentation XMLs in order.

src/types/xml-types.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export type ElementInfo = {
7474
cy: number;
7575
rot?: number;
7676
};
77+
placeholder: {
78+
type: string;
79+
sz: string;
80+
idx: number;
81+
};
7782
hasTextBody: boolean;
7883
getText: () => string[];
7984
getParagraphs: () => TextParagraph[];
@@ -92,18 +97,18 @@ export type TextParagraphProps = {
9297
indent?: number;
9398
bullet?: string;
9499
isNumbered?: boolean;
95-
numberingType?: string
96-
startAt?: string
97-
}
100+
numberingType?: string;
101+
startAt?: string;
102+
};
98103

99104
export type TextParagraph = {
100105
texts: string[];
101-
} & TextParagraphProps
106+
} & TextParagraphProps;
102107

103108
export type TextParagraphGroup = {
104109
properties: TextParagraphProps;
105110
texts: string[];
106-
}
111+
};
107112

108113
export type ContentMapType = 'slideMaster' | 'slideLayout';
109114
export type ContentMap = {

0 commit comments

Comments
 (0)