draft-js-clear-formatting

1.0.0 • Public • Published

Draft.js Clear Formatting

This package is a helper function for Draft JS users. It allows you toclear formatting in selected text in your app. You can choose to remove the following edits:

  • Inline styles(bold, italic, underline)
  • Entities(images, links etc.)
  • Lists(orders, unorderes)

For more details checks configuration section below

Usage

npm i --save draft-js-clear-formatting

then import the function

import clearFormatting from 'draft-js-clear-formatting'
import Editor from 'draft-js-plugins-editor'
 
const newEditorState = clearFormatting(editorState, options)
 

Options object

You can pass options object to the function. This object is not required. By default all options set to true.

const options = {
  inline: true,
  entities: true,
  lists: true,
}
Option Description Default value
inline Removes all inline styles true
entities Removes all entities true
lists Removes all lists true

TO DO

  • Add tests

/draft-js-clear-formatting/

    Package Sidebar

    Install

    npm i draft-js-clear-formatting

    Weekly Downloads

    1,051

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    197 kB

    Total Files

    8

    Last publish

    Collaborators

    • andrey-semin