diff --git a/src/core-interfaces.ts b/src/core-interfaces.ts index a52d71a83..36284c6ea 100644 --- a/src/core-interfaces.ts +++ b/src/core-interfaces.ts @@ -82,6 +82,8 @@ export type Color = HexColor | ThemeColor export type Margin = number | [number, number, number, number] export type HAlign = 'left' | 'center' | 'right' | 'justify' export type VAlign = 'top' | 'middle' | 'bottom' +export type TabStopAlign = 'l' | 'r' | 'ctr' | 'dec' + // used by charts, shape, text export interface BorderProps { /** @@ -381,6 +383,11 @@ export interface TextBaseProps { * @default 'top' */ valign?: VAlign + + /** + * tab stops + */ + tabStops?: (number | string | {position: number | string; alignment: TabStopAlign})[] } // image / media ================================================================================== diff --git a/src/gen-xml.ts b/src/gen-xml.ts index 0911e9a7a..a3b0ae314 100644 --- a/src/gen-xml.ts +++ b/src/gen-xml.ts @@ -820,7 +820,8 @@ function slideObjectRelationsToXml(slide: PresSlide | SlideLayout, defaultRels: function genXmlParagraphProperties(textObj: ISlideObject | TextProps, isDefault: boolean): string { let strXmlBullet = '', strXmlLnSpc = '', - strXmlParaSpc = '' + strXmlParaSpc = '', + strXmlTabStops = '' let tag = isDefault ? 'a:lvl1pPr' : 'a:pPr' let bulletMarL = valToPts(DEF_BULLET_MARGIN) @@ -927,9 +928,19 @@ function genXmlParagraphProperties(textObj: ISlideObject | TextProps, isDefault: strXmlBullet = '' } + // OPTION: tabStops + if (textObj.options.tabStops?.length) { + let tabStopsXml = textObj.options.tabStops.map(stop => { + let pos = inch2Emu(typeof stop === "object" ? stop.position : stop) + let algn = typeof stop === "object" ? stop.alignment : 'l' + return `` + }).join('') + strXmlTabStops = `${tabStopsXml}` + } + // B: Close Paragraph-Properties // IMPORTANT: strXmlLnSpc, strXmlParaSpc, and strXmlBullet require strict ordering - anything out of order is ignored. (PPT-Online, PPT for Mac) - let childPropXml = strXmlLnSpc + strXmlParaSpc + strXmlBullet + let childPropXml = strXmlLnSpc + strXmlParaSpc + strXmlBullet + strXmlTabStops if (isDefault) childPropXml += genXmlTextRunProperties(textObj.options, true) if (childPropXml) { paragraphPropXml += '>' + childPropXml + '' diff --git a/types/index.d.ts b/types/index.d.ts index 272a68da7..f1c3a1da0 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -896,6 +896,7 @@ declare namespace PptxGenJS { export type Margin = number | [number, number, number, number] export type HAlign = 'left' | 'center' | 'right' | 'justify' export type VAlign = 'top' | 'middle' | 'bottom' + export type TabStopAlign = 'l' | 'r' | 'ctr' | 'dec' // used by charts, shape, text export interface BorderProps { /** @@ -1193,6 +1194,10 @@ declare namespace PptxGenJS { * @default 'top' */ valign?: VAlign + /** + * tab stops + */ + tabStops?: (number | string | {position: number | string; alignment: TabStopAlign})[] } // image / media ==================================================================================