Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/docxml/mod.ts>StylesXml

TypeScript (component) library for building and parsing a DOCX file
Latest
class StylesXml
extends XmlFile
import { StylesXml } from "https://deno.land/x/docxml@5.15.3/mod.ts";

Constructors

new
StylesXml(location: string)

Properties

readonly
styles: AnyStyleDefinition[]

The list of custom styles. Does not include latent styles.

Methods

protected
toNode(): Document
add(properties: Omit<AnyStyleDefinition, "id"> & { id?: string; })

Add a custom style to the available style palette. If it does not have an identifier already, the system will propose an identifier based on the style name, or create a unique GUID. This method throws when the identifier is not unique.

addDefaults(properties: DocumentDefaults)

Adds default styles.

addLatent(properties: LatentStyle)

Adds a latent style, which means that the Word processor should determine its actual properties

addStyles(styles: AnyStyleDefinition[])

Add several custom styles to the available palette. Useful for cloning the style configuration of another DOCX.

deprecated
ensureStyle(id: string)

Ensure that a style with this identifier exists. If it doesn't already exist, an empty (paragraph) style is added just in time.

get(id: string)

Gets the style data by its identifier.

hasStyle(id: string)

Checks wether a custom style or a latent style with this identifier already exists.

Static Methods

fromArchive(archive: Archive, location: string): Promise<StylesXml>

Instantiate this class by looking at the DOCX XML for it.

fromDom(
dom: Document,
location: string,
theme?: ThemeXml,
): StylesXml