Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

draftjs-filters

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftjs-filters

Filter Draft.js content when copy-pasting rich text into the editor

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5K
decreased by-7.92%
Maintainers
1
Weekly downloads
 
Created
Source

Draft.js filters npm Build Status Coverage Status

Filter Draft.js content when copy-pasting rich text into the editor. Initially made for Draftail.

Check out the online demo.

Using the filters

First, grab the package from npm:

npm install --save draftjs-filters

WIP – Then, import the filters' entry point and use it in your <Editor>'s onChange function:

import { filterEditorState } from "draftjs-filters"

function onChange(nextEditorState) {
  const {
    stateSaveInterval,
    maxListNesting,
    enableHorizontalRule,
    stripPastedStyles,
    blockTypes,
    inlineStyles,
    entityTypes,
  } = this.props
  const { editorState } = this.state
  const content = editorState.getCurrentContent()
  const nextContent = nextEditorState.getCurrentContent()
  const shouldFilterPaste =
    nextContent !== content &&
    !stripPastedStyles &&
    nextEditorState.getLastChangeType() === "insert-fragment"

  let filteredEditorState = nextEditorState
  if (shouldFilterPaste) {
    filteredEditorState = filterEditorState(
      nextEditorState,
      maxListNesting,
      enableHorizontalRule,
      blockTypes,
      inlineStyles,
      entityTypes,
    )
  }

  this.setState({ editorState: filteredEditorState })
}

Browser support and polyfills

The Draft.js filters follow the browser support targets of Draft.js. Be sure to have a look at the Draft.js required polyfills.

Contributing

See anything you like in here? Anything missing? We welcome all support, whether on bug reports, feature requests, code, design, reviews, tests, documentation, and more. Please have a look at our contribution guidelines.

Development

Install

Clone the project on your computer, and install Node. This project also uses nvm.

nvm install
# Then, install all project dependencies.
npm install
# Install the git hooks.
./.githooks/deploy

Working on the project

Everything mentioned in the installation process should already be done.

# Make sure you use the right node version.
nvm use
# Start the server and the development tools.
npm run start
# Runs linting.
npm run lint
# Start a Flow server for type errors.
npm run flow
# Re-formats all of the files in the project (with Prettier).
npm run format
# Run tests in a watcher.
npm run test:watch
# Run test coverage
npm run test:coverage
# Open the coverage report with:
npm run report:coverage
# Open the build report with:
npm run report:build
# View other available commands with:
npm run

Releases

Credits

View the full list of contributors. MIT licensed. Website content available as CC0.

Keywords

FAQs

Package last updated on 10 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc