mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Merge "NWE: Fix selection when applying async links"
This commit is contained in:
commit
9ecd73f771
|
@ -83,18 +83,25 @@ ve.ui.MWWikitextLinkAnnotationInspector.prototype.getTeardownProcess = function
|
||||||
// Call grand-parent
|
// Call grand-parent
|
||||||
return ve.ui.FragmentInspector.prototype.getTeardownProcess.call( this, data )
|
return ve.ui.FragmentInspector.prototype.getTeardownProcess.call( this, data )
|
||||||
.first( function () {
|
.first( function () {
|
||||||
var insertion,
|
var insertion, insert,
|
||||||
annotation = this.getAnnotation(),
|
annotation = this.getAnnotation(),
|
||||||
fragment = this.getFragment(),
|
fragment = this.getFragment(),
|
||||||
surfaceModel = fragment.getSurface();
|
surfaceModel = fragment.getSurface();
|
||||||
|
|
||||||
if ( data && data.action === 'done' && annotation ) {
|
if ( data && data.action === 'done' && annotation ) {
|
||||||
if ( this.initialSelection.isCollapsed() && ( insertion = this.getInsertionData() ).length ) {
|
insert = this.initialSelection.isCollapsed() && ( insertion = this.getInsertionData() ).length;
|
||||||
|
if ( insert ) {
|
||||||
fragment.insertContent( insertion );
|
fragment.insertContent( insertion );
|
||||||
}
|
}
|
||||||
// Action is async, so we use auto select to ensure the content is selected
|
|
||||||
fragment.setAutoSelect( true );
|
|
||||||
fragment.annotateContent( 'set', annotation );
|
fragment.annotateContent( 'set', annotation );
|
||||||
|
// Fix selection after annotating is complete
|
||||||
|
fragment.getPending().then( function () {
|
||||||
|
if ( insert ) {
|
||||||
|
fragment.collapseToEnd().select();
|
||||||
|
} else {
|
||||||
|
fragment.select();
|
||||||
|
}
|
||||||
|
} );
|
||||||
} else if ( !data.action ) {
|
} else if ( !data.action ) {
|
||||||
// Restore selection to what it was before we expanded it
|
// Restore selection to what it was before we expanded it
|
||||||
surfaceModel.setSelection( this.previousSelection );
|
surfaceModel.setSelection( this.previousSelection );
|
||||||
|
|
Loading…
Reference in a new issue