mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +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
|
||||
return ve.ui.FragmentInspector.prototype.getTeardownProcess.call( this, data )
|
||||
.first( function () {
|
||||
var insertion,
|
||||
var insertion, insert,
|
||||
annotation = this.getAnnotation(),
|
||||
fragment = this.getFragment(),
|
||||
surfaceModel = fragment.getSurface();
|
||||
|
||||
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 );
|
||||
}
|
||||
// Action is async, so we use auto select to ensure the content is selected
|
||||
fragment.setAutoSelect( true );
|
||||
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 ) {
|
||||
// Restore selection to what it was before we expanded it
|
||||
surfaceModel.setSelection( this.previousSelection );
|
||||
|
|
Loading…
Reference in a new issue