UNPKG

pptx-automizer

Version:

A template based pptx generator

108 lines (107 loc) 5.41 kB
import { ElementInfo, ElementPosition, ElementType, ElementVisualType, GroupInfo, LayoutInfo, PlaceholderInfo, SlideHelperProps, TextParagraph, TextParagraphGroup, XmlDocument, XmlElement } from '../types/xml-types'; import { TableInfo } from '../types/table-types'; import IArchive from '../interfaces/iarchive'; import { FindElementMultiSelector } from '../types/types'; export declare const nsMain = "http://schemas.openxmlformats.org/presentationml/2006/main"; export declare const mapUriType: { 'http://schemas.openxmlformats.org/drawingml/2006/table': string; 'http://schemas.openxmlformats.org/drawingml/2006/chart': string; 'http://schemas.microsoft.com/office/drawing/2014/chartex': string; 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject': string; 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink': string; }; /** * Class that represents an XML slide helper */ export declare class XmlSlideHelper { private slideXml; protected sourceArchive: IArchive; protected slideNumber: number; protected sourceLayoutId: number; /** * Constructor for the XmlSlideHelper class. * @param {XmlDocument} slideXml - The slide XML document to be used by the helper. * @param params */ constructor(slideXml: XmlDocument, params: SlideHelperProps); getSlideCreationId(): number | undefined; getSlideLayout(): Promise<LayoutInfo>; /** * Get an ElementInfo object for the target element on the slide. * @param selector */ getElement(selector: string): Promise<ElementInfo>; /** * Get an array of ElementInfo objects for all named elements on a slide. * @param filterTags Use an array of strings to filter the output array * @param layoutPlaceholders */ getAllElements(filterTags?: string[], layoutPlaceholders?: PlaceholderInfo[]): ElementInfo[]; /** * Get all text element IDs from the slide. * @return {string[]} An array of text element IDs. */ getAllTextElementIds(useCreationIds?: boolean): string[]; static getElementInfo(slideElement: XmlElement, layoutPlaceholders?: PlaceholderInfo[]): ElementInfo; /** * Retrieves a list of all named elements on a slide. Automation requires at least a name. * @param filterTags Use an array of strings to filter the output array */ getNamedElements(filterTags?: string[]): XmlElement[]; static getTextBody(shapeNode: XmlElement): XmlElement; static parseTextFragments(shapeNode: XmlElement): string[]; static parseParagraphGroups(shapeNode: XmlElement): TextParagraphGroup[]; static parseTextParagraphs(shapeNode: XmlElement): TextParagraph[]; static setTextProperties(run: XmlElement, paragraph: TextParagraph): void; static setParagraphProperties(pPr: XmlElement, paragraph: TextParagraph): void; static groupSimilarParagraphs(paragraphs: TextParagraph[]): TextParagraphGroup[]; static getNonVisibleProperties(shapeNode: XmlElement): XmlElement; static getImageAltText(slideElement: XmlElement): string; static getElementName(slideElement: XmlElement): string; static getElementCreationId(slideElement: XmlElement, stripBrackets?: boolean): string | undefined; static getElementNameIdx(slideElement: XmlElement): number; /** * Parses local tag name to specify element type in case it is a 'graphicFrame'. * @param slideElementParent */ static getElementType(slideElementParent: XmlElement): ElementType; static parseShapeCoordinates(slideElementParent: XmlElement, returnDefaults?: boolean): ElementPosition; static parseCoordinate: (element: XmlElement, attributeName: string) => number; static parseGroupInfo: (element: XmlElement) => GroupInfo; getSlideLayoutXml(layoutId: number): Promise<XmlDocument>; static getSlideLayoutXml(sourceArchive: IArchive, layoutId: number): Promise<XmlDocument>; /** * Asynchronously retrieves the dimensions of a slide. * Tries to find the dimensions from the slide XML, then from the layout, master, and presentation XMLs in order. * * @returns {Promise<{ width: number, height: number }>} The dimensions of the slide. * @throws Error if unable to determine dimensions. */ getDimensions(): Promise<{ width: number; height: number; }>; /** * Fetches an XML file from the given path and extracts the dimensions. * * @param {string} path - The path of the XML file. * @returns {Promise<{ width: number; height: number } | null>} - A promise that resolves with an object containing the width and height, or `null` if there was an error. */ getAndExtractDimensions: (path: string) => Promise<{ width: number; height: number; } | null>; static readTableInfo: (element: XmlElement) => TableInfo[]; /** * Reconstruct the complete selector for a given xmlElement, including the * n-th occurance of the shape name on the current slide * @param slideElement */ static getSelector(slideElement: XmlElement): FindElementMultiSelector; /** * Determines the type of visual element in PowerPoint * @param element The XML element to check * @returns A string identifying the element type */ static getElementVisualType(element: XmlElement): ElementVisualType; }