diff --git a/common/util/parse.ts b/common/util/parse.ts index 6cca448a..7e3774c6 100644 --- a/common/util/parse.ts +++ b/common/util/parse.ts @@ -73,6 +73,7 @@ export const exhibitExts = [ Image, Link, Mention, + Mention.extend({ name: 'contract-mention' }), Iframe, TiptapTweet, TiptapSpoiler, diff --git a/web/components/editor/contract-mention.tsx b/web/components/editor/contract-mention.tsx index 01517aae..ea0d6e0d 100644 --- a/web/components/editor/contract-mention.tsx +++ b/web/components/editor/contract-mention.tsx @@ -6,16 +6,28 @@ import { } from '@tiptap/react' import clsx from 'clsx' import { useContract } from 'web/hooks/use-contract' -import { ContractMention } from '../contract/contract-mention' +import { ContractMention } from 'web/components/contract/contract-mention' +import Link from 'next/link' const name = 'contract-mention-component' const ContractMentionComponent = (props: any) => { - const contract = useContract(props.node.attrs.id) + const { label, id } = props.node.attrs + const contract = useContract(id) return ( - {contract && } + {contract ? ( + + ) : label ? ( + + + {label} + + + ) : ( + '[loading...]' + )} ) } @@ -29,8 +41,5 @@ export const DisplayContractMention = Mention.extend({ name: 'contract-mention', parseHTML: () => [{ tag: name }], renderHTML: ({ HTMLAttributes }) => [name, mergeAttributes(HTMLAttributes)], - addNodeView: () => - ReactNodeViewRenderer(ContractMentionComponent, { - // On desktop, render cards below half-width so you can stack two - }), + addNodeView: () => ReactNodeViewRenderer(ContractMentionComponent), })