@@ -6,12 +6,19 @@ import {
66 CHECKABLE_LIST_ITEM ,
77} from "draft-js-checkable-list-item" ;
88
9- import { Map } from "immutable" ;
10- import { getDefaultKeyBinding , Modifier , EditorState } from "draft-js" ;
9+ import { Map , OrderedSet } from "immutable" ;
10+ import {
11+ getDefaultKeyBinding ,
12+ Modifier ,
13+ EditorState ,
14+ RichUtils ,
15+ DefaultDraftInlineStyle ,
16+ } from "draft-js" ;
1117import adjustBlockDepth from "./modifiers/adjustBlockDepth" ;
1218import handleBlockType from "./modifiers/handleBlockType" ;
1319import handleInlineStyle from "./modifiers/handleInlineStyle" ;
1420import handleNewCodeBlock from "./modifiers/handleNewCodeBlock" ;
21+ import resetInlineStyle from "./modifiers/resetInlineStyle" ;
1522import insertEmptyBlock from "./modifiers/insertEmptyBlock" ;
1623import handleLink from "./modifiers/handleLink" ;
1724import handleImage from "./modifiers/handleImage" ;
@@ -152,31 +159,24 @@ const createMarkdownPlugin = (config = {}) => {
152159 }
153160 return "not-handled" ;
154161 } ,
155- keyBindingFn ( ev , { getEditorState, setEditorState } ) {
156- if ( ev . which === 13 ) {
157- const editorState = getEditorState ( ) ;
158- let newEditorState = checkReturnForState ( editorState , ev ) ;
159- if ( editorState !== newEditorState ) {
160- setEditorState ( newEditorState ) ;
161- return "handled" ;
162- }
162+ handleReturn ( ev , editorState , { setEditorState } ) {
163+ let newEditorState = checkReturnForState ( editorState , ev ) ;
164+ let selection = newEditorState . getSelection ( ) ;
163165
164- newEditorState = checkCharacterForState ( editorState , "" ) ;
165- if ( ! inCodeBlock ( editorState ) && editorState !== newEditorState ) {
166- const contentState = Modifier . splitBlock (
167- newEditorState . getCurrentContent ( ) ,
168- newEditorState . getSelection ( )
169- ) ;
166+ newEditorState = checkCharacterForState ( newEditorState , "" ) ;
167+ let content = newEditorState . getCurrentContent ( ) ;
170168
171- setEditorState (
172- EditorState . push ( newEditorState , contentState , "split-block" )
173- ) ;
169+ content = Modifier . splitBlock ( content , selection ) ;
174170
175- return "handled" ;
176- }
177- }
171+ setEditorState (
172+ EditorState . push (
173+ resetInlineStyle ( newEditorState ) ,
174+ content ,
175+ "split-block"
176+ )
177+ ) ;
178178
179- return getDefaultKeyBinding ( ev ) ;
179+ return "handled" ;
180180 } ,
181181 handleBeforeInput ( character , editorState , { setEditorState } ) {
182182 if ( character !== " " ) {
0 commit comments