mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Bypass API call when wikitext is empty string"
This commit is contained in:
commit
6e503cdb0b
|
@ -152,16 +152,23 @@ 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;
|
||||||
action: 'visualeditor',
|
if ( !source ) {
|
||||||
paction: 'parsefragment',
|
parsePromise = $.Deferred().resolve(
|
||||||
page: mw.config.get( 'wgRelevantPageName' ),
|
this.getDocument().shallowCloneFromRange( new ve.Range( 0 ) )
|
||||||
wikitext: source
|
).promise();
|
||||||
} ).then( function ( response ) {
|
} else {
|
||||||
return ve.dm.converter.getModelFromDom(
|
parsePromise = new mw.Api().post( {
|
||||||
ve.createDocumentFromHtml( response.visualeditor.content )
|
action: 'visualeditor',
|
||||||
);
|
paction: 'parsefragment',
|
||||||
} );
|
page: mw.config.get( 'wgRelevantPageName' ),
|
||||||
|
wikitext: source
|
||||||
|
} ).then( function ( response ) {
|
||||||
|
return ve.dm.converter.getModelFromDom(
|
||||||
|
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