For users of the 2003 editor (or if WikiEditor is not available), the
user is supposed to still be able to toggle CodeMirror on and off using
the visible preference in the new 'Syntax highlighting' section of
Special:Preferences. This patch fixes that, restoring use of standalone
CodeMirror for those who have the beta feature on but WikiEditor off.
This patch also fixes a bug that prevented 2017 editor users from
getting CM6 via the beta feature.
Bug: T376735
Change-Id: I69562ee1f936050301900ee80ab1aa8eaf92ec0d
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
TODO: Change the PluginModules in extension.json when fully migrated
to v6 and drop this hack.
Bug: T374072
Change-Id: I5f06af67928c491db330d9761084d8740cfc2487
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
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
Don't list beta feature if $wgCodeMirrorV6 is true
Move all images to new images directory
Bug: T376735
Change-Id: I3ce25cccb7c66fbf5c719e6b704af9c22f405876
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
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
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
Autocomplete magic words, tag names and url protocols. This patch also enables block comment using `<!-- -->`.
Bug: T95100
Change-Id: If37da956ac1eb945b96753e6728c0247b1a68b66
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
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
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
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
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
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