Expand all

ve.ui.Sequence

Constructor

new ve.ui.Sequence(name, commandName, data, [strip], [config]) #

Key sequence.

Parameters:

Name Type Attributes Default Description
name string

Symbolic name

commandName string

Command name this sequence executes

data string | Array | RegExp

Data to match. String, linear data array, or regular expression. When using a RegularExpression always match the end of the sequence with a '$' so that only sequences next to the user's cursor match.

strip number optional
0

Number of data elements to strip after execution (from the right)

config Object optional

[description]

Properties:
Name Type Attributes Default Description
setSelection boolean optional
false

Whether to set the selection to the range matching the sequence before executing the command.

delayed boolean optional
false

Whether to wait for the user to stop typing matching content before executing the command. When the sequence matches typed text, it will not be executed immediately, but only after more non-matching text is added afterwards or the selection is changed. This is useful for variable-length sequences (defined with RegExps).

checkOnPaste boolean optional
false

Whether the sequence should also be matched after paste.

checkOnDelete boolean optional
false

Whether the sequence should also be matched after delete.

Source:
Key sequence.

Methods

execute(surface, range) → {boolean} #

Execute the command associated with the sequence

Parameters:

Name Type Description
surface ve.ui.Surface
range ve.Range

Range to set

Source:

Returns:

The command executed

Type
boolean
Execute the command associated with the sequence

getCommandName() → {string} #

Get the command name which the sequence will execute

Source:

Returns:

Command name

Type
string
Get the command name which the sequence will execute

getMessage(explode) → {string} #

Get a representation of the sequence useful for display

What this means depends a bit on how the sequence was defined:

  • It strips out undisplayable things like the paragraph-start marker.
  • Regexps are just returned as a toString of the regexp.

Parameters:

Name Type Description
explode boolean

Whether to return the message split up into some reasonable sequence of inputs required to trigger the sequence (regexps in sequences will be considered a single "input" as a toString of the regexp, because they're hard to display no matter what…)

Source:

Returns:

Message for display

Type
string

Get a representation of the sequence useful for display

What this means depends a bit on how the sequence was defined:

  • It strips out undisplayable things like the paragraph-start marker.

getName() → {string} #

Get the symbolic name of the sequence

Source:

Returns:

Symbolic name

Type
string
Get the symbolic name of the sequence

match(data, offset, plaintext) → {ve.Range|null} #

Check if the sequence matches a given offset in the data

Parameters:

Name Type Description
data ve.dm.ElementLinearData

String or linear data

offset number
plaintext string

Plain text of data

Source:

Returns:

Range corresponding to the match, or else null

Type
ve.Range | null
Check if the sequence matches a given offset in the data