forked from emad-elsaid/xlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autocomplete.go
24 lines (20 loc) · 987 Bytes
/
autocomplete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package xlog
// Autocomplete defines what character triggeres the autocomplete feature and
// what is the list to display in this case.
type Autocomplete interface {
StartChar() string
Suggestions() []*Suggestion
}
// Suggestions represent an item in the list of autocomplete menu in the edit page
type Suggestion struct {
Text string // The text that gets injected in the editor if this option is chosen
DisplayText string // The display text for this item in the menu. this can be more cosmetic. it has to start with the StartChar as the editor filter the list using this field
}
// Holds a list of registered autocomplete functions
var autocompletes = []Autocomplete{}
// RegisterAutocomplete registers an autocomplete function. it should be used by an
// extension to register a new autocomplete function. these functions are going
// to be executed when rendering the edit page.
func RegisterAutocomplete(a Autocomplete) {
autocompletes = append(autocompletes, a)
}