prosekit/extensions/autocomplete
Classes
Section titled “Classes”AutocompleteRule
Section titled “AutocompleteRule”An autocomplete rule that can be used to create an autocomplete extension.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”-
new AutocompleteRule(
options
:AutocompleteRuleOptions
):AutocompleteRule
Interfaces
Section titled “Interfaces”MatchHandlerOptions
Section titled “MatchHandlerOptions”Options for the MatchHandler callback.
Properties
Section titled “Properties”-
The editor state.
-
match:
RegExpExecArray
-
The result of
RegExp.exec
.
-
from:
number
-
The start position of the matched text.
-
to:
number
-
The end position of the matched text.
-
ignoreMatch: () =>
void
-
Call this function to ignore the match. You probably want to call this function when the user presses the
Escape
key.
-
deleteMatch: () =>
void
-
Call this function to delete the matched text. For example, in a slash menu, you might want to delete the matched text first then do something else when the user presses the
Enter
key.
CanMatchOptions
Section titled “CanMatchOptions”Options for the CanMatchPredicate callback.
Properties
Section titled “Properties”-
The editor state.
AutocompleteRuleOptions
Section titled “AutocompleteRuleOptions”Options for creating an AutocompleteRule
Properties
Section titled “Properties”-
The regular expression to match against the text before the cursor. The last match before the cursor is used.
For a slash menu, you might use
/(?<!\S)/(|\S.*)$/u
. For a mention, you might use/@\w*$/
-
A callback that is called when the rule starts to match, and also on subsequent updates while the rule continues to match.
-
onLeave?:
VoidFunction
-
A callback that is called when the rule stops matching.
-
A predicate to determine if the rule can be applied in the current editor state. If not provided, it defaults to only allowing matches in empty selections that are not inside a code block or code mark.
Type Aliases
Section titled “Type Aliases”MatchHandler()
Section titled “MatchHandler()”-
type MatchHandler = (
options
:MatchHandlerOptions
) =>void
-
A callback that is called when the rule starts to match, and also on subsequent updates while the rule continues to match.
CanMatchPredicate()
Section titled “CanMatchPredicate()”-
type CanMatchPredicate = (
options
:CanMatchOptions
) =>boolean
-
A predicate to determine if the rule can be applied in the current editor state.
Functions
Section titled “Functions”defineAutocomplete()
Section titled “defineAutocomplete()”-
function defineAutocomplete(
rule
:AutocompleteRule
):Extension