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 - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="0.4.0"></a>
# [0.4.0](https://github.com/thibaudcolas/draftjs-filters/compare/v0.3.0...v0.4.0) (2018-01-17)
### Features
* **api:** add ability for whitelist to filter by undefined attribute ([a4af845](https://github.com/thibaudcolas/draftjs-filters/commit/a4af845))
<a name="0.3.0"></a>

@@ -7,0 +17,0 @@

4

dist/draftjs-filters.cjs.js

@@ -282,3 +282,5 @@ 'use strict';

var regex = new RegExp(whitelist[attr]);
return regex.test(data[attr]);
var hasData = data.hasOwnProperty(attr);
return hasData && regex.test(data[attr]);
});

@@ -285,0 +287,0 @@

@@ -278,3 +278,5 @@ import { CharacterMetadata, EditorState } from 'draft-js';

var regex = new RegExp(whitelist[attr]);
return regex.test(data[attr]);
var hasData = data.hasOwnProperty(attr);
return hasData && regex.test(data[attr]);
});

@@ -281,0 +283,0 @@

{
"name": "draftjs-filters",
"version": "0.3.0",
"version": "0.4.0",
"description": "Filter Draft.js content to preserve only the formatting you allow",

@@ -5,0 +5,0 @@ "author": "Thibaud Colas",

@@ -1,2 +0,2 @@

# [Draft.js filters](https://thibaudcolas.github.io/draftjs-filters/) [![npm](https://img.shields.io/npm/v/draftjs-filters.svg?style=flat-square)](https://www.npmjs.com/package/draftjs-filters) [![Build Status](https://travis-ci.org/thibaudcolas/draftjs-filters.svg?branch=master)](https://travis-ci.org/thibaudcolas/draftjs-filters) [![Coverage Status](https://coveralls.io/repos/github/thibaudcolas/draftjs-filters/badge.svg)](https://coveralls.io/github/thibaudcolas/draftjs-filters) [<img src="https://cdn.rawgit.com/springload/awesome-wagtail/ac912cc661a7099813f90545adffa6bb3e75216c/logo.svg" width="104" align="right" alt="Wagtail">](https://wagtail.io/)
# [Draft.js filters](https://thibaudcolas.github.io/draftjs-filters/) [![npm](https://img.shields.io/npm/v/draftjs-filters.svg)](https://www.npmjs.com/package/draftjs-filters) [![Build Status](https://travis-ci.org/thibaudcolas/draftjs-filters.svg?branch=master)](https://travis-ci.org/thibaudcolas/draftjs-filters) [![Coverage Status](https://coveralls.io/repos/github/thibaudcolas/draftjs-filters/badge.svg)](https://coveralls.io/github/thibaudcolas/draftjs-filters) [<img src="https://cdn.rawgit.com/springload/awesome-wagtail/ac912cc661a7099813f90545adffa6bb3e75216c/logo.svg" width="104" align="right" alt="Wagtail">](https://wagtail.io/)

@@ -22,13 +22,9 @@ > Filter [Draft.js](https://facebook.github.io/draft-js/) content to preserve only the formatting you allow. Built for [Draftail](https://github.com/springload/draftail) and [Wagtail](https://github.com/wagtail/wagtail).

function onChange(nextEditorState) {
const { editorState } = this.state
const content = editorState.getCurrentContent()
const nextContent = nextEditorState.getCurrentContent()
function onChange(editorState) {
const shouldFilterPaste =
nextContent !== content &&
nextEditorState.getLastChangeType() === "insert-fragment"
editorState.getLastChangeType() === "insert-fragment"
let nextState = editorState
let filteredEditorState = nextEditorState
if (shouldFilterPaste) {
filteredEditorState = filterEditorState(
nextState = filterEditorState(
{

@@ -53,7 +49,7 @@ blocks: ["header-two", "header-three", "unordered-list-item"],

},
filteredEditorState,
nextState,
)
}
this.setState({ editorState: filteredEditorState })
this.setState({ editorState: nextState })
}

@@ -60,0 +56,0 @@ ```

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