Add realtime preview to JSON editor for the Chart.JsonConfig content model
Closed, ResolvedPublic

Description

Realtime Preview is currently hard-coded to only run for wikitext. This is because for most everything else, it's not helpful, and even potentially dangerous (JavaScript for example).

The Chart.JsonConfig content model provided by thee Charts extension however is safe to render, and seems to work great:

Screenshot from 2026-05-06 22-50-26.png (1,881×1,278 px, 273 KB)

This is because behind the scenes, the JCChartContentView class is used for rendering chart pages, which feeds the JSON to the parser function, effectively making Chart.JsonConfig pages viewable without having to use the {{#chart:}} parser function on a wikitext page.

This could be a low-effort quick win for the Chart-Community-Wish-W414 project, and can be released separately from the new "visual mode".

Technical requirements

  • WikiEditor (2010) – add an extension attribute that allows other extensions to register content models appropriate for use with Realtime Preview
  • MediaWiki-extensions-CodeMirror – look for the aforementioned extension attribute and if present, un-hide .wikiEditor-ui-toolbar .section-secondary .group-default (but keep the duplicated search button hidden)
  • Charts – register Chart.JsonConfig with the WikiEditor extension attribute

Acceptance criteria

  • When editing the source of Chart pages, the "Preview" button and reload button to its left should be shown in the toolbar, just like when editing wikitext
  • Everything should work as normal with Realtime Preview – that is, changes to the JSON will update the preview after a brief delay when the user stops typing

Event Timeline

HMonroy raised the priority of this task from Low to Medium.May 14 2026, 11:15 PM
HMonroy moved this task from Backlog to Post-MVP on the Chart-Community-Wish-W414 board.

With the demise of CommTech, and potential abandonment of the Chart-Community-Wish-W414 project, I'm going to push the already-written patches for this. It's quite straightforward and is an easy win to make the wikitext editing experience easier.

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

[mediawiki/extensions/WikiEditor@master] RealtimePreview: allow usage for registered content models

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

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

[mediawiki/extensions/CodeMirror@master] Expose RealtimePreview in WikiEditor for applicable content models

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

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

[mediawiki/extensions/Chart@master] Add Chart.JsonConfig as an RealtimePreview-compatible content model

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

Change #1295549 merged by jenkins-bot:

[mediawiki/extensions/WikiEditor@master] RealtimePreview: allow usage for registered content models

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

Change #1295551 merged by jenkins-bot:

[mediawiki/extensions/Chart@master] Add Chart.JsonConfig as an RealtimePreview-compatible content model

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

Change #1295550 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Expose RealtimePreview in WikiEditor for applicable content models

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

MusikAnimal changed the task status from Open to In Progress.Mon, Jun 22, 11:00 PM