UNPKG

custom-x

Version:

A library to facilitate the storage of javascript objects in Custom XML Parts.

48 lines (47 loc) 2.58 kB
/** * Sets a custom XML part for the specified key and value. * * This asynchronous function converts the provided value into an XML string and associates it * with a namespace derived from the given key. If a custom XML part with the same namespace already * exists, it is deleted; otherwise, a new custom XML part is added. * * @param key - A string used to determine the namespace for the custom XML part. * @param value - The value to be converted into an XML format and stored as a custom XML part. * * @returns A promise that resolves when the operation is complete. */ export declare function setCustomXmlPartByValue(key: string, value: any): Promise<void>; /** * Retrieves a custom XML part associated with the specified key. * * @param key - The key used to derive a namespace for locating the custom XML part. * @returns A promise that resolves to the matching Office.CustomXmlPart if found, or null if not found. * * @remarks * This asynchronous function converts the provided key to a namespace using getNameSpace and then * obtains the related custom XML part by invoking getCustomXmlPartByNameSpace. It is primarily used * for accessing custom XML parts based on a key-to-namespace transformation. */ export declare function getCustomXmlPart(key: string): Promise<Office.CustomXmlPart | null>; /** * Retrieves and parses the value of a custom XML part by its key. * * This asynchronous function first attempts to locate the custom XML part identified by the provided key. If the XML part exists, * it fetches its XML content asynchronously using the Office API. The retrieved XML string is then parsed into an object. * * @param key - The unique key that identifies the custom XML part. * @returns A promise that resolves to the parsed XML value, or null if the XML part is not found. * @throws An error if the asynchronous retrieval of the XML content fails. */ export declare function getCustomXmlPartValue(key: string): Promise<any | null>; /** * Removes a custom XML part associated with the provided key. * * This asynchronous function retrieves the namespace corresponding to the given key, * then fetches the custom XML part using that namespace. If the XML part exists, * it attempts to delete it using Office's asynchronous API. * * @param key - The identifier used to determine the namespace of the custom XML part. * @returns A promise that resolves if the XML part is successfully removed, or rejects with an error if deletion fails. */ export declare function removeCustomXmlPart(key: string): Promise<void>;