jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/390876 )
Change subject: Fix insertion annotations in source mode
......................................................................
Fix insertion annotations in source mode
By default, do nothing if no text is selected.
NB ve-mw overrides these tools to insert placeholder text.
Bug: T181726
Change-Id: I84f28821bb00b4d61a824af5f4d0f64514641563
---
M src/ui/actions/ve.ui.AnnotationAction.js
M src/ui/ve.ui.Tool.js
2 files changed, 16 insertions(+), 6 deletions(-)
Approvals:
jenkins-bot: Verified
Jforrester: Looks good to me, approved
diff --git a/src/ui/actions/ve.ui.AnnotationAction.js
b/src/ui/actions/ve.ui.AnnotationAction.js
index f6c47c9..e0bd7fa 100644
--- a/src/ui/actions/ve.ui.AnnotationAction.js
+++ b/src/ui/actions/ve.ui.AnnotationAction.js
@@ -101,6 +101,8 @@
} else {
fragment.annotateContent( 'clear', name );
}
+ } else if ( surfaceModel.sourceMode ) {
+ return false;
} else {
insertionAnnotations = surfaceModel.getInsertionAnnotations();
existingAnnotations =
insertionAnnotations.getAnnotationsByName( annotation.name );
diff --git a/src/ui/ve.ui.Tool.js b/src/ui/ve.ui.Tool.js
index 96cf8ac..0a63bd1 100644
--- a/src/ui/ve.ui.Tool.js
+++ b/src/ui/ve.ui.Tool.js
@@ -104,23 +104,31 @@
* @inheritdoc
*/
ve.ui.Tool.prototype.onSelect = function () {
- var command = this.getCommand(),
- surface = this.toolbar.getSurface();
+ var contextClosePromise,
+ command = this.getCommand(),
+ surface = this.toolbar.getSurface(),
+ tool = this;
+
if ( command instanceof ve.ui.Command ) {
if ( surface.context.inspector ) {
- surface.context.inspector.close().closed.done( function
() {
- command.execute( surface );
- } );
+ contextClosePromise =
surface.context.inspector.close().closed;
} else {
+ contextClosePromise = $.Deferred().resolve().promise();
command.execute( surface );
}
}
if ( this.constructor.static.deactivateOnSelect ) {
- // Even if the promise route was taken above, it's fine to call
setActive here; it
+ // It's fine to call setActive here before the promise
resolves; it
// just disables the button, stopping double-clicks and making
it feel more responsive
// if the promise is slow.
this.setActive( false );
}
+ contextClosePromise.done( function () {
+ if ( !command.execute( surface ) ) {
+ // If the command fails, ensure the tool is not active
+ tool.setActive( false );
+ }
+ } );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/390876
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I84f28821bb00b4d61a824af5f4d0f64514641563
Gerrit-PatchSet: 2
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits