ui.MWSaveDialog: consistent handling of preview category links

Category links weren't being checked for redlink status, and weren't opening
in a new window.

Bug: T179913
Change-Id: Ic665583128bf51710178c5674cd35c273f5f207e
This commit is contained in:
David Lynch 2017-11-29 11:24:32 -06:00
parent 763e5f8078
commit efbfcd8b35

View file

@ -203,9 +203,6 @@ ve.ui.MWSaveDialog.prototype.showPreview = function ( docOrMsg, baseDoc ) {
// TODO: This code is very similar to ve.ui.PreviewElement+ve.ui.MWPreviewElement
ve.resolveAttributes( body, docOrMsg, ve.dm.Converter.static.computedAttributes );
ve.targetLinksToNewWindow( body );
// Add styles so links render with their appropriate classes
ve.init.platform.linkCache.styleParsoidElements( $( body ), baseDoc );
// Remove metadata
contents = ve.filterMetaElements( Array.prototype.slice.call( body.childNodes ) );
@ -223,12 +220,16 @@ ve.ui.MWSaveDialog.prototype.showPreview = function ( docOrMsg, baseDoc ) {
document.createTextNode( ve.msg( 'pagecategories', categories.length ) + ve.msg( 'colon-separator' ) ),
$( '<ul>' ).append( categories.map( function ( category ) {
var title = mw.Title.newFromText( category );
return $( '<li>' ).append( $( '<a>' ).attr( 'href', title.getUrl() ).text( title.getMainText() ) );
return $( '<li>' ).append( $( '<a>' ).attr( 'rel', 'mw:WikiLink' ).attr( 'href', title.getUrl() ).text( title.getMainText() ) );
} ) )
)
);
}
ve.targetLinksToNewWindow( this.$previewViewer[ 0 ] );
// Add styles so links render with their appropriate classes
ve.init.platform.linkCache.styleParsoidElements( this.$previewViewer, baseDoc );
// Run hooks so other things can alter the document
mw.hook( 'wikipage.content' ).fire( this.$previewViewer );
} else {