13c9eae26e
This is toggled by pressing Mod-Shift-, (or Command-Shift-, on MacOS), which then puts focus on the preferences panel. It can be closed with the Escape key, just like other CM panels. The CodeMirror class comes with these extension which can be toggled in preferences: * Bracket matching * Line numbering * Line wrapping * Highlight the active line * Show special characters Only bracket matching, line numbering, and line wrapping are available in the 2017 editor. The bidi isolation and template folding extensions are registered in CodeMirrorModeMediaWiki as they are MW-specific. CodeMirrorPreferences' new registerExtension() method allows any consumer of CodeMirror to add any arbitrary extensions to the preferences panel. This is expected to be called *after* CodeMirror has finished initializing. The 'ext.CodeMirror.ready' hook now passes the CodeMirror instance to accommodate this. The preferences are stored as a single user option in the database, called 'codemirror-preferences'. The defaults can be configured with the $wgCodeMirrorDefaultPreferences configuration setting. The sysadmin-facing values are the familiar boolean, but since CodeMirror is widely used, we make extra efforts to reduce the storage footprint (see T54777). This includes only storing preferences that differ from the defaults, and using binary representation instead of boolean values, since the user option is stored as a string. For now, all preferences are ignored in the 2017 editor. In a future patch, we may add some as toggleable Tools in the VE toolbar. Other changes: * Refactor CSS to use a .darkmode() mixin * Add a method to create a CSS-only fieldset in CodeMirrorPanel * Fix Jest tests now that there are more calls to mw.user.options.get() * Adjust Selenium tests to always use CM6 * Adjust Selenium tests to delete test pages (useful for local dev) * Remove unused code Bug: T359498 Change-Id: I70dcf2f49418cea632c452c1266440effad634f3 |
||
---|---|---|
.phan | ||
i18n | ||
includes | ||
resources | ||
tests | ||
.eslintignore | ||
.eslintrc.json | ||
.gitignore | ||
.gitreview | ||
.nvmrc | ||
.phpcs.xml | ||
.stylelintrc.json | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
COPYING | ||
extension.json | ||
jest.config.js | ||
jsdoc.json | ||
package-lock.json | ||
package.json | ||
README.md | ||
rollup.config.js |
The CodeMirror extension provides syntax highlighting in MediaWiki wikitext editors using the CodeMirror library.
CodeMirror 6 homepage: https://www.mediawiki.org/wiki/Extension:CodeMirror/6
JS documentation: https://doc.wikimedia.org/CodeMirror
Development
Preface
Extension:CodeMirror is currently in the process of being upgraded to the new major version, CodeMirror 6. See the change log for details.
Use of CodeMirror 6 is controlled by the wgCodeMirrorV6
configuration setting, or by
passing in cm6enable=1
in the URL query string.
CodeMirror 6 requires the use of NPM to bundle the dependencies. These are bundled in
resources/codemirror.bundle.js, built using Rollup,
and packaged as the ext.CodeMirror.v6.lib
ResourceLoader module. If you make changes to the
versions of the dependencies, you will need to run npm run build
to update the ResourceLoader module.
NPM commands
NOTE: Consider using Fresh to run these tasks.
npm install
to install dependencies.npm run doc
to generate the API documentation.npm test
to run the linting tools, JavaScript unit tests, and build checks.npm run test:lint
for linting of JS/LESS/CSS.npm run test:lint:js
for linting of just JavaScript.npm run test:lint:styles
for linting of just Less/CSS.npm run test:i18n
for linting of i18n messages with banana-checker.npm run test:unit
for the new Jest unit tests.npm run selenium-test
for the Selenium tests.npm run build
to rebundle the CodeMirror library. If changes are made to the@codemirror
or@lezer
dependencies in package.json, this command must be run before sending the patch or CI will fail.- Older QUnit tests are in
resources/mode/mediawiki/tests/qunit/
. These have been replaced and will be removed after the CodeMirror 6 upgrade is complete.