draftjs-filters
Advanced tools
+10
-0
@@ -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 @@ |
@@ -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 @@ |
+1
-1
| { | ||
| "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", |
+7
-11
@@ -1,2 +0,2 @@ | ||
| # [Draft.js filters](https://thibaudcolas.github.io/draftjs-filters/) [](https://www.npmjs.com/package/draftjs-filters) [](https://travis-ci.org/thibaudcolas/draftjs-filters) [](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/) [](https://www.npmjs.com/package/draftjs-filters) [](https://travis-ci.org/thibaudcolas/draftjs-filters) [](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 @@ ``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43554
0.35%664
0.3%0
-100%264
-1.49%