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”AutocompleteRuleOptions
Section titled “AutocompleteRuleOptions”Options for creating an AutocompleteRule
Properties
Section titled “Properties”-
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.
-
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.
-
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.*)$/u
. For a mention, you might use/@\w*$/
CanMatchOptions
Section titled “CanMatchOptions”Options for the CanMatchPredicate callback.
Properties
Section titled “Properties”-
The editor state.
MatchHandlerOptions
Section titled “MatchHandlerOptions”Options for the MatchHandler callback.
Properties
Section titled “Properties”-
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.
-
from:
number
-
The start 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.
-
match:
RegExpExecArray
-
The result of
RegExp.exec
.
-
The editor state.
-
to:
number
-
The end position of the matched text.
Type Aliases
Section titled “Type Aliases”CanMatchPredicate()
Section titled “CanMatchPredicate()”-
type CanMatchPredicate = (
options
:CanMatchOptions
) =>boolean
-
A predicate to determine if the rule can be applied in the current editor state.
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.
Functions
Section titled “Functions”defineAutocomplete()
Section titled “defineAutocomplete()”-
function defineAutocomplete(
rule
:AutocompleteRule
):Extension