diff --git a/app/editor/components/PasteMenu.tsx b/app/editor/components/PasteMenu.tsx index bb9b30a9fe..81dd4a3137 100644 --- a/app/editor/components/PasteMenu.tsx +++ b/app/editor/components/PasteMenu.tsx @@ -61,6 +61,7 @@ export const PasteMenu = observer(({ pastedText, embeds, ...props }: Props) => { name: "mention", title: t("Mention"), attrs: { type: mentionType }, + appendSpace: true, }); } diff --git a/app/editor/components/SuggestionsMenu.tsx b/app/editor/components/SuggestionsMenu.tsx index 7ce101c1aa..7fe4b62a5b 100644 --- a/app/editor/components/SuggestionsMenu.tsx +++ b/app/editor/components/SuggestionsMenu.tsx @@ -12,6 +12,7 @@ import filterExcessSeparators from "@shared/editor/lib/filterExcessSeparators"; import { findParentNode } from "@shared/editor/queries/findParentNode"; import { MenuItem } from "@shared/editor/types"; import { depths, s } from "@shared/styles"; +import { MentionType } from "@shared/types"; import { getEventFiles } from "@shared/utils/files"; import { AttachmentValidation } from "@shared/validations"; import Header from "~/components/ContextMenu/Header"; @@ -64,7 +65,7 @@ export type Props = { onFileUploadStop?: () => void; /** Callback when the menu is closed */ onClose: (insertNewLine?: boolean) => void; - /** Optional callback when a suggestion is selected */ + /** Optional callback when a suggestion is selected/ */ onSelect?: (item: MenuItem) => void; embeds?: EmbedDescriptor[]; renderMenuItem: ( @@ -233,7 +234,11 @@ function SuggestionsMenu(props: Props) { const attrs = typeof item.attrs === "function" ? item.attrs(view.state) : item.attrs; - if (item.name === "noop") { + const skipMention = + attrs?.type === MentionType.Issue || + attrs?.type === MentionType.PullRequest; // Mention node creation will be handled by PasteHandler. + + if (item.name === "noop" || (item.name === "mention" && skipMention)) { // Do nothing } else if (command) { command(attrs); diff --git a/app/editor/extensions/PasteHandler.tsx b/app/editor/extensions/PasteHandler.tsx index 34ae51dc31..f84580c792 100644 --- a/app/editor/extensions/PasteHandler.tsx +++ b/app/editor/extensions/PasteHandler.tsx @@ -479,6 +479,8 @@ export default class PasteHandler extends Extension { default: break; } + + return true; }; keys() { diff --git a/app/models/Integration.ts b/app/models/Integration.ts index e68e020d5e..3a7c96f319 100644 --- a/app/models/Integration.ts +++ b/app/models/Integration.ts @@ -60,7 +60,7 @@ class Integration extends Model { const type = pathParts[3]; return type === "pull" ? MentionType.PullRequest - : type === "issue" + : type === "issues" ? MentionType.Issue : undefined; } diff --git a/shared/editor/nodes/Mention.tsx b/shared/editor/nodes/Mention.tsx index 14d10d618d..6f66736149 100644 --- a/shared/editor/nodes/Mention.tsx +++ b/shared/editor/nodes/Mention.tsx @@ -207,8 +207,6 @@ export default class Mention extends Node { commands({ type }: { type: NodeType; schema: Schema }) { return (attrs: Record): Command => (state, dispatch) => { - console.log("running mention command", attrs); - const { selection } = state; const position = selection instanceof TextSelection