Commit graph

1243 commits

Author SHA1 Message Date
jenkins-bot c3689196ad Merge "CodeMirrorPanel: specify type="button" for ToggleButton" 2024-12-10 03:16:52 +00:00
jenkins-bot aac752edc7 Merge "CodeMirror: fix toggle-related issues" 2024-12-09 22:24:15 +00:00
Translation updater bot d8e078f1e8
Localisation updates from https://translatewiki.net.
Change-Id: I8cf03497a0f48fd431582d9d0bc0ce40f8f72cb2
2024-12-09 08:21:25 +01:00
bhsd 7ca5deebd3 CodeMirrorPanel: specify type="button" for ToggleButton
A button without the `type` attribute in a form is assumed to be the submit button. Obviously, the toggle buttons in a CM6 panel should not be one.

Bug: T381713
Change-Id: Ia732d49a3a61f85dd264d287ddd066b4d93e90c3
2024-12-07 13:58:11 +08:00
Func e75ca66a66 ve.ui.CodeMirror.v6: Use plugin callback to load the actual module
TODO: Change the PluginModules in extension.json when fully migrated
to v6 and drop this hack.

Bug: T374072
Change-Id: I5f06af67928c491db330d9761084d8740cfc2487
2024-12-07 09:36:54 +08:00
Translation updater bot 3d22ccc5a8
Localisation updates from https://translatewiki.net.
Change-Id: I42a97a0bd44b58a1f1ed813199a0aad82ea93340
2024-12-04 08:21:46 +01:00
bhsd f8a89ccf32 CodeMirror: fix toggle-related issues
The hook handlers and event listeners associated with `CodeMirror.prototype.initialize()` are now removed when CM is toggled off.

For 2017 Wikitext Editor, the focus is always set on the VE surface view.

Bug: T380840
Bug: T380983
Bug: T381358
Change-Id: Ib83f3d49c3d0496cb570f62e75f3fdc0d700be47
2024-12-04 13:23:48 +08:00
bhsd a91eb00b5d CodeMirror: indent with \t
Based on the discussion, the default indent unit should be `\t` instead of spaces.

Bug: T376351
Change-Id: Ib369501019e15c3d9bb7e83a6518c71896cecddc
2024-12-03 16:58:10 +08:00
Translation updater bot c4baf83933
Localisation updates from https://translatewiki.net.
Change-Id: I1f836697c32f043ed6c6782eb78cf5a41cb3895f
2024-12-02 08:21:39 +01:00
jenkins-bot ee76b6b446 Merge "mediaWikiLang: remove used hook handlers" 2024-12-02 05:46:13 +00:00
libraryupgrader d034df411d build: Updating jsdoc to 4.0.4
Change-Id: I67c82008faec77e191e8bc57f52dfafa0913accc
2024-12-02 00:52:19 +00:00
bhsd 60f450a773 mediaWikiLang: remove used hook handlers
Every time when `mediaWikiLang()` is called, a new handler is registered for the hook `ext.CodeMirror.ready`. This causes unexpected errors, so the used handler needs to be removed before registering a new handler.

Bug: T380840
Change-Id: I81bed58ec37a508e53a93895c7e20de358a658e0
2024-11-29 21:42:37 +08:00
Translation updater bot 4647e415d5
Localisation updates from https://translatewiki.net.
Change-Id: If9ef1cb1ca5feb67ac0c6835090073ca8dde18cd
2024-11-29 08:30:51 +01:00
Translation updater bot 55b81f755d
Localisation updates from https://translatewiki.net.
Change-Id: I2dcc41a48423a9cc5225388a86c75de2cadd655a
2024-11-27 08:20:06 +01:00
jenkins-bot be04b6c6e4 Merge "Add BetaFeature for CodeMirror 6" 2024-11-26 02:53:19 +00:00
jenkins-bot aef9282422 Merge "CodeMirrorWikiEditor: properly manage WikiEditor buttons" 2024-11-26 01:09:45 +00:00
MusikAnimal 6ad8e6231b Add BetaFeature for CodeMirror 6
Don't list beta feature if $wgCodeMirrorV6 is true

Move all images to new images directory

Bug: T376735
Change-Id: I3ce25cccb7c66fbf5c719e6b704af9c22f405876
2024-11-25 14:03:05 -05:00
MusikAnimal f62a2be966 CodeMirrorWikiEditor: properly manage WikiEditor buttons
Fixes an issue introduced with Ib65d47e989 where continually toggling on
and off CodeMirror would duplicate the search button exponentially, even
leading to browser crashes.

Create a new 'codemirror' toolbar group for the prefs button, styling it
just like the search group, and use WikiEditor's removeToToolbar() to
remove it.

Remove now redundant CSS classes.

Bug: T359498
Follow-Up: Ib65d47e98908b6a888d24157a235de4efe95a33b
Change-Id: If8ae9c0b04b2edcb30a5b8cd788214598a492d30
2024-11-25 02:37:57 -05:00
Translation updater bot 0c25c1745d
Localisation updates from https://translatewiki.net.
Change-Id: I6c9af893093cfaad20810b231f6ebecc20ae9763
2024-11-25 08:22:51 +01:00
jenkins-bot b61fe12dfe Merge "CodeMirrorSearch: catch exceptions from invalid regex input" 2024-11-22 23:21:05 +00:00
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 0906e75c94
Localisation updates from https://translatewiki.net.
Change-Id: Id5c298dca0d16de5ce38bb29810c6f05db980720
2024-11-22 08:41:05 +01:00
jenkins-bot d8cc644b99 Merge "CodeMirrorWikiEditor: add button to open preferences panel" 2024-11-21 18:37:47 +00:00
MusikAnimal efcf59e996 CodeMirrorWikiEditor: add button to open preferences panel
Add a 'Settings' button next to the search button in the advanced menu.

Refactor CodeMirrorPreferences to use its own toggle method.

Bug: T359498
Change-Id: Ib65d47e98908b6a888d24157a235de4efe95a33b
2024-11-21 13:05:52 -05: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