hotfix %mention, add load-fail state
This commit is contained in:
parent
310a41d63e
commit
8bd21c6693
|
@ -73,6 +73,7 @@ export const exhibitExts = [
|
||||||
Image,
|
Image,
|
||||||
Link,
|
Link,
|
||||||
Mention,
|
Mention,
|
||||||
|
Mention.extend({ name: 'contract-mention' }),
|
||||||
Iframe,
|
Iframe,
|
||||||
TiptapTweet,
|
TiptapTweet,
|
||||||
TiptapSpoiler,
|
TiptapSpoiler,
|
||||||
|
|
|
@ -6,16 +6,28 @@ import {
|
||||||
} from '@tiptap/react'
|
} from '@tiptap/react'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { useContract } from 'web/hooks/use-contract'
|
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 name = 'contract-mention-component'
|
||||||
|
|
||||||
const ContractMentionComponent = (props: any) => {
|
const ContractMentionComponent = (props: any) => {
|
||||||
const contract = useContract(props.node.attrs.id)
|
const { label, id } = props.node.attrs
|
||||||
|
const contract = useContract(id)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper className={clsx(name, 'not-prose inline')}>
|
<NodeViewWrapper className={clsx(name, 'not-prose inline')}>
|
||||||
{contract && <ContractMention contract={contract} />}
|
{contract ? (
|
||||||
|
<ContractMention contract={contract} />
|
||||||
|
) : label ? (
|
||||||
|
<Link href={label}>
|
||||||
|
<a className="rounded-sm !text-indigo-700 hover:bg-indigo-50">
|
||||||
|
{label}
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
'[loading...]'
|
||||||
|
)}
|
||||||
</NodeViewWrapper>
|
</NodeViewWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -29,8 +41,5 @@ export const DisplayContractMention = Mention.extend({
|
||||||
name: 'contract-mention',
|
name: 'contract-mention',
|
||||||
parseHTML: () => [{ tag: name }],
|
parseHTML: () => [{ tag: name }],
|
||||||
renderHTML: ({ HTMLAttributes }) => [name, mergeAttributes(HTMLAttributes)],
|
renderHTML: ({ HTMLAttributes }) => [name, mergeAttributes(HTMLAttributes)],
|
||||||
addNodeView: () =>
|
addNodeView: () => ReactNodeViewRenderer(ContractMentionComponent),
|
||||||
ReactNodeViewRenderer(ContractMentionComponent, {
|
|
||||||
// On desktop, render cards below half-width so you can stack two
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user