From 40cefaddd027e75c5cf8900b5036c6623ed3bc75 Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Wed, 8 Jul 2020 17:53:06 +0200 Subject: [PATCH] feat(suggestions): async items and filter support added --- packages/tiptap-extensions/src/plugins/Suggestions.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tiptap-extensions/src/plugins/Suggestions.js b/packages/tiptap-extensions/src/plugins/Suggestions.js index 8cebbcbf2..0f11f3ee6 100644 --- a/packages/tiptap-extensions/src/plugins/Suggestions.js +++ b/packages/tiptap-extensions/src/plugins/Suggestions.js @@ -95,7 +95,7 @@ export default function SuggestionsPlugin({ view() { return { - update: (view, prevState) => { + update: async (view, prevState) => { const prev = this.key.getState(prevState) const next = this.key.getState(view.state) @@ -133,7 +133,9 @@ export default function SuggestionsPlugin({ text: state.text, decorationNode, 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,