1.0.0 • Published 5 years ago

draft-js-clear-formatting v1.0.0

Weekly downloads
845
License
MIT
Repository
github
Last release
5 years ago

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,
}
OptionDescriptionDefault value
inlineRemoves all inline stylestrue
entitiesRemoves all entitiestrue
listsRemoves all liststrue

TO DO

  • Add tests