Expand all

mw.editcheck.AsyncTextCheck

Constructor

new mw.editcheck.AsyncTextCheck(controller, [config]) #

Abstract class for async checks that run on the plain text of a ContentBranchNode.

The check runs when selection focus changes branch node, or on pre-save. The subclass implements .checkAsync. This is called with the ContentBranchNode's plain text and returns an outcome, which gets processed by the subclass's .newAction method, returning a new EditCheckAction if appropriate.

Parameters:

Name Type Attributes Description
controller
config Object optional
Source:
Abstract class for async checks that run on the plain text of a ContentBranchNode.

Properties

newAction #

Build an action (or not), depending on the outcome of #checkAsync

Caution: The ContentBranchNode may have changed while waiting for #checkAsync to settle. For example, the fragment could be empty if the ContentBranchNode has been deleted.

Source:

Build an action (or not), depending on the outcome of #checkAsync

Caution: The ContentBranchNode may have changed while waiting for #checkAsync to settle.

checkAsyncabstractstatic #

Perform a possibly-asynchronous check on the plaintext of a ContentBranchNode.

The check must be deterministic; i.e. it must always return the same value for the same arguments. This allows the result to be memoized.

Source:
Perform a possibly-asynchronous check on the plaintext of a ContentBranchNode.

memoizedCheckAsyncstatic #

This static method gets implemented inside the AsyncTextCheck constructor. It memoizes the subclass's static method checkAsync.

Source:
This static method gets implemented inside the AsyncTextCheck constructor.

Methods

afterMemoized(outcome) → {any} #

A filter to apply after the memoized call has occurred

This is where instance-specific configuration would be applied

Parameters:

Name Type Description
outcome any

The outcome returned by #checkAsync

Source:

Returns:

Type
any

A filter to apply after the memoized call has occurred

This is where instance-specific configuration would be applied

checkText(text, [bypass]) → {Promise} #

Check provided text

Parameters:

Name Type Attributes Description
text string
bypass boolean optional

Whether to bypass any memoized result

Source:

Returns:

Type
Promise
Check provided text

handleListener(listener, surfaceModel) → {Array.<Promise>} #

Parameters:

Name Type Description
listener string

Type of listener, such as 'onBeforeSave' or 'onBranchNodeChange'

surfaceModel ve.dm.Surface

The surface

Source:

Returns:

An array of promises containing either an action or null

Type
Array.<Promise>