Extension talk:CodeMirror

Jump to navigation Jump to search

About this board

Thanks for your feedback about the Extension:CodeMirror used to provide wikitext syntax highlight to pages on MediaWiki-based projects.

Report a new bug in Phabricator

Error in extension distributor

2
Valerio Bozzolan (talkcontribs)
Valerio Bozzolan (talkcontribs)

Well, now it works. I don't know why.

Alzi24 (talkcontribs)
MediaWiki 	1.31.1
PHP 	7.2.10-0ubuntu0.18.04.1 (apache2handler)
MySQL 	5.7.24-0ubuntu0.18.04.1-log
https://www.perrypedia.proc.org

We are using CodeMirror for a few weeks now and rate it very useful. There is an odd phenomenon which I don't know whether it is intended:

  • Activate CodeMirror, place the caret (mouse cursor for text input) anywhere.
  • Move the mouse, press "Ctrl" and left-click. Now there are two carets.
  • This may be repeated several times.
  • Now when typing text, it'll be inserted multiple times at all of the caret locations!

It is a little bit cumbersome because (esp. if one has clumsy fingers like me) this happens often when insertig text via Copy&Paste; the "Ctrl+V" is executed and the oversensitive touchpad detects an additional "Ctrl+click".

Is it a bug or a feature?

I'm working with Firefox 62-something but it is also reproducible with Opera and Chrome, even if not logged in.

Reply to "Multiple carets, bug or feature?"

Red dot

6
Summary by 197.218.94.223

https://phabricator.wikimedia.org/T181677

https://stackoverflow.com/a/19269811

Alzi24 (talkcontribs)

MW 1.31.1, Code Mirror 4.0.0 (a435d54) 22:01, 26. Apr. 2018

Sometimes there is a red dot beneath a category link. What does it mean?

NKohli (WMF) (talkcontribs)

I don't think CodeMirror has any feature which produces a red dot under category links. Although a screenshot would help.

Alzi24 (talkcontribs)

Editor with CodeMirror off:

CodeMirror activated:

At the moment, this is the first and only where it happens.

NKohli (WMF) (talkcontribs)

@Alzi24 Thanks for the screenshots! I tried to reproduce this with the same categories on a random page but I didn't see the dot. Can you give me a link to the page you are editing with? I tried figuring it out from the screenshots but searches on dewiki turned up nothing for Aracyclin. :)

197.218.94.223 (talkcontribs)

This is a deliberate feature of codemirror. It highlights some invisible characters..

Alzi24 (talkcontribs)

@NKohli (WMF): Our wiki URL is https://www.perrypedia.proc.org Don't know what dewiki is, our article pages usually appear high-ranked in most search engines, as long as they are no trivial terms out of the real life.

@IP: I have no idea how it could happen that someone inserted invisible characters. Anyway, you've answered my question and our simple solution is: remove characters, save page.

Thanks to all!

Reply to "Red dot"

Using browser search with CodeMirror

8
Alzi24 (talkcontribs)

Nice feature, works good for us. There seems to be a minor bug when Code Mirror is active. The browser search (Ctrl+F) sometimes finds the search text within the editor, sometimes it doesn't. Maybe it depends on how far one has scrolled forward within the editor. With code mirror off, the search result is reliably correct regardless if one has scrolled or not.

(MW 1.27.4. Firefox 57.0)

DannyH (WMF) (talkcontribs)

Hmm, that's a bug that I believe we fixed a little while ago... Let's see if we can reproduce the problem.

I'm on Firefox 57.0 too, and I did a successful browser search on a random page (en:Geologic time scale, looking for the word Putman).

Can you show me an example or two where you have the problem? Wiki, page and search term would help a lot.

Alzi24 (talkcontribs)

Example for the problem is:

https://www.perrypedia.proc.org/mediawiki/index.php?title=Die_Dritte_Macht_(Zyklus)&action=edit

CodeMirror on & Ctrl+F & search for "al-khor", which is at the very bottom of the page => nothing found.

CodeMirror off => search successful

Edits are restricted to registrated users only, so you'll first have to create an account https://www.perrypedia.proc.org/wiki/Spezial:Benutzerkonto_anlegen

But maybe that is not necessary, maybe the bug has been fixed in a later version? We use MW 1.27.4 and what I get through the ExtensionDistributer is CodeMirror 3.4.0, wheras the current version is 4.something.

DannyH (WMF) (talkcontribs)

Yes, that must be it. Good, I was worried that the bug fix had been reverted somehow. :)

@NKohli (WMF) or @MaxSem (WMF), could you help this user update to a later version of CodeMirror?

NKohli (WMF) (talkcontribs)

Hi @Alzi24 you can either upgrade your MW to a higher version or you can choose to get the 'master' version of CodeMirror from ExtensionDistributor. We cannot guarantee that it won't break anything but you can revert back to 3.4.0 if it does. Hope this helps.

Pastakhov (talkcontribs)

there is a patch that breaks compatibility with older Extension:WikiEditor, I chosen one the 'master' version too and it worked fine for me, you may try to do the same.

Alzi24 (talkcontribs)

Not our day today.

I will rather not upgrade to a higher (but no-LTS) MW. So I tried the newer versions of CodeMirror to inject in our MW 1.27.4:

- the version for 1.29 is still 3.4.0 with the reported problem

- the version for 1.30 & master is 4.0.0 but will not run under MW 1.27.4. The editor icon for activating the feature is missing. The reason seems to be a dependency by MobileFrontend, which calls a function CodeMirrorHooks::getGlobalVariables() that no longer exists in 4.0.0.

In a nutshell, it's all way to expensive for the original minor problem. As far as I know the next LTS Mediawiki will appear mid of next year, so that's the best time for the next MW upgrade.

Thanks anyway!

Alzi24 (talkcontribs)

MW upgraded to 1.31, plus new version of the extension installed -> works fine!

Reply to "Using browser search with CodeMirror"

CodeMirror in collaboration with WikiEditor, MW 1.31

4
Summary by Alzi24

User's mistake

Alzi24 (talkcontribs)

Hello there! I have just upgraded our test wiki to Mediawiki 1.31.

In our previous MW version, the CodeMirror extension (3.4.something) broke the browser search Ctrl+F, which should have been solved in the newer extension (4.0.0)

Unfortunately now with MW 1.31 the extension does not work at all. Seems as if there are problems with the WikiEditor (0.5.1), if the CodeMirror extension is installed.

There should be an additional icon in the WikiEditor's toolbar to switch the code highlighting on or off, but there isn't. Worse: If I set the user preference for the extended toolbar, then in the WikiEditor the toolbar disappars at all. And worst: As soon as the CodeMirror extension is installed, I earn an additional malfunction within the user preferences; it refuses switching to another tab: the browser URL tells me e.g. Spezial:Einstellungen#mw-prefsection-rc but the preferance still sticks on the first tab.

Does anyone have any ideas what I am doing wrong here?

NKohli (WMF) (talkcontribs)
Alzi24 (talkcontribs)

I have to apologize, I've made a mistake yesterday. Don't know what I did wrong. Today I removed the extension and reinstalled it from the ExtensionDistributor (which I thought was the same procedure I performed yesterday). It is still version 4.0.0 but now everything works fine.

For your interest: the master version results in

 PHP Fatal error:  Uncaught ExtensionDependencyError: CodeMirror is not compatible with the current MediaWiki core (version 1.31.1), it requires: >= 1.32.0. 

which seems reasonable ;-)

Sorry for stealing your time!

NKohli (WMF) (talkcontribs)

Oops, sorry about that. :)

AEzell (WMF) (talkcontribs)

Recently, Marijn and Adrian, the developers and maintainers of CodeMirror posted an explanation of the big changes they have in-store for Version 6 of CodeMirror: https://codemirror.net/6/

I work with the Community Tech team which helped integrate CodeMirror with the wikitext editor. Given this new version, we want to do two things.

First, we want to voice our support for Marijn and Adrian in their efforts. CodeMirror and the syntax highlighting it provides via this extension are a valuable feature for MW users.

Second, I'd like to gather some feedback on the current extension's strengths and what it lacks. If we take on the work to integrate this new version, we want to be sure to keep things that users like now and possibly fix or add features that users want. Marijn and Adrian are building CodeMirror with their own feature set in mind. We cannot and would not try to dictate feature requests or bug fixes. In the interest of collaboration, we do want to collect as much user feedback as we can so we can all have a better library and extension.

Our hope is that the new version will enable much easier integration which will create fewer bugs with the extension. Your input here can go a long way to making that true. It's important to point out that this is a preliminary discussion as the timeline for a finished library and my team's ability to start working with it is currently unknown.

Reply to "Revamp of CodeMirror"

How to check if switched on and access its API

1
V111P (talkcontribs)

For some reason the page Extension:CodeMirror does not explain these simple questions. If the API is not accessible in MediaWiki this should obviously be documented on the extension's page.

P.S. thanks to a comment by User:Trustable in another thread I figured out that you can check if CodeMirror is switched on with: $('.mw-editbutton-codemirror-active').length > 0 and you can swith it on/off with: $('#mw-editbutton-codemirror').click()

Reply to "How to check if switched on and access its API"
George Ho (talkcontribs)

Some (if not most) of us know that the extension is not compatible at Internet Explorer and lesser-known browsers. The "Browser support" section should be updated to reflect that. What about other parts of the page?

Reply to "Page should be updated"
Delusion23 (talkcontribs)

en:User talk:GregU/dashes.js is a useful script on English Wikipedia for turning hyhens into dashes. It appears it is no longer works when I use "Wikitext syntax highlighting" beta.

NKohli (WMF) (talkcontribs)

@Delusion23 Thanks for letting us know. There are several similar user scripts which break with CodeMirror. It seems like the script author isn't active on wiki anymore, unfortunately. We'll try to take a look at it.

Perhelion (talkcontribs)

CodeMirror breaks any script wich need manipulating plain Wiki text. To need fix every script except of CodeMirror is an absolute no-go. Why need CodeMirror a new Textbox? Other older (sometimes better) Syntax-highlighter have not this problem (my favorite is de:User:Schnark/js/syntaxhighlight).

PS: There is a difference in the textbox access .

$( '#wpTextbox1' ).val() is different to $( '#wpTextbox1' )[0].value

Which is normally fully the same, but seems a use of hook or something.

Reply to "User talk:GregU/dashes.js"

Problem when copy/paste from external text editors

8
Summary by NKohli (WMF)

Resolved

Herr Klugbeisser (talkcontribs)

Hello, I consistently face a problem when I do the following:

  • I make big edits or write new articles in a text editor outside the web browser (mostly because I write when I am offline)
  • When I copy/paste the text into the edit window, then
    • no syntax is highlighted
    • after using the "preview" function, the original text is previsualized and the text in the edit window is reset (and thereby lost)

This is a new phenomenon that arrived together with syntax highlighting. It happens consistently in Win7 and Internet Explorer. I used to see a similar phenomenon in Linux and Firefox, but not consistently.

See below for your reference:

NKohli (WMF) (talkcontribs)

I don't see the syntax highlighting icon in the toolbar in your images. Which editor are you using?

As long as you are not using syntax highlighting, you should not be affected by it at all. The way you describe your problem, it does not seem like it is being caused by syntax highlighting.

Herr Klugbeisser (talkcontribs)

Hello, I also don't see any syntax highlighting icon, but syntax highlighting has been activated for me some weeks ago. At least syntax is highlighted when I open the source of an article.

I am not aware of having any choice of editor. I assume I use the default editor in the German wikipedia. I have noticed that syntax highlighting is "off" for my user in the English wikipedia, but "on" in the German. I can't see any difference in the preferences. Emptying *.js and *.css subpages has not helped, switching between skins also not.

Please understand that I'm here for writing good articles and not for messing around with this kind of issues. --Herr Klugbeisser (talk) 09:03, 30 July 2018 (UTC)

NKohli (WMF) (talkcontribs)

@Herr Klugbeisser the content in your screenshots above does not appear to have syntax highlighting. What makes you think syntax highlighting is causing these issues for you?

Herr Klugbeisser (talkcontribs)

Hello,

I let you see what I see:

When I open any article in the German Wikipedia under Win7/IE, I see the above picture.

Syntax highlighting is obviously active. There is no icon, I don't know why. I have deleted my *css and *js yesterday, maybe this is the reason; it is opaque for the average user. Anyway, the icons were completely useless to me so I'm happy they are gone.

Now, assume I scroll down in the text and I want to edit the line where the cursor is.

If I click on the word "Eisenbahn" in the textbox, then

  • the text displayed "jumps" to the beginning
  • the scroll bar of the text box remains where the cursor is
  • the user has to look for the cursor

Marking a text is practically impossible because at clicking, the focus is lost and the user does not see the text he wanted to mark any more.

This is extremely annoying (I read several complaints in discussions of the German wikipedia). I have not experienced this before syntax highlighting was introduced. If you are sure that syntax highlighting is not the cause of this issue, please channel this bug to the right place inside Wikimedia.

Given this bug, the only way to work efficiently for me is to copy the whole text into an external editor, carry out my edits, then copy the complete text back to the editing window.

However, when I copy such a text back from any text editor (I have tried several), syntax highlighting fails to highlight (no loss), but also saving or previewing fails to show the text pasted from the external editor but instead visualises the original text.

This means that at the moment, I can't contribute under Windows.

I don't know how many people experience this issue.

The implementation of syntax highlighting was very poorly communicated, it took me some time to find out the probable cause of these issues even though I consider myself a regular contributor.

For some reason, in English Wikipedia syntax highlighting seems to be "off" for me even though my user settings are identical.


Under Linux (Mint 19/Firefox), syntax highlighting is also obviously active. No icon, however.

Editing works fine.

Pasting text from a text editor (kate in my case) usually works, but I have observed the issue described above occasionally.

NKohli (WMF) (talkcontribs)

@Herr Klugbeisser Do you have the toolbar disabled? I would suggest you enable the toolbar and then in the toolbar click the icon which will turn off syntax highlighting. After that you can disable the toolbar again and you will have no problems with syntax highlighting any more.

Herr Klugbeisser (talkcontribs)

Hello NKohli, it seems that I have found the reason: the CodeMirror conflicts with other "Helpers", in my case this one:

https://de.wikipedia.org/wiki/Benutzer_Diskussion:TMg/autoFormatter#Nonfunctional_in_CodeMirror_and_Visual_Editor_wikitext_mode

After removing this helper from my subpages, and activating/deactivating the standard toolbar, it seems that everything works.

I mistook the toolbar from the above "helper" for the standard mediawiki toolbar, hence the confusion.

Sorry for this. This point can be closed.

NKohli (WMF) (talkcontribs)

I am glad it got resolved for you.