Commit graph

3 commits

Author SHA1 Message Date
MusikAnimal e1f397f048 CodeMirrorBidiIsolation: fix for when the tag is the first element
This fixes a careless error introduced in I1338afeefa where we don't do
a strict equality test and thus if the tag is the first element (at
position 0), the following bracket is also treated as the start
position. Here we simply do a strict equality test against null (the
reset value), and viola, several issues are fixed.

Bug: T358804
Change-Id: I86021d363ecc33a7551bc887439dc1902914026f
2024-04-09 22:04:45 -04:00
MusikAnimal 00f947e97f CM6: move bidiIsolation to be part of CodeMirrorModeMediaWiki
The extension is custom built for MediaWiki (i.e. handling of extension
tags like <ref> that aren't HTML tags), so it only makes sense to bundle
it as part of the MediaWiki language mode.

Resultantly, we can no longer check the direction of the textarea where
we enable bidi isolation, because the language mode should have no
knowledge of the textarea. Instead we offer a `config` object (akin to
other language modes offered by CodeMirror), with currently only one
option: `bidiIsolation`. It is the responsibility of the caller to
enable this where desired.

Also make templateFolding and CodeMirrorModeMediaWiki use
`export default` since they both only export one thing.

This commit is in preparation for Ide716247e5, where we need bidi
isolation separated from the CodeMirror class due to its dependency on
CodeMirrorModeMediaConfig.

Bug: T358804
Bug: T214989
Change-Id: If3211bd259bd7833919a627faabd86ae7aa81b53
2024-03-19 22:48:34 -04:00
MusikAnimal 18a92122ef CodeMirror 6: Add bidi isolation to HTML tags
HTML tags and similar markup may appear jumbled on RTL pages due to the
standard algorithm used for character placement. With this patch, we
detect all tags (HTML or MediaWiki-supplied) and wrap them with
<span class=cm-bidi-isolate>. This CSS class forces the content to be
LTR, making the tags easier to work with on RTL pages.

Bug: T358804
Change-Id: I1338afeefa16102d5cc8fd6c8a236c144e5cf81f
2024-03-11 17:34:41 -04:00