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 |
Properties
getSuggestionsabstract
#
Retrieve suggested completions for the given input
alwaysIncludeInputstatic
#
Properties:
Name | Type | Description |
---|---|---|
Whether |
boolean | the current input should be included as a completion automatically |
defaultLimitstatic
#
Properties:
Name | Type | Description |
---|---|---|
Length |
number | to which to limit the list of returned completions |
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. |
Methods
chooseItem(item, range)
#
Choose a specific item
Parameters:
Name | Type | Description |
---|---|---|
item |
OO.ui.MenuOptionWidget | Chosen item |
range |
ve.Range | Current surface range |
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 |
Returns:
Match object, containing two booleans, isMatch
and isExact
- Type
- Object
createSuggestion(input) → {any}
#
Create a suggestion from an input
Parameters:
Name | Type | Description |
---|---|---|
input |
string | User input |
Returns:
Suggestion data, string by default
- Type
- any
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 |
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
}
#
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 |
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 |
Returns:
getSequenceLength() → {number}
#
Get the length of the sequence which triggered this action
Returns:
Length of the sequence
- Type
- number
insertCompletion(data, range) → {ve.dm.SurfaceFragment}
#
open([isolateInput]) → {boolean}
#
Show the completions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
isolateInput |
boolean |
optional |
Isolate input from the surface |
Returns:
Action was executed
- Type
- boolean
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 |
Returns:
Whether to abandon
- Type
- boolean
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> |
Returns:
- Type
- Array.<OO.ui.MenuOptionWidget>