Skip to main content

docx-to-html

Documentation / lib/components/Editor/docx/docx-to-html

documentToTokens()​

function documentToTokens(docxInput: string | File | Blob | ArrayBuffer, options: any): Promise<any[]>;

Defined in: apps/web/src/lib/components/Editor/docx/docx-to-html.js:14

Converts docx file to array or token objects with text and formatting 1 - open document.xml and styles.xml by unzipping .docx file 2 - tokenize document.xml and pull info on named styles from styles.xml

Parameters​

ParameterTypeDescription

docxInput

string | File | Blob | ArrayBuffer

File Path, File object, Blob, or ArrayBuffer of a DOCX file

options

any

simplified: boolean

Returns​

Promise<any[]>

Array of token objects with text and formatting


documentToMarkup()​

function documentToMarkup(filepath: any): Promise<string>;

Defined in: apps/web/src/lib/components/Editor/docx/docx-to-html.js:62

1 - open document.xml 2 - tokenize xml 3 - reconstruct cleaned html

Parameters​

ParameterType

filepath

any

Returns​

Promise<string>


createStyleParser()​

function createStyleParser(styleXML: any): Promise<any>;

Defined in: apps/web/src/lib/components/Editor/docx/docx-to-html.js:68

Parameters​

ParameterType

styleXML

any

Returns​

Promise<any>


createTokenizer()​

function createTokenizer(docXML: string, styleData: any): any[];

Defined in: apps/web/src/lib/components/Editor/docx/docx-to-html.js:118

Parses doc xml to tokenize each text range into obj: text: "", format underline, strong, mark

Parameters​

ParameterTypeDescription

docXML

string

string from docx unzip

styleData

any

parsed object of style class names

Returns​

any[]

blocks