Guest User

Untitled

a guest
Dec 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. private toggleBlockStyle: DraftStyleChangeHandler = ({ type: blockStyle, data }) => {
  2. const { content, onChange } = this.props;
  3.  
  4. if (data) {
  5. const selection = content.getSelection();
  6. const nextContentState = Modifier.setBlockData(content.getCurrentContent(), selection, Map(data));
  7. const newEditorState = EditorState.push(content, nextContentState, 'change-block-data');
  8.  
  9. return onChange(newEditorState, 'change-block-data');
  10. }
  11.  
  12. onChange(
  13. RichUtils.toggleBlockType(
  14. content,
  15. blockStyle
  16. ),
  17. blockStyle
  18. );
  19. }
Add Comment
Please, Sign In to add comment