mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-23 23:03:46 +00:00
Remove inline CodeEditor for <syntaxhighlight>
This was an unfinished module to enable the CodeEditor to do inline editing of <syntaxhighlight> blocks. It was never finished and I think that with the VE and WE 2017 work, it likely will never be finished either. For that reason, it is better to remove it altogether. Change-Id: I83714188a53d2ca6bb7bf0dc6d0c89b7fb45a47a
This commit is contained in:
parent
99e6e25826
commit
07b24bb9f0
|
@ -44,12 +44,4 @@ class CodeEditorHooks {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function onBeforePageDisplay( $out, $skin ) {
|
||||
global $wgCodeEditorGeshiIntegration;
|
||||
if ( $wgCodeEditorGeshiIntegration ) {
|
||||
$out->addModules( 'ext.codeEditor.geshi' );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
]
|
||||
},
|
||||
"config": {
|
||||
"CodeEditorEnableCore": true,
|
||||
"CodeEditorGeshiIntegration": false
|
||||
"CodeEditorEnableCore": true
|
||||
},
|
||||
"ResourceModules": {
|
||||
"ext.codeEditor": {
|
||||
|
@ -101,20 +100,6 @@
|
|||
"ace/mode-scala.js"
|
||||
],
|
||||
"dependencies": "ext.codeEditor.ace"
|
||||
},
|
||||
"ext.codeEditor.geshi": {
|
||||
"scripts": [
|
||||
"ext.codeEditor.geshi.js"
|
||||
],
|
||||
"styles": [
|
||||
"ext.codeEditor.geshi.css"
|
||||
],
|
||||
"messages": [
|
||||
"editsection",
|
||||
"savearticle"
|
||||
],
|
||||
"dependencies": "mediawiki.api.parse",
|
||||
"group": "ext.wikiEditor"
|
||||
}
|
||||
},
|
||||
"ResourceFileModulePaths": {
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
.mw-geshi .mw-editsection {
|
||||
float: right;
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
/**
|
||||
* This is experimental and does not yet actually save anything back.
|
||||
* Has to be manually enabled.
|
||||
* Needs some code de-dup with the full-page JS/CSS page editing.
|
||||
*/
|
||||
/*global ace */
|
||||
( function ( $, mw ) {
|
||||
|
||||
$( function () {
|
||||
var $sources, setupEditor, openEditor;
|
||||
|
||||
$sources = $( '.mw-geshi' );
|
||||
|
||||
if ( $sources.length > 0 ) {
|
||||
setupEditor = function ( $div ) {
|
||||
var $link, $edit;
|
||||
|
||||
$link = $( '<a>' )
|
||||
.text( mw.msg( 'editsection' ) )
|
||||
.attr( 'href', '#' )
|
||||
.attr( 'title', 'Edit this code section' )
|
||||
.click( function ( event ) {
|
||||
openEditor( $div );
|
||||
event.preventDefault();
|
||||
} );
|
||||
$edit = $( '<span>' )
|
||||
.addClass( 'mw-editsection' )
|
||||
.append( '<span class="mw-editsection-bracket">[</span>' )
|
||||
.append( $link )
|
||||
.append( '<span class="mw-editsection-bracket">]</span>' );
|
||||
$div.prepend( $edit );
|
||||
};
|
||||
|
||||
openEditor = function ( $div ) {
|
||||
var $main, geshiLang, matches, $label, $langDropDown, $xcontainer, codeEditor;
|
||||
|
||||
$main = $div.find( 'div' );
|
||||
geshiLang = null;
|
||||
matches = /(?:^| )source-([a-z0-9_-]+)/.exec( $main.attr( 'class' ) );
|
||||
|
||||
if ( matches ) {
|
||||
geshiLang = matches[ 1 ];
|
||||
}
|
||||
mw.loader.using( 'ext.codeEditor.ace.modes', function () {
|
||||
var map, $container, $save, $cancel, $controls, setLanguage, closeEditor;
|
||||
|
||||
// @fixme de-duplicate
|
||||
map = {
|
||||
c: 'c_cpp',
|
||||
cpp: 'c_cpp',
|
||||
clojure: 'clojure',
|
||||
csharp: 'csharp',
|
||||
css: 'css',
|
||||
coffeescript: 'coffee',
|
||||
groovy: 'groovy',
|
||||
html4strict: 'html',
|
||||
html5: 'html',
|
||||
java: 'java',
|
||||
java5: 'java',
|
||||
javascript: 'javascript',
|
||||
jquery: 'javascript',
|
||||
json: 'json',
|
||||
ocaml: 'ocaml',
|
||||
perl: 'perl',
|
||||
php: 'php',
|
||||
python: 'python',
|
||||
ruby: 'ruby',
|
||||
scala: 'scala',
|
||||
xml: 'xml'
|
||||
};
|
||||
|
||||
$container = $( '<div>' )
|
||||
.attr( 'style', 'top: 32px; left: 0px; right: 0px; bottom: 0px; border: 1px solid gray; position: absolute;' )
|
||||
.text( $main.text() ); // quick hack :D
|
||||
|
||||
$label = $( '<label>' ).text( 'Source language: ' );
|
||||
$langDropDown = $( '<select>' );
|
||||
$.each( map, function ( geshiLang ) {
|
||||
$( '<option>' )
|
||||
.text( geshiLang )
|
||||
.val( geshiLang )
|
||||
.appendTo( $langDropDown );
|
||||
} );
|
||||
$langDropDown
|
||||
.val( geshiLang )
|
||||
.appendTo( $label )
|
||||
.change( function () {
|
||||
setLanguage( $( this ).val() );
|
||||
} );
|
||||
$save = $( '<button>' )
|
||||
.text( mw.msg( 'savearticle' ) )
|
||||
.click( function ( event ) {
|
||||
// horrible hack ;)
|
||||
var src, tag, api = new mw.Api();
|
||||
|
||||
src = codeEditor.getSession().getValue();
|
||||
tag = '<source lang="' + geshiLang + '">' + src + '</source>';
|
||||
|
||||
api.parse( tag )
|
||||
.done( function ( html ) {
|
||||
var $html = $( html );
|
||||
$div.replaceWith( $html );
|
||||
setupEditor( $html );
|
||||
|
||||
closeEditor();
|
||||
} );
|
||||
event.preventDefault();
|
||||
} );
|
||||
$cancel = $( '<button>' )
|
||||
.text( 'Close' ).click( function ( event ) {
|
||||
$xcontainer.remove();
|
||||
$div.show();
|
||||
event.preventDefault();
|
||||
} );
|
||||
$controls = $( '<div>' )
|
||||
.append( $label )
|
||||
.append( $save )
|
||||
.append( $cancel );
|
||||
$xcontainer = $( '<div style="position: relative"></div>' )
|
||||
.append( $controls )
|
||||
.append( $container );
|
||||
$xcontainer.width( $main.width() )
|
||||
.height( $main.height() * 1.1 + 64 + 32 );
|
||||
|
||||
$div.hide();
|
||||
$xcontainer.insertAfter( $div );
|
||||
|
||||
codeEditor = ace.edit( $container[ 0 ] );
|
||||
|
||||
setLanguage = function ( lang ) {
|
||||
var aceLang = map[ lang ],
|
||||
AceLangMode = ace.require( 'ace/mode/' + aceLang ).Mode;
|
||||
geshiLang = lang;
|
||||
codeEditor.getSession().setMode( new AceLangMode() );
|
||||
};
|
||||
setLanguage( geshiLang );
|
||||
|
||||
// Remove some annoying commands
|
||||
codeEditor.commands.removeCommand( 'replace' ); // ctrl+R
|
||||
codeEditor.commands.removeCommand( 'transposeletters' ); // ctrl+T
|
||||
codeEditor.commands.removeCommand( 'gotoline' ); // ctrl+L
|
||||
|
||||
closeEditor = function () {
|
||||
$xcontainer.remove();
|
||||
$div.show();
|
||||
};
|
||||
} );
|
||||
};
|
||||
|
||||
$sources.each( function () {
|
||||
setupEditor( $( this ) );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}( jQuery, mediaWiki ) );
|
Loading…
Reference in a new issue