Page MenuHomePhabricator

Upgrade to CodeMirror 6
Open, HighPublicGoal

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
Wed, Apr 15, 4:00 AM
Related Changes in Gerrit:

Related Objects

StatusSubtypeAssignedTask
OpenFeatureNone
ResolvedFeatureBhsd
ResolvedFeatureMusikAnimal
ResolvedFeatureMusikAnimal
ResolvedMusikAnimal
OpenGoalNone
ResolvedFeatureMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedBhsd
ResolvedBUG REPORTBhsd
ResolvedMusikAnimal
OpenMusikAnimal
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
OpenNone
ResolvedMusikAnimal
ResolvedMusikAnimal

Event Timeline

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

We are having quite the struggle over at T357482: 2017 wikitext editor integration in CodeMirror 6. Unless we get everything fixed in a timely fashion, I'm going to shift our target deployment date to align with MW 1.43, when CodeMirror 5 is supposed to be formally deprecated. So, the new goal is sometime in November 2024. This is better I think anyway because the other features of CM6 should be in place by then, and more importantly the ability to toggle them on and off (T359498). This way, when our users finally get CM6, it's a big giant "wow" moment, and there should be no complaints as all features are off by default (except line numbering, see T347211). And of course, all this extra time mean more quality assurance, too.

I apologize for the long wait. I severely underestimated the effort required for this project, but the silver lining is throughout development we have added some amazing new features that will (hopefully) radically improve the editor experience.

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 Wed, Apr 15, 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.