mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Prepend a colon to internal links to Category: and File: pages
Change-Id: I77570ea6ec9f29b5d5eb06b518cb08a1b2cea0b2
This commit is contained in:
parent
4eca804542
commit
1e62e9f64c
|
@ -220,7 +220,8 @@ $wgResourceModules += array(
|
||||||
'dependencies' => array(
|
'dependencies' => array(
|
||||||
'jquery',
|
'jquery',
|
||||||
'rangy',
|
'rangy',
|
||||||
'ext.visualEditor.base'
|
'ext.visualEditor.base',
|
||||||
|
'mediawiki.Title',
|
||||||
),
|
),
|
||||||
'messages' => array(
|
'messages' => array(
|
||||||
'visualeditor',
|
'visualeditor',
|
||||||
|
|
|
@ -183,6 +183,7 @@ ve.ui.LinkInspector.prototype.onClose = function( accept ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ve.ui.LinkInspector.getAnnotationForTarget = function( target ) {
|
ve.ui.LinkInspector.getAnnotationForTarget = function( target ) {
|
||||||
|
var title;
|
||||||
// Figure out if this is an internal or external link
|
// Figure out if this is an internal or external link
|
||||||
if ( target.match( /^(https?:)?\/\// ) ) {
|
if ( target.match( /^(https?:)?\/\// ) ) {
|
||||||
// External link
|
// External link
|
||||||
|
@ -192,6 +193,18 @@ ve.ui.LinkInspector.getAnnotationForTarget = function( target ) {
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Internal link
|
// Internal link
|
||||||
|
// TODO in the longer term we'll want to have autocompletion and existence&validity
|
||||||
|
// checks using AJAX
|
||||||
|
try {
|
||||||
|
title = new mw.Title( target );
|
||||||
|
if ( title.getNamespaceId() === 6 || title.getNamespaceId() === 14 ) {
|
||||||
|
// File: or Category: link
|
||||||
|
// We have to prepend a colon so this is interpreted as a link
|
||||||
|
// rather than an image inclusion or categorization
|
||||||
|
target = ':' + target;
|
||||||
|
}
|
||||||
|
} catch ( e ) { }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'type': 'link/wikiLink',
|
'type': 'link/wikiLink',
|
||||||
'data': { 'title': target }
|
'data': { 'title': target }
|
||||||
|
|
Loading…
Reference in a new issue