Files
Genarrative/src/components/image-editor/EditorAgentConversation/common.ts
T
k88936 9bb4942ae7
Project CI / Repository checks (push) Successful in 1m21s
Project CI / Frontend tests (push) Successful in 31s
Project CI / Native shell tests (push) Successful in 2m25s
Project CI / Backend tests (push) Successful in 3m7s
Editor agent 右键菜单支持复制, 引用,下载 (#95)
Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/95
Co-authored-by: 王德宇 <kvtodev@outlook.com>
Co-committed-by: 王德宇 <kvtodev@outlook.com>
2026-07-22 18:00:27 +08:00

42 lines
1.2 KiB
TypeScript

import type { MouseEvent as ReactMouseEvent } from 'react';
import type { EditorAgentAttachmentRef } from '@/packages/shared/src/contracts';
export enum EditorAgentRightClickAction {
CopyText = 'copy_text',
CopyImage = 'copy_image',
ReferenceImage = 'reference_image',
DownloadAsset = 'download_asset',
}
export type EditorAgentContextAsset =
| (EditorAgentAttachmentRef & {
kind: 'attachment';
mediaType: 'image';
suggestedFileName: string;
})
| {
kind: 'generated_media';
mediaType: 'image' | 'video' | 'audio';
mediaSrc: string;
objectKey?: string | null;
suggestedFileName: string;
};
export type RightClickMenuTarget =
| { kind: 'text'; text: string }
| { kind: 'asset'; asset: EditorAgentContextAsset };
export type RightClickMenuHandler = (
event: ReactMouseEvent<HTMLElement>,
asset: EditorAgentContextAsset,
) => void;
export function attachmentKey(attachment: EditorAgentAttachmentRef) {
return `${attachment.source}:${attachment.referenceId}`;
}
export function contextAssetMediaSrc(asset: EditorAgentContextAsset) {
return asset.kind === 'attachment' ? asset.imageSrc : asset.mediaSrc;
}