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 <dly...@wikimedia.org> Gerrit-Reviewer: Divec <da...@troi.org> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits