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.
|
2016-01-27 11:01:54 +00:00
|
|
|
* Uses embedded Ajax.org Cloud9 Editor: https://ace.c9.io/
|
2011-06-09 21:50:45 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2011-06-10 01:11:18 +00:00
|
|
|
/*
|
|
|
|
* JavaScript for WikiEditor Table of Contents
|
|
|
|
*/
|
2011-06-09 21:50:45 +00:00
|
|
|
|
2017-01-05 22:00:57 +00:00
|
|
|
$( function () {
|
2019-02-06 01:34:32 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2013-08-24 08:15:10 +00:00
|
|
|
var $wpTextbox1 = $( '#wpTextbox1' );
|
|
|
|
|
|
|
|
// Code is supposed to be always LTR. See bug 39364.
|
|
|
|
$wpTextbox1.parent().prop( 'dir', 'ltr' );
|
|
|
|
|
2011-06-10 01:11:18 +00:00
|
|
|
// Add code editor module
|
2013-08-24 08:15:10 +00:00
|
|
|
$wpTextbox1.wikiEditor( 'addModule', 'codeEditor' );
|
2015-08-27 19:22:09 +00:00
|
|
|
|
|
|
|
$wpTextbox1.on( 'wikiEditor-toolbar-doneInitialSections', function () {
|
|
|
|
$wpTextbox1.data( 'wikiEditor-context' ).fn.codeEditorMonitorFragment();
|
|
|
|
} );
|
2011-06-10 01:11:18 +00:00
|
|
|
} );
|