- Restore card to readable size (py-0.5, px-2, text-xs, rounded-md) - Add max-w-72 and truncate on title for long issue names - Move vertical-align: middle to [data-node-view-wrapper] (outermost inline element) instead of inner <a> — fixes centering within line - Always render card style even when issue not in store (fallback shows identifier only) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
"use client";
|
|
|
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
import type { NodeViewProps } from "@tiptap/react";
|
|
import { useIssueStore } from "@/features/issues/store";
|
|
import { StatusIcon } from "@/features/issues/components/status-icon";
|
|
|
|
export function MentionView({ node }: NodeViewProps) {
|
|
const { type, id, label } = node.attrs;
|
|
|
|
if (type === "issue") {
|
|
return (
|
|
<NodeViewWrapper as="span" className="inline">
|
|
<IssueMention issueId={id} fallbackLabel={label} />
|
|
</NodeViewWrapper>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<NodeViewWrapper as="span" className="inline">
|
|
<span className="mention">@{label ?? id}</span>
|
|
</NodeViewWrapper>
|
|
);
|
|
}
|
|
|
|
function IssueMention({
|
|
issueId,
|
|
fallbackLabel,
|
|
}: {
|
|
issueId: string;
|
|
fallbackLabel?: string;
|
|
}) {
|
|
const issue = useIssueStore((s) => s.issues.find((i) => i.id === issueId));
|
|
|
|
const handleClick = (e: React.MouseEvent) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
window.open(`/issues/${issueId}`, "_blank", "noopener,noreferrer");
|
|
};
|
|
|
|
const cardClass =
|
|
"issue-mention inline-flex items-center gap-1.5 rounded-md border mx-0.5 px-2 py-0.5 text-xs hover:bg-accent transition-colors cursor-pointer max-w-72";
|
|
|
|
if (!issue) {
|
|
return (
|
|
<a href={`/issues/${issueId}`} onClick={handleClick} className={cardClass}>
|
|
<span className="font-medium text-muted-foreground">
|
|
{fallbackLabel ?? issueId.slice(0, 8)}
|
|
</span>
|
|
</a>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<a href={`/issues/${issueId}`} onClick={handleClick} className={cardClass}>
|
|
<StatusIcon status={issue.status} className="h-3.5 w-3.5 shrink-0" />
|
|
<span className="font-medium text-muted-foreground shrink-0">{issue.identifier}</span>
|
|
<span className="text-foreground truncate">{issue.title}</span>
|
|
</a>
|
|
);
|
|
}
|