From 5d3290600b33c9c9758085d3aca14b6bbeea9e94 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 15 Sep 2022 14:28:51 -0700 Subject: [PATCH] Add a different pluginKey --- web/components/editor.tsx | 5 ++++- web/components/editor/contract-mention-suggestion.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/components/editor.tsx b/web/components/editor.tsx index e7107b9a..a972ff7a 100644 --- a/web/components/editor.tsx +++ b/web/components/editor.tsx @@ -255,7 +255,10 @@ export function RichContent(props: { smallImage ? DisplayImage : Image, DisplayLink.configure({ openOnClick: false }), // stop link opening twice (browser still opens) DisplayMention, - DisplayContractMention, + DisplayContractMention.configure({ + // Needed to set a different PluginKey for Prosemirror + suggestion: contractMentionSuggestion, + }), Iframe, TiptapTweet, ], diff --git a/web/components/editor/contract-mention-suggestion.ts b/web/components/editor/contract-mention-suggestion.ts index cf2a1b59..79525cfc 100644 --- a/web/components/editor/contract-mention-suggestion.ts +++ b/web/components/editor/contract-mention-suggestion.ts @@ -4,8 +4,8 @@ import { searchInAny } from 'common/util/parse' import { orderBy } from 'lodash' import tippy from 'tippy.js' import { getCachedContracts } from 'web/hooks/use-contracts' -// import { getCachedUsers } from 'web/hooks/use-users' import { MentionList } from './contract-mention-list' +import { PluginKey } from 'prosemirror-state' type Suggestion = MentionOptions['suggestion'] @@ -17,6 +17,7 @@ const beginsWith = (text: string, query: string) => export const contractMentionSuggestion: Suggestion = { char: '%', allowSpaces: true, + pluginKey: new PluginKey('contract-mention'), items: async ({ query }) => orderBy( (await getCachedContracts()).filter((c) =>