Please do not mark this page for translation yet. It is still being drafted, or it contains incomplete translation markup which should be fixed before marking for translation. |
Release status: stable | |
|---|---|
| Implementation | Page action,Extended syntax,Beta Feature,Skin |
| Description | Allows for editing pages as rich content |
| Author(s) | Alex Monk, Bartosz Dziewoński, C. Scott Ananian, Christian Williams, David Lynch, Ed Sanders, Inez Korczyński, James D. Forrester, Moriel Schottlender, Roan Kattouw, Rob Moen, Subramanya Sastry, Thalia Chan, Timo Tijhof, Trevor Parscal, ... |
| Latest version | continuous updates |
| Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
| Database changes | No |
| License | MIT License |
| Download | README |
| Help | Help:VisualEditor/User guide |
| |
| |
| Translate the VisualEditor extension | |
| Vagrant role | visualeditor |
| Issues | Open tasks ·Report a bug |
TheVisualEditor extension allows for editing pages as rich content. It is based around a JavaScript library, also called "VisualEditor", that can potentially be used outside of MediaWiki as well. This page covers instructions for installing and configuring the VisualEditor extension. For help on using it, seeHelp:VisualEditor/User guide. For information on the development of the extension and the library, seeVisualEditor.
The extension is bundled with MediaWiki core. It should already be present in the Extensions folder.
Add the following line of code to LocalSettings.php.
wfLoadExtension( 'VisualEditor' );
Run anupdate.
Done
VisualEditor folder to yourextensions/ directory.cdextensions/gitclone--recurse-submoduleshttps://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditorwfLoadExtension('VisualEditor');
If you downloaded the MediaWiki tarball, you do not need to download this extension.
Note:
REL1_39 branch (command:gitclone-bREL1_39https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor.git).gitsubmoduleupdate--init command is vital, as VisualEditor MediaWiki extension needs the core VisualEditor submodule to work.If you do not use this command, VisualEditor will fail to work.Though only tested and supported withVector,MonoBook, andMinerva Neue, VisualEditor is known to also be compatible with the following skins:
There are many other skins that are also not officially supported but should work; it should be compatible with any skin that uses the required HTML structure – seeVisualEditor/Skin requirements. Some fiddling with skin stylesheets might be necessary to make everything look nice. It will load on any skin if it matches the feature detection.
You should not need to change almost any of the configuration below, unless you have an unusual installation of MediaWiki. |
The following optional configurations can be used:
// Optional: Set VisualEditor as the default editor for logged-out users// otherwise they will have to switch to VE$wgDefaultUserOptions['visualeditor-editor']="visualeditor";// Optional: Don't allow users to disable it$wgHiddenPrefs[]='visualeditor-enable';// Optional: Enable VisualEditor's experimental code features$wgDefaultUserOptions['visualeditor-enable-experimental']=1;// Activate ONLY the 2017 wikitext editor by default$wgDefaultUserOptions['visualeditor-autodisable']=true;$wgDefaultUserOptions['visualeditor-newwikitext']=1;
Other extensions which load plugins for VE can be loaded before or after VE; the plugins should work either way.
By default, VisualEditor is enabled for the namespaces "User", "File", "Category", andcontent namespaces (contains "Main" by default). It is however possible to add or remove namespace using the English language canonical names defined for the respective namespaces such as e.g. "Project", "Talk" etc. Additional custom namespaces use the names used to create them.
// Enable for the meta namespace, disable for the "File" namespace and enable for the "Extra", the latter being a custom namespace$wgVisualEditorAvailableNamespaces=['Project'=>true,'File'=>false,'Extra'=>true];
If you are using non-standardshort URLs such as "https://wiki.example.org/Page_title" on Apache, you need toadapt the rewrite rules for the web server.
VisualEditor will display some broken links if the wiki is not configured with Short Urls. SeeT328337.
If you are serving MediaWiki from apache2, you will need to add the following to your top level server configuration (often a<VirtualHost> section in/etc/apache2/sites-enabled/000-default.conf or similar):
AllowEncodedSlashesNoDecodeIf you do not, then VisualEditor will complain that "Revision IDs returned by the server do not match" or simply "Error contacting the Parsoid/RESTBase server (HTTP 404)" when editing a page title containing a slash, for example a subpage. SeeT268953 and theapache documentation for more information.
If the Apache server happens to be behind a Nginx proxy then itsproxy_pass stanza should make use of the$request_uri parameter (cf.discussion on StackOverflow).
If Apache2 is configured with multiple virtual sites, Parsoid is (in standard configuration) only able to access the default site. To check for this problem, runcurl '[http://your-wiki-base-url]/rest.php/v1/page/Main_Page' on the server, or runcurl '[https://your-wiki-base-url]/rest.php/v1/page/Main_Page' ensuring the URL matches the SSL certificate used on the server.
If the response contains the main page of your wiki then you don't have the problem, but if it doesn't, you may need to configure a host alias that Parsoid can use:
Look at the apache2 configuration file for the virtual server hosting the wiki, near the top of the file there should be a line like:
<VirtualHost *:80>
If the '*' is present, then the alias can be to localhost, if there is an IP address replacing the '*' then the alias must be to that IP address.
In the same file add a line:
ServerAlias my_wiki_alias
In the hosts file of the server (/etc/hosts on Ubuntu), add a route for my_wiki_alias, either for 127.0.0.1 (if the apache2 virtual server configuration had the '*' above, else to the IP address from the apache2 virtual server configuration.
Now set the hostname in$wgServer toprotocol://my_wiki_alias on the host running VisualEditor (seeManual:$wgServer).
By default VisualEditor is automatically configured to talk to a Parsoid service running on the same host (and on the same port).You should not need to change this in most cases!
Some cases when you do need to change the URL of Parsoid:
If you need to do this, add the following code to yourLocalSettings.php to specify the URL for your Parsoid instance:
$wgVirtualRestConfig['modules']['parsoid']=array(// URL to the Parsoid instance.// You should change $wgServer to match the non-local host running Parsoid// Note! This is a server to server URL (it must be valid within your VM/container)// For a VM or docker this will probably be correct:// 'url' => "http://localhost/rest.php",'url'=>$wgServer.$wgScriptPath.'/rest.php',// Parsoid "domain", see below (optional, rarely needed)// 'domain' => 'localhost',);
Note that you do not need to the initialise the$wgVirtualRestConfig array anywhere in LocalSettings.
Parsoid'sdomain setting here must match the host portion of$wgServer on the host running the Parsoid service.
If you do set any property in$wgVirtualRestConfig['modules']['parsoid']you will have tomanually install Parsoid or VisualEditor will not work!
In a private wiki, you should do this:
| Potential security vulnerability. Enabling this setting on an HTTP-served private wiki will transmit cookie headers, including authentication data, unencrypted to Parsoid. Enable only if absolutely necessary and only with full understanding of the associated security risks. |
This is the default configuration for VisualEditor ifnot everyone is allowed to read every page, as suchthe below should not be required in most cases.
// Forward users' Cookie: headers to Parsoid. Required for private wikis (login required to read).// If the wiki is not private (i.e. $wgGroupPermissions['*']['read'] is true) this configuration// variable will be ignored.//// WARNING: ONLY enable this on private wikis and ONLY IF you understand the SECURITY IMPLICATIONS// of sending Cookie headers to Parsoid over HTTP.$wgVirtualRestConfig['modules']['parsoid']['forwardCookies']=true;
If you do set any property inyou will have tomanually install Parsoid or VisualEditor will not work!$wgVirtualRestConfig['modules']['parsoid']
| Feature | Beta Features opt-in state | Enabled for all to opt-in | Enabled for all to opt-out | Enabled for all without opt-out |
|---|---|---|---|---|
| Visual mode | MW 1.36+$wgVisualEditorEnableBetaFeature=true; $wgHiddenPrefs[]='visualeditor-enable'; | $wgDefaultUserOptions['visualeditor-autodisable']=true; | Enabled by default | As in "Enabled for all to opt-out" plus:$wgHiddenPrefs[]='visualeditor-enable'; |
| Wikitext mode | $wgVisualEditorEnableWikitextBetaFeature=true; | $wgVisualEditorEnableWikitext=true; | $wgVisualEditorEnableWikitext=true;$wgDefaultUserOptions['visualeditor-newwikitext']=1; | As in "Enabled for all to opt-out" plus:$wgHiddenPrefs[]='visualeditor-newwikitext'; |
| Single edit tab | Not a supported configuration. | $wgVisualEditorUseSingleEditTab=true;$wgDefaultUserOptions['visualeditor-tabs']='multi-tab'; | $wgVisualEditorUseSingleEditTab=true; $wgDefaultUserOptions['visualeditor-editor']='visualeditor'; | As in "Enabled for all to opt-out" plus:$wgHiddenPrefs[]='visualeditor-tabs'; |
| Visual diffs on history pages | $wgVisualEditorEnableDiffPageBetaFeature=true; | Not a supported configuration. | Not a supported configuration. | $wgVisualEditorEnableDiffPage=true; |
Each configuration option is shown without the$wgVisualEditor prefix for brevity; replace the '…' when using.
| Option | Default value | Useful for… | Documentation | ||
|---|---|---|---|---|---|
…PluginModules | [] | Extension developers | Array of ResourceLoader module names (strings) that should be loaded when VisualEditor is loaded. Other extensions that extend VisualEditor should add to this array.
| ||
…PreloadModules | ["site","user"] | Extension developers | Array of ResourceLoader module names (strings) that should be loaded before VisualEditor is loaded. Other extensions that extend VisualEditor and need to set up their environment before loading should add to this array.
| ||
…PreferenceModules | {"visualeditor-enable-experimental":"ext.visualEditor.experimental"} | Extension developers | Associative array of ResourceLoader module names (strings) that should be loaded when VisualEditor is loadedif the current user has a preference set. Other extensions that extend VisualEditor should add to this array if they want their addition to be opt-in or opt-out. Keys are preference names, values are ResourceLoader module names. Remember to also set defaults in | ||
…ParsoidAutoConfig | true | Sysadmins | Enables auto-configuration of the bundled version of the Parsoid REST API. Set tofalse if you have an unusual Parsoid configuration and want to manually configure it. | ||
…RestbaseURL | false | Sysadmins | URL to use to access the main RESTBase call. The page name will be appended directly to this value, so this needs to be set to something like 'https://en.wikipedia.org/api/rest_v1/page/html/'including the trailing slash.If this is set, the page HTML will be requested from RESTBase. If this is not set, the page HTML will be requested from the API, which will send an HTTP request to Parsoid or to RESTBase if available. | ||
…FullRestbaseURL | false | Sysadmins | URL to use to access the rest of RESTBase. The page name will be appended directly to this value, so this needs to be set to something like 'https://en.wikipedia.org/api/rest_'excluding the trailing slash. | ||
…AllowLossySwitching | true | Sysadmins | Whether to allow switching from wikitext to visual editor even if doing so may cause dirty diffs. See§ Switching between wikitext and visual editing. | ||
…SerializationCacheTimeout | 3600 | Sysadmins | Serialization cache timeout, in seconds | ||
…AvailableNamespaces | ["User"=>true,"File"=>true,"Category"=>true,"_merge_strategy"=>"array_plus"] | Sysadmins | Namespaces in which to enable VisualEditor (mapped from namespace canonical name to a boolean flag), on top of$wgContentNamespaces. | ||
…AvailableContentModels | ["wikitext"=>"article","_merge_strategy"=>"array_plus"] | Extension developers | Content models in which to enable VisualEditor (mapped from content model name to a boolean flag). | ||
…UseChangeTagging | true | Sysadmins | Whether to put achange tag on every edit made with VisualEditor. | ||
…EnableWikitext | false | Sysadmins | Whether to enable thewikitext source mode inside VisualEditor. | ||
…EnableDiffPage | false | Sysadmins | Whether to enable thevisual diff function on the history special page. | ||
…EnableDiffPageBetaFeature | false | Sysadmins | Whether to allow users to enable thevisual diff function on the history special page as a beta feature. | ||
…EnableVisualSectionEditing | mobile | Sysadmins | Whether to allow users to enable the section editing. | ||
…UseSingleEditTab | false | Sysadmins | Whether to use only one edit tab, switching back and forth, or add a dedicated VisualEditor edit tab next to the existing one. | ||
…SingleEditTabSwitchTime | 20160101000000 | Sysadmins | From what timestamp to warn existing editors that the installation has switched from two edit tabs to one. In general you should ignore this. | ||
…TabPosition | 'before' | Sysadmins | If showing two edit tabs, where to put the VisualEditor edit tab in relation to the system (or WikiEditor) one:
| ||
…TabMessages | {"edit":null,"editsource":"visualeditor-ca-editsource","create":null,"createsource":"visualeditor-ca-createsource","editlocaldescriptionsource":"visualeditor-ca-editlocaldescriptionsource","createlocaldescriptionsource":"visualeditor-ca-createlocaldescriptionsource","editsection":null,"editsectionsource":"visualeditor-ca-editsource-section"} | Sysadmins | Configuration of what messages to use for the various kinds of edit tab users can see, if showing two edit tabs: 'edit' – i18n message key to use for the VisualEditor edit tab; if 'editsource' – i18n message key to use for the old edit tab; if 'create' – i18n message key to use for the VisualEditor create tab; if 'createsource' – i18n message key to use for the old create tab; if 'editlocaldescriptionsource' – i18n message key to use for the old edit tab on pages for files in foreign repos; if 'createlocaldescriptionsource' – i18n message key to use for the old create tab on pages for files in foreign repos; if 'editsection' – i18n message key to use for the VisualEditor section edit link; if 'editsectionsource' – i18n message key to use for the source section edit link; if | ||
…AutoAccountEnable | false | Sysadmins | Whether to enable VisualEditor for every new account. This allows you to keep the ' | ||
…DisableForAnons | false | Sysadmins | Whether to disable VisualEditor for non-logged-in users This allows you to enable the ' | ||
…TransitionDefault | false | Sysadmins | For wikis planning to use the 'visualeditor-betatempdisable' preference to auto-opt-out existing users whilst enabling by default for all existing users, whether to start recording explicit opt-outs against implicit ones. | ||
…ShowBetaWelcome | true | Sysadmins | Whether to show the "welcome to the beta" dialog the first time a user uses VisualEditor | ||
…NewAccountEnableProportion | false | Sysadmins running user analytics | Whether to enable VisualEditor for a proportion (Egyptian fraction) of all new accounts based on userID. | ||
…FeedbackTitle | false | Sysadmins | Whether to enable the MediaWiki feedback tool inside the help menu of VisualEditor. If enabled, the title of the page at which to point the MediaWiki feedback tool. | ||
…FeedbackAPIURL | false | Sysadmins | If set, the API of the remote wiki at which to point the MediaWiki feedback tool. | ||
…SkinToolbarScrollOffset | [] | Skin developers | An array of skin names mapped to pixel values to which to set the toolbar scroll offsets. | ||
…BrowserUnsupportedList | VisualEditor developers | List of browsers with which VisualEditor is incompatible. Seejquery.Client for specification. If the user's browser is matched, VisualEditor will refuse to load.Firefox – There is a wikilink corruption ( Safari – Older versions of Safari suffered from corruption issues from various old browser plugins. Opera – Below version 12, Opera was untested, and as its user base is almost non-existent anyway it's blocked. Internet Explorer – At or below version 9, there are various incompatibilities in layout and feature support. Versions 10 and 11 should work correctly. Not listed independently, because it's inherited from MediaWiki itself,Android at 3.x and below "support" CE but don't trigger keyboard input or have other issues, making it useless for users. | |||
…EnableTocWidget | false | VisualEditor developers | Whether to enable the (currently experimental) Table Of Contents widget | ||
…RebaserURL | false | VisualEditor developers | URL to use to access the experimental rebaser technology. If false, the technology isn't loaded. |
See alsoUpload dialog § Configuration (for wiki sysadmins) for information about configuring the drag-and-drop/copy&paste functionality for uploading media files through VisualEditor.
To enable the so-called "2017 wikitext editor", follow the instructions forWikitext mode in the§ Quick configuration guide.
It is also possible to enable wikitext syntax highlighting for this editor; to do this, you must install theCodeMirror extension.
Extension:TemplateData allows the addition of template information, making templates easier to insert with the VisualEditor
Citations can be improved by configuring thecitation tool, and also by setting upCitoid.
As of 2023, Visual Editor sets around 10 JavaScript hooks and 3 PHP hooks that are listed atVisualEditor/Hooks.
AllowEncodedSlashes NoDecode must be added in the VirtualHost section of the wiki (T268953)./rest.php/?$query_string block – see respectiveManual:Short_URL#GuidesAllowEncodedSlashes NoDecode must be added in the VirtualHost section of the wiki (T261921).wfLoadExtension( 'Parsoid', 'vendor/wikimedia/parsoid/extension.json' );.$wgVirtualRestConfig['modules']['parsoid'] (see:#Linking with Parsoid).mediawiki package, and if the filerest.php is not in your installation path, you are probably missing some new symbolic links (eventually evaluate the commandln -s /var/lib/mediawiki/* . from the installation path to install only the missing ones. In this case, you can ignore the errors about links you aready have)//wiki.example.org), you might be encountering bugT299175.$wgTmpDirectory (for example "/tmp") has not write permissions.<Directory"D:/Wiki/htdocs">...Allowfrom127.0.0.1SatisfyAny</Directory>
$wgVirtualRestConfig['modules']['parsoid']['url'] is not set correctly/usr/lib/parsoid/src/lib/config/ParsoidConfig.js so thatParsoidConfig.prototype.strictAcceptCheck = false;. The latter will be overwritten on any package upgrade, so it is up to the administrator to lock the package and keep on top of updates manually.api.php in Parsoid'slocalsettings.js config file. If you have set up following the recommendations, your API path would be "http://localhost/w/api.php". Add this API path to "localsettings.js" like "parsoidConfig.setMwApi({uri: 'http://localhost/w/api.php' });".| This extension is being used on one or moreWikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia'sCommonSettings.php andInitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki'sSpecial:Version page. |
| This extension is included in the following wiki farms/hosts and/or packages:This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
| VisualEditor is maintained byEditing team. Get help:
|