CodeMirror 5 does not work on RTL pages. This commit does a crude check
of the `dir` attribute of `.mw-body-content .mw-parser-output` because
the VisualEditor surface and even the native textarea isn't available
when the module is first loaded.
Bug: T363752
Change-Id: If3825d6e5467d2bcff2d83e838081bf041243920
Add highlighting for a special one-line definition list syntax `;a:b`. Also highlight `;a` in bold.
Bug: T170042
Change-Id: Ia3bdf481469368fcb5a7651729dde4b5f3682ed8
A 'ext.CodeMirror.input' hook is added to give integrations direct
access to the ViewUpdate object when changes are made in CodeMirror.
Bug: T174811
Change-Id: Idb6166996abb7d64ac8a956f362aea5eda0392bc
Documentation is at https://w.wiki/9kxt
The idea is that modules ending in `.init` imply they initialize
CodeMirror and maniuplate the DOM. The others only export classes for
use in integreations.
In doing so, 'ext.CodeMirror.v6.WikiEditor' now only exports the
CodeMirrorWikiEditor class, while 'ext.CodeMirror.v6.WikiEditor.init'
is added for use on #wpTextbox1 through action=edit.
Bug: T174811
Change-Id: Iec62ac9dc77918904bed886d2d46ccc03e0927f7
We want to get moving on rolling out CodeMirror 6 to LTR wikis, but want
to slow rollout to RTL wikis since we are still ironing out some issues
there, specifically T358804.
Bug: T170001
Bug: T358804
Change-Id: Iac30ffe2746139326159fd406fab3b097b3187f5
Bidi isolation is still not exactly 'stable'. Instead of removing it, we
look for the URL query param `cm6bidi=1`. This allows users to test out
bidi isolation and give feedback as we iterate on it. Once stable, this
should be removed and bidi isolation should be on by default -- and
eventually, can be opted out of via CodeMirror preferences (T359498).
Bug: T358804
Change-Id: If7e024f0da71ddf1b0a38c0fc49f033ddbe745fd
The number sign in `[[Link#Section]]` is supposed to have the class
.cm-mw-link, but didn't because it was missing a TagStyle which actually
gives it the CSS class. Now it does.
Add test case for all known CSS classes.
Bug: T348019
Follow-Up: I8f8a81f362bed60dea14ecde9487a2b0c89225e8
Change-Id: I613f8bead76523fbe1a9f05ed75d81893b8737d3
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
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
We don't have access to the HTML attributes for .cm-panels, so we just
use CSS to set the direction.
Bug: T359611
Change-Id: I1d40ae4f7dc093f585051d388c70cde151faa5e6
Restore the ResourceLoaderGetConfigVars hook which CodeMirror 5 still
relies on when it checks $wgCodeMirrorLineNumberingNamespaces.
In CM6, this is set in the config provided by DataScript.php.
Partially reverts I67518c0968
Bug: T347211
Follow-Up: I67518c0968f64c79e290f57b4884d30a161212d3
Change-Id: Id34858da68f7e08d16f8d1312bbbd355ccf8d140
Realtime Preview is unique to WikiEditor, so we only add support in
CodeMirrorWikiEditor.
Bug: T360708
Change-Id: I2122a114359c74d311777b5f2872149e64d95254
The Tab key should navigate to the edit summary from the editor, or to
the Realtime Preview pane if it is open.
Change-Id: I7810bfd098f6b9dd5afab9aa534685d3e4166af6
CodeMirror is meant to be used without WikiEditor, so we add a destroy()
method that does much the same things as CodeMirrorWikiEditor.
The hooks added with this patch aren't used by anything yet, but offer
feature parity with CodeMirrorWikiEditor, which fires the
'ext.CodeMirror.switch' hook. That hook can't be moved for
backwards-compatibility reasons.
The actual fix for T360075 here was to nullify the `textSelection` class
property.
Bug: T360075
Change-Id: Ife6a3f1ef90df66cd1bf8bab33c9ef3b39ed17a0
There is a known bug with JSDoc and using `export default`. These must
be separate statements for JSDoc to parse properly.
See https://github.com/jsdoc/jsdoc/issues/1132
Update README; change log now lives on the wiki.
Bug: T359986
Depends-On: I58a0766e35eddaf7bebe2c080757bb09963d8555
Change-Id: Ibc2212ef9eab512511b13a99ecc2ccbda8c52ece
See https://w.wiki/9Twh for example usage with ResourceLoader.
Webpack is retired in favor of Rollup, which allows us to convert the
ECMAScript Modules into CommonJS modules for use by ResourceLoader.
We now have a file in dist/ for each RL module that we want to offer,
including the 'lib' module which includes the CM library itself.
Because Rollup has no knowledge of the ResourceLoader module registry,
the generated output requires other modules via relative path, when it
needs to be the RL module name. To get around this, we do a crude
find/replace after the files are generated. Hacky, but necessary to make
CodeMirror usable by gadgets and scripts that don't also want
WikiEditor.
Add new RL modules 'ext.CodeMirror.v6.lib' (vendor code) and
'ext.CodeMirror.v6' (the main CodeMirror class, sans WikiEditor).
Clean up extension.json, listing the v6 modules beneath the old ones.
Bug: T214989
Change-Id: Ide716247e545cf2bdd977bea645729564ebbe6e2
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
We want CodeMirror to be usable outside WikiEditor. This commit moves
the more critical extensions from the CodeMirrorWikiEditor class to the
parent CodeMirror class.
The linked tasks are only broadly related. In Ide716247e5 we will
introduce a ResourceLoader module that makes CodeMirror usable on any
textarea.
Bug: T214989
Bug: T190108
Change-Id: Ib199cf700c3235812f7c9a9bcb3703917f0887de
This legacy CM5 test has always been flaky and is now consistently
failing. It can be reinstated with T357482, or not at all, seeing as
bracket matching is a core extension in CodeMirror 6 and probably
doesn't need a dedicated test on top of what's upstream.
Change-Id: I77362c1c47be902cc888682aae926154470f1a56
Now that RTP has been enabled for a while, we no longer need this and
jquery.ui is deprecated.
Bug: T323329
Change-Id: Idbb92bd4f18e2c6e0adc51d1a3fa909efc129686
Template folding is likely going to be a big 'hit' of a feature, but not
everyone will want it. Until CodeMirror prefs are introduced (T359498),
we need a way to control the rollout of template folding. This commit
adds $wgCodeMirrorTemplateFoldingNamespaces which acts similar to the
existing $wgCodeMirrorLineNumberingNamespaces.
We also move template folding to be part of CodeMirrorModeMediaWiki,
since the feature is unique to MediaWiki wikitext.
Move configuration settings to be part of the DataScript, thus removing
the need for the ResourceLoaderGetConfigVarsHook (which unnecessarily
makes the config settings available on every page load).
Other minor changes like adding missing JSDoc blocks.
Bug: T30684
Change-Id: I67518c0968f64c79e290f57b4884d30a161212d3