@@ -79,9 +79,9 @@ describe("handleInlineStyle", () => {
79
79
} ,
80
80
selection : new SelectionState ( {
81
81
anchorKey : "item1" ,
82
- anchorOffset : 14 ,
82
+ anchorOffset : 16 ,
83
83
focusKey : "item1" ,
84
- focusOffset : 14 ,
84
+ focusOffset : 16 ,
85
85
isBackward : false ,
86
86
hasFocus : true ,
87
87
} ) ,
@@ -123,9 +123,9 @@ describe("handleInlineStyle", () => {
123
123
} ,
124
124
selection : new SelectionState ( {
125
125
anchorKey : "item1" ,
126
- anchorOffset : 14 ,
126
+ anchorOffset : 16 ,
127
127
focusKey : "item1" ,
128
- focusOffset : 14 ,
128
+ focusOffset : 16 ,
129
129
isBackward : false ,
130
130
hasFocus : true ,
131
131
} ) ,
@@ -167,9 +167,9 @@ describe("handleInlineStyle", () => {
167
167
} ,
168
168
selection : new SelectionState ( {
169
169
anchorKey : "item1" ,
170
- anchorOffset : 14 ,
170
+ anchorOffset : 16 ,
171
171
focusKey : "item1" ,
172
- focusOffset : 14 ,
172
+ focusOffset : 16 ,
173
173
isBackward : false ,
174
174
hasFocus : true ,
175
175
} ) ,
@@ -310,9 +310,9 @@ describe("handleInlineStyle", () => {
310
310
} ,
311
311
selection : new SelectionState ( {
312
312
anchorKey : "item1" ,
313
- anchorOffset : 14 ,
313
+ anchorOffset : 16 ,
314
314
focusKey : "item1" ,
315
- focusOffset : 14 ,
315
+ focusOffset : 16 ,
316
316
isBackward : false ,
317
317
hasFocus : true ,
318
318
} ) ,
@@ -398,9 +398,9 @@ describe("handleInlineStyle", () => {
398
398
} ,
399
399
selection : new SelectionState ( {
400
400
anchorKey : "item1" ,
401
- anchorOffset : 14 ,
401
+ anchorOffset : 16 ,
402
402
focusKey : "item1" ,
403
- focusOffset : 14 ,
403
+ focusOffset : 16 ,
404
404
isBackward : false ,
405
405
hasFocus : true ,
406
406
} ) ,
@@ -456,9 +456,9 @@ describe("handleInlineStyle", () => {
456
456
} ,
457
457
selection : new SelectionState ( {
458
458
anchorKey : "item1" ,
459
- anchorOffset : 14 ,
459
+ anchorOffset : 16 ,
460
460
focusKey : "item1" ,
461
- focusOffset : 14 ,
461
+ focusOffset : 16 ,
462
462
isBackward : false ,
463
463
hasFocus : true ,
464
464
} ) ,
@@ -529,7 +529,25 @@ describe("handleInlineStyle", () => {
529
529
EditorState . createWithContent ( contentState ) ,
530
530
selection
531
531
) ;
532
- it ( "converts block type" , ( ) => {
532
+
533
+ const wrongSelectionState = selection . merge ( {
534
+ anchorOffset : 0 ,
535
+ focusOffset : 0 ,
536
+ } ) ;
537
+ const sameEditorState = EditorState . forceSelection (
538
+ editorState ,
539
+ wrongSelectionState
540
+ ) ;
541
+
542
+ it ( "does not convert markdown to style or block type if selection is at the wrong place" , ( ) => {
543
+ const newEditorState = handleInlineStyle ( sameEditorState , character ) ;
544
+ expect ( newEditorState ) . toEqual ( sameEditorState ) ;
545
+ expect ( Draft . convertToRaw ( newEditorState . getCurrentContent ( ) ) ) . toEqual (
546
+ before
547
+ ) ;
548
+ } ) ;
549
+
550
+ it ( "converts markdown to style or block type" , ( ) => {
533
551
const newEditorState = handleInlineStyle ( editorState , character ) ;
534
552
expect ( newEditorState ) . not . toEqual ( editorState ) ;
535
553
expect ( Draft . convertToRaw ( newEditorState . getCurrentContent ( ) ) ) . toEqual (
0 commit comments