Make live preview work when section=new&nosummary=1

#wpSummaryWidget does not exist if index.php has
section=new&nosummary=1.

Bug: T293892
Change-Id: Icfff6c70b4967edd4b70affa13b7584ab356bc8b
This commit is contained in:
Nardog 2021-10-21 04:50:24 +09:00
parent b0313250e4
commit 2204a6d01a

View file

@ -180,7 +180,8 @@
*/
function doLivePreview( e ) {
var isDiff, api, parseRequest, diffRequest, postData, copySelectors, section, summary,
$wikiPreview, $wikiDiff, $editform, $textbox, $copyElements, $spinner, $errorBox;
$wikiPreview, $wikiDiff, $editform, $textbox, $summaryWidget, $copyElements,
$spinner, $errorBox;
isDiff = ( e.target.name === 'wpDiff' );
$wikiPreview = $( '#wikiPreview' );
@ -188,7 +189,10 @@
$editform = $( '#editform' );
$textbox = $editform.find( '#wpTextbox1' );
summary = OO.ui.infuse( $( '#wpSummaryWidget' ) );
$summaryWidget = $( '#wpSummaryWidget' );
if ( $summaryWidget.length ) {
summary = OO.ui.infuse( $summaryWidget ).getValue();
}
$spinner = $( '.mw-spinner-preview' );
$errorBox = $( '.errorbox' );
@ -249,7 +253,7 @@
formatversion: 2,
action: 'parse',
title: mw.config.get( 'wgPageName' ),
summary: summary.getValue(),
summary: summary,
prop: ''
};