mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Use new CE Surface selectAnnotation method
Change-Id: Ic26c46d3cdabc7b9949527d04eada5203cf6f7d3 Depends-On: I23f3586e340899801c99b3015e51dd0965a8ef0b
This commit is contained in:
parent
7197fd49c3
commit
d14d443aff
|
@ -75,12 +75,9 @@ ve.ui.MWNumberedExternalLinkNodeContextItem.prototype.onLabelButtonClick = funct
|
|||
ve.dm.TransactionBuilder.static.newFromReplacement( doc, nodeRange, content )
|
||||
);
|
||||
setTimeout( function () {
|
||||
// Note: we can't rely on surfaceView.activeAnnotations, because the selection-focus created
|
||||
// by the transaction might be outside the link node. As such, get the node immediately
|
||||
// after the offset where we inserted the annotation, and then get the closest link
|
||||
// annotation to it.
|
||||
var node = surfaceView.getDocument().getNodeAndOffset( nodeRange.start + 1 ).node;
|
||||
surfaceView.selectNodeContents( $( node ).closest( '.ve-ce-linkAnnotation' )[ 0 ] );
|
||||
surfaceView.selectAnnotation( function ( view ) {
|
||||
return view.model instanceof ve.dm.MWExternalLinkAnnotation;
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
|
@ -135,21 +135,9 @@ ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
|
|||
ve.dm.TransactionBuilder.static.newFromReplacement( doc, nodeRange, content )
|
||||
);
|
||||
setTimeout( function () {
|
||||
// This just removed the node and turned it into an annotation. Thus, this inspector
|
||||
// is about to go away. It'll be replaced by a context popup for the new annotation,
|
||||
// because the cursor will still be contained within it. Before it goes away, adjust
|
||||
// the selection to make _sure_ that if the user just starts typing, it won't delete
|
||||
// the entire link. We need to manually fiddle the selection a little, because
|
||||
// annotations mean that the LinearSelection can't granularly say whether the
|
||||
// selection starts inside or outside of the node.
|
||||
// If you can think of a test function for "the selection has stabilised", this could
|
||||
// be moved to ve.scheduler.
|
||||
// Note: we can't rely on surfaceView.activeAnnotations, because the selection-focus created
|
||||
// by the transaction might be outside the link node. As such, get the node immediately
|
||||
// after the offset where we inserted the annotation, and then get the closest link
|
||||
// annotation to it.
|
||||
var node = surfaceView.getDocument().getNodeAndOffset( nodeRange.start + 1 ).node;
|
||||
surfaceView.selectNodeContents( $( node ).closest( '.ve-ce-linkAnnotation' )[ 0 ] );
|
||||
surfaceView.selectAnnotation( function ( view ) {
|
||||
return view.model instanceof ve.dm.MWExternalLinkAnnotation;
|
||||
} );
|
||||
} );
|
||||
} else {
|
||||
surfaceModel.change(
|
||||
|
|
Loading…
Reference in a new issue