User:PerfektesChaos/js/editorContent

JavaScript gadget – use advanced text editor depending on the current situation and user requirements.

Usage

 * If your project has registered this as a gadget, just activate on your Preferences page.
 * Otherwise include the following lines into your common.js or skin dependant like vector.js:

Effects
The gadget selects the appropriate editor among various choices, and will avoid conflicts between competing tools.

Currently there are considered: Another advantage is to avoid loading of the nearly 600 kB Code of WikEd on every displayed page, even if the page is not edited now. Just to conclude that there is no editing, or the current browser does not support WikEd. The same goes for any other tool.
 * WikEd
 * CodeEditor (Ace; mw:Extension:CodeEditor)
 * VisualEditor

The defaults on a glance:

Rules
A “rule” is either
 * (respective default)
 * (turn off explicitly)
 * string (Regular expression, which is to be matched by the current page name; might be an empty string)
 * Array of a string as before and some numbers of namespaces, from which one has to be met.

CodeEditor
Precondition by namespace number: If the precondition is not satisfied, no further rule comes into effect.
 * > 0
 * even
 * not 828

For every single  (programming language) to be considered a keyword is to be defined together with a rule.

The CodeEditor integration at MediaWiki was equipped recently with the following  capabilities:
 * css
 * Default:
 * Meaning: page name terminated by  (lowercase letters)


 * javascript
 * Default:
 * Meaning: page name terminated by  (lowercase letters)


 * json
 * Currently no general rule known.


 * lua
 * Default:
 * Meaning: rule (user space sandbox subpage)

Any other keyword automatically causes loading of the RL module with additional  support. Example (after user configuration of the  object):

The same action will be taken, if the global configuration variable  was found; independent of the rules the CodeEditor will be loaded.

If more than one rule is matching and different keywords will result, choice and behaviour cannot be predicted.

The general statement  wlll exclude the CodeEditor from user defined loading (with exception of Module: namespace  ).

VisualEditor
The VisualEditor is supposed to be activated explicitly by the user, or can be turned off by preferences. If that is not possible one day, any link to VE can be hidden to avoid misclicks.
 * VisualEditor “Edit” link will be removed if any kind of non-wikitext content is detected.
 * CSS and Javascript sources are assumed if page title is terminated by  or   “extension”.

WikEd
Precondition by browser type:
 * Only if Gecko based WikEd will be taken into account.

WikEd must not be loaded by preferences page in advance for any visited page.
 * The default value  loads WikEd, if not CodeEditor is used automatically or on non-documentation pages in Module: namespace   (page name ends with  ).
 * The specification  won’t activate WikEd.

wikiEditor
No actions possible here.

User options
Individual configuration is possible: Insert the lines below into your common.js etc. (best before mw.loader.load, if present):

Other languages
This gadget is prepared for multilingual support.
 * If you like a version in your own language, please forward translations to me:
 * This documentation page.
 * Name of the standard template sandbox (and Module: namespace).


 * German

de:User:PerfektesChaos/js/editorContent