
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
draft-js-richbuttons-plugin
Advanced tools
This is a plugin for the draft-js-plugins-editor
.
This plugin allows you to add essential rich formatting buttons (inline and block styles) to your plugins-enabled editor.
First instantiate the plugin:
import createRichButtonsPlugin from 'draft-js-richbuttons-plugin';
const richButtonsPlugin = createRichButtonsPlugin();
In order to ensure buttons are re-rendered in sync with your editor even when other events change state, subscribe the plugin to your state changes like this in your component's onChage
handler:
onChange(editorState) {
this.setState({content: editorState}, () => {
richButtonsPlugin.onEditorChange(editorState);
});
}
Now get any desired components for inline or block formatting buttons from the instance:
/* import only the ones you need; all available shown */
const {
// inline buttons
ItalicButton, BoldButton, MonospaceButton, UnderlineButton,
// block buttons
ParagraphButton, BlockquoteButton, CodeButton, OLButton, ULButton, H1Button, H2Button, H3Button, H4Button, H5Button, H6Button
} = richButtonsPlugin;
Render these where desired in your component:
<div className="myToolbar">
<BoldButton/>
<ItalicButton/>
<H2Button/>
<ULButton/>
<OLButton/>
</div>
The default buttons are intentionally plain, but will pass the needed props down to their child, allowing you to customize rendering to your needs.
Props passed to both inline and block buttons:
Props unique to inline buttons:
Props unique to block buttons:
Example:
/*
Stateless component for inline style buttons, using the passed props as well as a custom prop "iconName"
*/
const MyIconButton = ({iconName, toggleInlineStyle, isActive, label, inlineStyle, onMouseDown }) =>
<a onClick={toggleInlineStyle} onMouseDown={onMouseDown}>
<span
className={`fa fa-${iconName}`}
toolTip={label}
style={{ color: isActive ? '#000' : '#777' }}
/>
</a>;
The above presentational component could then be used this way:
<BoldButton>
<MyIconButton iconName="bold"/>
</BoldButton>
<ItalicButton>
<MyIconButton iconName="italic"/>
</ItalicButton>
The plugin automatically applies default key bindings from draft's RichUtils
, including Tab / Shift-Tab behavior for nested lists.
MIT
1.0.1 - 2016-06-17
Cleand up npm module
FAQs
Rich Editing Buttons Plugin for DraftJS Plugins Editor
The npm package draft-js-richbuttons-plugin receives a total of 129 weekly downloads. As such, draft-js-richbuttons-plugin popularity was classified as not popular.
We found that draft-js-richbuttons-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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.