feat(suggestions): async items and filter support added

This commit is contained in:
Chrissi2812 2020-07-08 17:53:06 +02:00
parent 2922a8feaf
commit 40cefaddd0
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA

View File

@ -95,7 +95,7 @@ export default function SuggestionsPlugin({
view() { view() {
return { return {
update: (view, prevState) => { update: async (view, prevState) => {
const prev = this.key.getState(prevState) const prev = this.key.getState(prevState)
const next = this.key.getState(view.state) const next = this.key.getState(view.state)
@ -133,7 +133,9 @@ export default function SuggestionsPlugin({
text: state.text, text: state.text,
decorationNode, decorationNode,
virtualNode, virtualNode,
items: onFilter(Array.isArray(items) ? items : items(), state.query), items: (handleChange || handleStart)
? await onFilter(Array.isArray(items) ? items : await items(), state.query)
: [],
command: ({ range, attrs }) => { command: ({ range, attrs }) => {
command({ command({
range, range,