Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass onChange to custom toolbar actions
Allows for much more robust (and modular) changes from custom toolbar actions. Example: A simple "Smile" action: ``` import { EditorState, Modifier } from 'draft-js'; import actions from 'megadraft/lib/actions/default'; export default actions.concat([ { type: 'custom', icon: props => ( <Smile {...props} width="24" height="18" fill="currentColor" fillRule="evenodd" /> ), action(editorState, onChange) { const contentState = Modifier.replaceText( editorState.getCurrentContent(), editorState.getSelection(), '😀', editorState.getCurrentInlineStyle() ); onChange(EditorState.push(editorState, contentState, 'insert-characters')); } } ]); ```
- Loading branch information