close
Page MenuHomePhabricator

Upgrade to CodeMirror 6
Closed, ResolvedPublicGoal

Description

This is Epic task for the CodeMirror 6 upgrade. This is a complete rewrite of the library that fixes many of the fundamental issues with CodeMirror 5. Specifically, accessibility issues, mobile compatibility, and RTL support should largely be addressed.

Checklist

These tasks are considered vital to retiring CodeMirror 5.

Deployment task: T357795

Beta feature task: T376735

Short-term goals

Not necessary for rolling out CodeMirror 6 on the WMF cluster, or retiring CodeMirror 5, but we are still aiming to bring these the extension.

These features can be tried now on @Bhsd's demo page: https://bhsd-harry.github.io/codemirror-mediawiki/

Longer-term maybes

Consider replacing other syntax highlighting systems

We should consider replacing other syntax highlighting systems (i.e. Ace) with CodeMirror to reduce maintenance burden and keep code DRY. (Tasks to be created once CodeMirror 6 has proven itself.)

Details

Due Date
Apr 15 2026, 4:00 AM
Related Changes in Gerrit:

Related Objects

StatusSubtypeAssignedTask
OpenFeatureNone
ResolvedFeatureBhsd
ResolvedFeatureMusikAnimal
ResolvedFeatureMusikAnimal
ResolvedMusikAnimal
ResolvedGoalMusikAnimal
ResolvedFeatureMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedBhsd
ResolvedBUG REPORTBhsd
ResolvedMusikAnimal
ResolvedMusikAnimal
OpenNone
ResolvedTheresNoTime
ResolvedMusikAnimal
ResolvedBUG REPORTBhsd
ResolvedMusikAnimal
ResolvedBUG REPORTMusikAnimal
ResolvedBUG REPORTFunc
ResolvedBUG REPORTMusikAnimal
DeclinedNone
ResolvedBUG REPORTFunc
ResolvedBUG REPORTFunc
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedBhsd
OpenMusikAnimal
ResolvedMusikAnimal
ResolvedBUG REPORTBhsd
ResolvedFeatureBhsd
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Aklapper changed the task status from In Progress to Open.Apr 11 2025, 10:13 PM

Resetting task status from "In Progress" to "Open" as this task has been "in progress" for more than one and a half years (see T380300).

MusikAnimal set Due Date to Apr 15 2026, 4:00 AM.Mar 8 2026, 4:49 AM
MusikAnimal added a project: User-notice.

Looks like we're aiming to do this by MW 1.46, with T419332 happening at the same time. I'll put something in Tech News.

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

See also discussion over at T419332#11821789. It sounds like we're still good to at least change the default config settings in MW 1.46. For this task (retiring CM5), I would also like to remove the old modules. At any rate, there will be nothing backported to MW 1.46 that hasn't already been battle-tested in WMF production.

I'll start with those patches then work on another Tech News entry, with the goal of the actual switchover happening on Tuesday, April 21. Everything using CM5 (other than the CM5 modules loaded by Extension:CodeMirror itself) has been emitting a warning for some time now, so I'm hoping gadget developers etc. have their CM6 version ready by now. Even if they don't, myself and Bhsd will be here to assist them with the migration.

In the worst case scenario, we can temporarily keep .v5 modules around to accommodate our cluster a tad bit longer, but I think they should be removed from the MW 1.46 branch.

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

r1271263 is the change to the WMF configuration. All other relevant patches may be found at https://gerrit.wikimedia.org/r/q/topic:%22codemirror6%22+status:open . Any help with code review is appreciated.

What I've done with respect to T419332 is leave the various *UseCodeMirror and *UseCodeEditor flags still set to CodeEditor, and we'll override it in the WMF config. This is because CodeEditor is bundled with MW, while CodeMirror still isn't (T391926). We can take care of that and the full replacement of CodeEditor by MW 1.47, which is fitting given that is also an LTS release. The plan for MW 1.46 is for Extension:CodeMirror itself to ship with default values assuming the sysadmin wants to use CM6, including replacing CodeEditor. This in turn greatly simplifies the WMF config, and we don't have to change any release notes etc. for MW itself.

Meanwhile, CodeMirror 5 will be completely removed, which is the biggest and most pressing goal. r1271092 looks like a beast of a patch, but it's mostly just changing ext.CodeMirror.v6 to ext.CodeMirror in a bunch of places, and removing the beta feature code. I had considered leaving the .v6 ResourceLoader modules aliased to their MW 1.46 replacements, but it seems like this sort of aliasing isn't really a thing in RL. Turns out that shouldn't be a problem, as there are only ~25 instances of the v6 modules being used on-wiki, so I can fix those manually as a global interface editor. Known usage in MW code is also accounted for in the patches (except the Citizen skin, which still supports MW 1.43 LTS; Once things are merged I will file an issue on their GitHub).

As for deployment, I think it's still safest to do this all in one go, so I will stick to the Tuesday, April 21 goal. If for whatever reason that doesn't work out, I can backport config changes to wmf release branches as necessary, and delay a bit further.

What I've done with respect to T419332 is leave the various *UseCodeMirror and *UseCodeEditor flags still set to CodeEditor, and we'll override it in the WMF config. This is because CodeEditor is bundled with MW, while CodeMirror still isn't (T391926). We can take care of that and the full replacement of CodeEditor by MW 1.47, which is fitting given that is also an LTS release. The plan for MW 1.46 is for Extension:CodeMirror itself to ship with default values assuming the sysadmin wants to use CM6, including replacing CodeEditor.

I just wonder what will happen if a third-party wiki installs both CodeEditor and CodeMirror without manually changing the extension configurations?

I just wonder what will happen if a third-party wiki installs both CodeEditor and CodeMirror without manually changing the extension configurations?

I had thought it would pick the first one that has a true value for that mode (or at least that worked in some of my tests), but it does seem it's possible for both to be running in parallel, which is no good. I can fix that and will get that patch backported as well.

I should be upfront I'm not really familiar with the MW bundling process (I have never used the bundle myself on 3rd party wikis), but I thought it reasonable that everything in the bundle should work out of the box. Things outside of it presumably are not subject to the same standard, and the normal expectation to read the sysadmin docs remains. But if there's disagreement there I can change r1271092 to keep $wgCodeMirrorEnabledModes with just mediawiki. The more important part to me is retiring CM5.

But if there's disagreement there I can change r1271092 to keep $wgCodeMirrorEnabledModes with just mediawiki.

That sounds better to me, and we can give CodeMirror a higher precedence than CodeEditor when it is bundled with the core in MW 1.47.

Okay! Done. I'm hoping CodeEditor will be all but completely replaced by MW 1.47, but either way yes, we will at least be able to change the default values in favour of CodeMirror.

CodeMirror isn't yet in the tarball, so unless you're adding it really swiftly this is just dropping the functionality for third parties, right?

CodeMirror isn't yet in the tarball, so unless you're adding it really swiftly this is just dropping the functionality for third parties, right?

Sorry, dropping what functionality? I hope we're not dropping anything!

I was not planning to do T391926: Bundle Extension:CodeMirror with MediaWiki core for MW 1.46. All of the patches that were just merged are about promoting CM6 out of beta, and with r1271263 (needs some tweaking as of the time of writing), we will resolve T419332 for the WMF cluster.

Out of the box, MW 1.46 will be like previous versions with respect to CodeMirror and CodeEditor. Config changes are still necessary to replace CodeEditor, and here at WMF we'll be doing just that so we can perfect everything and (likely) replace CodeEditor entirely for the 1.47 LTS.

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

Revisiting this, it seems I don't even have the option to backport to MW 1.46. Does that mean what we just merged will still go in MW 1.46?

CodeMirror isn't yet in the tarball, so unless you're adding it really swiftly this is just dropping the functionality for third parties, right?

Sorry, dropping what functionality? I hope we're not dropping anything!

Ah, I was going by the original content of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CodeEditor/+/1271093 but I see it's been changed.

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

Revisiting this, it seems I don't even have the option to backport to MW 1.46. Does that mean what we just merged will still go in MW 1.46?

Yes, the weekly alphas (deployment branches) are done, but the creation of REL1_46 will happen with whatever the status of the master branches are at around UTC midnight on Monday -> Tuesday next week, after which point the branch will exist in each repo to back-port into.

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

MusikAnimal claimed this task.
MusikAnimal added subscribers: ppelberg, SD0001, DLynch and 3 others.

And that's a wrap! After a long and hard two years of development, CodeMirror 6 is live on all wikis, and v5 is no more. I'll be updating the mediawiki.org documentation over the next few hours.

Way back in 2016, Community-Tech worked with volunteer @Pastakhov to deliver the original CodeMirror 5 implementation. At the time, the CodeMirror library itself did not support RTL. WMF helped fund the CodeMirror 6 development which brought native RTL supprot, and with today's deployment (which took over an hour, by the way!), we are finally closing out that 2016 wish by offering syntax highlighting to all users.

The CodeMirror 6 upgrade started with just a version bump, but it was quickly noticed just how many powerful editing features we could have, so the scope expanded more and more into what you see today. It was an official Community Tech project but ballooned into a mostly volunteer-led effort. I hope the long wait was worth it for our users, because it was certainly worth it to me! This is easily the biggest move of my professional career, and I couldn't have done it without all the help from so many…

Please join me in giving a huge THANK YOU to volunteer and co-maintainer, @Bhsd!!! He is the brains behinds many of the awesome features you are able to enjoy. I had fully intended on implementing most of these myself, but at this point, I think it's safe to say I wouldn't have accomplished it without Bhsd's help – and even if I did, it wouldn't have been done so brilliantly and with such professional expertise. Bhsd, you are a true rock star! <3

Special thanks to everyone else who has helped in this 2-year long project, especially @SD0001, and the many other volunteers who have helped shape the product. At WMF, a very special thanks @DLynch, @Esanders, @ppelberg and all at the Editing-team for providing me with this opportunity, and of course my dear colleagues at Community-Tech, in particular @Samwilson and @TheresNoTime.

PS – we aren't done yet, either! There are many more awesome features to come :D

Thanks again to everyone. Closing as resolved!