Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
draftmirror
Advanced tools
DraftMirror provides a Draft.js-like API on top of ProseMirror.
$ npm install draftmirror
var DraftMirror = require('draftmirror');
var MyApp = React.createClass({
getInitialState: function() {
return {
editorState: DraftMirror.EditorState.createFromJSON(schema, defaultJson)
}
},
onChange: function(newEditorState) {
this.setState({
editorState: newEditorState
});
},
render: function() {
return <DraftMirror
editorState={this.state.editorState}
onChange={this.onChange}
/>;
}
});
var newEditorState = DraftMirror.StyleUtils.toggleInlineStyle(editorState, 'strong');
DraftMirror allows the extension of ProseMirror syntax using custom React widgets:
var DraftMirror = require('draftmirror');
var schema = DraftMirror.schema;
var MyWidgetComponent = React.createClass({
render: function() {
return <div>...</div>;
}
});
var MyWidget = DraftMirror.createWidget({
component: MyWidgetComponent
});
const mySchema = new Schema({
nodes: schema.nodeSpec.addBefore('image', 'mywidget', {
type: MyWidget, group: "inline"
}),
marks: schema.markSpec
});
You can ask to render tooltips by providing a callback function as prop getTooltip
. You callback should have such signature:
/**
* Return tooltip depending on context
*
* @param {DraftMirror.SelectionContext} context The current context
* @return {DraftMirror.Tooltip}
*/
function getTooltip(context) {
return {
component: <ReactComponent>,
props: <Object>
position: 'bottom' | 'center' | 'right' | 'left',
type: 'mark' | 'node',
className: <String>, // Additionnal class for the div
};
}
FAQs
React component for ProseMirror providing a Draft.js like API
The npm package draftmirror receives a total of 0 weekly downloads. As such, draftmirror popularity was classified as not popular.
We found that draftmirror 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.