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) {
31163116 }
31173117}
31183118
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+
31193140$ ( editor . getInputField ( ) )
31203141 . textcomplete ( [
31213142 { // emoji strategy
@@ -3317,29 +3338,10 @@ $(editor.getInputField())
33173338 } ,
33183339 'textComplete:show' : function ( e ) {
33193340 $ ( 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 )
33403342 } ,
33413343 'textComplete:hide' : function ( e ) {
33423344 $ ( this ) . data ( 'autocompleting' , false )
3343- editor . setOption ( 'extraKeys' , editorInstance . defaultExtraKeys )
3345+ editor . removeKeyMap ( textCompleteKeyMap )
33443346 }
33453347 } )
Original file line number Diff line number Diff line change @@ -166,19 +166,25 @@ export function initTableEditor (editor) {
166166 'Alt-Shift-Ctrl-Down' : ( ) => { tableEditor . moveRow ( 1 , opts ) } ,
167167 'Alt-Shift-Cmd-Down' : ( ) => { tableEditor . moveRow ( 1 , opts ) }
168168 } )
169+ let lastActive
169170 // enable keymap if the cursor is in a table
170171 function updateActiveState ( ) {
171172 const tableTools = $ ( '.toolbar .table-tools' )
172173 const active = tableEditor . cursorIsInTable ( opts )
174+ // avoid to update if state not changed
175+ if ( lastActive === active ) {
176+ return
177+ }
173178 if ( active ) {
174179 tableTools . show ( )
175180 tableTools . parent ( ) . scrollLeft ( tableTools . parent ( ) [ 0 ] . scrollWidth )
176- editor . setOption ( 'extraKeys' , keyMap )
181+ editor . addKeyMap ( keyMap )
177182 } else {
178183 tableTools . hide ( )
179- editor . setOption ( 'extraKeys' , null )
184+ editor . removeKeyMap ( keyMap )
180185 tableEditor . resetSmartCursor ( )
181186 }
187+ lastActive = active
182188 }
183189 // event subscriptions
184190 editor . on ( 'cursorActivity' , ( ) => {
You can’t perform that action at this time.
0 commit comments