Expand all

CodeMirrorPreferences

CodeMirrorPreferences is a panel that allows users to configure CodeMirror preferences. It is toggled by pressing Ctrl-Shift-, (or Command-Shift-, on macOS).

Note that this code, like MediaWiki Core, refers to the user's preferences as "options". In this class, "preferences" refer to the user's preferences for CodeMirror, which are stored as a single user 'option' in the database.

Constructor

new CodeMirrorPreferences(extensionRegistry, [isVisualEditor]) #

Parameters:

Name Type Attributes Default Description
extensionRegistry Object

Key-value pairs of CodeMirror Extensions.

isVisualEditor boolean optional
false

Whether the VE 2017 editor is being used.

Source:

Fires:

Properties

compartmentRegistry :Object.<Compartment> #

Registry of CodeMirror Compartments that are made available for reconfiguration in CodeMirrorPreferences.

Type:

Source:

Registry of CodeMirror Compartments that are made available for reconfiguration in CodeMirrorPreferences.

defaultPreferences :Object #

The default CodeMirror preferences, as defined by $wgCodeMirrorPreferences.

Type:

Source:
The default CodeMirror preferences, as defined by $wgCodeMirrorPreferences.

extension #

extensionRegistry :Object.<Extension> #

Registry of CodeMirror Extensions that are made available to CodeMirrorPreferences.

Type:

Source:
Registry of CodeMirror Extensions that are made available to CodeMirrorPreferences.

isVisualEditor :boolean #

Type:

  • boolean
Source:

optionName :string #

Type:

  • string
Source:

panelStateField :StateField #

preferences :Object #

The user's CodeMirror preferences.

Type:

Source:
The user's CodeMirror preferences.

Methods

fetchPreferences() → {Object} #

Fetch the user's CodeMirror preferences from the user options API, or clientside storage for unnamed users.

Source:

Returns:

Type
Object

Fetch the user's CodeMirror preferences from the user options API, or clientside storage for unnamed users.

getCheckbox() #

getPreference(prefName) → {boolean} #

Get the value of the given CodeMirror preference.

Parameters:

Name Type Description
prefName string
Source:

Returns:

Type
boolean
Get the value of the given CodeMirror preference.

onKeydown(event) #

Handle keydown events on the preferences panel.

Parameters:

Name Type Description
event KeyboardEvent
Source:
Handle keydown events on the preferences panel.

registerExtension(name, extension, view) #

Register an Extension with CodeMirrorPreferences, along with a corresponding Compartment so that the Extension can be reconfigured.

Parameters:

Name Type Description
name string
extension Extension
view EditorView
Source:

Register an Extension with CodeMirrorPreferences, along with a corresponding Compartment so that the Extension can be reconfigured.

setPreference(key, value) #

Set the given CodeMirror preference and update the user option in the database, or clientside storage for unnamed users.

Parameters:

Name Type Description
key string
value Mixed
Source:

Set the given CodeMirror preference and update the user option in the database, or clientside storage for unnamed users.

toggle(view, [force]) → {boolean} #

Toggle display of the preferences panel.

Parameters:

Name Type Attributes Description
view EditorView
force boolean optional

Force the panel to open or close.

Source:

Returns:

Type
boolean
Toggle display of the preferences panel.