jenkins-bot has submitted this change and it was merged.
Change subject: AnnotationInspector insertion over blank selection
..
AnnotationInspector insertion over blank selection
This commit fixes two issues with insertion of annotations in blank space:
* LanguageInspector issue with inserting an language annotation inside any
whitespace (selection of space between words or collapsed selection in
blank line)
* AnnotationInspector issue with collapsed selection inside slugs. If
the marker was in a slug collapsed selection, activating
AnnotationInspector would expand the range to the closest word (on the
next paragraph). This commit makes sure the expansion for the next word
only happens if the selection is outside a slug.
Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
---
M modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
M modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
M modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
3 files changed, 14 insertions(+), 10 deletions(-)
Approvals:
Catrope: Looks good to me, but someone else must approve
Trevor Parscal: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
index 6d5c59e..1afb2b9 100644
--- a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
@@ -60,10 +60,9 @@
// Parent method
ve.ui.Inspector.prototype.onSetup.call( this );
-
// Initialize range
if ( !annotation ) {
- if ( fragment.getRange().isCollapsed() ) {
+ if ( fragment.getRange().isCollapsed()
!this.surface.view.hasSlugAtOffset( fragment.getRange().start ) ) {
// Expand to nearest word
expandedFragment = fragment.expandRange( 'word' );
fragment = expandedFragment;
diff --git a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
index 0d4774e..3f2503d 100644
--- a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
@@ -149,14 +149,19 @@
var langCode, langDir, annData;
// Validate the given annotation:
+ if ( annotation ) {
+ // Give precedence to dir value if it already exists
+ // in the annotation:
+ langDir = annotation.getAttribute( 'dir' );
- // Give precedence to dir value if it already exists
- // in the annotation:
- langDir = annotation.getAttribute( 'dir' );
-
- // Set language according to the one in the given annotation
- // or leave blank if element has no language set
- langCode = annotation.getAttribute( 'lang' );
+ // Set language according to the one in the given annotation
+ // or leave blank if element has no language set
+ langCode = annotation.getAttribute( 'lang' );
+ } else {
+ // No annotation (empty text or collapsed fragment on empty
line)
+ langCode = this.initLang;
+ langDir = this.initDir;
+ }
// If language exists, but dir is undefined/null,
// fix the dir in terms of language:
diff --git a/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
b/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
index 5605c77..21f08c9 100644
--- a/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
@@ -133,7 +133,7 @@
*/
ve.ui.LanguageInputWidget.prototype.getValue = function () {
// Specifically to be displayed
- return this.lang;
+ return this.$langNameDisp.text();
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/81437
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo mor...@gmail.com
Gerrit-Reviewer: Amire80 amir.ahar...@mail.huji.ac.il
Gerrit-Reviewer: Catrope roan.katt...@gmail.com
Gerrit-Reviewer: Inez i...@wikia-inc.com
Gerrit-Reviewer: Krinkle krinklem...@gmail.com
Gerrit-Reviewer: Trevor Parscal tpars...@wikimedia.org
Gerrit-Reviewer: jenkins-bot
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits