Commit graph

1190 commits

Author SHA1 Message Date
MusikAnimal 2ad096a580 ve.ui.CodeMirrorAction.v6: use infinity viewport to avoid misalignment
The 2017 editor has an infinite viewport, meaning the entire document is
printed on page load. CodeMirror 6 meanwhile only processes text in the
visible viewport. This presents a situation where if large chunks of
text are inserted outside the visible range (such as the "Changes
recovered" feature of VE), it can cause misalignment of the VE surface
and visible CodeMirror layer, as CodeMirror has not accounted for the
off-screen lines of text.

CodeMirror 5 had a `viewportMargin: infinity` option that prevented this
issue, but at the cost of performance. CodeMirror 6 removed this option,
but the same effect can be achieved by tricking CodeMirror into thinking
we're printing the document, in which case it will process all lines.
This seriously hurts performance, and is a nasty hack, but until the
2017 editor is reworked to have a viewport, there may be no other means
to prevent the misalignment.

The discovery of this issue and the fix are courtesy of Fandom engineers

Bug: T357482
Change-Id: If11ce48459e8faf55015108e8c2eabdc16e0d917
2024-08-20 14:08:04 -04:00
Translation updater bot a921171236
Localisation updates from https://translatewiki.net.
Change-Id: Ic80bf56c8809a2cd13beaf405c251fc5eacff4dc
2024-08-20 09:42:01 +02:00
John Bolorinos 608c799aa8 selenium: Document when, how and why a test is skipped
Bug: T280652
Change-Id: I065c6ff4f50626904fde2d3e676c4b71d62c43e0
2024-08-19 15:02:18 +02:00
Translation updater bot 84c9051241
Localisation updates from https://translatewiki.net.
Change-Id: Iad21458855117c703abd5a10edaebbad69e568cf
2024-08-19 09:22:41 +02:00
MusikAnimal 1413e288c6 Hooks: use CM6 wording for colorblind preference
The message existed since I4bc069e0d3 but accidentally went unused.

Change-Id: Ic03ec526d7f807e6031e495f033c6fce1b6bb51a
2024-08-15 01:33:43 -04:00
bhsd f23f487028 CodeMirrorModeMediaWiki: indented table
This is a follow-up of the patch 1032770, which misses one type of indented table in the test. It also specifies a unified `cm-mw-indenting` CSS class for all types of table indentation.

Bug: T108454
Change-Id: I77174cf3fa56382add6d80bf2ec7106c9b2cb642
2024-08-15 12:59:13 +08:00
jenkins-bot 75710d6d05 Merge "CodeMirrorModeMediaWiki: various small fixes" 2024-08-15 03:10:01 +00:00
jenkins-bot 2973880c28 Merge "CodeMirror: add Ctrl+Shift+z as redo shortcut on Windows" 2024-08-14 23:10:58 +00:00
jenkins-bot 61d71a5f53 Merge "Use dispatchEvent instead of jQuery triggerHandler for focus/blur events" 2024-08-14 23:10:56 +00:00
jenkins-bot c079dab531 Merge "CodeMirror 6 for VE 2017 wikitext editor" 2024-08-14 08:57:35 +00:00
Translation updater bot 76daceca00
Localisation updates from https://translatewiki.net.
Change-Id: I4afa253d54f04fc2cc1ac078aa3153adb3696b39
2024-08-14 09:22:15 +02:00
Translation updater bot 601809c398
Localisation updates from https://translatewiki.net.
Change-Id: Ie18f6ee98278aa546985c465449c29286bf68932
2024-08-13 09:50:22 +02:00
libraryupgrader 4fd186c142 build: Updating mediawiki/mediawiki-codesniffer to 44.0.0
Change-Id: I8e4e1901da3f1bd416d7dc2c85fbaa5ac9fb20c0
2024-08-11 04:36:17 +00:00
Taavi Väänänen 7e0d3cf2fd
build: Upgrade stylelint-config-wikimedia to 0.17.2
And convert the disable statements to individual ones so LibUp can
automatically push the next upgrade.

Change-Id: Id5fbfb4ebf4641c7577a4e2be2ab8bae678227c7
2024-08-10 08:03:19 +03:00
MusikAnimal 27b6aaebcc CodeMirrorWikiEditor: use new icon and add text to toggle button
For years, users have complained that the CodeMirror toggle button is
confusing and concealed. The icon looked too similar to the edit icon,
when it was supposed to be a highlighter. The new icon is similar but
has a highlighted line to help clarify what it is. We also now have the
text 'Syntax' accompanying the icon. Translators are instructed to try
to be brief to conserve space in the toolbar. "Syntax highlighting" is
the full correct term, and remains the text for the button's tooltip.

The new icon is ~0.3KB uncompressed, just meeting performance guidelines
for using @embed <https://w.wiki/AsPW>. This is also only temporary until the icon is upstreamed in Codex/OOUI.

New icon courtesy of Thiemo Kreuz (WMDE)

A corresponding change for the 2017 editor will follow I15453b33e7.

Bug: T174145
Change-Id: Ib6dbfc261214ed6672c1a54738e3401fa2f5d262
2024-08-09 06:08:33 +00:00
Translation updater bot f7d64fd0ee
Localisation updates from https://translatewiki.net.
Change-Id: I9c6f2b49bf726d8c51e0e90de14c6d9a78a92b9d
2024-08-06 09:46:18 +02:00
MusikAnimal bdb8e008df CodeMirror: add Ctrl+Shift+z as redo shortcut on Windows
This worked in CM5, so we'll retain it in CM6 for those who have the
muscle memory.

Bug: T365072
Change-Id: I4d45ca03773b5140f3e39e15bfba664b577c055d
2024-08-05 15:11:41 -04:00
MusikAnimal f9ecb5b2de Use dispatchEvent instead of jQuery triggerHandler for focus/blur events
triggerHandler will not bubble up the DOM, which is necessary for some
listeners such as Charinsert.

This patch applies the fix to both CodeMirror 5 and CodeMirror 6.

Bug: T361465
Change-Id: I4c01b031de0b19d72b6f2c31566a7f9cc0b02ad8
2024-08-05 13:45:06 -04:00
bhsd 925775778a CodeMirror 6 for VE 2017 wikitext editor
Add new temporary ext.CodeMirror.visualEditor.init RL module which
selects the temporary ext.CodeMirror.visualEditor.v6 or non-v6 based on
$wgCodeMirrorV6. This will allow us to deploy CM6 further.

As a result of this work, the core CodeMirror class now has knowledge
of ve.ui.Surface.

Other changes:
* Add Compartment for specialCharsExtension so it can be disabled in VE.
* Add option to mediaWikiLang() to disable template folding.
* Add support for RTL wikis where $wgCodeMirrorRTL is enabled.
* Make CodeMirror.logUsage() and setCodeMirrorPreference() static.
* Fix unit and linting tests.

Some code courtesy of Fandom, GPLv2-or-later; see:
https://github.com/Wikia/mediawiki-extensions-CodeMirror/commit/ef297c48c

Bug: T357482
Change-Id: I15453b33e77e1c1b4d5e5183e41e53d56ff14c3e
2024-08-01 03:15:21 -04:00
bhsd 8ba52cdfcb CodeMirrorModeMediaWiki: various small fixes
This patch fixes a few minor issues in the tokenizer, including indented table (T108454), tag name followed by punctuations (T357720), free external link ending with `~` and `'` (T358643), and Hebrew parser function containing whitespace (T170004).

Bug: T108454
Bug: T357720
Bug: T358643
Bug: T170004
Change-Id: Ib3fff9ea8f9045d885ecfb1dc58c72f5afb8877a
2024-08-01 02:03:17 -04:00
MusikAnimal 7d3482f89e Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.

CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.

This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.

This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.

Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)

Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-07-31 22:45:48 -04:00
jenkins-bot f3be172173 Merge "Apply color inversion until dark syntax styles are chosen" 2024-07-29 16:11:07 +00:00
Translation updater bot e4581a0709
Localisation updates from https://translatewiki.net.
Change-Id: Ieebb12aee6a8be9a67c81d3af95b0bd4e81227e3
2024-07-29 09:26:16 +02:00
Sjoerd de Bruin c25da847c2 Apply color inversion until dark syntax styles are chosen
Bug: T365311
Change-Id: I72cf4e5ca776e7fda11b07174493696bfde7fde0
2024-07-27 21:37:47 +00:00
bhsd 0e0e4927ab codemirror.mediawiki.js: add Mod-Shift-x
This patch adds a keyboard shortcut `Mod-Shift-x` to toggle between left-to-right (LTR) and right-to-left (RTL) text directions.

Bug: T170001
Change-Id: Ia857ad0b0aff0bb206b45e4d27dee6e91a3effce
2024-07-20 17:29:09 +08:00
Translation updater bot 999382fd16
Localisation updates from https://translatewiki.net.
Change-Id: Iecc5ff3b0f6c6fad86812e1557bcf4249f308085
2024-07-18 09:22:26 +02:00
Translation updater bot e229edaf75
Localisation updates from https://translatewiki.net.
Change-Id: I1ec995a128047fc153a26b08463aab1b37e2f394
2024-07-16 09:39:20 +02:00
jenkins-bot a1770cb3e8 Merge "build: Update jsdoc-wmf-theme to 1.1.0" 2024-07-08 13:34:52 +00:00
Fomafix e0dc1c0c32 Use service 'GadgetsRepo' instead of deprecated GadgetRepo::singleton()
The service 'GadgetsRepo' gets injected as optional service.

This change requires a phan dependency on extension Gadgets in
project integration/config in file zuul/parameter_functions.py:
I5052e0c666b7dc7af6061e57001f9feac666e029

Change-Id: Ib405ad79b3c348bed51a8938a6a8f73bd35267d2
2024-07-01 09:32:50 +00:00
Ed Sanders 17fefeb8fb build: Update jsdoc-wmf-theme to 1.1.0
Bug: T368081
Change-Id: I188c5549415f4620bb95df2e285c5519bc97ead1
2024-06-26 12:09:52 +01:00
MusikAnimal 08730d2a85 CM5 mediawiki.less: Inherit font color from skin
This is a short-gap measure to make the 2017 editor + dark theme more
readable. Implementing a dark theme for all of the MediaWiki tokens will
come in a future patch.

Bug: T365311
Change-Id: Ie56b88960eb0d27e9a1f821101dfa14af37c0130
2024-06-25 00:43:18 +00:00
Ed Sanders b3316356c0 Remove unnecessary local context variables
Change-Id: If73c0cfca93711003ece3332c9cdc6f3e3fa4944
2024-06-22 10:26:58 +01:00
Ed Sanders f0fb93d3e1 ESLint: Enforce prefer-const
Change-Id: I7f45137a47dddcd2fc70201f28680edce907b522
2024-06-22 10:26:58 +01:00
Ed Sanders 1b101f09ee ESLint: Update syntax to ES6 and autofix
Change-Id: I613cc64a9bf3f375a40f75a1441b83f181a2ab42
2024-06-22 10:26:58 +01:00
Ed Sanders 6958b99f2e build: Update eslint-config-wikimedia to 0.28.2 and autofix
Change-Id: I622f53bf5f56782b7a0529cdc6bb27c1315ff5a0
2024-06-17 13:02:26 +00:00
James D. Forrester 170869190c HooksTest: Swap out use of deprecated getOptionKinds()
Change-Id: I992b102de6fc4e346d27d6a729c5b518a6d2fb3c
2024-06-14 11:34:06 -04:00
libraryupgrader f98b120974 build: Updating braces to 3.0.3
* https://github.com/advisories/GHSA-grv7-fg5c-xmjg

Change-Id: I637259940dcc6d3a3c1bec1cd6d75a671db921f9
2024-06-11 02:56:45 +00:00
Translation updater bot 3c741fd43c Localisation updates from https://translatewiki.net.
Change-Id: Ie9f17ba7a7f7417fb7cd5ee42aeadd777721554e
2024-06-10 09:54:59 +02:00
MusikAnimal 293a15725d ext.CodeMirror.visualEditor: check language dir of html for new pages
New pages do not have body content yet, so the LTR check added with
If3825d6e54 failed. This commit adds the document root (<html> element)
as the fallback, so CodeMirror can be used on new pages.

This is just a quick fix. CM6 for VE 2017 wikitext editor is almost
done, and that will come with RTL support (T357482).

Bug: T366201
Bug: T363752
Follow-Up: If3825d6e5467d2bcff2d83e838081bf041243920
Change-Id: I9d4a4b817ac2462396c159ceae6f1510c0fae64d
2024-05-30 23:48:05 -04:00
James D. Forrester 0c7044e764 .nvmrc: Update version from 18.17.0 to 18.20.2
Change-Id: Ie6b0918ff7cd627e9323e5f447c993f6b1448d8f
2024-05-30 22:04:13 -04:00
MusikAnimal 7856e62dea CodeMirror: +rectangularSelection and crosshairCursor as def extensions
These were default in CM5

To be added to the preferences panel once that's a thing (T359498)

Change-Id: I5a8b330444dd2dff0acfbd8e2d429a5b5273cd61
2024-05-21 22:52:08 -04:00
MusikAnimal 0e5fe342d9 CodeMirror: make bracket matching match CJK full-width brackets
This is only done for wikitext because CJK brackets can cause unexpected
errors in other languages.

Bug: T362992
Change-Id: Icf98e8fd7e0392845df2e3b7d3201e7f94f95a3f
2024-05-21 23:17:43 +00:00
Translation updater bot a21aa79e2d Localisation updates from https://translatewiki.net.
Change-Id: Ibcc25f7b10ec183fd83c14f459a9f0e62006bcd7
2024-05-20 09:24:50 +02:00
libraryupgrader 31815d8036 build: Updating grunt-banana-checker to 0.13.0
Change-Id: Ieeb3108280f96193a45dd8e5c5472ee97a985388
2024-05-18 03:53:50 +00:00
jenkins-bot 549539c3b5 Merge "rollup: speed up dev build by bypassing babel and terser plugins" 2024-05-14 02:12:23 +00:00
MusikAnimal 198a1f7d72 rollup: speed up dev build by bypassing babel and terser plugins
Brings it down from ~3 secs on my machine to ~600 ms.

This also allows for debuggers, and essentially eliminates the need
for source maps on your local (though we should probably still look
into them for prod).

Change-Id: I4c164b409b2c327e439e1524d4a898693bd8d907
2024-05-14 01:51:13 +00:00
jenkins-bot b23a901106 Merge "CM6: Add 'ext.CodeMirror.input' hook; improve code examples" 2024-05-14 01:48:35 +00:00
jenkins-bot d594143c04 Merge "CM6: Rework ResourceLoader modules" 2024-05-14 01:23:01 +00:00
jenkins-bot f4e9eb38e2 Merge "ext.CodeMirror.visualEditor: don't load on RTL pages" 2024-05-13 23:46:31 +00:00
Translation updater bot 2e3aac9a1e Localisation updates from https://translatewiki.net.
Change-Id: I91c6d789d652e152d42ba5567e54b71107b4453c
2024-05-13 09:26:46 +02:00