Jiabao has uploaded a new change for review.

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


Change subject: This patch adds the functionality for the hyperlink inspector 
to edit the displayed text, which allows pasting here. The UI need to be 
improved after community direction.
......................................................................

This patch adds the functionality for the hyperlink inspector to
edit the displayed text, which allows pasting here. The UI need to
be improved after community direction.

Change-Id: Ibfcf490698559f673c8b60005a085108cf4f2b46
---
M modules/ve/ui/inspectors/ve.ui.LinkInspector.js
1 file changed, 17 insertions(+), 2 deletions(-)


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

diff --git a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js 
b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js
index f566795..84b663e 100644
--- a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js
@@ -37,6 +37,8 @@
 
 ve.ui.LinkInspector.static.linkTargetInputWidget = ve.ui.LinkTargetInputWidget;
 
+ve.ui.LinkInspector.static.InputWidget = ve.ui.InputWidget;
+
 /* Methods */
 
 /**
@@ -50,10 +52,14 @@
 
        // Properties
        this.targetInput = new this.constructor.static.linkTargetInputWidget( {
-               '$$': this.$$, '$overlay': this.surface.getEditor().$overlay
+               '$$': this.$$, '$overlay': this.surface.$overlay
+       } );
+       this.displayInput = new this.constructor.static.InputWidget( {
+               '$$': this.$$, '$overlay': this.surface.$overlay
        } );
 
        // Initialization
+       this.$form.append( this.displayInput.$ );
        this.$form.append( this.targetInput.$ );
 };
 
@@ -113,12 +119,16 @@
 ve.ui.LinkInspector.prototype.onOpen = function () {
        var fragment = this.surface.getModel().getFragment( null, true ),
                annotation = this.getMatchingAnnotations( fragment ).get( 0 );
+               display = fragment.getText();
 
        // Call parent method
        ve.ui.Inspector.prototype.onOpen.call( this );
 
        // Wait for animation to complete
        setTimeout( ve.bind( function () {
+               // Setup display
+               this.initialDisplayHash = display && ve.getHash(display);
+               this.displayInput.setValue( display ); 
                // Setup annotation
                this.initialAnnotationHash = annotation && ve.getHash( 
annotation );
                this.targetInput.setAnnotation( annotation );
@@ -144,6 +154,7 @@
                remove = action === 'remove',
                target = this.targetInput.getValue(),
                annotation = this.targetInput.getAnnotation(),
+               display = this.displayInput.getValue(),
                fragment = this.surface.getModel().getFragment( 
this.initialSelection, false );
        // Undefined annotation causes removal
        if ( !annotation ) {
@@ -163,9 +174,13 @@
                        }
                        set = true;
                }
+               if (ve.getHash( display ) !== this.initialDisplayHash) {
+                       insert = true;
+                       set = true;
+               }
        }
        if ( insert ) {
-               fragment.insertContent( target, false );
+               fragment.insertContent( display, false );
 
                // Move cursor to the end of the inserted content, even if back 
button is used
                this.previousSelection = new ve.Range( 
this.initialSelection.start + target.length );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibfcf490698559f673c8b60005a085108cf4f2b46
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Jiabao <[email protected]>

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

Reply via email to