Expand all

mw.editcheck.EditCheckFactory

Extends

Constructor

new mw.editcheck.EditCheckFactory() #

EditCheckFactory

This class provides a registry of Edit Checks, and instantiates and calls them when createAllActionsByListener() is called.

The controller keeps track of the actions which have been returned by previous invocations, and deduplicates actions which it has seen before. This allows us to keep state (mostly) out of the checks and EditCheckFactory itself.

Source:

EditCheckFactory

This class provides a registry of Edit Checks, and instantiates and calls them when createAllActionsByListener() is called.

Methods

buildConfig(checkName, [extraConfig]) → {Object} #

Build the config for a check

Parameters:

Name Type Attributes Default Description
checkName string
extraConfig Object optional
{}

extra configuration to apply

Source:

Returns:

Type
Object
Build the config for a check

create(checkName, controller, [extraConfig], [includeSuggestions]) → {mw.editcheck.BaseEditCheck} #

Create a check

This generates the configuration to pass to the check from the various overrides.

Parameters:

Name Type Attributes Default Description
checkName string
controller
extraConfig Object optional
{}

extra configuration to apply

includeSuggestions boolean optional
false
Source:

Returns:

Type
mw.editcheck.BaseEditCheck

Create a check

This generates the configuration to pass to the check from the various overrides.

createAllActionsByListener(controller, listenerName, surfaceModel, [includeSuggestions]) → {Promise} #

Create all checks actions for a given listener

Invoked by Controller.prototype.updateForListener, which itself is called in response to user actions such as navigating away from a paragraph, making changes to the document, or clicking 'Save changes...'

Checks are created statelessly and then mapped to their 'originals' by the controller. This way if we track state on the original, or use object identity with the actions to track UI updates, the object remains stable.

Parameters:

Name Type Attributes Default Description
controller
listenerName string

Listener name

surfaceModel ve.dm.Surface

Surface model

includeSuggestions boolean optional
false
Source:

Returns:

Promise that resolves with an updated list of Actions

Type
Promise

Create all checks actions for a given listener

Invoked by Controller.prototype.updateForListener, which itself is called in response to user actions such as navigating away from a paragraph, making changes to the document, or clicking 'Save changes...'

Checks are created statelessly and then mapped to their 'originals' by the controller.

getNamesByListener(listener) → {Array.<string>} #

Get a list of registered command names.

Parameters:

Name Type Description
listener string

Listener name, 'onDocumentChange', 'onBeforeSave'

Source:

Returns:

Type
Array.<string>
Get a list of registered command names.