handle multiple creation error

This commit is contained in:
hmacr committed 2025-04-02 16:44:41 +05:30
1 parent e1a12fd78b
commit 00ef7c46f6
5 files changed
+11 -5

No files matched your search

+1
View File
@@ -61,6 +61,7 @@ export const PasteMenu = observer(({ pastedText, embeds, ...props }: Props) => {
name: "mention",
title: t("Mention"),
attrs: { type: mentionType },
appendSpace: true,
});
}
+7 -2
View File
@@ -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<T extends MenuItem = MenuItem> = {
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<T extends MenuItem>(props: Props<T>) {
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);
+2
View File
@@ -479,6 +479,8 @@ export default class PasteHandler extends Extension {
default:
break;
}
return true;
};
keys() {
+1 -1
View File
@@ -60,7 +60,7 @@ class Integration<T = unknown> extends Model {
const type = pathParts[3];
return type === "pull"
? MentionType.PullRequest
: type === "issue"
: type === "issues"
? MentionType.Issue
: undefined;
}
-2
View File
@@ -207,8 +207,6 @@ export default class Mention extends Node {
commands({ type }: { type: NodeType; schema: Schema }) {
return (attrs: Record<string, Primitive>): Command =>
(state, dispatch) => {
console.log("running mention command", attrs);
const { selection } = state;
const position =
selection instanceof TextSelection