rich-to-word
v0.1.1
Published
rich text convert to docx
Downloads
5
Readme
rich-to-word
Installation
npm install rich-to-word
Use
import richToWord from rich-to-word;
const richText = `<p>hello rich-to-word</p><p><img src="https://avatars.githubusercontent.com/u/8125081?v=4" alt="" data-href="" style=""/></p>`
const blob = await richToWord(html);
const link = document.createElement('a');
const blobUrl = window.URL.createObjectURL(blob);
link.href = blobUrl;
link.download = 'word.docx';
link.click();
or
import { richToWordSave } from 'rich-to-word';
// use file-saver to download
const richText = `<p>hello rich-to-word</p><p><img src="https://avatars.githubusercontent.com/u/8125081?v=4" alt="" data-href="" style=""/></p>`;
richToWordSave(richText, 'word');
// await richToWordSave(richText, 'word');
Options
richToWord(richText, options)
richToWordSave(richText, fileName, options)
- [imgDefaultStyle] (string): set img default style
- [disablePreprocess] (boolean): if need to handle it yourself, disable the default style
Use in Vite
LICENSE
MIT