Skip to content

A helper for draft-js that allows you to clear all formatting from selection

Notifications You must be signed in to change notification settings

andrey-semin/draft-js-clear-formatting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A helper for draft-js that allows you to clear all formatting from selection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published