mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-24 07:13:27 +00:00
Merge "Use mediawiki.api.parse"
This commit is contained in:
commit
aefe1def47
|
@ -104,7 +104,8 @@ $wgResourceModules['ext.codeEditor.geshi'] = array(
|
|||
'messages' => array(
|
||||
'editsection',
|
||||
'savearticle'
|
||||
)
|
||||
),
|
||||
'dependencies' => 'mediawiki.api.parse',
|
||||
) + $tpl;
|
||||
|
||||
// Experimental feature; not ready yet.
|
||||
|
|
|
@ -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 = '<source lang="' + geshiLang + '">' + src + '</source>';
|
||||
|
||||
$.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['*'] );
|
||||
api.parse( tag )
|
||||
.done( function ( html ) {
|
||||
var $html = $( html );
|
||||
$div.replaceWith( $html );
|
||||
setupEditor( $html );
|
||||
|
||||
closeEditor();
|
||||
event.preventDefault();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
$cancel = $( '<button>' )
|
||||
|
|
Loading…
Reference in a new issue