Page MenuHomePhabricator

Add preferences panel to CodeMirror 6
Closed, ResolvedPublic

Description

Background

With the advent of CodeMirror 6, we open the door to a lot of amazing new features:

  • Autocompletion (T95100)
  • Code folding (T30684)
  • Line numbering (would take precedence over $wgCodeMirrorLineNumberingNamespaces)
  • Active line highlighting

To come later:

  • Themes (T163533)
  • Bidi isolation (T358804)
  • Modifier + clicking to open templates (T303392)
  • HTML tag matching
  • Rectangular selection
  • Linting

These are amazing, but surely won't be desired by all. Meanwhile we want to avoid adding these to Special:Preferences both to not clutter it further, but also that ideally you could customize your editor in realtime, rather than having to save your preferences and refresh.

Proposed solution

Introduce a "CodeMirror preferences" panel, akin to the one seen in CodeEditor with the +, keystroke. Here we could house all the advanced features, most of which will probably be off by default.

Turning CodeMirror on/off by itself should still be done either via the toggles shown in WikiEditor (2010) and VisualEditor-MediaWiki-2017WikitextEditor.

Relevant links:

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Please make the CM panel more discoverable. I know the CodeEditor panel exists, I use it every now and then, yet I struggle each time recalling/finding out the hotkey.

Meanwhile we want to avoid adding these to Special:Preferences both to not clutter it further

On the other hand, this cluttering would make it possible to configure the features in global preferences, which would probably be welcomed by people active on multiple wikis. Realtime customization would also be possible by interfacing the preferences both in Special:Preferences and in the panel (I don’t know how well it interacts with global preferences, but if someone wants global preferences, they can use that, if someone wants realtime customization, they can have that).

Good point about Global Preferences! I know I would want that. I'll see what's doable.

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

[mediawiki/extensions/CodeMirror@master] Implement dark mode styles and use Codex CSS components in search panel

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

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

[mediawiki/extensions/CodeMirror@master] [WIP] CodeMirrorPreferences: panel to tweak prefs with the editor open

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

Change #1059166 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Implement dark mode styles and use Codex CSS components in search panel

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

Test wiki created on Patch demo by MusikAnimal using patch(es) linked to this task:
http://patchdemo.wmcloud.org/wikis/f67b3f09f0/w/

Test wiki on Patch demo by MusikAnimal using patch(es) linked to this task was deleted:

http://patchdemo.wmcloud.org/wikis/f67b3f09f0/w/

Test wiki created on Patch demo by MusikAnimal using patch(es) linked to this task:
http://patchdemo.wmcloud.org/wikis/89a3c214db/w/

Change #1063929 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirrorPreferences: add panel to tweak prefs with the editor open

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

This will go out with the Beta deployment planned for next week.

We have a system in place now to add preferences dynamically, see https://www.mediawiki.org/wiki/Extension:CodeMirror/6#Registering_an_extension_in_CodeMirror_preferences

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

[mediawiki/extensions/CodeMirror@master] CodeMirrorWikiEditor: add button to open preferences panel

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