diff --git a/CodeEditor.php b/CodeEditor.php index 2363b413..b4d2402e 100644 --- a/CodeEditor.php +++ b/CodeEditor.php @@ -104,7 +104,8 @@ $wgResourceModules['ext.codeEditor.geshi'] = array( 'messages' => array( 'editsection', 'savearticle' - ) + ), + 'dependencies' => 'mediawiki.api.parse', ) + $tpl; // Experimental feature; not ready yet. diff --git a/modules/ext.codeEditor.geshi.js b/modules/ext.codeEditor.geshi.js index 791dd5eb..57892a80 100644 --- a/modules/ext.codeEditor.geshi.js +++ b/modules/ext.codeEditor.geshi.js @@ -91,26 +91,19 @@ $( function () { .text( mw.msg( 'savearticle' ) ) .click( function () { // horrible hack ;) - var src, tag; + var src, tag, api = new mw.Api(); src = codeEditor.getSession().getValue(); tag = '' + src + ''; - $.ajax( mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ), { - data: { - action: 'parse', - text: tag, - format: 'json' - }, - type: 'POST', - success: function ( data ) { - var $html = $( data.parse.text['*'] ); - $div.replaceWith( $html ); - setupEditor( $html ); + api.parse( tag ) + .done( function ( html ) { + var $html = $( html ); + $div.replaceWith( $html ); + setupEditor( $html ); - closeEditor(); - event.preventDefault(); - } + closeEditor(); + event.preventDefault(); } ); } ); $cancel = $( '