2011-06-09 21:50:45 +00:00
|
|
|
/**
|
|
|
|
* MediaWiki:Gadget-codeeditor.js
|
|
|
|
* (c) 2011 Brion Vibber <brion @ pobox.com>
|
|
|
|
* GPLv2 or later
|
|
|
|
*
|
|
|
|
* Syntax highlighting, auto-indenting code editor widget for on-wiki JS and CSS pages.
|
|
|
|
* Uses embedded Ajax.org Cloud9 Editor: http://ace.ajax.org/
|
|
|
|
*
|
|
|
|
* Browsers tested:
|
|
|
|
* - Firefox 4.0 / Linux
|
|
|
|
* - Chrome 10.0.648.204 / Linux
|
|
|
|
*
|
|
|
|
* Browsers tested with issues:
|
|
|
|
* - Opera 11.10 / Linux: copy fails, paste sometimes crashes
|
|
|
|
* - IE 8.0.6001.18702 / Win XP: some newlines mysteriously removed, corrupting data;
|
|
|
|
* insertion point keeps resetting back to the top of the page after a click (arrow keys ok)
|
|
|
|
* - Safari / iPad 4.3 (8F190): renders ok, but can't set focus or scroll vertically. No focus means no typing. :(
|
|
|
|
* There is some work in progress that needs merging upstream...
|
|
|
|
* https://github.com/ajaxorg/ace/issues/37
|
|
|
|
*
|
|
|
|
* Known issues:
|
2011-06-16 22:30:01 +00:00
|
|
|
* - extension version doesn't have optional bits correct
|
|
|
|
* - ties into WikiEditor, so doesn't work on classic toolbar
|
|
|
|
* - background worker for JS syntax check doesn't load in non-debug mode (probably also fails if extension assets are offsite)
|
2011-06-09 21:50:45 +00:00
|
|
|
* - copy/paste not available from context menu (Firefox, Chrome on Linux -- kbd & main menu commands ok)
|
|
|
|
* - accessibility: tab/shift-tab are overridden. is there a consistent alternative for keyboard-reliant users?
|
|
|
|
* - accessibility: accesskey on the original textarea needs to be moved over or otherwise handled
|
|
|
|
* - 'discard your changes?' check on tab close doesn't trigger
|
|
|
|
* - scrollbar initializes too wide; need to trigger resize check after that's filled
|
|
|
|
* - cursor/scroll position not maintained over previews/show changes
|
|
|
|
*
|
|
|
|
* Reported upstream:
|
|
|
|
* - ctrl+R, ctrl+L, ctrl+T are taken over by the editor, which is SUPER annoying
|
|
|
|
* https://github.com/ajaxorg/ace/issues/210
|
|
|
|
*/
|
2011-06-10 01:11:18 +00:00
|
|
|
/*
|
|
|
|
* JavaScript for WikiEditor Table of Contents
|
|
|
|
*/
|
2011-06-09 21:50:45 +00:00
|
|
|
|
2011-06-10 01:11:18 +00:00
|
|
|
$( document ).ready( function() {
|
|
|
|
// Add code editor module
|
|
|
|
$( '#wpTextbox1' ).wikiEditor( 'addModule', 'codeEditor' );
|
2012-04-23 11:40:43 +00:00
|
|
|
} );
|
|
|
|
$( window ).load( function() {
|
2012-04-23 04:09:47 +00:00
|
|
|
// If there is a fragment giving a line number, scroll to the relevant location
|
2012-04-23 11:40:43 +00:00
|
|
|
// Wait for the load event since it doesn't scroll properly on ready
|
2012-04-23 04:09:47 +00:00
|
|
|
$( '#wpTextbox1' ).data('wikiEditor-context').fn.codeEditorMonitorFragment();
|
2011-06-10 01:11:18 +00:00
|
|
|
} );
|