mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-15 03:35:58 +00:00
Use jQuery.textSelection API for compat with CodeMirror extension
We were already using it for almost all interactions with the editing area, except for this code which restores the selection after closing a dialog. Bug: T254612 Change-Id: I26d22d9c5d64fe8c861405e65cd4464c349aeac9
This commit is contained in:
parent
6703fdefae
commit
036b7c28a3
|
@ -448,10 +448,7 @@
|
|||
saveSelection: function () {
|
||||
context.$focusedElem = $( ':focus' );
|
||||
context.$textarea.trigger( 'focus' );
|
||||
context.savedSelection = {
|
||||
selectionStart: context.$textarea[ 0 ].selectionStart,
|
||||
selectionEnd: context.$textarea[ 0 ].selectionEnd
|
||||
};
|
||||
context.savedSelection = context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } );
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -460,7 +457,7 @@
|
|||
restoreSelection: function () {
|
||||
if ( context.savedSelection ) {
|
||||
context.$textarea.trigger( 'focus' );
|
||||
context.$textarea[ 0 ].setSelectionRange( context.savedSelection.selectionStart, context.savedSelection.selectionEnd );
|
||||
context.$textarea.textSelection( 'setSelection', { start: context.savedSelection[ 0 ], end: context.savedSelection[ 1 ] } );
|
||||
context.savedSelection = null;
|
||||
}
|
||||
if ( context.$focusedElem ) {
|
||||
|
|
Loading…
Reference in a new issue