
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
draftjs-filters
Advanced tools
Filter Draft.js content when copy-pasting rich text into the editor. Initially made for Draftail.
Check out the online demo.
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 })
}
The Draft.js filters follow the browser support targets of Draft.js. Be sure to have a look at the Draft.js required polyfills.
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.
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
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
View the full list of contributors. MIT licensed. Website content available as CC0.
FAQs
Filter Draft.js content to preserve only the formatting you allow
The npm package draftjs-filters receives a total of 5,614 weekly downloads. As such, draftjs-filters popularity was classified as popular.
We found that draftjs-filters demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.