Remove exclusions code from Tiptap utils
This commit is contained in:
parent
d88945ad95
commit
84131c96bf
1 changed files with 18 additions and 6 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import type { JSONContent } from '@tiptap/core'
|
||||
import { ReactRenderer } from '@tiptap/react'
|
||||
import { MentionOptions } from '@tiptap/extension-mention'
|
||||
import { SuggestionKeyDownProps, SuggestionProps } from '@tiptap/suggestion'
|
||||
import tippy, { Instance as TippyInstance } from 'tippy.js'
|
||||
import { getCookie } from 'cookies-next'
|
||||
|
||||
|
|
@ -44,13 +43,23 @@ function transform(object: RawSearchResponse) {
|
|||
}
|
||||
return result
|
||||
}
|
||||
//
|
||||
|
||||
function parseMentions(data: JSONContent) {
|
||||
const mentions: string[] = (data.content || []).flatMap(parseMentions)
|
||||
if (data.type === 'mention') {
|
||||
const granblueId = data.attrs?.id.granblue_id
|
||||
mentions.push(granblueId)
|
||||
}
|
||||
|
||||
return [...new Set(mentions)]
|
||||
}
|
||||
|
||||
export const mentionSuggestionOptions: Omit<SuggestionOptions, 'editor'> = {
|
||||
items: async ({ query }): Promise<MentionSuggestion[]> => {
|
||||
items: async ({ query, editor }): Promise<MentionSuggestion[]> => {
|
||||
const locale = getCookie('NEXT_LOCALE')
|
||||
? (getCookie('NEXT_LOCALE') as string)
|
||||
: 'en'
|
||||
const response = await api.searchAll(query, locale)
|
||||
const response = await api.searchAll(query, [], locale)
|
||||
const results = response.data.results
|
||||
|
||||
return results
|
||||
|
|
@ -72,7 +81,6 @@ export const mentionSuggestionOptions: Omit<SuggestionOptions, 'editor'> = {
|
|||
render: () => {
|
||||
let component: ReactRenderer<MentionRef> | undefined
|
||||
let popup: TippyInstance | undefined
|
||||
|
||||
return {
|
||||
onStart: (props) => {
|
||||
component = new ReactRenderer(MentionList, {
|
||||
|
|
@ -80,6 +88,10 @@ export const mentionSuggestionOptions: Omit<SuggestionOptions, 'editor'> = {
|
|||
editor: props.editor,
|
||||
})
|
||||
|
||||
console.log('in onStart')
|
||||
const rect = props.clientRect?.()
|
||||
console.log(rect)
|
||||
|
||||
popup = tippy('body', {
|
||||
getReferenceClientRect: props.clientRect,
|
||||
appendTo: () => document.body,
|
||||
|
|
|
|||
Loading…
Reference in a new issue