diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index 12df277d21..12cd48280d 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -239,6 +239,8 @@ class ApiVisualEditor extends ApiBase { $wgTitle = $title; RequestContext::getMain()->setTitle( $title ); + $preloaded = false; + // Get information about current revision if ( $title->exists() ) { $latestRevision = Revision::newFromTitle( $title ); @@ -287,6 +289,7 @@ class ApiVisualEditor extends ApiBase { $params['preload'], $params['preloadparams'], $title, $params['paction'] !== 'wikitext' ); + $preloaded = true; } } else { $apiParams['rvsection'] = $section; @@ -327,6 +330,7 @@ class ApiVisualEditor extends ApiBase { $params['preload'], $params['preloadparams'], $title, $params['paction'] !== 'wikitext' ); + $preloaded = true; } $baseTimestamp = wfTimestampNow(); $oldid = 0; @@ -584,6 +588,15 @@ class ApiVisualEditor extends ApiBase { ( !empty( $params['preload'] ) && isset( $content ) ) ) { $result['content'] = $content; + if ( $preloaded ) { + // If the preload param was actually used, pass it + // back so the caller knows. (It's not obvious to the + // caller, because in some situations it'll depend on + // whether the page has been created. They can work it + // out from some of the other returns, but this is + // simpler.) + $result['preloaded'] = $params['preload']; + } } break; diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js index d60da7202f..66889b720f 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js @@ -283,6 +283,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) { this.fromEditedState = data.fromEditedState; this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query; this.doc = this.constructor.static.parseDocument( this.originalHtml, this.getDefaultMode() ); + this.preloaded = data.preloaded; this.remoteNotices = ve.getObjectValues( data.notices ); this.protectedClasses = data.protectedClasses; @@ -1882,7 +1883,7 @@ ve.init.mw.ArticleTarget.prototype.updateToolbarSaveButtonState = function () { return; } - this.edited = this.getSurface().getModel().hasBeenModified() || this.fromEditedState; + this.edited = this.getSurface().getModel().hasBeenModified() || this.fromEditedState || this.preloaded; if ( this.sectionTitle ) { this.edited = this.edited || this.sectionTitle.getValue() !== ''; }