@prezly/docx-cleaner
TypeScript icon, indicating that this package has built-in type declarations

0.5.2 • Public • Published

@prezly/docx-cleaner

Normalize dirty HTML and DOCX/RTF documents into clean, understandable HTML

Version License

Usage

import React, { ClipboardEvent, useState } from 'react';
import { cleanDocx } from '@prezly/docx-cleaner';

const MyComponent = () => {
    const [value, setValue] = useState<string>('');

    function handlePaste(event: ClipboardEvent<HTMLTextAreaElement>) {
        const html = event.clipboardData.getData('text/html');
        const rtf = event.clipboardData.getData('text/rtf');

        try {
            const cleanHtml = cleanDocx(html, rtf);
            setValue(cleanHtml);
        } catch (error) {
            setValue(error.message);
            console.error(error);
        }
    };

    return <textarea value={value} onPaste={handlePaste} />;
};

export default MyComponent;

Development

In order to start developing, run the build in watch mode.

Setup

npm install           # install dependencies
npm run build:watch   # start watcher

Publishing

npm run release     # reinstall & rebuild everything from scratch and...
                    # ...and run a wizard that'll guide you through publishing the npm package

Brought to you by Prezly.

Readme

Keywords

none

Package Sidebar

Install

npm i @prezly/docx-cleaner

Weekly Downloads

427

Version

0.5.2

License

MIT

Unpacked Size

163 kB

Total Files

242

Last publish

Collaborators

  • mohammadxali
  • francis-prezly
  • pestaa
  • kudlik
  • digitalbase
  • e1npm
  • satoav
  • makanda