Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/81437


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 on the first line. If
  the marker was on the first blank line with collapsed selection, activating
  AnnotationInspector would expand the range to the closest word (on the next
  paragraph), probably because of the slug. This commit fixes that, and
  instead inserts a new annotation like in any other blank line.

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(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/37/81437/1

diff --git a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js 
b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
index 6d5c59e..7448b7b 100644
--- a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
@@ -63,7 +63,7 @@
 
        // Initialize range
        if ( !annotation ) {
-               if ( fragment.getRange().isCollapsed() ) {
+               if ( fragment.getRange().isCollapsed() && 
fragment.getRange().start > 0 ) {
                        // 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: newchange
Gerrit-Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to