Esanders has uploaded a new change for review.

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

Change subject: Allow the link inspector to open without expanding the selection
......................................................................

Allow the link inspector to open without expanding the selection

Bug: T133516
Change-Id: If8ab31a7eacb4d8fa6d9787b7ac9872be0de04e7
---
M src/ui/inspectors/ve.ui.AnnotationInspector.js
M src/ui/ve.ui.CommandRegistry.js
2 files changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/57/285157/1

diff --git a/src/ui/inspectors/ve.ui.AnnotationInspector.js 
b/src/ui/inspectors/ve.ui.AnnotationInspector.js
index dd08f36..907d773 100644
--- a/src/ui/inspectors/ve.ui.AnnotationInspector.js
+++ b/src/ui/inspectors/ve.ui.AnnotationInspector.js
@@ -157,6 +157,7 @@
  *
  * @method
  * @param {Object} [data] Inspector opening data
+ * @param {boolea} [data.noExpand] Don't expand the selection when opening
  */
 ve.ui.AnnotationInspector.prototype.getSetupProcess = function ( data ) {
        return ve.ui.AnnotationInspector.super.prototype.getSetupProcess.call( 
this, data )
@@ -177,7 +178,9 @@
                                        
fragment.getDocument().data.isContentOffset( 
fragment.getSelection().getRange().start )
                                ) {
                                        // Expand to nearest word
-                                       fragment = 
fragment.expandLinearSelection( 'word' );
+                                       if ( !data.noExpand ) {
+                                               fragment = 
fragment.expandLinearSelection( 'word' );
+                                       }
 
                                        // TODO: We should review how 
getMatchingAnnotation works in light of the fact
                                        // that in the case of a collapsed 
range, the method falls back to retrieving
@@ -206,7 +209,7 @@
                                        }
                                }
                        }
-                       if ( annotation ) {
+                       if ( annotation && !data.noExpand ) {
                                // Expand range to cover annotation
                                fragment = fragment.expandLinearSelection( 
'annotation', annotation );
                        }
diff --git a/src/ui/ve.ui.CommandRegistry.js b/src/ui/ve.ui.CommandRegistry.js
index 4fbb20e..2d08ec8 100644
--- a/src/ui/ve.ui.CommandRegistry.js
+++ b/src/ui/ve.ui.CommandRegistry.js
@@ -116,6 +116,12 @@
 );
 ve.ui.commandRegistry.register(
        new ve.ui.Command(
+               'linkNoExpand', 'window', 'open',
+               { args: [ 'link', { noExpand: true } ], supportedSelections: [ 
'linear' ] }
+       )
+);
+ve.ui.commandRegistry.register(
+       new ve.ui.Command(
                'specialCharacter', 'window', 'toggle',
                { args: [ 'specialCharacter' ], supportedSelections: [ 'linear' 
] }
        )

-- 
To view, visit https://gerrit.wikimedia.org/r/285157
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8ab31a7eacb4d8fa6d9787b7ac9872be0de04e7
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to