refactor: post editor
This commit is contained in:
parent
3d06421acb
commit
78725d1e88
31 changed files with 1603 additions and 766 deletions
20
src/components/PostEditor/PostTextarea/MentionNode.tsx
Normal file
20
src/components/PostEditor/PostTextarea/MentionNode.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useFetchProfile } from '@/hooks'
|
||||
import { formatUserId } from '@/lib/pubkey'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { NodeViewRendererProps, NodeViewWrapper } from '@tiptap/react'
|
||||
|
||||
export default function MentionNode(props: NodeViewRendererProps & { selected: boolean }) {
|
||||
const { profile } = useFetchProfile(props.node.attrs.id)
|
||||
|
||||
return (
|
||||
<NodeViewWrapper
|
||||
className={cn(
|
||||
'inline text-primary bg-primary/10 rounded-md px-1 transition-colors',
|
||||
props.selected ? 'bg-primary/20' : ''
|
||||
)}
|
||||
>
|
||||
{'@'}
|
||||
{profile ? profile.username : formatUserId(props.node.attrs.id)}
|
||||
</NodeViewWrapper>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue