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 CodeMirrorExtensionRegistry
isVisualEditor boolean optional
false

Whether the VE 2017 editor is being used.

Source:

Fires:

Properties

extension #

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.

firePreferencesApplyHook(prefName) #

Parameters:

Name Type Description
prefName string
Source:

Fires:

getCheckbox() #

getDefaultPreferences() → {Object} #

The default CodeMirror preferences, as defined by $wgCodeMirrorPreferences and taking into account the page namespace and content model.

Source:

Returns:

Type
Object

The default CodeMirror preferences, as defined by $wgCodeMirrorPreferences and taking into account the page namespace and content model.

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.

hasNonDefaultPreferences() → {boolean} #

Check if the user has any preferences that differ from the defaults. This is used to determine whether EventLogging should happen.

Source:

Returns:

Type
boolean
Check if the user has any preferences that differ from the defaults.

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 CodeMirrorExtensionRegistry and enable it if the corresponding preference is set.

Parameters:

Name Type Description
name string
extension Extension
view EditorView
Source:

Register an Extension with CodeMirrorExtensionRegistry and enable it if the corresponding preference is set.

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 boolean
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.

toggleExtension(name, view) #

Toggle an Extension on or off with CodeMirrorExtensionRegistry and update the preference.

Parameters:

Name Type Description
name string
view EditorView
Source:

Toggle an Extension on or off with CodeMirrorExtensionRegistry and update the preference.