mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 11:45:15 +08:00
feat!: Add editor to items prop in suggestion plugin (#2082)
* add editor to items prop * docs: update content
This commit is contained in:
parent
c01afc6791
commit
a6f731af39
@ -3,7 +3,7 @@ import tippy from 'tippy.js'
|
|||||||
import { MentionList } from './MentionList'
|
import { MentionList } from './MentionList'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
items: query => {
|
items: ({ query }) => {
|
||||||
return [
|
return [
|
||||||
'Lea Thompson', 'Cyndi Lauper', 'Tom Cruise', 'Madonna', 'Jerry Hall', 'Joan Collins', 'Winona Ryder', 'Christina Applegate', 'Alyssa Milano', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey', 'Mickey Rourke', 'John Cusack', 'Matthew Broderick', 'Justine Bateman', 'Lisa Bonet',
|
'Lea Thompson', 'Cyndi Lauper', 'Tom Cruise', 'Madonna', 'Jerry Hall', 'Joan Collins', 'Winona Ryder', 'Christina Applegate', 'Alyssa Milano', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey', 'Mickey Rourke', 'John Cusack', 'Matthew Broderick', 'Justine Bateman', 'Lisa Bonet',
|
||||||
].filter(item => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
|
].filter(item => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
|
||||||
|
@ -3,7 +3,7 @@ import tippy from 'tippy.js'
|
|||||||
import MentionList from './MentionList.vue'
|
import MentionList from './MentionList.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
items: query => {
|
items: ({ query }) => {
|
||||||
return [
|
return [
|
||||||
'Lea Thompson', 'Cyndi Lauper', 'Tom Cruise', 'Madonna', 'Jerry Hall', 'Joan Collins', 'Winona Ryder', 'Christina Applegate', 'Alyssa Milano', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey', 'Mickey Rourke', 'John Cusack', 'Matthew Broderick', 'Justine Bateman', 'Lisa Bonet',
|
'Lea Thompson', 'Cyndi Lauper', 'Tom Cruise', 'Madonna', 'Jerry Hall', 'Joan Collins', 'Winona Ryder', 'Christina Applegate', 'Alyssa Milano', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey', 'Mickey Rourke', 'John Cusack', 'Matthew Broderick', 'Justine Bateman', 'Lisa Bonet',
|
||||||
].filter(item => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
|
].filter(item => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
|
||||||
|
@ -3,7 +3,7 @@ import { VueRenderer } from '@tiptap/vue-3'
|
|||||||
import CommandsList from './CommandsList.vue'
|
import CommandsList from './CommandsList.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
items: query => {
|
items: ({ query }) => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: 'H1',
|
title: 'H1',
|
||||||
|
@ -3,7 +3,7 @@ import tippy from 'tippy.js'
|
|||||||
import MentionList from './MentionList.vue'
|
import MentionList from './MentionList.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
items: query => {
|
items: ({ query }) => {
|
||||||
return [
|
return [
|
||||||
'Lea Thompson', 'Cyndi Lauper', 'Tom Cruise', 'Madonna', 'Jerry Hall', 'Joan Collins', 'Winona Ryder', 'Christina Applegate', 'Alyssa Milano', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey', 'Mickey Rourke', 'John Cusack', 'Matthew Broderick', 'Justine Bateman', 'Lisa Bonet',
|
'Lea Thompson', 'Cyndi Lauper', 'Tom Cruise', 'Madonna', 'Jerry Hall', 'Joan Collins', 'Winona Ryder', 'Christina Applegate', 'Alyssa Milano', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey', 'Mickey Rourke', 'John Cusack', 'Matthew Broderick', 'Justine Bateman', 'Lisa Bonet',
|
||||||
].filter(item => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
|
].filter(item => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
|
||||||
|
@ -44,7 +44,7 @@ Default: `() => {}'`
|
|||||||
### items
|
### items
|
||||||
Pass an array of filtered suggestions, can be async.
|
Pass an array of filtered suggestions, can be async.
|
||||||
|
|
||||||
Default: `() => {}`
|
Default: `({ editor, query }) => []`
|
||||||
|
|
||||||
### render
|
### render
|
||||||
A render function for the autocomplete popup.
|
A render function for the autocomplete popup.
|
||||||
|
@ -17,7 +17,10 @@ export interface SuggestionOptions {
|
|||||||
range: Range,
|
range: Range,
|
||||||
props: any,
|
props: any,
|
||||||
}) => void,
|
}) => void,
|
||||||
items?: (query: string) => any[] | Promise<any[]>,
|
items?: (props: {
|
||||||
|
query: string,
|
||||||
|
editor: Editor,
|
||||||
|
}) => any[] | Promise<any[]>,
|
||||||
render?: () => {
|
render?: () => {
|
||||||
onStart?: (props: SuggestionProps) => void,
|
onStart?: (props: SuggestionProps) => void,
|
||||||
onUpdate?: (props: SuggestionProps) => void,
|
onUpdate?: (props: SuggestionProps) => void,
|
||||||
@ -99,7 +102,10 @@ export function Suggestion({
|
|||||||
query: state.query,
|
query: state.query,
|
||||||
text: state.text,
|
text: state.text,
|
||||||
items: (handleChange || handleStart)
|
items: (handleChange || handleStart)
|
||||||
? await items(state.query)
|
? await items({
|
||||||
|
editor,
|
||||||
|
query: state.query,
|
||||||
|
})
|
||||||
: [],
|
: [],
|
||||||
command: commandProps => {
|
command: commandProps => {
|
||||||
command({
|
command({
|
||||||
|
Loading…
Reference in New Issue
Block a user