UNPKG

pptx-automizer

Version:

A template based pptx generator

54 lines (53 loc) 4.69 kB
import { Node } from '@xmldom/xmldom'; import { DefaultAttribute, HelperElement, ModifyXmlCallback, OverrideAttribute, RelationshipAttribute, XmlDocument, XmlElement } from '../types/xml-types'; import { GetRelationshipsCallback, Target } from '../types/types'; import IArchive from '../interfaces/iarchive'; import { ContentTypeExtension } from '../enums/content-type-map'; export declare class XmlHelper { static modifyXmlInArchive(archive: IArchive, file: string, callbacks: ModifyXmlCallback[]): Promise<void>; static getXmlFromArchive(archive: IArchive, file: string): Promise<XmlDocument>; static writeXmlToArchive(archive: IArchive, file: string, xml: XmlDocument): void; static appendIf(element: HelperElement): Promise<XmlElement | boolean>; static append(element: HelperElement): Promise<XmlElement>; static removeIf(element: HelperElement): Promise<XmlElement[]>; static getNextRelId(rootArchive: IArchive, file: string): Promise<string>; static getMaxId(rels: NodeListOf<ChildNode> | HTMLCollectionOf<XmlElement>, attribute: string, increment?: boolean, minId?: number): number; static getRelationshipTargetsByPrefix(archive: IArchive, path: string, prefix: string | string[]): Promise<Target[]>; static parseRelationTarget(element: XmlElement, prefix?: string): Target; static targetMatchesRelationship(relType: string, subtype: string, file: string, prefix: string): boolean; static getTargetsByRelationshipType(archive: IArchive, path: string, type: string): Promise<Target[]>; static getRelationshipItems(archive: IArchive, path: string, cb: GetRelationshipsCallback, tag?: string): Promise<Target[]>; static findByAttribute(xml: XmlDocument | Document, tagName: string, attributeName: string, attributeValue: string): boolean; static replaceAttribute(archive: IArchive, path: string, tagName: string, attributeName: string, attributeValue: string, replaceValue: string, replaceAttributeName?: string): Promise<void>; static getTargetByRelId(archive: IArchive, relsPath: string, element: XmlElement, type: string): Promise<Target>; static isElementCreationId(selector: string): boolean; static findByElementCreationId(archive: IArchive, path: string, creationId: string): Promise<XmlElement>; static findByElementName(archive: IArchive, path: string, name: string, nameIdx?: number): Promise<XmlElement>; static findByName(doc: Document, name: string, nameIdx?: number): XmlElement; static findByCreationId(doc: Document, creationId: string): XmlElement; static findFirstByAttributeValue(nodes: NodeListOf<ChildNode> | HTMLCollectionOf<XmlElement>, attributeName: string, attributeValue: string): XmlElement; static findByAttributeValue(nodes: NodeListOf<ChildNode> | HTMLCollectionOf<XmlElement>, attributeName: string, attributeValue: string): XmlElement[]; static createContentTypeChild(archive: IArchive, attributes: OverrideAttribute | DefaultAttribute): HelperElement; static createRelationshipChild(archive: IArchive, targetRelFile: string, attributes: RelationshipAttribute): HelperElement; static appendImageExtensionToContentType(targetArchive: IArchive, extension: ContentTypeExtension): Promise<XmlElement | boolean>; static appendSharedString(sharedStrings: Document, stringValue: string): number; static insertAfter(newNode: XmlElement, referenceNode: XmlElement): XmlElement; static sliceCollection(collection: HTMLCollectionOf<XmlElement>, length: number, from?: number): void; static getClosestParent(tag: string, element: XmlElement): XmlElement; static remove(toRemove: XmlElement): void; static removeAllChildren(element: XmlElement): void; static moveChild(childToMove: XmlElement, insertBefore?: XmlElement): void; static appendClone(childToClone: XmlElement, parent: XmlElement): XmlElement; static sortCollection(collection: HTMLCollectionOf<XmlElement>, order: number[], callback?: ModifyXmlCallback): void; static modifyCollection(collection: HTMLCollectionOf<XmlElement>, callback: ModifyXmlCallback): void; static modifyCollectionAsync(collection: HTMLCollectionOf<XmlElement>, callback: ModifyXmlCallback): Promise<void>; static dump(element: XMLDocument | Element | Node): void; static removeByTagName: (element: XmlElement, tagName: string, i?: number) => void; /** * Find an element with the given tag name, searching deeply through the structure * @param element The root element to search in * @param tagName The tag name to search for * @returns The found element or null */ static findElement(element: XmlElement, tagName: string): XmlElement | null; }