Jump to content

Extensió:CodeEditor

From mediawiki.org
This page is a translated version of the page Extension:CodeEditor and the translation is 52% complete.
No s'ha de confondre amb CodeMirror .
Manual d'extensions de MediaWiki
CodeEditor
Notes de la versió: estable
Descripció Proporciona un editor de codi que ressalta la sintaxi per a pàgines JS, CSS i Lua del lloc web i dels usuaris, integrant-se amb la barra d'eines d'edició avançada
Autor(s)
  • Brooke Vibber
  • Derk-Jan Hartman
  • authors of Ace (ace.c9.io)
Política de compatibilitat Es publiquen noves instantànies juntament amb MediaWiki. La branca mestra no manté la retrocompatibilitat
Canvis a la base de dades No
  • $wgCodeEditorEnableCore
Descàrrega
Traduir l'extensió CodeEditor si està disponible a translatewiki.net
Incidències Tasques obertes · Informar d'un error

Nota Nota:

L'extensió CodeEditor estén la barra d'eines d'edició avançada del WikiEditor amb un giny d'edició Ace integrat, proporcionant algunes funcions útils per a pàgines JavaScript d'usuari/lloc, pàgines CSS, pàgines JSON i, quan també s'instal·la l'extensió Scribunto , per a pàgines Lua, és a dir, pàgines a l'espai de noms de Mòdul. L'editor de codi no es mostra a les pàgines wiki normals, és a dir, a les pàgines wiki amb el model de contingut "wikitext". (Vegeu Extension:CodeMirror per al ressaltat de sintaxi del wikitext quan s'utilitza l'editor de codi font.)

Proporciona les funcions següents:

  • ressaltat de sintaxi per a JavaScript, CSS i Lua
  • sagnia automàtica
  • la tecla de tabulació produeix sagnies de tabulació (des de la versió 1.22), abans sagnies suaus.
  • selecció de sagnia/dessagnia amb les tecles Tab ↹/⇧ Shift+Tab ↹
  • comprovació de validesa de la sintaxi per a JavaScript
  • Comprovació que parèntesis, claus i claudàtors tinguin el mateix nombre d'obertures que de tancaments

Instal·lació

This extension comes with MediaWiki 1.31 and later, so you do not need to download it. The remaining configuration instructions must still be followed.
The WikiEditor extension needs to be installed for this extension to work. Installing the Scribunto extension is optional.
  • Download and move the extracted CodeEditor folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
    
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'CodeEditor' );
    $wgDefaultUserOptions['usebetatoolbar'] = 1; // user option provided by WikiEditor extension
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


Vagrant installation:

  • If using Vagrant , install with vagrant roles enable codeeditor --provision

Configuration

$wgCodeEditorEnableCore
To disable the editor on JavaScript and CSS pages in the MediaWiki, User and other core namespaces, set $wgCodeEditorEnableCore = false; (default is true)
$wgCodeEditorContentModels
Temporary feature flag to control conflicts with Extension:CodeMirror .
$wgScribuntoUseCodeEditor
To disable this extension for Scribunto, i.e. in the module namespace set $wgScribuntoUseCodeEditor = false; (default is true)
This configuration parameter is provided by the Scribunto extension and must therefore be added after invoking the CodeEditor as well as the Scribunto extension which also needs to be installed for this to work.

JavaScript

It is possible to change the configuration of the ACE editor, by hooking into the MediaWiki JS hook (i.e. mw.hook( 'codeEditor.configure' ).add( ... )). The argument passed to your hook will be an ACE EditSession object.

If you need to interact with the contents of a CodeEditor instance, use module-jquery.textSelection.$.fn.textSelection().

Llicència

Vegeu també