@@ -96,33 +96,34 @@ class ContentEditor extends React.Component {
96
96
const { editorState } = this . state ;
97
97
const selection = editorState . getSelection ( ) ;
98
98
const content = editorState . getCurrentContent ( ) ;
99
+ const style = editorState . getCurrentInlineStyle ( ) ;
99
100
const currentIndex = selection . getEndOffset ( ) ;
100
101
const currentBlock = editorState . getCurrentContent ( ) . getBlockForKey ( selection . getStartKey ( ) ) . getText ( ) . substring ( 0 , currentIndex ) ;
101
102
102
103
let contentReplaced = Modifier . insertText ( content , selection , str ) ;
103
104
104
105
if ( currentBlock !== "" ) {
105
106
if ( str === '\"' && currentBlock . lastIndexOf ( '“' ) <= currentBlock . lastIndexOf ( '”' ) && currentBlock [ currentIndex - 1 ] . match ( / [ \s - ] / g) ) {
106
- contentReplaced = Modifier . insertText ( content , selection , '“' ) ;
107
+ contentReplaced = Modifier . insertText ( content , selection , '“' , style ) ;
107
108
}
108
109
else if ( str === '\"' ) {
109
- contentReplaced = Modifier . insertText ( content , selection , '”' ) ;
110
+ contentReplaced = Modifier . insertText ( content , selection , '”' , style ) ;
110
111
}
111
112
else if ( str === "\'" && currentBlock . lastIndexOf ( '‘' ) <= currentBlock . lastIndexOf ( '’' ) && currentBlock [ currentIndex - 1 ] . match ( / [ \s - ] / g) ) {
112
- contentReplaced = Modifier . insertText ( content , selection , '‘' ) ;
113
+ contentReplaced = Modifier . insertText ( content , selection , '‘' , style ) ;
113
114
}
114
115
else if ( str === "\'" ) {
115
- contentReplaced = Modifier . insertText ( content , selection , ) ;
116
+ contentReplaced = Modifier . insertText ( content , selection , '’' , style ) ;
116
117
} else {
117
118
return false ;
118
119
}
119
120
}
120
121
else {
121
122
if ( str === "\'" ) {
122
- contentReplaced = Modifier . insertText ( content , selection , '‘' ) ;
123
+ contentReplaced = Modifier . insertText ( content , selection , '‘' , style ) ;
123
124
}
124
125
else if ( str === '\"' ) {
125
- contentReplaced = Modifier . insertText ( content , selection , '“' ) ;
126
+ contentReplaced = Modifier . insertText ( content , selection , '“' , style ) ;
126
127
}
127
128
else {
128
129
return false ;
0 commit comments