File tree Expand file tree Collapse file tree 2 files changed +31
-23
lines changed Expand file tree Collapse file tree 2 files changed +31
-23
lines changed Original file line number Diff line number Diff line change @@ -3116,6 +3116,27 @@ function matchInContainer (text) {
3116
3116
}
3117
3117
}
3118
3118
3119
+ const textCompleteKeyMap = {
3120
+ Up : function ( ) {
3121
+ return false
3122
+ } ,
3123
+ Right : function ( ) {
3124
+ editor . doc . cm . execCommand ( 'goCharRight' )
3125
+ } ,
3126
+ Down : function ( ) {
3127
+ return false
3128
+ } ,
3129
+ Left : function ( ) {
3130
+ editor . doc . cm . execCommand ( 'goCharLeft' )
3131
+ } ,
3132
+ Enter : function ( ) {
3133
+ return false
3134
+ } ,
3135
+ Backspace : function ( ) {
3136
+ editor . doc . cm . execCommand ( 'delCharBefore' )
3137
+ }
3138
+ }
3139
+
3119
3140
$ ( editor . getInputField ( ) )
3120
3141
. textcomplete ( [
3121
3142
{ // emoji strategy
@@ -3317,29 +3338,10 @@ $(editor.getInputField())
3317
3338
} ,
3318
3339
'textComplete:show' : function ( e ) {
3319
3340
$ ( this ) . data ( 'autocompleting' , true )
3320
- editor . setOption ( 'extraKeys' , {
3321
- Up : function ( ) {
3322
- return false
3323
- } ,
3324
- Right : function ( ) {
3325
- editor . doc . cm . execCommand ( 'goCharRight' )
3326
- } ,
3327
- Down : function ( ) {
3328
- return false
3329
- } ,
3330
- Left : function ( ) {
3331
- editor . doc . cm . execCommand ( 'goCharLeft' )
3332
- } ,
3333
- Enter : function ( ) {
3334
- return false
3335
- } ,
3336
- Backspace : function ( ) {
3337
- editor . doc . cm . execCommand ( 'delCharBefore' )
3338
- }
3339
- } )
3341
+ editor . addKeyMap ( textCompleteKeyMap )
3340
3342
} ,
3341
3343
'textComplete:hide' : function ( e ) {
3342
3344
$ ( this ) . data ( 'autocompleting' , false )
3343
- editor . setOption ( 'extraKeys' , editorInstance . defaultExtraKeys )
3345
+ editor . removeKeyMap ( textCompleteKeyMap )
3344
3346
}
3345
3347
} )
Original file line number Diff line number Diff line change @@ -166,19 +166,25 @@ export function initTableEditor (editor) {
166
166
'Alt-Shift-Ctrl-Down' : ( ) => { tableEditor . moveRow ( 1 , opts ) } ,
167
167
'Alt-Shift-Cmd-Down' : ( ) => { tableEditor . moveRow ( 1 , opts ) }
168
168
} )
169
+ let lastActive
169
170
// enable keymap if the cursor is in a table
170
171
function updateActiveState ( ) {
171
172
const tableTools = $ ( '.toolbar .table-tools' )
172
173
const active = tableEditor . cursorIsInTable ( opts )
174
+ // avoid to update if state not changed
175
+ if ( lastActive === active ) {
176
+ return
177
+ }
173
178
if ( active ) {
174
179
tableTools . show ( )
175
180
tableTools . parent ( ) . scrollLeft ( tableTools . parent ( ) [ 0 ] . scrollWidth )
176
- editor . setOption ( 'extraKeys' , keyMap )
181
+ editor . addKeyMap ( keyMap )
177
182
} else {
178
183
tableTools . hide ( )
179
- editor . setOption ( 'extraKeys' , null )
184
+ editor . removeKeyMap ( keyMap )
180
185
tableEditor . resetSmartCursor ( )
181
186
}
187
+ lastActive = active
182
188
}
183
189
// event subscriptions
184
190
editor . on ( 'cursorActivity' , ( ) => {
You can’t perform that action at this time.
0 commit comments