Page MenuHomePhabricator

Make CodeMirror compatible with ProofreadPage headers and footers
Closed, ResolvedPublicFeature

Description

Feature summary:
Modify Extension:CodeMirror to work in Extension:ProofreadPage's headers and footers.

It doesn't look very complicated, e.g. stuffing the code given in the doc to add CM to a textarea, looped for the three textareas, in a browser console, works.

Use case(s):
All pages in Page: namespace on the Wikisources.

Benefits:
The same benefits that CodeMirror has in the first place.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
MusikAnimal changed the task status from Open to In Progress.Apr 29 2025, 2:38 AM
MusikAnimal claimed this task.

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

[mediawiki/extensions/ProofreadPage@master] ext.proofreadpage.page.edit: add CodeMirror to header and footer

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

Change #1139588 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] ext.proofreadpage.page.edit: add CodeMirror to header and footer

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

Looks like this was broken with r1107061, and now there's no CodeMirror at all on Wikisource :(

I'm investigating. There are no more backport windows this week so the fix may not go live until Monday.

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

[mediawiki/extensions/ProofreadPage@master] Use CodeMirrorGetModeHook instead of extension attribute

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

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

[integration/config@master] Zuul: [extensions/ProofreadPage] Add CodeMirror as phan dependency

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

Change #1147809 merged by jenkins-bot:

[integration/config@master] Zuul: [extensions/ProofreadPage] Add CodeMirror as phan dependency

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

Change #1144673 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] Use CodeMirrorGetModeHook instead of extension attribute

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

Remaining issues:

  • The header and the footer disappear when previewing.
  • The CSS looks broken when line wrapping is disabled.
  • Code folding does not work.

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

[mediawiki/extensions/ProofreadPage@master] page.edit.js: fix a few remaining issues with CodeMirror integration

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

Remaining issues:

  1. The header and the footer disappear when previewing.
  2. The CSS looks broken when line wrapping is disabled.
  3. Code folding does not work.

I believe r1186190 may incidentally fix #1 and #3 by using CodeMirrorChild instances. For #2, I was not able to devise a solution without potentially breaking something, given Proofread Page uses flexbox. But a nice little alternative solution came to mind, which hopefully will do for now.

@Alien333 How important would you say turning line wrapping off is to Wikisourcers? Here we're forcing it to be on.

@Alien333 How important would you say turning line wrapping off is to Wikisourcers? Here we're forcing it to be on.

I won't claim to speak for everyone everywhere, but probably not that much? I didn't even know one could turn line wrapping off, tbh. I think that the intersection of people who know it was possible and people who routinely use it is pretty small.
It would perhaps be more of a problem for wikis where they have content much wider than tall. But then again, they already have a full-width window, so not that bad.
So in the end I think it'd be fine to force it on. If you want to be 100% sure, go ask at the mulws scriptorium; over there they have plenty of languages and different perspectives.
(Sorry for not being very responsive, a bit busy irl.)

Change #1186190 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] page.edit.js: fix a few remaining issues with CodeMirror integration

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

Sohom's comments in r1186190:

  • CodeMirror v5 breaks (this is probably okay? since it is going away)
  • If I start with the headers/footers collapsed, and then I reopen the headers and footers, they do not display anymore at all. (this works fine without CodeMirror so I think it is a issue with the integration). (fixed by r1242739)

Additional issues I find:

  • There are multiple panels for keyboard shortcuts opened at the same time. (fixed by r1243057)
  • Switching on and off CodeMirror breaks textarea heights. (fixed by r1238991)

Change #1238991 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/ProofreadPage@master] Fix CodeMirror layout of header/body/footer fields

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

  • When WikiEditor is disabled while CodeMirror 6 is enabled, #wpTextbox1 is not correctly wrapped inside .ext-codemirror-wrapper. (fixed by r1242412)

Change #1242412 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/ProofreadPage@master] Do not run WikiEditor-specific function when WikiEditor is disabled

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

Change #1242412 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] Do not run WikiEditor-specific function when WikiEditor is disabled

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

Change #1243057 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] CodeMirrorKeymap: limit the number of click listeners

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

@Alien333 commented on Discord:

  • The body should be auto-fucused instead of the footer. (fixed by r1247077)

Change #1247077 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] CodeMirror: do not apply autofocus to child instances

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

Change #1247077 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirror: do not apply autofocus to child instances

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

Change #1238991 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] Fix CodeMirror layout of header/body/footer fields

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

Change #1247514 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] jest: fix a test that always passes

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

Change #1243057 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirrorKeymap: limit the number of click listeners

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

Change #1247514 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] jest: fix a test that always passes

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

Change #1251315 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/ProofreadPage@master] Page: slightly adjust the header/footer size

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

Change #1251315 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] Page: slightly adjust the header/footer size

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

Is there anything left for this ticket? I think all known issues have been fixed (except for CM5 which is not expected to work).

MusikAnimal moved this task from Improvement to Done on the MediaWiki-extensions-CodeMirror board.

Seems like the functionality is all there. Any follow-ups or bugs can be filed under new tasks.