Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
draft-js-single-line-plugin
Advanced tools
Restrict a draft-js editor to a single line of input.
This is a plugin for the draft-js-plugins-editor
, a plugin system that sits on top of Draft.js.
This plugin adds support restricting Facebook’s Draft.js editor to a single line of content. It will condense any blocks into a single block, and (optionally) strip any rich entities.
Madness I know, however there places you want to allow some rich styling yet the underlying value should still be a single line. Allowing titles for things like blog posts or pages to contain strong/emphasis is our main use-case.
import createSingleLinePlugin from 'draft-js-single-line-plugin'
const singleLinePlugin = createSingleLinePlugin()
This can then be passed into a draft-js-plugins-editor
component:
import createSingleLinePlugin from 'draft-js-single-line-plugin'
const singleLinePlugin = createSingleLinePlugin()
import Editor from 'draft-js-plugins-editor'
const plugins = [singleLinePlugin]
<Editor plugins={plugins}
blockRenderMap={singleLinePlugin.blockRenderMap} />
The plugin export a custom blockRenderMap
that overrides the draft-js defaults and restricts the editor from rendering anything except an unstyled
block. You’ll need to manually pass it as above as the draft-js-plugins-editor
doesn’t yet support this.
You can pass options to the plugin as you call it:
const options = {
stripEntities: false
}
const singleLinePlugin = createSingleLinePlugin(options)
There’s only one option so far: stripEntities: true/false
.
npm install
npm install react react-dom draft-js
npm run test
v2.0.5 2019-07-23
FAQs
Restrict a draft-js editor to a single line of input.
The npm package draft-js-single-line-plugin receives a total of 2,672 weekly downloads. As such, draft-js-single-line-plugin popularity was classified as popular.
We found that draft-js-single-line-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.