Expand all

abstract ve.ui.CompletionAction

Extends

Constructor

new ve.ui.CompletionAction(surface, [source])abstract #

Completion action.

This is a very specialized action, which mostly exists to be a data-provider to a completion widget. Completion-types must override getSuggestions.

Parameters:

Name Type Attributes Description
surface ve.ui.Surface

Surface to act on

source string optional
Source:
Completion action.

Properties

getSuggestionsabstract #

Retrieve suggested completions for the given input

Source:
Retrieve suggested completions for the given input

alwaysIncludeInputstatic #

Properties:

Name Type Description
Whether boolean

the current input should be included as a completion automatically

Source:

defaultLimitstatic #

Properties:

Name Type Description
Length number

to which to limit the list of returned completions

Source:

sequenceLengthstatic #

Properties:

Name Type Description
Length number

of the trigger sequence for the action

This many characters will be stripped from the start of the current input by CompletionWidget when triggered by a sequence, see #getSequenceLength.

Source:

Methods

chooseItem(item, range) #

Choose a specific item

Parameters:

Name Type Description
item OO.ui.MenuOptionWidget

Chosen item

range ve.Range

Current surface range

Source:
Choose a specific item

compareSuggestionToInput(suggestion, normalizedInput) → {Object} #

Compare a suggestion to the normalized user input (lower case)

Parameters:

Name Type Description
suggestion any

Suggestion data, string by default

normalizedInput string

Noramlized user input

Source:

Returns:

Match object, containing two booleans, isMatch and isExact

Type
Object
Compare a suggestion to the normalized user input (lower case)

createSuggestion(input) → {any} #

Create a suggestion from an input

Parameters:

Name Type Description
input string

User input

Source:

Returns:

Suggestion data, string by default

Type
any
Create a suggestion from an input

filterSuggestionsForInput(suggestions, input) → {Array.<any>}protected #

Filter a suggestion list based on the current input

This is for an implementor who has fetched/gathered a list of potential suggestions and needs to trim them down to a viable set to display as completion options for a given input.

It restricts the selection to only suggestions that start with the input, shortens the list to the configured defaultLimit, and adds the current input to the list if alwaysIncludeInput and there wasn't an exact match.

Parameters:

Name Type Description
suggestions Array.<any>

List of valid completions, strings by default

input string

Input to filter the suggestions to

Source:

Returns:

Type
Array.<any>

Filter a suggestion list based on the current input

This is for an implementor who has fetched/gathered a list of potential suggestions and needs to trim them down to a viable set to display as completion options for a given input.

getHeaderLabel(input, [suggestions]) → {jQuery|string|OO.ui.HtmlSnippet|function|null|undefined} #

Get a label to show as the menu header

This is called twice per input, once with the new user input immediately after it is entered, and again later with the same input and its resolved suggestions

Parameters:

Name Type Attributes Description
input string

User input

suggestions Array optional

Returned suggestions

Source:

Returns:

Label. Use undefined to avoid updating the label, and null to clear it.

Type
jQuery | string | OO.ui.HtmlSnippet | function | null | undefined

Get a label to show as the menu header

This is called twice per input, once with the new user input immediately after it is entered, and again later with the same input and its resolved suggestions

getMenuItemForSuggestion(suggestion) → {OO.ui.MenuOptionWidget}protected #

Make a menu item for a given suggestion

Parameters:

Name Type Description
suggestion any

Suggestion data, string by default

Source:

Returns:

Type
OO.ui.MenuOptionWidget
Make a menu item for a given suggestion

getSequenceLength() → {number} #

Get the length of the sequence which triggered this action

Source:

Returns:

Length of the sequence

Type
number
Get the length of the sequence which triggered this action

insertCompletion(data, range) → {ve.dm.SurfaceFragment} #

Perform the insetion for the chosen suggestion

Parameters:

Name Type Description
data Object

Whatever data was attached to the menu option widget

range ve.Range

The range the widget is considering

Source:

Returns:

The fragment containing the inserted content

Type
ve.dm.SurfaceFragment
Perform the insetion for the chosen suggestion

open([isolateInput]) → {boolean} #

Show the completions

Parameters:

Name Type Attributes Description
isolateInput boolean optional

Isolate input from the surface

Source:

Returns:

Action was executed

Type
boolean
Show the completions

shouldAbandon(input, matches) → {boolean} #

Should the widget abandon trying to find matches given the current state?

Parameters:

Name Type Description
input string
matches number

Number of matches before the input occurred

Source:

Returns:

Whether to abandon

Type
boolean
Should the widget abandon trying to find matches given the current state?

updateMenuItems(menuItems) → {Array.<OO.ui.MenuOptionWidget>}protected #

Update the menu item list before adding, e.g. to add menu groups

Parameters:

Name Type Description
menuItems Array.<OO.ui.MenuOptionWidget>
Source:

Returns:

Type
Array.<OO.ui.MenuOptionWidget>
Update the menu item list before adding, e.g.