rich-to-word
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

rich-to-word

NPM version NPM downloads

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

see rich-to-word-vite

LICENSE

MIT

Readme

Keywords

Package Sidebar

Install

npm i rich-to-word

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

9.68 kB

Total Files

5

Last publish

Collaborators

  • iclae0