Page MenuHomePhabricator

Replacing CodeEditor with CodeMirror by MW 1.46
Closed, ResolvedPublic

Description

Background

This is the task to formally propose replacing CodeEditor with MediaWiki-extensions-CodeMirror on Wikimedia wikis (T373711 was getting too noisy). So far for users of the "Improved Syntax Highlighting" beta feature – which forces use of CodeMirror over CodeEditor – reception has largely been positive. We have a goal of shipping CM6 by MW 1.46 in May–June 2026, and it would make configuration and maintenance easier if we went forward with replacing CodeEditor at the same time.

Note however this initially will only effect action=edit pages, i.e. when editing JS/CSS/JSON/Vue and Lua. See below for the outstanding integrations that still need addressing.

Why?

Pros

  • User preferences are consistent across all editors (for CodeEditor that is/was T261118)
  • User experience is more consistent across all editors
  • JavaScript integrations from extensions, gadgets, etc. work the same for all editors (even the 2017 editor, to a degree)
  • Maintenance is simpler as everything is under one roof
  • Users can opt to have syntax highlighting without WikiEditor (i.e. the toolbar), if they so desire
  • Better autocompletion
  • Better linting tools (T373711#10350551), including linting against unsupported JS/CSS (T394965)
  • Dark mode support
  • Fully localized

Cons

  • Complete feature parity is unlikely, but we should be able to port over whatever users consider the most important features
  • Fixes something that arguably isn't broken (apart from perhaps the outdated linters)
  • If something in CodeMirror breaks, it may affect editing in all content models (counterpoint to the "pro" above of being able to fix everything at once)
Other integrations

We plan to tackle these as well, so that eventually CodeEditor is not used at all and can be removed from WMF wikis. Until then, these can live happily as-is, and are not blockers for replacing CodeEditor for editing pages (action=edit) directly on the wiki.

Blockers

Anything deemed a potential blocker should be a subtask of this task. Note that some things like T413457, T419331 and T412883 are on our radar but not considered blockers for the CodeEditor-to-CodeMirror switchover.

Details

Due Date
Apr 15 2026, 4:00 AM
Related Changes in Gerrit:
SubjectAuthorRepoBranchLines +/-
MusikAnimalmediawiki/extensions/TemplateStyleswmf/1.46.0-wmf.24+1 -6
MusikAnimalmediawiki/extensions/CodeEditorwmf/1.46.0-wmf.24+4 -55
MusikAnimalmediawiki/extensions/JsonConfigwmf/1.46.0-wmf.24+1 -6
MusikAnimalmediawiki/extensions/Scribuntowmf/1.46.0-wmf.24+1 -6
MusikAnimalmediawiki/extensions/Gadgetswmf/1.46.0-wmf.24+1 -8
MusikAnimalmediawiki/extensions/UploadWizardwmf/1.46.0-wmf.24+1 -6
MusikAnimaloperations/mediawiki-configmaster+29 -71
MusikAnimalmediawiki/extensions/CodeEditormaster+4 -55
MusikAnimalmediawiki/extensions/UploadWizardmaster+1 -6
MusikAnimalmediawiki/extensions/TemplateStylesmaster+1 -6
MusikAnimalmediawiki/extensions/Gadgetsmaster+1 -8
MusikAnimalmediawiki/extensions/Scribuntomaster+1 -6
MusikAnimalmediawiki/extensions/JsonConfigmaster+1 -6
Show related patches Customize query in gerrit

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

@MusikAnimal: The last production alpha branch of 1.46 was cut last night, I'm afraid. Should we re-target this to 1.47?

@MusikAnimal: The last production alpha branch of 1.46 was cut last night, I'm afraid. Should we re-target this to 1.47?

https://lists.wikimedia.org/hyperkitty/list/wikitech-l@lists.wikimedia.org/thread/MST6INZTOHFO5WYPQYBD3X43GOHP6KZG/ must have been sent a week too late then, I guess?

The only thing that needs to be backported are config changes, so I say we do it.

It even says:

If you are working on a new feature that you wish to land for the release, you now have a few days to finish your work and land it in the development branch

So it seems it's not too late?

@MusikAnimal: The last production alpha branch of 1.46 was cut last night, I'm afraid. Should we re-target this to 1.47?

The only thing that needs to be backported are config changes, so I say we do it.

You have to re-write the list of tarball extensions, write all the sysadmin- and user-facing documentation about the change, add notes to the release announcements, etc. I don't know what config change you mean – the tarball list? — but it's rather more than that.

IIUC (correct me if I'm wrong!), this task only seems to be proposing changing the default on Wikimedia wikis, rather than in MW generally.

The task description is a bit misleading; We're not removing CodeEditor just yet (it's still being used in some places like WikiLambda, as you know).

The config changes are to the various extensions that integrate with CodeMirror, and we'd only be backporting what is currently in our production config. On the CodeMirror side (T259059), I'd like to also go ahead and retire CM5 entirely. That also involves just config changes, and deleting a bunch of files (in other words, only changes that have already been battle-tested in production).

The email announcing this is what I was waiting for, and it makes it sound like it's not too late. If at all possible, let's please move forward with this.

I will go ahead and make the patches to switch the default config settings.

OK, sure. But let's not abuse the release tag with unrelated tasks?

Sorry, I guess I didn't understand when was the appropriate time to remove the tag. Frankly I'm still confused, but whatever, so long as I can get these config changes into MW 1.46, I'm happy :)

Change #1271093 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeEditor@master] Change default values for CodeEditorEnabledModes to false

https://gerrit.wikimedia.org/r/1271093

Change #1271092 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeMirror@master] Promote CM6 out of beta, remove CM5 modules, and add v6 aliases

https://gerrit.wikimedia.org/r/1271092

Change #1271098 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/Gadgets@master] Use CodeMirror by default instead of CodeEditor

https://gerrit.wikimedia.org/r/1271098

Change #1271101 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/Scribunto@master] Use CodeMirror by default instead of CodeEditor

https://gerrit.wikimedia.org/r/1271101

Change #1271102 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/TemplateStyles@master] Use CodeMirror by default instead of CodeEditor

https://gerrit.wikimedia.org/r/1271102

Change #1271103 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/UploadWizard@master] Use CodeMirror by default instead of CodeEditor

https://gerrit.wikimedia.org/r/1271103

Change #1271239 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/JsonConfig@master] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1271239

Change #1271263 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[operations/mediawiki-config@master] Promote CodeMirror 6 out of beta and use in place of CodeEditor

https://gerrit.wikimedia.org/r/1271263

IIUC (correct me if I'm wrong!), this task only seems to be proposing changing the default on Wikimedia wikis, rather than in MW generally.

To confirm, is my understanding here correct? The task description says:

This is the task to formally propose replacing CodeEditor with MediaWiki-extensions-CodeMirror on Wikimedia wikis

...but there've been patches uploaded here for the codebases of MW extensions themselves (rather than e.g. just patches to operations/mediawiki-config), so I just want to confirm :)

The conundrum so to speak is that in order to promote CodeMirror 6 from a beta feature, it would also come with replacing CodeEditor. Or at least, doing it in one fell swoop makes it much simpler.

Per T259059#11822688, I've gone with what I hope is the happy medium. That is, out of the box, you still get CodeEditor with the MediaWiki 1.46 bundle. CodeMirror however is not bundled (yet, T391926), so it can proceed separately with the extension itself only supporting CM6. This means changing the RL modules and everywhere that uses them, and removing references to the beta feature – hence all the patches to extensions that integrate with CodeMirror.

Change #1271239 merged by jenkins-bot:

[mediawiki/extensions/JsonConfig@master] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1271239

Change #1271098 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@master] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1271098

Change #1271101 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1271101

Change #1271102 merged by jenkins-bot:

[mediawiki/extensions/TemplateStyles@master] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1271102

Change #1271103 merged by jenkins-bot:

[mediawiki/extensions/UploadWizard@master] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1271103

Change #1271093 merged by jenkins-bot:

[mediawiki/extensions/CodeEditor@master] Hooks: remove temporary CodeMirror code following promotion from beta

https://gerrit.wikimedia.org/r/1271093

Change #1275998 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeEditor@wmf/1.46.0-wmf.24] Hooks: remove temporary CodeMirror code following promotion from beta

https://gerrit.wikimedia.org/r/1275998

Change #1275999 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/UploadWizard@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1275999

Change #1276004 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/TemplateStyles@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276004

Change #1276006 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/Scribunto@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276006

Change #1276007 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/JsonConfig@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276007

Change #1276008 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/Gadgets@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276008

Change #1271263 merged by jenkins-bot:

[operations/mediawiki-config@master] Promote CodeMirror 6 out of beta and use in place of CodeEditor

https://gerrit.wikimedia.org/r/1271263

Change #1275999 merged by jenkins-bot:

[mediawiki/extensions/UploadWizard@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1275999

Change #1276008 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276008

Change #1276006 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276006

Change #1276007 merged by jenkins-bot:

[mediawiki/extensions/JsonConfig@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276007

Change #1275998 merged by jenkins-bot:

[mediawiki/extensions/CodeEditor@wmf/1.46.0-wmf.24] Hooks: remove temporary CodeMirror code following promotion from beta

https://gerrit.wikimedia.org/r/1275998

Change #1276004 merged by jenkins-bot:

[mediawiki/extensions/TemplateStyles@wmf/1.46.0-wmf.24] CodeEditorHooks: remove temporary code for CodeMirror beta feature

https://gerrit.wikimedia.org/r/1276004

Mentioned in SAL (#wikimedia-operations) [2026-04-21T22:02:08Z] <musikanimal@deploy1003> Started scap sync-world: Backport for [[gerrit:1275997|Promote CM6 out of beta, remove CM5 modules, and add v6 aliases (T373720)]], [[gerrit:1276002|VisualEditor.CodeMirror.less: remove CM5 styles]], [[gerrit:1276004|CodeEditorHooks: remove temporary code for CodeMirror beta feature (T419332)]], [[gerrit:1276005|DescriptionField: use new module name for loading CodeMirror]], [[gerrit:1275998|Ho

Mentioned in SAL (#wikimedia-operations) [2026-04-21T22:18:58Z] <musikanimal@deploy1003> musikanimal: Backport for [[gerrit:1275997|Promote CM6 out of beta, remove CM5 modules, and add v6 aliases (T373720)]], [[gerrit:1276002|VisualEditor.CodeMirror.less: remove CM5 styles]], [[gerrit:1276004|CodeEditorHooks: remove temporary code for CodeMirror beta feature (T419332)]], [[gerrit:1276005|DescriptionField: use new module name for loading CodeMirror]], [[gerrit:1275998|Hooks: remove

Mentioned in SAL (#wikimedia-operations) [2026-04-21T22:37:25Z] <musikanimal@deploy1003> Finished scap sync-world: Backport for [[gerrit:1275997|Promote CM6 out of beta, remove CM5 modules, and add v6 aliases (T373720)]], [[gerrit:1276002|VisualEditor.CodeMirror.less: remove CM5 styles]], [[gerrit:1276004|CodeEditorHooks: remove temporary code for CodeMirror beta feature (T419332)]], [[gerrit:1276005|DescriptionField: use new module name for loading CodeMirror]], [[gerrit:1275998|H

MusikAnimal claimed this task.
MusikAnimal added a subscriber: Bhsd.

This is done! Huge thanks to everyone in helped, especially co-maintainer @Bhsd, and also @SD0001 who helped a bunch with code review and also implemented the server-side linting for TemplateStyles and JavaScript.

More broader thanks on the CodeMirror effort to be given at T259059

Cheers!

Hi, I tried the new "Syntax" button on wikitext pages, and it looks like you still need to fix some things.

  1. When I activate the "Syntax", keyboard events are fired twice, looks like they're being duplicated by CodeMirror:
VM2692:3 hello
(anonymous)	@	VM2692:3
dispatch	@	jquery.js:5145
(anonymous)	@	jquery.js:4949
(anonymous)	@	codemirror.js:391
(anonymous)	@	codemirror.bundle.lib.js:8596
runHandlers	@	codemirror.bundle.lib.js:8487
handleEvent	@	codemirror.bundle.lib.js:8477
VM2692:3 hello
(anonymous)	@	VM2692:3
dispatch	@	jquery.js:5145
(anonymous)	@	jquery.js:4949
  1. The textSelection jQuery plugin fails when "Syntax" is active. Here I was calling a replaceSelection:
jquery.textSelection.js:98 Uncaught TypeError: this.select is not a function
    at HTMLDivElement.eval (jquery.textSelection.js:98:10)
    at jQuery.each (jquery.js:383:19)
    at jQuery.fn.init.each (jquery.js:205:17)
    at jQuery.fn.init.setContents (jquery.textSelection.js:96:16)
    at $.fn.textSelection (jquery.textSelection.js:489:77)
    at HTMLDivElement.eval (jquery.textSelection.js:142:16)
    at execInsertText (jquery.textSelection.js:72:13)
    at HTMLDivElement.eval (jquery.textSelection.js:136:5)
    at jQuery.each (jquery.js:383:19)
    at jQuery.fn.init.each (jquery.js:205:17)

Also, would be possible to have separate settings depending on the language? I may want to always use syntax highlighting on JS/CSS pages, and never use it on Wikitext pages. Right now, it remembers my last choice everywhere.
Thanks.

  1. When I activate the "Syntax", keyboard events are fired twice, looks like they're being duplicated by CodeMirror:

Yes, this is intentional. The events are fired both from the CodeMirror content-editable div (the actual editor) and the hidden native textarea, so that other integrations will not break.

  1. The textSelection jQuery plugin fails when "Syntax" is active.

Could you provide steps for us to reproduce?

Also, would be possible to have separate settings depending on the language? I may want to always use syntax highlighting on JS/CSS pages, and never use it on Wikitext pages. Right now, it remembers my last choice everywhere.

This can be discussed in T418352.

Hi, I tried the new "Syntax" button on wikitext pages, and it looks like you still need to fix some things.

Actually this is not the right ticket for wikitext pages. This ticket is only for non-wikitext content models, such as JavaScript/CSS/JSON/Lua/Vue.

  1. When I activate the "Syntax", keyboard events are fired twice, looks like they're being duplicated by CodeMirror:

Yes, this is intentional. The events are fired both from the CodeMirror content-editable div (the actual editor) and the hidden native textarea, so that other integrations will not break.

And will this not create problems with gadgets and scripts, if the intended action is performed twice? Suppose I have a custom shortcut to quickly insert some predefined template, I press it once and I get two templates...
How do you suggest to get around that?

Actually this is not the right ticket for wikitext pages. This ticket is only for non-wikitext content models, such as JavaScript/CSS/JSON/Lua/Vue.

And what is the right ticket, please?

And will this not create problems with gadgets and scripts, if the intended action is performed twice?

No, I do not see why it will create any problems, unless you can provide a reproducible example.

And what is the right ticket, please?

You can create new tickets with reproducible steps if you notice any bugs.

Note that the MediaWiki Download ships with CodeEditor, but not CodeMirror, so that needs to be rectified for MediaWiki 1.46.