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
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
And convert the disable statements to individual ones so LibUp can
automatically push the next upgrade.
Change-Id: Id5fbfb4ebf4641c7577a4e2be2ab8bae678227c7
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
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
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
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
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
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
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
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
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
This is only done for wikitext because CJK brackets can cause unexpected
errors in other languages.
Bug: T362992
Change-Id: Icf98e8fd7e0392845df2e3b7d3201e7f94f95a3f
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