扩展:代码编辑器

This page is a translated version of the page Extension:CodeEditor and the translation is 84% complete.
Outdated translations are marked like this.
此扩展已绑定在MediaWiki 1.31及以上版本。 因此您不需要再次下载。 然而,您仍需要跟随提供的其他指示。
MediaWiki的扩展的手冊
CodeEditor
發佈狀態: 穩定版本
描述
对于网站和用户JS、CSS和Lua页面,提供一个与高级编辑工具栏整合的语法高亮的代码编辑器。
作者
  • Brion Vibber
  • Derk-Jan Hartman
  • authors of Ace (ace.c9.io)
兼容性政策 快照跟随MediaWiki发布。 master分支不向後兼容。
MediaWiki 1.32+
数据库更改
许可协议 GPL-2.0-or-later AND BSD-3-Clause
下載
  • $wgCodeEditorEnableCore
季度下載量 251 (Ranked 46th)
公開的wiki使用 8,385 (Ranked 17th)
翻譯CodeEditor的扩展,若在translatewiki.net可用
問題 尚未完成的工作 · 报告錯誤

代码编辑器扩展给予WikiEditor高级编辑工具栏一个嵌入式的Ace编辑器小组件,为用户/网站的JavaScript页面、CSS页面、JSON页面以及其他由已安装扩展提供的页面(如“Module”名字空间提供的Lua页面)提供一些便利。 代码编辑器不会在常规Wiki页面(即内容模型为“wikitext”的页面)上显示。 (使用源代码编辑器时,參见扩展:CodeMirror 的wikitext的语法高亮)。

它提供以下功能:

  • 为JavaScript、CSS和Lua提供语法高亮
  • 自动缩进
  • 1.22版本起Tab键会生成制表符缩进,而之前是软缩进。
  • 使用Tab/Shift+Tab键进行缩进的增减
  • 针对JavaScript的语法有效性检查
  • 括号、大括号和方括号的配对标示

安裝

此扩展需要已安装WikiEditor才能运转。 可选安装Scribunto扩展。
  • 下载文件,并将其放置在您extensions/文件夹中的CodeEditor目录内。
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'CodeEditor' );
    $wgDefaultUserOptions['usebetatoolbar'] = 1; // user option provided by WikiEditor extension
    
  • 根据需要配置。
  •   完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。


Vagrant安装:

  • 如果使用Vagrant ,请通过vagrant roles enable codeeditor --provision安装

配置

$wgCodeEditorEnableCore
要在MediaWiki、用户和其他核心名字空间中的JavaScript和CSS页面上禁用编辑器,设置$wgCodeEditorEnableCore = false;(默认为“true”)
$wgScribuntoUseCodeEditor
如要为Scribunto(即“模块”名字空间)禁用此扩展,请将$wgScribuntoUseCodeEditor = false;设为false,默认是"true"
此配置参数由Scribunto扩展提供,因此在CodeEditor和Scribunto扩展安装后调用才能生效。

JavaScript

有可能通过连接到MediaWiki JS hook(也就是mw.hook( 'codeEditor.configure' ).add( ... )),改变ACE编辑器的配置。 传递给您的hook的参数是一个[$ace-editor ACE编辑器会话]。

If you need to interact with the contents of a CodeEditor instance, use jQuery.plugin.textSelection.

许可证

尽管此扩展以GNU通用公共许可证2.0版或更高版本(GPL-2.0+)授权,它同样使用Ace编辑器软件,而它则以3句版BSD许可证“新版”或“修正版”(BSD-3-Clause)授权。