Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
created highlight plugin
- Loading branch information
Julian Krispel-Samsel
committed
Jun 18, 2017
1 parent
934e413
commit e25f78be560ff2719bda4123f24dfd886582eaa6
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RichUtils } from 'draft-js'; | ||
|
||
export default () => { | ||
return { | ||
customStyleMap: { | ||
'HIGHLIGHT': { | ||
background: 'blue', | ||
padding: '0 .3em', | ||
color: '#fff', | ||
} | ||
}, | ||
keyBindingFn: (e) => { | ||
if (e.metaKey && e.key === 'h') { | ||
return 'highlight'; | ||
} | ||
}, | ||
handleKeyCommand: (command, editorState, { setEditorState }) => { | ||
if (command === 'highlight') { | ||
setEditorState(RichUtils.toggleInlineStyle(editorState, 'HIGHLIGHT')); | ||
return true; | ||
} | ||
}, | ||
}; | ||
}; |