Jump to content

Extensão: CodeEditor

From mediawiki.org
This page is a translated version of the page Extension:CodeEditor and the translation is 33% complete.
Não confundir com CodeMirror .
Manual de extensões da MediaWiki
CodeEditor
Estado de lançamento: estável
Descrição Proporciona um editor de código de destaque de sintaxe para as páginas JS, CSS e Lua de para o site e utilizador, integrando-se com a barra de ferramentas de edição avançada
Autor(es)
  • Brooke Vibber
  • Derk-Jan Hartman
  • authors of Ace (ace.c9.io)
Política de compatibilidade Lançamentos de capturas de ecrã em conjunto com o MediaWiki. Original não é compatível com as versões anteriores.
Alterações à base de dados Não
Licença GPL-2.0-or-later AND BSD-3-Clause
Transferência
  • $wgCodeEditorEnableCore
Traduza a extensão CodeEditor se esta estiver disponível em translatewiki.net
Problemas Tarefas em aberto · Reportar um erro

The CodeEditor extension extends the WikiEditor advanced editing toolbar with an embedded Ace editor widget, providing some handy features for user/site JavaScript pages, CSS pages, JSON pages, and when extension Scribunto is also installed, for Lua pages, i.e. pages in the Module namespace. The code editor does not show on regular wiki pages, i.e. wiki pages with the "wikitext" content model. (See Extensão: CodeMirror for syntax highlighting of wikitext when using the source editor.)

It provides the following features:

  • syntax highlighting for JavaScript, CSS and Lua
  • auto-indent
  • tab key produces tab indents (since 1.22), soft indents before.
  • indent/unindent selection with Tab ↹/⇧ Shift+Tab ↹ keys
  • syntax validity check for JavaScript
  • Pair-matching for parenthesis, braces and square brackets

Instalação

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.
A extensão WikiEditor precisa de ser instalada para que esta extensão funcione. A instalação da extensão Scribunto é opcional.
  • Exporte e coloque o ficheiro, ou ficheiros, num diretório chamado CodeEditor, na sua pasta extensions/.
    Developers and code contributors should install the extension from Git instead, using:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
    
  • Acrescente o seguinte código ao fundo do ficheiro $LocalSettings:
    wfLoadExtension( 'CodeEditor' );
    $wgDefaultUserOptions['usebetatoolbar'] = 1; // user option provided by WikiEditor extension
    
  • Configure conforme necessário.
  • Yes Pronto – Na página especial Special:Version da sua wiki verifique se a extensão foi instalada.


Vagrant installation:

  • Se estiver a utilizar Vagrant , instale com vagrant roles enable codeeditor --provision

Configuração

$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 Extensão: 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().

Licença

Consultar também