This repository was archived by the owner on Oct 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,20 @@ describe("draft-js-markdown-plugin", () => {
331331 character = " " ;
332332 subject = ( ) =>
333333 plugin . handleBeforeInput ( character , store . getEditorState ( ) , store ) ;
334+ currentRawContentState = {
335+ entityMap : { } ,
336+ blocks : [
337+ {
338+ key : "item1" ,
339+ text : "" ,
340+ type : "unstyled" ,
341+ depth : 0 ,
342+ inlineStyleRanges : [ ] ,
343+ entityRanges : [ ] ,
344+ data : { } ,
345+ } ,
346+ ] ,
347+ } ;
334348 } ) ;
335349 [
336350 "handleBlockType" ,
Original file line number Diff line number Diff line change @@ -140,7 +140,6 @@ const createMarkdownPlugin = (config = {}) => {
140140 return "not-handled" ;
141141 } ,
142142 handleReturn ( ev , editorState , { setEditorState } ) {
143- console . log ( "HANDLE RETURN" ) ;
144143 const newEditorState = checkReturnForState ( editorState , ev ) ;
145144 if ( editorState !== newEditorState ) {
146145 setEditorState ( newEditorState ) ;
@@ -152,6 +151,16 @@ const createMarkdownPlugin = (config = {}) => {
152151 if ( character !== " " ) {
153152 return "not-handled" ;
154153 }
154+ // If we're in a code block don't add markdown to it
155+ const startKey = editorState . getSelection ( ) . getStartKey ( ) ;
156+ if ( startKey ) {
157+ const currentBlockType = editorState
158+ . getCurrentContent ( )
159+ . getBlockForKey ( startKey )
160+ . getType ( ) ;
161+ if ( currentBlockType === "code-block" ) return "not-handled" ;
162+ }
163+
155164 const newEditorState = checkCharacterForState ( editorState , character ) ;
156165 if ( editorState !== newEditorState ) {
157166 setEditorState ( newEditorState ) ;
You can’t perform that action at this time.
0 commit comments