Cscott has uploaded a new change for review.

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

Change subject: Use ve.dm.MWInternalLinkAnnotation for autolinks where 
appropriate
......................................................................

Use ve.dm.MWInternalLinkAnnotation for autolinks where appropriate

Change-Id: I904e797732c98a07654772a4f2432ba3ae5d7050
---
M modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
1 file changed, 14 insertions(+), 4 deletions(-)


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

diff --git a/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js 
b/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
index 69d456c..a199a44 100644
--- a/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
+++ b/modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js
@@ -41,10 +41,20 @@
  * @return {ve.dm.MWExternalLinkAnnotation} The annotation to use.
  */
 ve.ui.MWLinkAction.prototype.getLinkAnnotation = function ( href ) {
-       return new ve.dm.MWExternalLinkAnnotation( {
-               type: 'link/mwExternal',
-               attributes: { href: href }
-       } );
+       var title,
+               targetData = 
ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref(
+                       href,
+                       this.surface.getModel().getDocument().getHtmlDocument()
+               );
+       if ( targetData.internal ) {
+               title = mw.Title.newFromText( targetData.title );
+       }
+       return title
+               ? ve.dm.MWInternalLinkAnnotation.static.newFromTitle( title )
+               : new ve.dm.MWExternalLinkAnnotation( {
+                       type: 'link/mwExternal',
+                       attributes: { href: href }
+               } );
 };
 
 /**

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

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

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

Reply via email to