Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
draft-js-divider-plugin
Advanced tools
This is a plugin for the draft-js-plugins-editor
.
import createDividerPlugin from 'draft-js-divider-plugin';
const dividerPlugin = createDividerPlugin();
It exposes addDivider
function and DividerButton
.
You can use this plugin like below.
/* eslint-disable */
import React, { Component } from 'react';
import 'draft-js/dist/Draft.css';
import Editor, { createEditorStateWithText } from 'draft-js-plugins-editor';
import createSideToolbarPlugin from 'draft-js-side-toolbar-plugin';
import BlockTypeSelect from 'draft-js-side-toolbar-plugin/lib/components/BlockTypeSelect';
import 'draft-js-side-toolbar-plugin/lib/plugin.css';
import createDividerPlugin from 'draft-js-divider-plugin';
import 'draft-js-divider-plugin/lib/plugin.css';
const dividerPlugin = createDividerPlugin();
const DefaultBlockTypeSelect = ({ getEditorState, setEditorState, theme }) => (
<BlockTypeSelect
getEditorState={getEditorState}
setEditorState={setEditorState}
theme={theme}
structure={[dividerPlugin.DividerButton]}
/>
);
const sideToolbarPlugin = createSideToolbarPlugin({
structure: [DefaultBlockTypeSelect],
});
import './Editor.css';
const plugins = [sideToolbarPlugin, dividerPlugin];
const { SideToolbar } = sideToolbarPlugin;
class CustomEditor extends Component {
state = {
editorState: createEditorStateWithText(''),
};
onChange = editorState => {
this.setState({
editorState,
});
};
render() {
return (
<div className="App">
<div className="editor">
<Editor
placeholder="placeholder ..."
readOnly={false}
editorState={this.state.editorState}
onChange={this.onChange}
plugins={plugins}
ref={element => {
this.editor = element;
}}
/>
<SideToolbar />
</div>
</div>
);
}
}
export default CustomEditor;
The plugin ships with a default styling available at this location in the installed package:
draft-js-divider-plugin/lib/plugin.css
.
If you want to use the default styles, you can include this stylesheet.
Otherwise you can supply your own styles via the theme
config option.
FAQs
Divider Plugin for DraftJS
The npm package draft-js-divider-plugin receives a total of 109 weekly downloads. As such, draft-js-divider-plugin popularity was classified as not popular.
We found that draft-js-divider-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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.