Expand all

ext.CodeMirror.v6.modes

This module provides syntax highlighting for JavaScript, JSON, CSS, Lua, and Vue in CodeMirror. Each mode is exposed as a method that returns a LanguageSupport-compatible instance that can be used with the CodeMirror constructor.

For MediaWiki wikitext syntax highlighting, use ext.CodeMirror.v6.mode.mediawiki.

Example

const require = await mw.loader.using( [ 'ext.CodeMirror.v6', 'ext.CodeMirror.v6.modes' ] );
const CodeMirror = require( 'ext.CodeMirror.v6' );
const { javascript, css } = require( 'ext.CodeMirror.v6.modes' );
const cmJs = new CodeMirror( myJsTextarea, javascript() );
cmJs.initialize();
const cmCss = new CodeMirror( myCssTextarea, css() );
cmCss.initialize();
Source:

Methods

css() → {CodeMirrorCss|LanguageSupport}inner #

Source:

Returns:

LanguageSupport for the CSS mode.

Type
CodeMirrorCss | LanguageSupport

javascript() → {CodeMirrorJavaScript|LanguageSupport}inner #

Source:

Returns:

LanguageSupport for the JavaScript mode.

Type
CodeMirrorJavaScript | LanguageSupport

json() → {CodeMirrorJson|LanguageSupport}inner #

Source:

Returns:

LanguageSupport for the JSON mode.

Type
CodeMirrorJson | LanguageSupport

lua() → {CodeMirrorLua|LanguageSupport}inner #

Source:

Returns:

LanguageSupport for the Lua mode.

Type
CodeMirrorLua | LanguageSupport

vue() → {CodeMirrorVue|LanguageSupport}inner #

Source:

Returns:

LanguageSupport for the Vue mode.

Type
CodeMirrorVue | LanguageSupport