Rename to contract-mention
This commit is contained in:
parent
5c6e75afa8
commit
3bcbde65a2
|
@ -18,8 +18,8 @@ import { uploadImage } from 'web/lib/firebase/storage'
|
||||||
import { useMutation } from 'react-query'
|
import { useMutation } from 'react-query'
|
||||||
import { FileUploadButton } from './file-upload-button'
|
import { FileUploadButton } from './file-upload-button'
|
||||||
import { linkClass } from './site-link'
|
import { linkClass } from './site-link'
|
||||||
import { mentionSuggestion } from './editor/mention-suggestion'
|
import { mentionSuggestion } from './editor/contract-mention-suggestion'
|
||||||
import { DisplayMention } from './editor/mention'
|
import { DisplayContractMention } from './editor/contract-mention'
|
||||||
import Iframe from 'common/util/tiptap-iframe'
|
import Iframe from 'common/util/tiptap-iframe'
|
||||||
import TiptapTweet from './editor/tiptap-tweet'
|
import TiptapTweet from './editor/tiptap-tweet'
|
||||||
import { EmbedModal } from './editor/embed-modal'
|
import { EmbedModal } from './editor/embed-modal'
|
||||||
|
@ -90,7 +90,7 @@ export function useTextEditor(props: {
|
||||||
CharacterCount.configure({ limit: max }),
|
CharacterCount.configure({ limit: max }),
|
||||||
simple ? DisplayImage : Image,
|
simple ? DisplayImage : Image,
|
||||||
DisplayLink,
|
DisplayLink,
|
||||||
DisplayMention.configure({ suggestion: mentionSuggestion }),
|
DisplayContractMention.configure({ suggestion: mentionSuggestion }),
|
||||||
Iframe,
|
Iframe,
|
||||||
TiptapTweet,
|
TiptapTweet,
|
||||||
],
|
],
|
||||||
|
@ -247,7 +247,7 @@ export function RichContent(props: {
|
||||||
StarterKit,
|
StarterKit,
|
||||||
smallImage ? DisplayImage : Image,
|
smallImage ? DisplayImage : Image,
|
||||||
DisplayLink.configure({ openOnClick: false }), // stop link opening twice (browser still opens)
|
DisplayLink.configure({ openOnClick: false }), // stop link opening twice (browser still opens)
|
||||||
DisplayMention,
|
DisplayContractMention,
|
||||||
Iframe,
|
Iframe,
|
||||||
TiptapTweet,
|
TiptapTweet,
|
||||||
],
|
],
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { orderBy } from 'lodash'
|
||||||
import tippy from 'tippy.js'
|
import tippy from 'tippy.js'
|
||||||
import { getCachedContracts } from 'web/hooks/use-contracts'
|
import { getCachedContracts } from 'web/hooks/use-contracts'
|
||||||
// import { getCachedUsers } from 'web/hooks/use-users'
|
// import { getCachedUsers } from 'web/hooks/use-users'
|
||||||
import { MentionList } from './mention-list'
|
import { MentionList } from './contract-mention-list'
|
||||||
|
|
||||||
type Suggestion = MentionOptions['suggestion']
|
type Suggestion = MentionOptions['suggestion']
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ const beginsWith = (text: string, query: string) =>
|
||||||
text.toLocaleLowerCase().startsWith(query.toLocaleLowerCase())
|
text.toLocaleLowerCase().startsWith(query.toLocaleLowerCase())
|
||||||
|
|
||||||
// copied from https://tiptap.dev/api/nodes/mention#usage
|
// copied from https://tiptap.dev/api/nodes/mention#usage
|
||||||
|
// TODO: merge with mention-suggestion.ts?
|
||||||
export const mentionSuggestion: Suggestion = {
|
export const mentionSuggestion: Suggestion = {
|
||||||
char: '%',
|
char: '%',
|
||||||
allowSpaces: true,
|
allowSpaces: true,
|
|
@ -8,9 +8,9 @@ import clsx from 'clsx'
|
||||||
import { useContract } from 'web/hooks/use-contract'
|
import { useContract } from 'web/hooks/use-contract'
|
||||||
import { ContractCard } from '../contract/contract-card'
|
import { ContractCard } from '../contract/contract-card'
|
||||||
|
|
||||||
const name = 'mention-component'
|
const name = 'contract-mention-component'
|
||||||
|
|
||||||
const MentionComponent = (props: any) => {
|
const ContractMentionComponent = (props: any) => {
|
||||||
const contract = useContract(props.node.attrs.id)
|
const contract = useContract(props.node.attrs.id)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -30,11 +30,11 @@ const MentionComponent = (props: any) => {
|
||||||
* https://tiptap.dev/guide/custom-extensions#extend-existing-extensions
|
* https://tiptap.dev/guide/custom-extensions#extend-existing-extensions
|
||||||
* https://tiptap.dev/guide/node-views/react#render-a-react-component
|
* https://tiptap.dev/guide/node-views/react#render-a-react-component
|
||||||
*/
|
*/
|
||||||
export const DisplayMention = Mention.extend({
|
export const DisplayContractMention = Mention.extend({
|
||||||
parseHTML: () => [{ tag: name }],
|
parseHTML: () => [{ tag: name }],
|
||||||
renderHTML: ({ HTMLAttributes }) => [name, mergeAttributes(HTMLAttributes)],
|
renderHTML: ({ HTMLAttributes }) => [name, mergeAttributes(HTMLAttributes)],
|
||||||
addNodeView: () =>
|
addNodeView: () =>
|
||||||
ReactNodeViewRenderer(MentionComponent, {
|
ReactNodeViewRenderer(ContractMentionComponent, {
|
||||||
// On desktop, render cards below half-width so you can stack two
|
// On desktop, render cards below half-width so you can stack two
|
||||||
className: 'inline-block sm:w-[calc(50%-1rem)] sm:mr-1',
|
className: 'inline-block sm:w-[calc(50%-1rem)] sm:mr-1',
|
||||||
}),
|
}),
|
Loading…
Reference in New Issue
Block a user