mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-27 16:40:07 +00:00
CodeEditor: fix to avoid selecting when inserting non-samples such as character insertions
Logging some stub func calls
This commit is contained in:
parent
3603c6acae
commit
5d42ce5f24
Notes:
Brion Vibber
2011-06-10 23:09:52 +00:00
|
@ -75,8 +75,10 @@ context.fn = $.extend( context.fn, {
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
'saveSelection': function() {
|
'saveSelection': function() {
|
||||||
|
mw.log('codeEditor stub function saveSelection called');
|
||||||
},
|
},
|
||||||
'restoreSelection': function() {
|
'restoreSelection': function() {
|
||||||
|
mw.log('codeEditor stub function restoreSelection called');
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Sets up the iframe in place of the textarea to allow more advanced operations
|
* Sets up the iframe in place of the textarea to allow more advanced operations
|
||||||
|
@ -152,6 +154,7 @@ context.fn = $.extend( context.fn, {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'getElementAtCursor': function() {
|
'getElementAtCursor': function() {
|
||||||
|
mw.log('codeEditor stub function getElementAtCursor called');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,10 +174,10 @@ context.fn = $.extend( context.fn, {
|
||||||
var sel = context.codeEditor.getSelection();
|
var sel = context.codeEditor.getSelection();
|
||||||
var range = sel.getRange();
|
var range = sel.getRange();
|
||||||
var selText = context.fn.getSelection();
|
var selText = context.fn.getSelection();
|
||||||
var selectAfter = false;
|
var isSample = false;
|
||||||
if ( !selText ) {
|
if ( !selText ) {
|
||||||
selText = options.peri;
|
selText = options.peri;
|
||||||
selectAfter = true;
|
isSample = true;
|
||||||
} else if ( options.replace ) {
|
} else if ( options.replace ) {
|
||||||
selText = options.peri;
|
selText = options.peri;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +185,7 @@ context.fn = $.extend( context.fn, {
|
||||||
text += selText;
|
text += selText;
|
||||||
text += options.post;
|
text += options.post;
|
||||||
context.codeEditor.insert( text );
|
context.codeEditor.insert( text );
|
||||||
if ( selectAfter ) {
|
if ( isSample && options.selectPeri && !options.splitlines ) {
|
||||||
// May esplode if anything has newlines, be warned. :)
|
// May esplode if anything has newlines, be warned. :)
|
||||||
range.setStart( range.start.row, range.start.column + options.pre.length );
|
range.setStart( range.start.row, range.start.column + options.pre.length );
|
||||||
range.setEnd( range.start.row, range.start.column + selText.length );
|
range.setEnd( range.start.row, range.start.column + selText.length );
|
||||||
|
@ -195,6 +198,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
||||||
*/
|
*/
|
||||||
'getCaretPosition': function( options ) {
|
'getCaretPosition': function( options ) {
|
||||||
|
mw.log('codeEditor stub function getCaretPosition called');
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Sets the selection of the content
|
* Sets the selection of the content
|
||||||
|
@ -237,7 +241,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
||||||
*/
|
*/
|
||||||
'scrollToCaretPosition': function( options ) {
|
'scrollToCaretPosition': function( options ) {
|
||||||
//context.fn.scrollToTop( context.fn.getElementAtCursor(), true );
|
mw.log('codeEditor stub function scrollToCaretPosition called');
|
||||||
return context.$textarea;
|
return context.$textarea;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -248,6 +252,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* @param force If true, scroll the element even if it's already visible
|
* @param force If true, scroll the element even if it's already visible
|
||||||
*/
|
*/
|
||||||
'scrollToTop': function( $element, force ) {
|
'scrollToTop': function( $element, force ) {
|
||||||
|
mw.log('codeEditor stub function scrollToTop called');
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue