
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.
draftjs-conductor
Advanced tools
📝✨ Little Draft.js helpers to make rich text editors just work. Built for Draftail and Wagtail.
Check out the online demo!
By default, Draft.js only provides support for 5 list levels for bulleted and numbered lists. While this is often more than enough, some editors need to go further.
Instead of manually writing and maintaining the list nesting styles, use this little helper:
import { ListNestingStyles, blockDepthStyleFn } from "draftjs-conductor";
<Editor blockStyleFn={blockDepthStyleFn} />
<ListNestingStyles max={6} />
ListNestingStyles
will generate the necessary CSS for your editor’s lists. blockDepthStyleFn
will then apply classes to blocks based on their depth, so the styles take effect. Voilà!
Relevant Draft.js issues:
The default Draft.js copy-paste handlers lose a lot of the formatting when copy-pasting between Draft.js editors. While this might be ok for some use cases, sites with multiple editors on the same page need them to reliably support copy-paste.
Relevant Draft.js issues:
<p>
tags on paste – facebook/draft-js#523 (comment)To make it just work:
import {
registerCopySource,
handleDraftEditorPastedText,
} from "draftjs-conductor";
class MyEditor extends Component {
constructor(props: Props) {
super(props);
this.state = {
editorState: EditorState.createEmpty(),
};
this.onChange = this.onChange.bind(this);
this.handlePastedText = this.handlePastedText.bind(this);
}
componentDidMount() {
this.copySource = registerCopySource(this.editorRef);
}
onChange(nextState: EditorState) {
this.setState({ editorState: nextState });
}
handlePastedText(text: string, html: ?string, editorState: EditorState) {
let newState = handleDraftEditorPastedText(html, editorState);
if (newState) {
this.onChange(newState);
return true;
}
return false;
}
componentWillUnmount() {
if (this.copySource) {
this.copySource.unregister();
}
}
render() {
const { editorState } = this.state;
return (
<Editor
ref={(ref) => {
this.editorRef = ref;
}}
editorState={editorState}
onChange={this.onChange}
handlePastedText={this.handlePastedText}
/>
);
}
}
registerCopySource
will ensure the clipboard contains a full representation of the Draft.js content state on copy, while handleDraftEditorPastedText
retrieves Draft.js content state from the clipboard. Voilà! This also changes the HTML clipboard content to be more semantic, with less styles copied to other word processors/editors.
Note: IE11 isn’t supported, as it doesn't support storing HTML in the clipboard.
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.
View the full list of contributors. MIT licensed. Website content available as CC0.
FAQs
📝✨ Little Draft.js helpers to make rich text editors “just work”
The npm package draftjs-conductor receives a total of 5,777 weekly downloads. As such, draftjs-conductor popularity was classified as popular.
We found that draftjs-conductor 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
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.