Commit graph

1220 commits

Author SHA1 Message Date
MusikAnimal b464df36ab CodeMirrorSearch: catch exceptions from invalid regex input
Invalid regular expressions would error out on SearchQuery's getCursor()
method. This is arguably an upstream bug, but we want to inform the user
of invalid input anyway. We now show "Invalid regular expression" where
the "$1 of $2" codemirror-find-results message is normally shown, and we
add the error class to the Codex input. This is to be consistent with
how the 2017 editor behaves.

Also disable autocompletion which is more often distracting that
helpful for a search field.

Bump codemirror/search to include a fix where the selection isn't
updated after a regex replacement.
See https://discuss.codemirror.net/t/8832

Bug: T371436
Change-Id: I68722da98ef4925439caa64e8f3366031d56cf8e
2024-11-22 19:42:11 +00:00
Translation updater bot 4dfd50860f
Localisation updates from https://translatewiki.net.
Change-Id: I9b6c86cd502005c69784a3335936f29f210a94fb
2024-11-21 08:21:22 +01:00
Translation updater bot b250cf90d5
Localisation updates from https://translatewiki.net.
Change-Id: I188738969d1a83e0f00c3d42c327d4ee3c88d119
2024-11-20 08:25:15 +01:00
jenkins-bot 8fb5d8cc5d Merge "CodeMirrorModeMediaWiki: autocompletion" 2024-11-19 18:54:45 +00:00
bhsd 197b5649ff CodeMirrorModeMediaWiki: autocompletion
Autocomplete magic words, tag names and url protocols. This patch also enables block comment using `<!-- -->`.

Bug: T95100
Change-Id: If37da956ac1eb945b96753e6728c0247b1a68b66
2024-11-19 16:02:35 +08:00
Translation updater bot 94128280de
Localisation updates from https://translatewiki.net.
Change-Id: Ie7df21a656a64634e8086784cb0213ffd16d678b
2024-11-19 08:17:32 +01:00
jenkins-bot 6cfde8a849 Merge "ve.ui.CodeMirrorAction.v6: Use direction of surface view, not model view" 2024-11-19 05:03:00 +00:00
jenkins-bot 5e6047bd4c Merge "templateFoldingExtension: hide tooltip when typing" 2024-11-19 05:01:46 +00:00
MusikAnimal 2710eade97 ve.ui.CodeMirrorAction.v6: Use direction of surface view, not model view
This fixes an issue where the VE document model is incorrectly used in
computing gutter width based on directionality. It should instead be the
VE surface view's direction, in the event the user the is editing in RTL
on a LTR document. See T374196#10311711.

Bug: T374196
Follow-Up: I81e863e19d6d0bad2cc2be743df896e17a8dc548
Change-Id: Ic37d1004e9606dc2d29d98d29f28743202dd5683
2024-11-18 23:09:16 -05:00
MusikAnimal 13c9eae26e CodeMirrorPreferences: add panel to tweak prefs with the editor open
This is toggled by pressing Mod-Shift-, (or Command-Shift-, on MacOS),
which then puts focus on the preferences panel. It can be closed with
the Escape key, just like other CM panels.

The CodeMirror class comes with these extension which can be toggled in
preferences:
* Bracket matching
* Line numbering
* Line wrapping
* Highlight the active line
* Show special characters

Only bracket matching, line numbering, and line wrapping are available
in the 2017 editor.

The bidi isolation and template folding extensions are registered in
CodeMirrorModeMediaWiki as they are MW-specific. CodeMirrorPreferences'
new registerExtension() method allows any consumer of CodeMirror to add
any arbitrary extensions to the preferences panel. This is expected to
be called *after* CodeMirror has finished initializing. The
'ext.CodeMirror.ready' hook now passes the CodeMirror instance to
accommodate this.

The preferences are stored as a single user option in the database,
called 'codemirror-preferences'. The defaults can be configured with the
$wgCodeMirrorDefaultPreferences configuration setting. The
sysadmin-facing values are the familiar boolean, but since CodeMirror is
widely used, we make extra efforts to reduce the storage footprint (see
T54777). This includes only storing preferences that differ from the
defaults, and using binary representation instead of boolean values,
since the user option is stored as a string.

For now, all preferences are ignored in the 2017 editor. In a future
patch, we may add some as toggleable Tools in the VE toolbar.

Other changes:
* Refactor CSS to use a .darkmode() mixin
* Add a method to create a CSS-only fieldset in CodeMirrorPanel
* Fix Jest tests now that there are more calls to mw.user.options.get()
* Adjust Selenium tests to always use CM6
* Adjust Selenium tests to delete test pages (useful for local dev)
* Remove unused code

Bug: T359498
Change-Id: I70dcf2f49418cea632c452c1266440effad634f3
2024-11-18 22:23:22 -05:00
MusikAnimal 5d6d0ba56a extension.json: set default user option for usecodemirror-colorblind
This preference doesn't have a default value, meaning any and all values
are saved when it should only save if it doesn't match the default. This
causes bloat to the user_properties table (see T286270 for the same
situation that happened with the 'usecodemirror' preference).

This patch sets a default value so that only values different than it
are stored.

Bug: T286270
Change-Id: Ie9fc1f4265a6f6df2bc2cc4e99ad4294a76e2769
2024-11-13 02:04:05 -05:00
Translation updater bot a1415b27ac
Localisation updates from https://translatewiki.net.
Change-Id: I4c547c321bed98305ec2b6d90ea3cbc6446e6c43
2024-11-12 08:17:29 +01:00
Translation updater bot 57b6aa9ee2
Localisation updates from https://translatewiki.net.
Change-Id: I649f015a8970fb96c2c73942c6eeec2ec6807bbb
2024-11-11 08:22:09 +01:00
Translation updater bot c412a73fb8
Localisation updates from https://translatewiki.net.
Change-Id: I408bc2b7e6ab5f35a98be57a94ee0e39f7603f1f
2024-11-08 08:28:18 +01:00
MusikAnimal f4cf12b383 ve.ui.CodeMirror.v6: use DOMRect width when updating gutter width
This fixes some Chromium-specific issues where offsetWidth was rounded
up and could cause misalignment issues. It does not fix all alignment
issues, but should hopefully be an improvement in most cases.

Other changes:
* Add Core VE padding to match CM5 variant (doesn't affect WMF cluster)
* Remove redundant margin rules from VE surface
* Minor code cleanup

Bug: T357482
Change-Id: Ic4246c0b8c39914021bbc2a84d52b332dafec20a
2024-11-05 23:41:06 -05:00
jenkins-bot 0ebd773243 Merge "CodeMirror support for WikiEditor keyboard shortcuts" 2024-11-05 16:12:34 +00:00
Translation updater bot 4770cb4c3a
Localisation updates from https://translatewiki.net.
Change-Id: Ie2e1351e68cd7b86034ebc1b39001b123cbad0f9
2024-11-05 08:32:03 +01:00
Translation updater bot 93ed8014a3
Localisation updates from https://translatewiki.net.
Change-Id: Id23e2ee7484d1c83d56f2031f5076b6a0b052367
2024-11-04 08:21:12 +01:00
bhsd 081f0a17af templateFoldingExtension: hide tooltip when typing
Temporary solution to T367256 before a folding gutter is applied. Hide the folding tooltip when typing, and make the tooltip semi-transparent until hovered.

Bug: T367256
Change-Id: I3ee3de737aa36692d094a54e0eea94d6f5690767
2024-11-02 15:16:16 +08:00
libraryupgrader 7efeb2ff11 build: Updating mediawiki/mediawiki-codesniffer to 45.0.0
Change-Id: I00edd943d064c39f878f0bf1ec01ccdc9e80d659
2024-11-02 04:47:15 +00:00
jenkins-bot 140ac0cdb0 Merge "CodeMirrorSearch: add num results and current selection; improve tabbing" 2024-11-01 05:52:50 +00:00
MusikAnimal 3c3050447b CodeMirrorSearch: add num results and current selection; improve tabbing
Just like the 2017 editor, we show the number of results and which one
is currently highlighted.

This patch also brings the Tab behaviour closer to the 2017 editor.
Hitting Tab from the search input focuses the replace input, followed by
the replacement buttons, then the find buttons, then the content
editable. Shift+Tab largely does the reverse, except Shift+Tab from the
editor doesn't bring you to the search panel. Doing this would require a
lot of work for minor benefit, as we'd need to determine which panel to
focus to.

Add basic unit test

Bug: T371436
Change-Id: I968f91320ecb6ab9e9da0994052d33c76f85974b
2024-10-31 18:25:05 -04:00
MusikAnimal c4286f2bef ve.ui.CodeMirror.v6: don't auto-flip CSS rules affecting gutter
RTL rules within and around the content need to apply to the content
language, not the interface language, so we want to disable the normal
CSSJanus auto-flipping.

Bug: T357482
Bug: T374196
Change-Id: If0becbf7e0baa61118a22af375be0d107567226d
2024-10-31 16:22:12 -04:00
jenkins-bot cac24f0fa6 Merge "selenium: Delete 'CodeMirror bracket match highlighting for the wikitext 2017 editor'" 2024-10-31 17:47:06 +00:00
MusikAnimal 2f4c265ba9 ve.ui.CodeMirror.v6: use view's direction when updating gutter width
I74bcbc46b0 erroneously passed the model's directionality (how it is
saved) and not the view. This caused misalignment issues when changing
directionality.

Bug: T374196
Follow-Up: I74bcbc46b0b62ff2ed138fe57d852a3cd87c22d0
Change-Id: I81e863e19d6d0bad2cc2be743df896e17a8dc548
2024-10-31 00:38:47 -04:00
Translation updater bot e87db823f3
Localisation updates from https://translatewiki.net.
Change-Id: I768adf6767f0e1e2bc344e4b8e7e0b37531e302f
2024-10-28 08:21:50 +01:00
Translation updater bot 9c13028f12
Localisation updates from https://translatewiki.net.
Change-Id: I625c8d853d02be6664c70afacd2fd23a9214a62d
2024-10-21 09:19:46 +02:00
Umherirrender 75428fa046 Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: Ic474721ccdb77614f46b0237251927e04b2f183d
2024-10-19 23:29:39 +02:00
Siddharth VP bc897f3002 CodeMirror support for WikiEditor keyboard shortcuts
Forward keydown events on the CodeMirror DOM element to the #wpTextbox1
element, on which WikiEditor's handlers are registered.

CM6 support to come later.

Bug: T62928
Depends-On: I18db5b6c53000457524573a9ae06939e8df0dc4f
Change-Id: I0e67f2db6b29636fe25583e926a9fb12a69e3851
2024-10-17 13:55:28 +05:30
Željko Filipin 37159fdae4 selenium: Delete 'CodeMirror bracket match highlighting for the wikitext 2017 editor'
The entire file was disabled more that 6 months ago.

Bug: T280652
Change-Id: I4fe43a15a35c51c3d84ab4061dff579f4f00fdc3
2024-10-15 12:01:48 +02:00
Translation updater bot 7add5426ea
Localisation updates from https://translatewiki.net.
Change-Id: I6654e248d55c964c519b37ceefb3c13d12cae6ab
2024-10-14 09:28:45 +02:00
Translation updater bot f26c3a8058
Localisation updates from https://translatewiki.net.
Change-Id: I67ed443c460e29d8eb67aabb0af0d00a79fe31bd
2024-10-07 09:25:22 +02:00
Translation updater bot ea4541b775
Localisation updates from https://translatewiki.net.
Change-Id: I6d32a192d4c7157ace9ff41cc39aabb456814d0b
2024-10-01 09:37:05 +02:00
Translation updater bot 20e9b86a28
Localisation updates from https://translatewiki.net.
Change-Id: Id53c1bee9ce52a934ab014d646102a152e6724b4
2024-09-30 09:20:46 +02:00
Translation updater bot c867ff594f
Localisation updates from https://translatewiki.net.
Change-Id: Ia3f52be7871f943cdd12f877eb812eab63299db1
2024-09-27 09:18:19 +02:00
Translation updater bot 8ad93bdc50
Localisation updates from https://translatewiki.net.
Change-Id: I81c8e65f19693ec50504dc09f22c6967449c2ee6
2024-09-25 09:17:21 +02:00
libraryupgrader ab9d06c7eb build: Updating rollup to 4.22.4
Change-Id: I1b340e39467f574abc5f1d3d3740aa2e81add198
2024-09-24 00:56:45 +00:00
Translation updater bot e3113cf1bc
Localisation updates from https://translatewiki.net.
Change-Id: I2b3b14dfcbd76942ee1a5e5ddc5383633902a21d
2024-09-23 09:21:07 +02:00
jenkins-bot a32d8005ea Merge "Remove $wgCodeMirrorRTL as redundant config setting" 2024-09-19 17:09:17 +00:00
Translation updater bot 63a49bbe28
Localisation updates from https://translatewiki.net.
Change-Id: I30145fe0a9b34fda3007d8652078e2e94e633720
2024-09-19 09:17:58 +02:00
Translation updater bot 293606db65
Localisation updates from https://translatewiki.net.
Change-Id: I0b9ed1626e0055b646f496e7f6911b7072669a9b
2024-09-18 09:18:41 +02:00
Translation updater bot cb9a82fa0d
Localisation updates from https://translatewiki.net.
Change-Id: I398d6d7e3d9b05cd1ea1d039249eeeba644f6d20
2024-09-17 09:26:51 +02:00
Translation updater bot 4d1619c8a3
Localisation updates from https://translatewiki.net.
Change-Id: I1feeed69abdb34a710eaf651fe0ab6e5078472e0
2024-09-16 09:25:36 +02:00
thiemowmde f5a5598ba4 Make use of upstream markTestSkippedIfExtensionNotLoaded
This does the same as before.

Also:
* Make use of more fitting ??= operator.
* We can use & for union types, I believe.

Change-Id: I359408473882a9337b40ec464562a4358f8d3241
2024-09-13 12:38:53 +02:00
libraryupgrader 3b6e74ded4 build: Updating path-to-regexp to 6.3.0
* https://github.com/advisories/GHSA-9wv6-86v2-598j

Change-Id: Ia251367fc7be5d1d2ba94e2b5e1808e5266bdb7a
2024-09-12 02:17:10 +00:00
Translation updater bot fe4770e96f
Localisation updates from https://translatewiki.net.
Change-Id: I070793164c7b347d41393f10aa415bfc1460d5da
2024-09-09 09:22:16 +02:00
Translation updater bot c587a83a50
Localisation updates from https://translatewiki.net.
Change-Id: Idc5b8af4ac5acad8c0b11fd6e713b53fb8f22530
2024-09-06 09:39:03 +02:00
Translation updater bot b8cf07f86f
Localisation updates from https://translatewiki.net.
Change-Id: I5943df57e0abe8c8892b21d2c325b2b8cde7217a
2024-09-05 09:23:03 +02:00
jenkins-bot 23325fe19b Merge "ve.ui.CodeMirror.init: make cm6enable=1 query param work for 2017 editor" 2024-09-05 03:32:46 +00:00
jenkins-bot 7d56c5ee8a Merge "ve.ui.CodeMirror.v6: update gutter width after CM view is updated" 2024-09-05 03:32:45 +00:00