1
1
import { HtmlView } from '@/components/html-view'
2
2
import { BoldIcon , ItalicIcon , LinkIcon , ListIcon } from '@/components/icons'
3
3
import { browserEnv } from '@/env/browser'
4
- import { api } from '@/lib/api'
5
4
import { classNames } from '@/lib/classnames'
6
5
import {
7
6
getSuggestionData ,
8
7
uploadImageCommandHandler ,
9
8
markdownToHtml ,
10
9
} from '@/lib/editor'
10
+ import { trpc } from '@/lib/trpc'
11
11
import { Switch } from '@headlessui/react'
12
12
import { matchSorter } from 'match-sorter'
13
13
import * as React from 'react'
14
14
import { useDetectClickOutside } from 'react-detect-click-outside'
15
- import { useQuery } from '@tanstack/ react-query'
15
+ import { useQuery } from 'react-query'
16
16
import TextareaAutosize , {
17
- type TextareaAutosizeProps ,
17
+ TextareaAutosizeProps ,
18
18
} from 'react-textarea-autosize'
19
19
import getCaretCoordinates from 'textarea-caret'
20
- import type { TextareaMarkdownRef } from 'textarea-markdown-editor'
21
- import TextareaMarkdown from 'textarea-markdown-editor'
22
- import { useItemList , type ItemOptions } from 'use-item-list'
20
+ import TextareaMarkdown , { TextareaMarkdownRef } from 'textarea-markdown-editor'
21
+ import { ItemOptions , useItemList } from 'use-item-list'
23
22
24
23
type MarkdownEditorProps = {
25
24
label ?: string
@@ -358,7 +357,7 @@ function Suggestion({
358
357
const isEmojiType = state . type === 'emoji'
359
358
360
359
const emojiListQuery = useQuery (
361
- [ 'emojiList' ] ,
360
+ 'emojiList' ,
362
361
async ( ) => {
363
362
const gemoji = ( await import ( 'gemoji' ) ) . gemoji
364
363
return gemoji
@@ -369,7 +368,7 @@ function Suggestion({
369
368
}
370
369
)
371
370
372
- const mentionListQuery = api . user . mentionList . useQuery ( undefined , {
371
+ const mentionListQuery = trpc . useQuery ( [ ' user.mentionList' ] , {
373
372
enabled : state . isOpen && isMentionType ,
374
373
staleTime : 5 * 60 * 1000 ,
375
374
} )
@@ -381,10 +380,7 @@ function Suggestion({
381
380
keys : [ 'name' ] ,
382
381
} )
383
382
. slice ( 0 , 5 )
384
- . map ( ( item ) => ( {
385
- label : item . name ,
386
- value : item . id ,
387
- } ) ) as SuggestionResult [ ]
383
+ . map ( ( item ) => ( { label : item . name ! , value : item . id } ) )
388
384
}
389
385
390
386
if ( isEmojiType && emojiListQuery . data ) {
@@ -491,13 +487,13 @@ function SuggestionResult({
491
487
index : number
492
488
highlight : ( ) => void
493
489
select : ( ) => void
494
- // eslint-disable-next-line @typescript-eslint/ban-types
490
+ selected : any
495
491
useHighlighted : ( ) => Boolean
496
492
}
497
493
suggestionResult : SuggestionResult
498
494
} ) {
499
495
const ref = React . useRef < HTMLLIElement > ( null )
500
- const { id, highlight, select, useHighlighted } = useItem ( {
496
+ const { id, index , highlight, select, useHighlighted } = useItem ( {
501
497
ref,
502
498
value : suggestionResult ,
503
499
} )
0 commit comments