[MediaWiki-commits] [Gerrit] Add ve.ce.Surface selectActiveLinkContents - change (VisualEditor/VisualEditor)

2015-11-23 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add ve.ce.Surface selectActiveLinkContents
..


Add ve.ce.Surface selectActiveLinkContents

Provides a way to force the selection to the contents of the active
link. Needed because links are annotations, and so a LinearSelection
is ambiguous as to whether the selection should start within/without
the link.

Bug: T114643
Change-Id: I7c46a917d9752145174919f41066b4841b203218
---
M src/ce/ve.ce.Surface.js
1 file changed, 21 insertions(+), 0 deletions(-)

Approvals:
  Divec: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index f7ffc94..702961b 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -3074,6 +3074,27 @@
 };
 
 /**
+ * Update the selection to contain the contents of the activeLink, if it exists
+ *
+ * @return {boolean} Whether the selection changed
+ */
+ve.ce.Surface.prototype.selectActiveLinkContents = function () {
+   var anchor, focus;
+   if ( !this.activeLink ) {
+   return false;
+   }
+   anchor = ve.ce.nextCursorOffset( this.activeLink.childNodes[ 0 ] );
+   focus = ve.ce.previousCursorOffset( this.activeLink.childNodes[ 
this.activeLink.childNodes.length - 1 ] );
+   return this.showSelectionState( new ve.SelectionState( {
+   anchorNode: anchor.node,
+   anchorOffset: anchor.offset, // past the nail
+   focusNode: focus.node,
+   focusOffset: focus.offset, // before the nail
+   isCollapsed: false
+   } ) );
+};
+
+/**
  * Get the linkAnnotation node containing the cursor fous
  *
  * If there is no focus, or it is not inside a linkAnnotation, return null

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7c46a917d9752145174919f41066b4841b203218
Gerrit-PatchSet: 2
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch 
Gerrit-Reviewer: Divec 
Gerrit-Reviewer: Esanders 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] Add ve.ce.Surface selectActiveLinkContents - change (VisualEditor/VisualEditor)

2015-11-20 Thread DLynch (Code Review)
DLynch has uploaded a new change for review.

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

Change subject: Add ve.ce.Surface selectActiveLinkContents
..

Add ve.ce.Surface selectActiveLinkContents

Provides a way to force the selection to the contents of the active
link. Needed because links are annotations, and so a LinearSelection
is ambiguous as to whether the selection should start within/without
the link.

Bug: T114643
Change-Id: I7c46a917d9752145174919f41066b4841b203218
---
M src/ce/ve.ce.Surface.js
1 file changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/13/254613/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index f7ffc94..73591b9 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -3074,6 +3074,24 @@
 };
 
 /**
+ * Update the selection to contain the contents of the activeLink, if it exists
+ *
+ * @return {boolean} Whether the selection changed
+ */
+ve.ce.Surface.prototype.selectActiveLinkContents = function () {
+   if ( !this.activeLink ) {
+   return false;
+   }
+   return this.showSelectionState( new ve.SelectionState( {
+   anchorNode: this.activeLink,
+   anchorOffset: 1, // past the nail
+   focusNode: this.activeLink,
+   focusOffset: this.activeLink.childNodes.length - 1, // before 
the nail
+   isCollapsed: false
+   } ) );
+};
+
+/**
  * Get the linkAnnotation node containing the cursor fous
  *
  * If there is no focus, or it is not inside a linkAnnotation, return null

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7c46a917d9752145174919f41066b4841b203218
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch 

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