jenkins-bot has submitted this change and it was merged.
Change subject: ce.Surface: Convenience function for selecting node contents
......................................................................
ce.Surface: Convenience function for selecting node contents
Change-Id: I3954c7f8f8e5870b13a8f6c4f0e86fb3b20b3cd3
---
M src/ce/ve.ce.Surface.js
1 file changed, 15 insertions(+), 5 deletions(-)
Approvals:
Jforrester: 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 c16c336..2998abb 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -3318,17 +3318,18 @@
};
/**
- * Update the selection to contain the contents of the activeLink, if it exists
+ * Update the selection to contain the contents of a node
*
+ * @param {HTMLElement} node
* @return {boolean} Whether the selection changed
*/
-ve.ce.Surface.prototype.selectActiveLinkContents = function () {
+ve.ce.Surface.prototype.selectNodeContents = function ( node ) {
var anchor, focus;
- if ( !this.activeLink ) {
+ if ( !node ) {
return false;
}
- anchor = ve.ce.nextCursorOffset( this.activeLink.childNodes[ 0 ] );
- focus = ve.ce.previousCursorOffset( this.activeLink.childNodes[
this.activeLink.childNodes.length - 1 ] );
+ anchor = ve.ce.nextCursorOffset( node.childNodes[ 0 ] );
+ focus = ve.ce.previousCursorOffset( node.childNodes[
node.childNodes.length - 1 ] );
return this.showSelectionState( new ve.SelectionState( {
anchorNode: anchor.node,
anchorOffset: anchor.offset, // past the nail
@@ -3339,6 +3340,15 @@
};
/**
+ * 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 () {
+ return this.selectLinkContents( this.activeLink );
+};
+
+/**
* Get the linkAnnotation node containing the cursor focus
*
* If there is no focus, or it is not inside a linkAnnotation, return null
--
To view, visit https://gerrit.wikimedia.org/r/284221
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3954c7f8f8e5870b13a8f6c4f0e86fb3b20b3cd3
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits