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", () => {
331
331
character = " " ;
332
332
subject = ( ) =>
333
333
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
+ } ;
334
348
} ) ;
335
349
[
336
350
"handleBlockType" ,
Original file line number Diff line number Diff line change @@ -140,7 +140,6 @@ const createMarkdownPlugin = (config = {}) => {
140
140
return "not-handled" ;
141
141
} ,
142
142
handleReturn ( ev , editorState , { setEditorState } ) {
143
- console . log ( "HANDLE RETURN" ) ;
144
143
const newEditorState = checkReturnForState ( editorState , ev ) ;
145
144
if ( editorState !== newEditorState ) {
146
145
setEditorState ( newEditorState ) ;
@@ -152,6 +151,16 @@ const createMarkdownPlugin = (config = {}) => {
152
151
if ( character !== " " ) {
153
152
return "not-handled" ;
154
153
}
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
+
155
164
const newEditorState = checkCharacterForState ( editorState , character ) ;
156
165
if ( editorState !== newEditorState ) {
157
166
setEditorState ( newEditorState ) ;
You can’t perform that action at this time.
0 commit comments