| 1 |
The CodeMirror extension provides syntax highlighting in MediaWiki wikitext editors using |
| 2 |
the [CodeMirror library](https://codemirror.net/). |
| 3 |
|
| 4 |
CodeMirror 6 homepage: [https://www.mediawiki.org/wiki/Extension:CodeMirror/6](https://www.mediawiki.org/wiki/Extension:CodeMirror/6) |
| 5 |
|
| 6 |
JS documentation: [https://doc.wikimedia.org/CodeMirror](https://doc.wikimedia.org/CodeMirror) |
| 7 |
|
| 8 |
## Development |
| 9 |
|
| 10 |
### Preface |
| 11 |
|
| 12 |
Extension:CodeMirror is currently in the process of being upgraded to the new major version, CodeMirror 6. |
| 13 |
See the [change log](https://www.mediawiki.org/wiki/Extension:CodeMirror/6#Change_log) for details. |
| 14 |
|
| 15 |
Use of CodeMirror 6 is controlled by the `wgCodeMirrorV6` configuration setting, or by |
| 16 |
passing in `cm6enable=1` in the URL query string. |
| 17 |
|
| 18 |
CodeMirror 6 requires the use of NPM to bundle the dependencies. These are bundled in |
| 19 |
[resources/codemirror.bundle.js](resources/codemirror.bundle.js), built using [Rollup](https://rollupjs.org/), |
| 20 |
and packaged as the `ext.CodeMirror.v6.lib` ResourceLoader module. If you make changes to the |
| 21 |
versions of the dependencies, you will need to run `npm run build` to update the ResourceLoader module. |
| 22 |
|
| 23 |
### NPM commands |
| 24 |
|
| 25 |
_NOTE: Consider using [Fresh](https://gerrit.wikimedia.org/g/fresh/) to run these tasks._ |
| 26 |
|
| 27 |
* `npm install` to install dependencies. |
| 28 |
* `npm run doc` to generate the API documentation. |
| 29 |
* `npm test` to run the linting tools, JavaScript unit tests, and build checks. |
| 30 |
* `npm run test:lint` for linting of JS/LESS/CSS. |
| 31 |
* `npm run test:lint:js` for linting of just JavaScript. |
| 32 |
* `npm run test:lint:styles` for linting of just Less/CSS. |
| 33 |
* `npm run test:i18n` for linting of i18n messages with banana-checker. |
| 34 |
* `npm run test:unit` for the new Jest unit tests. |
| 35 |
* `npm run selenium-test` for the Selenium tests. |
| 36 |
* `npm run build` to rebundle the CodeMirror library. If changes are made to the `@codemirror` |
| 37 |
or `@lezer` dependencies in [package.json](package.json), this command *must* be run before |
| 38 |
sending the patch or CI will fail. |
| 39 |
* Older QUnit tests are in `resources/mode/mediawiki/tests/qunit/`. These have been |
| 40 |
replaced and will be removed after the CodeMirror 6 upgrade is complete. |