Commit graph

1042 commits

Author SHA1 Message Date
MusikAnimal d1863e4d0b tests: disable flaky CM5 bracket matching test for 2017 editor
This legacy CM5 test has always been flaky and is now consistently
failing. It can be reinstated with T357482, or not at all, seeing as
bracket matching is a core extension in CodeMirror 6 and probably
doesn't need a dedicated test on top of what's upstream.

Change-Id: I77362c1c47be902cc888682aae926154470f1a56
2024-03-19 22:47:23 -04:00
jenkins-bot ffa569a472 Merge "CM6: put template folding behind feature flag and rework config settings" 2024-03-19 05:45:49 +00:00
Derk-Jan Hartman fbf02b1dc2 Remove dependency on jquery.ui from CodeMirror
Now that RTP has been enabled for a while, we no longer need this and
jquery.ui is deprecated.

Bug: T323329
Change-Id: Idbb92bd4f18e2c6e0adc51d1a3fa909efc129686
2024-03-18 22:19:08 +00:00
Translation updater bot d9ec236217 Localisation updates from https://translatewiki.net.
Change-Id: Idc883aa4cbc25c3b82026257e2ee25ac8ec11aa6
2024-03-18 08:30:34 +01:00
libraryupgrader 396549bb4a build: Updating mediawiki/mediawiki-codesniffer to 43.0.0
Change-Id: I199a98e2f874e201d3ff05dd06df98c6200335db
2024-03-17 16:17:35 +00:00
libraryupgrader b19d4c3383 build: Updating bundlesize to 0.18.2
Change-Id: I746631d5890930cf7d37673d88ce00e49d68c973
2024-03-15 22:32:23 +00:00
MusikAnimal 7e9d90bb52 CM6: put template folding behind feature flag and rework config settings
Template folding is likely going to be a big 'hit' of a feature, but not
everyone will want it. Until CodeMirror prefs are introduced (T359498),
we need a way to control the rollout of template folding. This commit
adds $wgCodeMirrorTemplateFoldingNamespaces which acts similar to the
existing $wgCodeMirrorLineNumberingNamespaces.

We also move template folding to be part of CodeMirrorModeMediaWiki,
since the feature is unique to MediaWiki wikitext.

Move configuration settings to be part of the DataScript, thus removing
the need for the ResourceLoaderGetConfigVarsHook (which unnecessarily
makes the config settings available on every page load).

Other minor changes like adding missing JSDoc blocks.

Bug: T30684
Change-Id: I67518c0968f64c79e290f57b4884d30a161212d3
2024-03-14 23:54:39 -04:00
libraryupgrader 3a6c805135 build: Updating follow-redirects to 1.15.6
* https://github.com/advisories/GHSA-cxjh-pqwp-8mfp

Change-Id: I21a0b0aee97783e57e3860276df6eab3850ac9b6
2024-03-15 00:44:16 +00:00
jenkins-bot 6b2edf37a6 Merge "Remove WikiEditor toolbar z-index override" 2024-03-15 00:27:42 +00:00
Ed Sanders a4027375c3 Remove WikiEditor toolbar z-index override
Upstreamed in I85ca9727b0

Bug: T360084
Change-Id: Ic87b8c377cb9c68f97009070525284b7cd95c933
2024-03-14 10:16:26 -07:00
MusikAnimal 911b2d3d46 CodeMirror: add 'dir' and 'lang' attrs to .cm-editor and not .cm-content
Before we were adding these attributes to .cm-content, which didn't
encompass the gutter (line numbers). When you edited a LTR page in a RTL
interface language (or vice versa), the line gutter appeared on the
wrong side, which caused the cursor to be misaligned.

This commit fixes this by applying the direction and language to the
entire editor (.cm-editor), and not just .cm-content. However this means
the search panel could be in the page language when it should be the
interface language. This will be addressed in a follow-up patch.

Other attributes like 'class' that are copied from the textarea must
remain on .cm-content, because the parent .cm-scroller would otherwise
override them.

Bug: T359589
Change-Id: Id805944231fd75c1dc1c336e3cd4c7bc5c42c036
2024-03-13 11:19:16 -04:00
MusikAnimal aa3876a97e CodeMirrorWikiEditor: Remove hack to fix height in WikiEditor
WikiEditor's ResizingDragBar makes the editor resizable, so we need to
set the height to 100%. This was attempted in Ib49d1d9e71 and
I4deeda192b but both ultimately suffer from race conditions. Instead
we're setting the height in WikiEditor with Ia5e9767e08.

The heightExtension in the CodeMirror class still remains, in the event
a subclass wishes to override the default behaviour in CM directly and
not with CSS.

Bug: T357794
Depends-On: Ia5e9767e0814eac29d58bc0d9c1023344a29dd84
Change-Id: Ic55dd098d70fd173ddee7100e392b889ee6ddd08
2024-03-13 11:18:20 -04:00
jenkins-bot c63e81539a Merge "CodeMirror: fix implementation of jQuery.textSelection encapsulate" 2024-03-13 00:28:26 +00:00
jenkins-bot 8dd82a8b86 Merge "CodeMirror 6: show wikitext highlighting on protected pages" 2024-03-12 18:47:28 +00:00
jenkins-bot 6281f799c8 Merge "CodeMirror 6: Add bidi isolation to HTML tags" 2024-03-12 18:47:22 +00:00
Translation updater bot 9b01891916 Localisation updates from https://translatewiki.net.
Change-Id: Ibe1f917f664fb1f6adfda1b689a110771867b55e
2024-03-12 08:24:09 +01:00
jenkins-bot 7fa0883811 Merge "styles: Replace error color with #d73333" 2024-03-11 23:15:44 +00:00
MusikAnimal d927b01ec1 CodeMirror: fix implementation of jQuery.textSelection encapsulate
In Idc0abb64eb we added support for 'encapsulateSelection' and multiple
cursors, but broke other jQuery.textSelection functionality in the
process. In this commit, we move the logic to a dedicated class, and
more fully and accurately mimic the native implementation.

All functionality in WikiEditor should now be supported.

Bug: T359671
Follow-Up: Idc0abb64eb036fa4a60382aca401d1dba1722405
Change-Id: I9b947d80616bd4c4372b981b2271a281d1fc0252
2024-03-11 17:38:20 -04:00
MusikAnimal 63cd3e4ff8 CodeMirror 6: show wikitext highlighting on protected pages
It is necessary to have a way to toggle CodeMirror on and off, so we use
WikiEditor and hide all other buttons. This is more costly than loading
just vanilla CodeMirror, but it ensures a consistent experience with
pages that are editable, with the toggle button in the familiar place.
At a later time, WikiEditor may be updated to better support read only
pages in a lightweight fashion (T188817).

Bug: T301615
Change-Id: I8ea7597d07ff60a3f58ba306d2d6d12d3ec08b16
2024-03-11 17:35:20 -04:00
MusikAnimal 18a92122ef CodeMirror 6: Add bidi isolation to HTML tags
HTML tags and similar markup may appear jumbled on RTL pages due to the
standard algorithm used for character placement. With this patch, we
detect all tags (HTML or MediaWiki-supplied) and wrap them with
<span class=cm-bidi-isolate>. This CSS class forces the content to be
LTR, making the tags easier to work with on RTL pages.

Bug: T358804
Change-Id: I1338afeefa16102d5cc8fd6c8a236c144e5cf81f
2024-03-11 17:34:41 -04:00
MusikAnimal 894d2c33e9 Hooks: further limit where CodeMirror RL modules are loaded
This fixes a preexisting issue where we were loading CodeMirror on pages
where it would never be used. We use the EditPage__showEditForm_initial
hook so we don't need to check the action.

This commit introduces the CodeMirrorContentModels extension attribute,
used to limit where CodeMirror is loaded automatically. By default,
this includes only CONTENT_MODEL_WIKITEXT ('wikitext'). This extension
attribute serves as a stepping stone to CM being used on content types
other than just wikitext.

Bug: T359206
Change-Id: Ibefc028c5ef6275393202fe773c26162715e1bca
2024-03-11 17:30:10 -04:00
Volker E 0e0e55e143 styles: Replace error color with #d73333
This patch promotes a consistent design decision across projects in
MediaWiki core, extensions, and skins. The darker red color meets the
W3C Web Content Accessibility Guidelines (WCAG) at Level AA that text
or images of text must have a contrast ratio of at least 4.5:1.

Bug: T343239
Change-Id: Id66e6636e2237ae956d3c0e4821e862f875a6e30
2024-03-11 22:03:30 +01:00
Translation updater bot e578597263 Localisation updates from https://translatewiki.net.
Change-Id: I3130f67228f31701a7fa1e193566647e9fe520ad
2024-03-11 08:26:33 +01:00
jenkins-bot 829ad8e79f Merge "Use namespaces class MediaWiki\Context\RequestContext" 2024-03-08 20:26:44 +00:00
Translation updater bot 9696056dfe Localisation updates from https://translatewiki.net.
Change-Id: Iab371c59161a0f585d71cffe9232692152699098
2024-03-08 08:22:43 +01:00
jenkins-bot 985f2991e5 Merge "CodeMirror 6 template folding" 2024-03-08 02:38:43 +00:00
Fomafix f706c0dc99 Use namespaces class MediaWiki\Context\RequestContext
This change depends on I4dbef138fd0110c14c70214282519189d70c94fb
included in MediaWiki 1.42.

Change-Id: I37b5bbe06dfb99b5ff819188a1b76ad6c669ecda
2024-03-07 20:05:27 +00:00
jenkins-bot 210f78aa90 Merge "Avoid wgTitle in tests" 2024-03-07 19:21:51 +00:00
Translation updater bot dda2606d3a Localisation updates from https://translatewiki.net.
Change-Id: I17b34d8855bfe7930a6e0c9a8d9e6910c22c020c
2024-03-07 08:48:12 +01:00
bhsd 506d998767 CodeMirror 6 template folding
This patch adds an icon displayed above the cursor inside a template. By clicking it, the template parameters become hidden and replaced by three dots, while the template name remains visible. Clicking the dots will unfold the template. New key bindings include fold (Ctrl-Shift-[/Cmd-Alt-[), unfold (Ctrl-Shift-]/Cmd-Alt-]) and unfoldAll (Ctrl-Alt-]).

Bug: T30684
Change-Id: I631fe0ecf21d0a80306bd40d66d22478a1aefe58
2024-03-07 13:47:47 +08:00
jenkins-bot 4c01432da8 Merge "CodeMirrorModeMediaWikiConfig: add missing tokens for nested templates" 2024-03-07 04:23:56 +00:00
gerritbot 1a906e41ad styles: Update color in Less from #d33 to #d73333
This patch promotes a consistent design decision across projects in
MediaWiki core, extensions, and skins. The darker red color meets the
W3C Web Content Accessibility Guidelines (WCAG) at Level AA that text
or images of text must have a contrast ratio of at least 4.5:1 (or 3:1
for large text).

Bug: T343239
Change-Id: I1c3a7a91e28a8fe9695531cdfd7be6807d7c8999
2024-03-06 22:48:56 +00:00
Fomafix b4b1004499 Avoid wgTitle in tests
Change-Id: I1323b9b9542598d33f7150cc0d468e581b0d8c09
2024-03-06 15:59:33 +00:00
MusikAnimal 321d462311 CodeMirrorModeMediaWikiConfig: add missing tokens for nested templates
Nested templates have background shading relative to their level of
nesting. See the newly added test case as an example. Without these
tokens registered, the styling won't show properly.

Since these tokens aren't referenced directly by the StreamParser, nor
do they have a parent Tag, we don't need them as constants like we do
for other tokens.

Bug: T348019
Change-Id: I87bb99d538344957987b2bd88f902a1427a36522
2024-03-05 00:34:34 -05:00
MusikAnimal 7002bc434d CM6: use textarea height unless WikiEditor's Realtime Preview is loaded
The ResizingDragBar makes the editor resizable, so we need to set the
CodeMirror height to 100%. This only happens when the Realtime Preview
module is loaded.

This fixes a critical issue introduced by I4deeda192b that caused blank
renderings when scrolling large documents.

Bug: T357794
Follow-Up: I4deeda192bdc233101ba61739a636f8fd143c1de
Change-Id: Ib49d1d9e71df3653b13dfd44a8efedbf1ef9cd93
2024-03-04 17:41:04 -05:00
Fomafix c3df98cff6 Remove $this->setService( 'UserOptionsLookup', ... ) in tests
The mocked service UserOptionsLookup is already injected via contructor
to Hooks.

Change-Id: I013aa6f62bd50802889a0037721ba06902d1a18e
2024-03-04 20:04:02 +00:00
Translation updater bot 6b3c480f02 Localisation updates from https://translatewiki.net.
Change-Id: Ib2ea3432f11878c67facd2d430478e5469632607
2024-03-04 08:23:06 +01:00
jenkins-bot 21a6adca11 Merge "fix scroll behavior of CodeMirror 6" 2024-03-01 19:25:00 +00:00
Translation updater bot 2f4917dfd7 Localisation updates from https://translatewiki.net.
Change-Id: I15076c6940e5def9f1663e7000ec65a538846f56
2024-03-01 08:32:46 +01:00
bhsd e4eb2846c9 fix scroll behavior of CodeMirror 6
Previously, the CM6 editor always scrolls into view, which is annoying during preview. With this patch, the CM6 editor only scrolls to the selection while the whole webpage does not scroll. In addition, the editor's scroll position will be memorized when previewing.

This patch requires an update of the @codemirror/view package.

Bug: T212899
Bug: T254962
Change-Id: I7f5e4694fa55c380958fa60ff6b3341bea1d2f02
2024-03-01 13:01:11 +08:00
MusikAnimal c9c9ed27d3 CodeMirror: default to using the same height as the textarea
CodeMirrorWikiEditor: add a 'ext.CodeMirror.initialize' hook to allow
integrations to manipulate the DOM before CodeMirror is initialized.

This is necessary for ProofreadPage, for example (I5c0824bf38cf7).

Bug: T357794
Change-Id: I4deeda192bdc233101ba61739a636f8fd143c1de
2024-02-26 14:22:33 -05:00
jenkins-bot 5bfb8dddad Merge "CodeMirror: sync text editor font preference" 2024-02-26 09:08:14 +00:00
Translation updater bot 734f9a386b Localisation updates from https://translatewiki.net.
Change-Id: I64825d7fd6613a52ec05cca28c65cd8c9d8701df
2024-02-26 08:35:40 +01:00
MusikAnimal 657ba3648a CodeMirror: sync text editor font preference
This only effects users of the CM6 CodeMirror class, so doesn't (yet)
solve the issue for the 2017 editor which is partly what T245568 is for.

I135bf0f7bf supposedly fixed it for the 2010 editor, but that fix
apparently doesn't work anymore, and thus those styles have simply been
removed (the .CodeMirror element is never a child of the edit font
classes).

This change also incidentally fixes font sizing issues by ensuring the
styles are applied to `.cm-content` and not `.cm-editor`. This prior bug
was most notably visible in other skins such as Timeless and Monobook.
The colorblind CSS class is now applied in the same way using the
EditorView.contrentAttributes facet.

Bug: T245568
Change-Id: Iaaf65e47ce8ed9303147aadc7e18a9aaa051405b
2024-02-25 23:08:38 -05:00
jenkins-bot 0b7916bc59 Merge "CodeMirror: partially implement $.textSelection 'encapsulateSelection'" 2024-02-26 04:02:30 +00:00
Translation updater bot 2696e69570 Localisation updates from https://translatewiki.net.
Change-Id: I44dbf8cd5420e6eff38c6bcba24451e0c70e597c
2024-02-20 08:38:14 +01:00
Translation updater bot 74d7847358 Localisation updates from https://translatewiki.net.
Change-Id: If4ec7835d8ee076f665c0e112d1e6d257dfb281f
2024-02-19 08:39:50 +01:00
MusikAnimal 26d5023bb7 CodeMirror: partially implement $.textSelection 'encapsulateSelection'
Popular extensions like Charinsert use this method to wrap text around a
selection. This patch adds support for multiple selections in CM6.

Some options to encapsulateSelection do not yet have explicit support
here, such as 'peri', but it's unclear if they are truly needed.

Bug: T211205
Change-Id: Idc0abb64eb036fa4a60382aca401d1dba1722405
2024-02-16 04:42:14 +00:00
jenkins-bot 113c179138 Merge "Localisation updates from https://translatewiki.net." 2024-02-15 13:40:58 +00:00
Translation updater bot 39783e901e Localisation updates from https://translatewiki.net.
Change-Id: Iefd780f09b6dac93a0b9bbba5f66ccddc4ebba1d
2024-02-15 13:27:47 +01:00