diff --git a/ApiVisualEditorEdit.php b/ApiVisualEditorEdit.php index 9327a9fa7c..743a0f011f 100644 --- a/ApiVisualEditorEdit.php +++ b/ApiVisualEditorEdit.php @@ -116,6 +116,15 @@ class ApiVisualEditorEdit extends ApiVisualEditor { } $result['isRedirect'] = $page->isRedirect(); + $parserOutput = $this->getOutput()->getWikiPage()->getParserOutput( + $this->getOutput()->parserOptions() + ); + if ( $parserOutput ) { + $result['displayTitleHtml'] = $parserOutput->getDisplayTitle(); + } else { + wfDebug( '[VE] ApiVisualEditorEdit - parserOutput was false' ); + } + if ( isset( $saveresult['edit']['newrevid'] ) ) { $result['newrevid'] = intval( $saveresult['edit']['newrevid'] ); } diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 9e801f93df..3220a6fce6 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -421,9 +421,11 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceReady = function () { * @method * @param {string} html Rendered page HTML from server * @param {string} categoriesHtml Rendered categories HTML from server - * @param {number} [newid] New revision id, undefined if unchanged + * @param {number} newid New revision id, undefined if unchanged + * @param {boolean} isRedirect Whether this page is a redirect or not + * @param {string} displayTitle What HTML to show as the page title */ -ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, newid, isRedirect ) { +ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, newid, isRedirect, displayTitle ) { var newUrlParams, watchChecked; if ( !this.pageExists || this.restoring ) { // This is a page creation or restoration, refresh the page @@ -466,7 +468,7 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, ne } this.saveDialog.close(); this.saveDialog.reset(); - this.replacePageContent( html, categoriesHtml, isRedirect ); + this.replacePageContent( html, categoriesHtml, isRedirect, displayTitle ); this.setupSectionEditLinks(); this.tearDownBeforeUnloadHandler(); this.deactivate( true ); @@ -1534,8 +1536,10 @@ ve.init.mw.ViewPageTarget.prototype.onWindowPopState = function ( e ) { * @method * @param {string} html Rendered HTML from server * @param {string} categoriesHtml Rendered categories HTML from server + * @param {boolean} isRedirect Whether this page is a redirect or not + * @param {string} displayTitle What HTML to show as the page title */ -ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, categoriesHtml, isRedirect ) { +ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, categoriesHtml, isRedirect, displayTitle ) { var $content = $( $.parseHTML( html ) ), $editableContent; if ( $( '#mw-imagepage-content' ).length ) { @@ -1555,6 +1559,9 @@ ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, catego } mw.hook( 'wikipage.content' ).fire( $editableContent.empty().append( $content ) ); + if ( displayTitle ) { + $( '#content > #firstHeading > span' ).html( displayTitle ); + } $( '#catlinks' ).replaceWith( categoriesHtml ); if ( isRedirect ) { $( '#contentSub' ).text( ve.msg( 'redirectpagesub' ) ); diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 4334238f7d..46966840f9 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -543,7 +543,14 @@ ve.init.mw.Target.onSave = function ( doc, saveData, response ) { } else if ( typeof data.content !== 'string' ) { this.onSaveError( doc, saveData, null, 'Invalid HTML content in response from server', response ); } else { - this.emit( 'save', data.content, data.categorieshtml, data.newrevid, data.isRedirect ); + this.emit( + 'save', + data.content, + data.categorieshtml, + data.newrevid, + data.isRedirect, + data.displayTitleHtml || null + ); } };