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

Maksim E. Otstavnov (talkcontribs)
wfLoadExtension( 'CodeMirror' );
$wgDefaultUserOptions['usecodemirror'] = 1;
# Enable bracket matching in CodeMirror
$wgCodeMirrorEnableBracketMatching = true;
# Enable accessible colors in CodeMirror
$wgCodeMirrorAccessibilityColors = true;
#Enable line numbering in CodeMirror
#defaults to the template namespace `[ NS_TEMPLATE ]`
#`null` enables it for all namespace
#[] for disabling everywhere
$wgCodeMirrorLineNumberingNamespaces = [];

seems to have no effect on editing templates, I still see the line numbers. (Unfortunately, this forum prevents me from attaching screenshots.)

MediaWiki 1.36.1, PHP 7.4.15 (cgi-fcgi), MySQL 5.7.28-log, ICU 60.2, Apache 2.4.29-1ubuntu4.16 Extensions: Echo – (1a15ef8), VisualEditor 0.1.2, MyVariables 3.5.1, NoTitle 0.4.0 (780dbb6), DynamicSidebar 1.1 (b2f3feb), Lockdown – (2409546), MassMessage0.4.0 (c9b6e87), CodeMirror4.0.0 (508b9f6) 15:59, 22 July 2021.

Thiemo Kreuz (WMDE) (talkcontribs)

Using [] is correct and should do the job. Maybe it's a caching thing and you need to shift+reload the page?

Maksim E. Otstavnov (talkcontribs)

I see no effect even for newly created pages.

I believe something went wrong with my local settings. Just encountered the same problem with $wgNamespacesWithSubpages.

Christoph Jauera (WMDE) (talkcontribs)

Hej @Maksim E. Otstavnov, thanks for the report.

We just took another look at this and it seems that there is a bug that disallows disabling the default namespace. The bug is tracked in task T290226 now and will be taken care of. :-)

Adamw (talkcontribs)

The bug should be fixed, if you check out the newest version of CodeMirror it will disable line numbering given the OP's config.

Shall I download the newest version from Git? --previous unsigned comment by Maksim E. Otstavnov

Adamw (talkcontribs)

Yes, take the newest code from Git. Let us know how it goes!

Maksim E. Otstavnov (talkcontribs)
Reply to "Disabling line numbering?"

Suggestion: Bold some codes in 2017 wiki editor like 2010 wiki editor

4
50829! (talkcontribs)

I advise to bold some codes in 2017 wiki editor. Bolds can make the wiki syntax clear. With bolds, we can edit pages more easily.

Thiemo Kreuz (WMDE) (talkcontribs)

What is the most relevant syntax that should be bolded, in your opinion?

50829! (talkcontribs)
Christoph Jauera (WMDE) (talkcontribs)

Hi @50829!

The text in the 2017 editor is not highlighted the same way as in the 2010 editor due to some technical compatibility issues with the library used for the highlighting and the VisualEditor. There seems to be no easy solution to fix this but the issue is tracked in task T184467

Reply to "Suggestion: Bold some codes in 2017 wiki editor like 2010 wiki editor"

Disabling CodeMirror by a user

4
Maksim E. Otstavnov (talkcontribs)
 wfLoadExtension( 'CodeMirror' );
 # Enables use of CodeMirror by default but still allow users to disable it
 $wgDefaultUserOptions['usecodemirror'] = 1;
 # Enable bracket matching in CodeMirror
 $wgCodeMirrorEnableBracketMatching = true;
 # Enable accessible colors in CodeMirror
 $wgCodeMirrorAccessibilityColors = true;
 #Enable line numbering in CodeMirror
 #defaults to the template namespace `[ NS_TEMPLATE ]`
 #`null` enables it for all namespace
 #[] for disabling everywhere
 $wgCodeMirrorLineNumberingNamespaces = [];

How exactly a user can disable CodeMirror?

MediaWiki 1.36.1, PHP 7.4.15 (cgi-fcgi), MySQL 5.7.28-log, ICU 60.2, Apache 2.4.29-1ubuntu4.16 Extensions: Echo – (1a15ef8), VisualEditor 0.1.2, MyVariables 3.5.1, NoTitle 0.4.0 (780dbb6), DynamicSidebar 1.1 (b2f3feb), Lockdown – (2409546), MassMessage0.4.0 (c9b6e87), CodeMirror4.0.0 (508b9f6) 15:59, 22 July 2021.

Maksim E. Otstavnov (talkcontribs)

...Just toggling syntax highlight button when editing a particular page?

Thiemo Kreuz (WMDE) (talkcontribs)

Do you ask the question for Wikipedia or another Wikimedia wiki, or for a wiki you own and maintain? The short answer is yes. Users don't have to use syntax highlighting. Even if it's enabled by default, every user can disable it (both in VisualEditor's 2017 wikitext editor as well as in the older 2010 wikitext editor). It will stay disabled for this user then.

Maksim E. Otstavnov (talkcontribs)

I meant my instance of MediaWiki, and I was in search for the option at Preferences. I suggest mentioning the toggle in the extension page Extension:CodeMirror.

Thank you!

Reply to "Disabling CodeMirror by a user"
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?

Summary last edited by Thiemo Kreuz (WMDE) 06:36, 16 August 2021 1 month ago

Some invisible characters like non-breaking spaces or soft hyphens are shown as red dots. See e.g. phab:T181677 or https://stackoverflow.com/a/19269811.

AnonymusGdpr (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.

AnonymusGdpr (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..

AnonymusGdpr (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!

Highlighting does not work with Visual Editor

6
87.122.24.188 (talkcontribs)

Hi everybody.


According to special-page I have successfully installed extensions in my mediawiki 1.36.1:

CodeMirror 4.0.0 (ed712c3) 03:16, 25. Mai 2021

VisualEditor 0.1.2 (64b7bb3) 04:22, 25. Mai 2021


But I can't enable syntax highlighting in options, it is shown as menu item, but grayed out


Here's my LocalSettings.php:

wfLoadExtension( 'CodeMirror' ); //siehe einstellungen weiter unten

wfLoadExtension( 'VisualEditor' ); //siehe einstellungen weiter unten

#einstellungen codemirror

$wgDefaultUserOptions['usecodemirror'] = 1;

# Enable bracket matching in CodeMirror

$wgCodeMirrorEnableBracketMatching = true;

#Enable accessible colors in CodeMirror

$wgCodeMirrorAccessibilityColors = true;

# Enable line numbering in CodeMirror

# defaults to the template namespace `[ NS_TEMPLATE ]`

# `null` enables it for all namespace

# [] for disabling everywhere

$wgCodeMirrorLineNumberingNamespaces = null;

#einstellungen visualeditor

$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

$wgVisualEditorEnableWikitextBetaFeature = true;


If I change to source-editing I only see black text and have no icon-bar

I tested with Firefox 89 and Vivaldi 4.0


Thanks allready for upcoming suggestions

Thiemo Kreuz (WMDE) (talkcontribs)

With $wgVisualEditorEnableWikitextBetaFeature = true; the "New wikitext mode" is a Beta feature. You need to enable this first in your user's Beta feature settings. Alternatively you can try to set $wgVisualEditorEnableWikitext = true;.

87.122.24.188 (talkcontribs)

I already read about the Beta features. But how do I enable them in my selfhosted mediawiki?

Do i need to download and install Extension:BetaFeatures ?


Setting $wgVisualEditorEnableWikitext = true; does not work for me :(

uncommenting $wgVisualEditorEnableWikitextBetaFeature = true; also does not work.

Thiemo Kreuz (WMDE) (talkcontribs)
87.122.24.188 (talkcontribs)

ok i have installed the extension.

How to enable the highlighting as default for all users?

Although the setting $wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

was set, I had to enable it in the new beta menu.

Thiemo Kreuz (WMDE) (talkcontribs)

The point of Beta features is to let the users opt-in if they want. If you want it the other way around you need to use $wgVisualEditorEnableWikitext = true;. According to this code the syntax highlighting feature should be enabled by default then.

Reply to "Highlighting does not work with Visual Editor"
Z929669 (talkcontribs)

I'm guessing that there is no way to show line numbers with this. That would be a great feature to add. Love it otherwise.

Johanna Strodt (WMDE) (talkcontribs)

@Z929669 Hello! In the Technical Wishes project at WMDE, we're planning to add line numbers to the syntax highlighting feature soon, probably in April 2021. More info: WMDE_Technical_Wishes/Line_Numbering

Best,

Johanna

Z929669 (talkcontribs)

Excellent. Thank you

Johanna Strodt (WMDE) (talkcontribs)

@Z929669 Hi! Line numbers are now available for the template namespace on all wikis using CodeMirror. More namespaces will follow soon. Wishing you a good weekend,

Johanna

Reply to "Line Numbers?"

Screenshot shows Codemirror without WikiEditor

4
Gunnar.offel (talkcontribs)

At the third screenshot it shows that the extension works with Wikieditor not active. Work this actually? Could you name me which Editor is used?

Thanks --Gunnar.offel (talk) 11:21, 1 November 2019 (UTC)

Jdforrester (WMF) (talkcontribs)

This was the old 2006 editor which was removed from MediaWiki a few years ago.

Jdforrester (WMF) (talkcontribs)

I've replaced the first image with an up-to-date version, but I don't know how to trigger the popup. @NKohli (WMF), do you remember how?

NKohli (WMF) (talkcontribs)

@Jdforrester (WMF) We did away with the popup when we took the feature out of beta because it'd have triggered a popup for every user. Thanks for updating the image.

Error in extension distributor

2
Valerio Bozzolan (talkcontribs)
Valerio Bozzolan (talkcontribs)

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

Multiple carets, bug or feature?

1
AnonymusGdpr (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?"