| 1 |
( function () { |
| 2 |
|
| 3 |
Object.assign( mw.Api.prototype, { |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
parse: function ( content, additionalParams ) { |
| 14 |
const config = Object.assign( { |
| 15 |
formatversion: 2, |
| 16 |
action: 'parse', |
| 17 |
|
| 18 |
prop: 'text', |
| 19 |
contentmodel: 'wikitext' |
| 20 |
}, additionalParams ); |
| 21 |
|
| 22 |
let apiPromise; |
| 23 |
if ( mw.Title && content instanceof mw.Title ) { |
| 24 |
|
| 25 |
config.page = content.getPrefixedDb(); |
| 26 |
apiPromise = this.get( config ); |
| 27 |
} else { |
| 28 |
|
| 29 |
config.text = String( content ); |
| 30 |
apiPromise = this.post( config ); |
| 31 |
} |
| 32 |
|
| 33 |
return apiPromise |
| 34 |
.then( ( data ) => data.parse.text ) |
| 35 |
.promise( { abort: apiPromise.abort } ); |
| 36 |
} |
| 37 |
} ); |
| 38 |
|
| 39 |
}() ); |