ve.ui.MWSaveDialog: Improve handling of links in edit summary preview

* Pass the page title, so that links to section point to the current
  page rather than "API"
* Make all links open in a new window, instead of producing a warning
  about losing your changes

Bug: T208978
Change-Id: Ia1924e1af644ee41ebcaa1da40ca004cb72dcdaf
This commit is contained in:
Bartosz Dziewoński 2018-11-27 02:38:37 +01:00
parent b34e625f4c
commit b983538038

View file

@ -392,13 +392,18 @@ ve.ui.MWSaveDialog.prototype.swapPanel = function ( panel, noFocus ) {
.addClass( 'mw-ajax-loader' );
this.editSummaryXhr = ve.init.target.getContentApi().post( {
action: 'parse',
title: ve.init.target.getPageName(),
prop: '',
summary: currentEditSummaryWikitext
} ).done( function ( result ) {
if ( result.parse.parsedsummary[ '*' ] === '' ) {
dialog.$reviewEditSummary.parent().addClass( 'oo-ui-element-hidden' );
} else {
// Intentionally treated as HTML
dialog.$reviewEditSummary.html( ve.msg( 'parentheses', result.parse.parsedsummary[ '*' ] ) );
dialog.$reviewEditSummary
// Intentionally treated as HTML
.html( ve.msg( 'parentheses', result.parse.parsedsummary[ '*' ] ) )
// Make any links open in a new window
.find( 'a' ).prop( 'target', '_blank' ).attr( 'rel', 'noopener' );
}
} ).fail( function () {
dialog.$reviewEditSummary.parent().addClass( 'oo-ui-element-hidden' );