Jsahleen has uploaded a new change for review.

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

Change subject: Links: Enable removing target link when clicking on source link
......................................................................

Links: Enable removing target link when clicking on source link

* Modifies removeLink function
* If a source link is clicked, removes the corresponding target link
* Modifies getTargetLink so it only returns the first corresponding target link

Bug: T85928
Change-Id: I62caf392f324b519748998e6394c3166da116ca7
---
M modules/tools/ext.cx.tools.link.js
1 file changed, 13 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/27/184427/1

diff --git a/modules/tools/ext.cx.tools.link.js 
b/modules/tools/ext.cx.tools.link.js
index f93bdb2..5a50b00 100644
--- a/modules/tools/ext.cx.tools.link.js
+++ b/modules/tools/ext.cx.tools.link.js
@@ -126,10 +126,21 @@
 
        /**
         * Removes a link if the link is an editable target link
+        * If the link is a source link, removes the corresponding
+        * link editable target link.
         * @return {boolean}
         */
        LinkCard.prototype.removeLink = function () {
-               var $parentSection = null;
+               var $targetLink, $parentSection = null;
+
+               mw.cx.selection.restore( 'translation' );
+
+               if ( this.isSourceLink() ) {
+                       $targetLink = this.getTargetLink();
+                       if ( $targetLink ) {
+                               this.$link = $targetLink;
+                       }
+               }
 
                if ( this.isEditableTargetLink() ) {
                        $parentSection = this.$link.parents( 
'[contenteditable]' );
@@ -137,6 +148,7 @@
                        this.$link.before( this.$link.text() ).remove();
                        this.stop();
                }
+
        };
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62caf392f324b519748998e6394c3166da116ca7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Jsahleen <[email protected]>

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

Reply via email to