Expand all

ext.CodeMirror.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.mode.mediawiki.

Example

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

Methods

css() → {CodeMirrorCss|LanguageSupport}inner #

Returns:

LanguageSupport for the CSS mode.

Type
CodeMirrorCss | LanguageSupport
Source:

javascript() → {CodeMirrorJavaScript|LanguageSupport}inner #

Returns:

LanguageSupport for the JavaScript mode.

Type
CodeMirrorJavaScript | LanguageSupport
Source:

json() → {CodeMirrorJson|LanguageSupport}inner #

Returns:

LanguageSupport for the JSON mode.

Type
CodeMirrorJson | LanguageSupport
Source:

lua() → {CodeMirrorLua|LanguageSupport}inner #

Returns:

LanguageSupport for the Lua mode.

Type
CodeMirrorLua | LanguageSupport
Source:

vue() → {CodeMirrorVue|LanguageSupport}inner #

Returns:

LanguageSupport for the Vue mode.

Type
CodeMirrorVue | LanguageSupport
Source: