mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Bypass API call when wikitext is empty string"
This commit is contained in:
commit
6e503cdb0b
|
@ -152,7 +152,13 @@ ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ve.dm.MWWikitextSurfaceFragment.prototype.convertFromSource = function ( source ) {
|
ve.dm.MWWikitextSurfaceFragment.prototype.convertFromSource = function ( source ) {
|
||||||
var parsePromise = new mw.Api().post( {
|
var parsePromise;
|
||||||
|
if ( !source ) {
|
||||||
|
parsePromise = $.Deferred().resolve(
|
||||||
|
this.getDocument().shallowCloneFromRange( new ve.Range( 0 ) )
|
||||||
|
).promise();
|
||||||
|
} else {
|
||||||
|
parsePromise = new mw.Api().post( {
|
||||||
action: 'visualeditor',
|
action: 'visualeditor',
|
||||||
paction: 'parsefragment',
|
paction: 'parsefragment',
|
||||||
page: mw.config.get( 'wgRelevantPageName' ),
|
page: mw.config.get( 'wgRelevantPageName' ),
|
||||||
|
@ -162,6 +168,7 @@ ve.dm.MWWikitextSurfaceFragment.prototype.convertFromSource = function ( source
|
||||||
ve.createDocumentFromHtml( response.visualeditor.content )
|
ve.createDocumentFromHtml( response.visualeditor.content )
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Show progress bar without breaking WindowAction
|
// TODO: Show progress bar without breaking WindowAction
|
||||||
// ve.init.target.getSurface().createProgress(
|
// ve.init.target.getSurface().createProgress(
|
||||||
|
|
Loading…
Reference in a new issue