
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@jimmycode/draft-js-autosave-plugin
Advanced tools
Autosave changes of your draft-js editor.
This is a plugin for draft-js-plugins-editor.
npm install @jimmycode/draft-js-autosave-plugin
Instantiate the plugin passing the necessary config:
import createAutosavePlugin from '@jimmycode/draft-js-autosave-plugin';
const autosavePlugin = createAutosavePlugin(config);
And then pass the plugin into a draft-js-plugins-editor component:
import Editor from 'draft-js-plugins-editor';
<Editor
plugins={[autosavePlugin]} />
The config options and their defaults are:
| Option | Default | Description |
|---|---|---|
saveFunction | null | Required callback function that will be called upon a save event. |
debounceTime | 3000 | Time, in milliseconds, to debounce the firing of save events after changes. |
import React from 'react';
import ReactDOM from 'react-dom';
import { EditorState, convertToRaw } from 'draft-js';
import Editor from 'draft-js-plugins-editor';
import createAutosavePlugin from '@jimmycode/draft-js-autosave-plugin';
const saveDraft = (editorState) => {
const rawContent = convertToRaw(editorState.getCurrentContent());
localStorage.setItem('draft', JSON.stringify(rawContent));
}
const autosavePlugin = createAutosavePlugin({
saveFunction: saveDraft,
debounceTime: 3000
})
class MyEditor extends React.Component {
constructor(props) {
super(props);
this.state = {
editorState: EditorState.createEmpty()
};
this.plugins = [
autosavePlugin
];
}
onChange = (editorState) => {
this.setState({ editorState });
}
render() {
return (
<div className="editor">
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
plugins={this.plugins}
placeholder="Tell a story" />
</div>
);
}
}
ReactDOM.render(<MyEditor />, document.getElementById('root'));
FAQs
Autosave changes of your draft-js editor
The npm package @jimmycode/draft-js-autosave-plugin receives a total of 10 weekly downloads. As such, @jimmycode/draft-js-autosave-plugin popularity was classified as not popular.
We found that @jimmycode/draft-js-autosave-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.