# Extension talk:VisualEditor

Please note that the Wikimedia Foundation does not provide support for installing VisualEditor on third-party wikis. However, if you have a question we may try to help.

## Can't search for pictures in Media Tab

1

Hello,

i noticed a problem with my companys Mediawiki.

In the Mediatab from VE no pictures are found with any input, even exact filenames.

We have Mediawiki-1.30.0 and VisualEditor-REL1_30 installed.

Uploading pictures work fine and they are also displayed.

They also exist as a File and are in the images folder.

If i enable $wgUseInstantCommons, pictures are found. This seems strange. Does anyone know what the problem could be? Thanks Reply to "Can't search for pictures in Media Tab" ## Visual Editor + Flagged Rev issue on MW 1.31 10 Since I have upgraded the MW from 1.27 to 1.31, clicking the "Edit" now shows "Warning: You are editing an out-of-date revision of this page. If you save it, any changes made since this revision will be lost." if you try to edit a page with the accepted revision (from Flagged Rev) Back in 1.27, clicking the "Edit" button always displayed the latest (unapproved) version... How can we force Visual Editor to show the latest version? As far as I can tell, the VE dev team introduced an (not very well documented ) autosave feature. I was experiencing the same issue as you so I disabled it (sessionStore=false at line 354 in \modules\ve-mw\init\targets\ve.init.mw.DesktopArticleTarget.init.js) and it seems to have fixed it. Thank you for the response - I have disabled the session store but the problem still persists. Do you remember any other changes that you've made along with the line 354 change? It worked for me. Did you hard clear your browser cache? Tried in both IE and Chrome with cache cleared - no go. I will try to download fresh copy of the extension and try again Unfortunately changing the sessionstore didn't help my issue. Note that my "Edit" button has the oldid paramter that is forcing the visual editor to display the "approved" version and not the "latest version" URL Example - *wiki address*/index.php?title=Test&oldid=52301&veaction=edit Hmmm, it does not sound like the problem I was experiencing. You would have to look at the code to check why the oldid is tacked to the vedit action in the VE code... No, I do not use this extension. I would try disabling it to see if you still run into the issue. I've fixed the problem by looking at the MW 1.32 codes for both Visual Editor and Flagged Rev. For others who are encountering this problem - please see below 1. Download Visual Editor and Flagged Rev extension for MW 1.32 2. Copy the following files to your MW 1.31 environment 1. FlaggedRevs\frontend\FlaggablePageView.php 2. VisualEditor\modules\ve-mw\int\targets\ve.init.mw.DesktopArticleTarget.init.js Explanation • FlaggedRevision added "wgFlaggedRevsEditLatestRevision" config variable to check if the page you are looking at the is stable or latest version • Please see line 1383 and 1384 in the FlaggablePageView.php from MW 1.32 • Using the newly added "wgFlaggedRevsEditLatestRevision" variable, Visual Editor can now determine if you are looking at the stable or the latest version • Please see the line 491 in the ve.init.mw.DesktopArticleTarget.init.js from MW 1.32 I didn't read the entire script and have cause problem. If I find it, I will come back here to mention it. Also, I will create a simple DL link that fixes both revision and media link issue later today when I get back home Reply to "Visual Editor + Flagged Rev issue on MW 1.31" ## Update Parsoid/MediaWiki compatibility table 4 Because • I am particularly interested in the fix for the direct file links (https://phabricator.wikimedia.org/T151277); • I noticed WikiPedia does not exhibit this issue and it runs MW 1.33 and VisualEditor 0.1.1; • there are no corresponding entries in the Parsoid/MediaWiki compatibility table, Would it be possible to update the table to include these versions? Subsidiary question: is it possible to run newer versions of VE and Parsoid with an older version of MW? https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/325341 was merged in May 2017 and released in Parsoid v0.8.0. Note that VisualEditor is not versioned independently of MediaWiki. "0.1.1" is a prototype artefact, not a real version number, and has been this way for most of the decade. Finally, in general, no, running old versions of MediaWiki is impossible with new Parsoid and VisualEditor, as we have to add new core functionality for them to work. Hello, Thank you for your help. Note that, with respect to this thread and https://www.mediawiki.org/wiki/Topic:Uvk268dxeel41txe, the reason why I am using MW 1.31 is because it is the Long Term Support version, hence my question above. Since 1.31 is supposed to be maintained up to June 2021, is there any chance/possibility the fix can be backported? No. "LTS" refers to security updates for the core of MediaWiki and bundled extensions, not other extensions, sorry. Note that any security issues with VisualEditor would not be back-ported (though, in the eight years to date, the project has not had to release any). Reply to "Update Parsoid/MediaWiki compatibility table" ## Visual Editor converting [[Media:]] tags to Protocol-relative external link 4 Anyone having the issue where the Visual Editor is converting Media tags ([[Media:file.pdf|example]] to protocol-relative external link ([\\sitename\path\file.pdf example])? Thank you for the response - i have manually updated the modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js file using the https://gerrit.wikimedia.org/r/454860 It looks like Media link is back but would like your feedback before implementing the change in the live wiki Reply to "Visual Editor converting [[Media:]] tags to Protocol-relative external link" ## MsCatSelect like category management 1 Hi, MsCatSelect extension provides an easy and intuitive way of managing categories in MediaWiki. On our wiki, we recently switched to Visual editor due to it's better features but now we lost the ability to use MsCatSelect extension to manage categories. We miss the feature of drop down lists and that It can automatically detect/create new subcategories. I've tried to hack it around but with no lock, I could display the extension on the edit page but I have no clue how I can also use it for saving the new category lists/settings. I'd like to ask whether somebody has successfully connected MsCatSelect with VisualEditor or if there are any plans on implementing such a feature into VisualEditor. Thank you! Reply to "MsCatSelect like category management" ## mediawiki 1.32.1 apierror-visualeditor-docserver-http-error: (curl error: 6) 1 I have been browsing all reaches of the internet and just cannot seem to find anyone else with this same error code. (of if i do its not entirely related, such as they can create but not edit, etc). This is a clean installation and i have spend the better part of the last couple of days troubleshooting this before posing here. [environment] CentOS 7 64x Apache 2.4.6 PHP 7.0.33 MySQL 5.7.25 MediaWiki 1.32.1 Visual Editor REL1_31-6854 (VE 1.32 was throwing an exception for incompatibility and demanding my to update mw to v1.33...) I referred to this resource to preform the VE and Parsoid install. https://www.howtoforge.com/tutorial/how-to-install-visualeditor-for-mediawiki-on-centos-7/ So here is where I'm at. MediaWiki is currently functioning as intended, as well is the parsoid instance which loads at mydomain:8000. - When i try to create a wiki page with the visual editor, it will open and allow me to use the editor but when i try and save i get error "Something went wrong - (curl error: 6) Couldn't resolve host name." - When i attempt to edit any page with the virtual editor i get error "Error loading data from server: apierror-visualeditor-docserver-http-error: (curl error: 6)" The actual call is "http://wiki.domain.local/api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en" Which is correct. Access logs are recorded but nothing is reported in the httpd error log. Doing some trouble shooting, i ensured every file is chown/chgrp to apache, all /www -R files are set to 644 and directories are 755. I have disabled SElinux, ensured all config paths are correct, etc. I'm truly stumped... Parsoid: Config.yaml https://pastebin.com/JVnv7iGC Parsoid: localsettings.js https://pastebin.com/EuHjZV40 mediawiki: LocalSettings.php https://pastebin.com/EStrUNmn EDIT: I'll leave this in the event anyone else stumbles across this. Curl error 6 was caused in my case by resolv.conf getting overwritten on startup. Had to disable dhcp script as I'm statically configured anyway. Sometimes its not always a complicated solution to a cryptic problem. ## Mediawiki 1.32 2 We just upgraded to mediawiki 1.32. We have visual editor working fine with mediawiki 1.31, but with 1.32 the visual editor fails to even start loading and has this warning/error in the js console in the browser: > VisualEditor failed to load: Error: One or more dependencies failed to load Has anyone else experienced similar? More details here: https://github.com/AgileVentures/SocialPrescribingWiki/issues/76 Bump, pretty frustrating... Reply to "Mediawiki 1.32" ## "Unknown error, HTTP status 500" 3 When I attempt to save a page using VisualEditor, the normal "Save your changes" box comes up. When I click on Save page in the upper right-hand corner of that box, the box receives a modal overlay with the message "Unknown error, HTTP status 500". Here's my set up: Ubuntu 16.04, Apache 2.4.18, PHP 7.0.28, MySQL 5.7.21, MediaWiki 1.30.0, VisualEditor 0.1.0, Node.js 8.10.0, Parsoid 0.9.0. My wiki is using Let's Encrypt. The first thing I want to do is find out more about this 500 error. I cannot find it in the following log files: • The error_log for the virtual host (/home/wiki/logs/error_log). • The error_log for Apache as a whole (/var/log/apache/error.log). • The log for the Parsoid service (/var/log/parsoid/parsoid.log). Where else may I look? I'm not savvy about Node.js or applications built on it, and I couldn't find any places by googling "parsoid error log location". Solution: Turns out the php-curl extension wasn't installed. Installing this extension fixed this issue. How exactly did you solve this issue? I have the same problem, and i got cURL enabled from my provider, but the issue still exist. Reply to ""Unknown error, HTTP status 500"" ## Enable VisualEditor for 'create' page 32 Any suggestions for turning on the visual editor for as the default for creating a page? It still defaults to the old editor. Still experimenting. Great work everyone. If you have VisualEditor switched on, you should get "Create" and "Create source". The first takes you into VisualEditor, the second to the wikitext editor. Does this not show up for you? Almost, the visual editor is available as an option, and works when I click on the tab. However it defaults to the edit source. Here's my localsettings: require_once("$IP/extensions/VisualEditor/VisualEditor.php");

## Visual Editor Settings:

// Create VisualEditor namespace
define( 'NS_VISUALEDITOR', 2500 );
define( 'NS_VISUALEDITOR_TALK', 2501 );
$wgExtraNamespaces[NS_VISUALEDITOR] = 'VisualEditor';$wgExtraNamespaces[NS_VISUALEDITOR_TALK] = 'VisualEditor_talk';

// Allow using VisualEditor in the main namespace only (default)
$wgVisualEditorNamespaces ['*']; //$wgVisualEditorNamespaces = array( NS_MAIN, NS_TALK, NS_USER, NS_USER_TALK );

// Restrict VisualEditor to the VisualEditor namespace
//$wgVisualEditorNamespaces = array(); //$wgVisualEditorNamespaces[] = NS_VISUALEDITOR;

// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1; // Don't allow users to disable it$wgHiddenPrefs[] = 'visualeditor-enable';


I have the same request. Creating pages through a link or through the search box always loads the markup editor, and you have to change to VE manually with the "create" tab. This behaviour is very confusing for my users. By the way, preloading a template also doesn't work with VE.

Hello, I also work on this issue. I developed a special page extension for creating an article. The user has to type the name of article, then after a search (checking if already exists) user select a template and click create. Behind "create" there's this link 'http://yourmedia.wiki/index.php?title=[ARTICLE_NAME]&veaction=edit&redlink=1'. So, the visual editor will start and the user can create content.

But the preloading of templates also doesn't work. With the standard eitor this was easy by using NewArticleTemplate extension. But the used hook 'EditPage::showEditForm:initial' doesn't work with VE. Can anyone help? Otherwise I implement an work-around (some 'Javascript magic').

If you have a workaround, that would be great. I have the same issue, and it would be enough if an extension just creates and saves a new page by copying the template, and the user then can click on "edit" to actually modify it. This would solve both problems (that VE isn't default, and it doesn't handle templates). Is it possible to copy a page using URL parameters?

I implement an extension for this issue. Actually, it's based on MediaWiki WriteAPI which is not a good solution because it makes it easy for automatic editing by bots. But it works. The user chooses a name and a template from a list and click create. In background AJAX is used to get MediaWiki text from choosen template and then creates the page by using the WriteAPI (where you give template text as a parameter). Finaly, the user is automatically forwarded to the new page with opened visual editor.

Is this extension available somewhere? Sounds useful and I'd like to test it.

I would also like to test this extension...

I have implemented the following crude hack into the top of my index.php:

if($_GET['redlink']==1 &&$_GET['action']=='edit') {
header('Location: index.php?title='.$_GET['title'].'&veaction=edit&redlink=1'); die(); }  Hope this helps someone. Thanks for your workaround. It works well! Thanks for that, it's a great workaround! Hi - is this suppose to be placed in the index.php of the wiki folder? I did that and got all kinds of errors. Nevermind I figured out how to do it. You can't simply use that code, you have to modify it to first check if the page even has those tags in the url. this works if(isset($_GET["redlink"]) && isset($_GET["action"])){$clicked_edit_link = ($_GET["redlink"]);$action_doing_now = ($_GET["action"]); if($clicked_edit_link==1 && $action_doing_now=='edit') { header('Location: index.php?title='.$_GET['title'].'&veaction=edit&redlink=1'); die(); }}

All you need is to modify (noarticletext) message at Special:Allmessages - just replace action=edit by veaction=edit

Thanks! That works great for creating pages based on what you type in the URL (ie: www.example.com/wiki/newpage123). But it does not work if you type "newpage123" in the search box. If you want to be able to create pages from the search box using Visual Editor, you would also have to edit the special message MediaWiki:Searchmenu-new

Here is what I came up with for that:

<strong>[{{fullurl:$1|veaction=edit}} Create the page "$1"] on this wiki!</strong>

@Vedmaka & @Potrod's suggestions worked well for me. I recommend this method.

for me too!!! S2

@Vedmaka@Potrod any idea how to also make VisualEditor the default when clicking on a red link to create a new article?

There was an idea above that seemed to work for some people.

@Vedmaka's tip and the code above worked for me and seems to cover all bases (page creation via a redlink, search or URL). The code above works fine when placed in the LocalSettings.php (instead of index) but you need to check for the existence of all $_GET parameters with isset($_GET['var']). Here is the final result:

# A hack that redirects users to the visual editor when clicking a redlink rather that to the wikicode editor.
if(isset($_GET['redlink']) && isset($_GET['action']) && isset($_GET['title']) &&$_GET['redlink'] == 1 && $_GET['action']=='edit') { header('Location: index.php?title='.$_GET['title'].'&veaction=edit&redlink=1');
die();
}


Thanks Tinss. Your solution solved my problem too.

Kevin

Note that this is now supported in VisualEditor-MediaWiki master (as will come out for compatibility with MW 1.27.0).

How is it supported?

@Ianmelchior Maybe a little late to the party. I am using Mediawiki 1.27.1 stable and to set visual editor as default for redlink I write a hook on LinkBegin. Hope it helps someone.

public static function onLinkBegin( $dummy,$target, &$html, &$customAttribs,

&$query, &$options, &$ret ) { if ( in_array( 'broken',$options, true ) && empty( $query['action'] ) &&$target->getNamespace() !== NS_SPECIAL ) {

$ret = Html::rawElement ('a', ['href' =>$target->getFullURL('veaction=edit&redlink=1'), 'class' => 'new'], $target->getPrefixedDBKey()); return false; } return true; } Great idea @Baongoc124! But your code as is does not quite work as it needs to be hooked to the event ($wgHooks['LinkBegin'][] = 'onLinkBegin';) and would not display the correct link text. Here is an improved and simplified version:

# A hack that redirects users to the visual editor when clicking a redlink rather that to the wikicode editor.
function onLinkBegin( $dummy,$target, &$html, &$customAttribs, &$query, &$options, &$ret ) { if ( in_array( 'broken',$options, true ) && empty( $query['action'] ) &&$target->getNamespace() !== NS_SPECIAL )
{
$query['veaction'] = 'edit';$query['action'] = 'view'; // Important! Otherwise MediaWiki will override veaction.
$query['redlink'] = '1'; } return true; }$wgHooks['LinkBegin'][] = 'onLinkBegin'; // WARNING! Will be superseded by HtmlPageLinkRendererBegin in MediaWiki 1.28.


Note: to cover all bases, you still need to modify the noarticletext message as @Vedmaka suggested.

I have done this job with a little java script placed in page MediaWiki:Common.js

if ( wgArticleId === 0 && wgAction === 'edit' ) { window.location = 'index.php?title=' + wgPageName + '&veaction=edit&redlink=1'; }

It works for me. Hope it helps!

Based on @Tinss answer, here is a hook using HtmlPageLinkRendererBegin that can be added to LocalSettings.php:

# Default to VisualEditor for red links
class MyHooks {
public static function onHtmlPageLinkRendererBegin($linkRenderer,$target, &$text, &$extraAttribs, &$query, &$ret) {
$title = Title::newFromLinkTarget($target);
$isKnown =$title->isKnown();

if (!$isKnown) {$query['veaction'] = 'edit';
$query['action'] = 'view'; // prevent MediaWiki from overriding veaction } } }$wgHooks['HtmlPageLinkRendererBegin'][] = 'MyHooks::onHtmlPageLinkRendererBegin';


Excellent work guys! This thread solved all my redlink problems XD Here is a shortened version of the snippet for those like me who don't like any fat in their code.

$wgHooks['HtmlPageLinkRendererBegin'][] = function ($linkRenderer, $target, &$text, &$extraAttribs, &$query, &$ret ) {$title = Title::newFromLinkTarget( $target ); if ( !$title->isKnown() ) {
$query['veaction'] = 'edit';$query['action'] = 'view'; // Prevent MediaWiki from overriding veaction
}
};


Thanks to @Beatlicker from the post Enable All Name space see this --> Topic:Spky5rat787g67fj

Add blow lines to your LocalSettings.php page

$wgVisualEditorNamespaces = array_merge($wgContentNamespaces, array( NS_USER, NS_CATEGORY ) );

\$wgVisualEditorAvailableNamespaces = [

NS_MAIN => true,

NS_USER => true,

NS_HELP => true,

"_merge_strategy" => "array_plus"

];

If you need other standard namespace see Help:Namespaces to added standard that enable VisualEditor all the pages. Hope this Helps.

This did not work, is there more to the instructions?@Aravind2905

What are you trying to achieve? If it's enabling the Visual Editor for the create page, put Sophivorus' code at the bottom of LocalSettings.php.

Reply to "Enable VisualEditor for 'create' page"

## Not logged in?

1

I have installed VisualEditor and it seems to be properly linked to parsoid service. However, when I try to edit a page I get a message warning that I am not loggedin to the wiki, even if I am. I cannot edit the text (I can add new text but I see the paragraphs and photos in green boxes non editable) and when I finally try to save changes I am asked to confirm my e-mail. Everything so strange. How can I fix that?

Reply to "Not logged in?"
Return to "VisualEditor" page.