扩展:代码编辑器
![]() 發布狀態: 穩定版本 |
|
---|---|
![]() |
|
描述 | 对于网站和用户JS、CSS和Lua页面提供一个语法高亮的代码编辑器,与高级编辑工具栏相整合。 |
作者 |
|
兼容性政策 | 快照跟随MediaWiki发布。 master分支不向後兼容。 |
MediaWiki | 1.32+ |
数据庫更改 | 否 |
许可协议 | GPL-2.0-or-later AND BSD-3-Clause |
下載 | |
|
|
翻譯CodeEditor扩展,若在translatewiki.net可用 | |
問題 | 尚未完成的工作 · 报告錯誤 |
代码编辑器扩展给予WikiEditor高级编辑工具栏一个嵌入式的Ace编辑器部件,为用户/网站的JavaScript页面、CSS页面、JSON页面以及其他由已安装扩展提供的页面(如“Module”名字空间提供的Lua页面)提供一些便利。 代码编辑器不会在常规Wiki页面(即内容模型为“wikitext”的页面)上显示。 (See 扩展:CodeMirror for syntax highlighting of wikitext when using the source editor.)
它提供以下功能:
- 为JavaScript、CSS和Lua提供语法高亮
- 自动缩进
- 1.22版本起Tab键会生成制表符缩进,而之前是软缩进。
- 使用Tab/Shift+Tab键进行缩进的增减
- 针对JavaScript的语法有效性检查
- 括号、大括号和方括号的配对标示
安装
- 下载文件,并将其放置在您
extensions/
文件夹中的CodeEditor
目录内。 - 将下列代码放置在您的
LocalSettings.php
的底部:wfLoadExtension( 'CodeEditor' ); $wgDefaultUserOptions['usebetatoolbar'] = 1; // user option provided by WikiEditor extension
- 根据需要配置。
完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
Vagrant installation:
- 如果使用Vagrant ,请通过
vagrant roles enable codeeditor --provision
安装
配置
$wgCodeEditorEnableCore
- 要在MediaWiki、用户和其他核心名字空间中的JavaScript和CSS页面上禁用编辑器,设置
$wgCodeEditorEnableCore = false;
(默认为“true”)
$wgScribuntoUseCodeEditor
- 如要为Scribunto(即“模块”名字空间)禁用此扩展,请将
$wgScribuntoUseCodeEditor = false;
设为false,默认是"true"
JavaScript
可以更改ACE编辑器的配置,只需使用MediaWiki JS hook (i.e. mw.hook( 'codeEditor.configure' ).add( ... )
)。
传递给您的hook的参数是一个ACE编辑器会话。
Wiki编辑器集成
![]() | 此頁面已过时。 |
I've been integrating CodeEditor into the pluggable portions of 扩展:Wiki编辑器 as prep for Future editor work, since we'll want to be able to extend it to edit things that aren't plain wikitext, which'll need some changes to the toolbar setup and whatnot. JS/CSS here still return plain text in the end, making it an easier intermediate project. --brion 00:26, 14 June 2011 (UTC)
Good:
- special char insertions work, including quote pairs to surround text
- basic formatting insertions work, including link dialogs
- search/replace dialog works
- ace's built-in search/replace UI also triggers from keyboard commands, still need to disable them! (onCommandKey)
Bad:
- multi-line formatting doesn't apply correctly (but really should that apply here? :)
To-do:
- remove toolbar buttons that don't apply (formatting, syntax help?)
- add toolbar buttons that are more directly useful
- indent/outdent
- insertion helpers for common keywords or code bits
- help reference to MW JS API reference, JS & CSS specs/documentation
已知的问题
![]() | 此頁面已过时。 |
- accessibility: tab/shift-tab are overridden. Is there a consistent alternative for keyboard-reliant users?
- accessibility: access key on the original textarea needs to be moved over or otherwise handled
- scrollbar initializes too wide; need to trigger resize check after that's filled (maybe fixed?)
- cursor/scroll position not maintained over previews/show changes
许可证
尽管此扩展以GNU通用公共许可证2.0版或更高版本(GPL-2.0+)授权,它同样使用Ace编辑器软件,而它则以3句版BSD许可证“新版”或“修正版”(BSD-3-Clause)授权。
![]() | 此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
![]() | This extension is included in the following packages and/or wiki farms: |
- Extensions bundled with MediaWiki 1.31/zh
- Stable extensions/zh
- Extensions with invalid or missing type/zh
- Extensions with unknown license/zh
- Extensions in Wikimedia version control/zh
- EditPage::showEditForm:initial extensions/zh
- EditPage::showReadOnlyForm:initial extensions/zh
- GetPreferences extensions/zh
- All extensions/zh
- Outdated pages/zh
- Extensions used on Wikimedia/zh
- Extensions included in BlueSpice/zh
- Extensions included in Canasta/zh
- Extensions included in Fandom/zh
- Extensions included in Miraheze/zh
- Extensions included in MyWikis/zh
- Extensions included in ProWiki/zh
- Extensions included in semantic::core/zh
- Syntax highlighting extensions/zh
- Scribunto extensions/zh
- Edit extensions/zh