ad72e4691c
生成视频结果写入编辑器资源和素材库,并返回视频素材快照 上传视频使用真实视频尺寸创建素材和画布图层 素材库视频卡片使用签名地址渲染首帧预览并显示视频标签 剪贴板图片粘贴重新接入系统粘贴和右键粘贴路径 多选图层拖拽保留已有选区并批量移动 图标规范引用支持对象存储资源和素材引用,不再要求 Data URL 音效和背景音乐生成失败展示上游详细原因
156 lines
3.5 KiB
TypeScript
156 lines
3.5 KiB
TypeScript
import type {
|
|
ComponentType,
|
|
DragEventHandler,
|
|
MouseEventHandler,
|
|
PointerEventHandler,
|
|
ReactNode,
|
|
} from 'react';
|
|
|
|
import {
|
|
PlatformIconButton,
|
|
type PlatformIconButtonVariant,
|
|
} from '../common/PlatformIconButton';
|
|
import { PlatformMediaFrame } from '../common/PlatformMediaFrame';
|
|
|
|
type IconComponent = ComponentType<{ className?: string }>;
|
|
|
|
export type EditorIconButtonProps = {
|
|
label: string;
|
|
title?: string;
|
|
icon: IconComponent;
|
|
className?: string;
|
|
type?: 'button' | 'submit';
|
|
disabled?: boolean;
|
|
pressed?: boolean;
|
|
expanded?: boolean;
|
|
variant?: PlatformIconButtonVariant;
|
|
onClick?: () => void;
|
|
};
|
|
|
|
export function EditorIconButton({
|
|
label,
|
|
title = label,
|
|
icon: Icon,
|
|
className,
|
|
type = 'button',
|
|
disabled,
|
|
pressed,
|
|
expanded,
|
|
variant,
|
|
onClick,
|
|
}: EditorIconButtonProps) {
|
|
return (
|
|
<PlatformIconButton
|
|
variant={variant}
|
|
type={type}
|
|
className={className}
|
|
label={label}
|
|
title={title}
|
|
disabled={disabled}
|
|
aria-pressed={pressed}
|
|
aria-expanded={expanded}
|
|
onClick={onClick}
|
|
icon={<Icon className="h-4 w-4" />}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export type SidebarMediaItemProps = {
|
|
title: string;
|
|
detail: string;
|
|
imageSrc: string;
|
|
objectKey?: string | null;
|
|
imageAlt: string;
|
|
selected?: boolean;
|
|
primaryLabel: string;
|
|
onPrimaryClick: () => void;
|
|
thumbnailClassName: string;
|
|
metaClassName: string;
|
|
rowClassName: string;
|
|
primaryClassName?: string;
|
|
actions?: ReactNode;
|
|
titleNode?: ReactNode;
|
|
previewNode?: ReactNode;
|
|
previewOverlay?: ReactNode;
|
|
footerNode?: ReactNode;
|
|
draggable?: boolean;
|
|
onDragStart?: DragEventHandler<HTMLElement>;
|
|
onDragEnd?: DragEventHandler<HTMLElement>;
|
|
onDragOver?: DragEventHandler<HTMLDivElement>;
|
|
onDrop?: DragEventHandler<HTMLDivElement>;
|
|
onPointerDown?: PointerEventHandler<HTMLDivElement>;
|
|
onPointerEnter?: PointerEventHandler<HTMLDivElement>;
|
|
onContextMenu?: MouseEventHandler<HTMLDivElement>;
|
|
};
|
|
|
|
export function SidebarMediaItem({
|
|
title,
|
|
detail,
|
|
imageSrc,
|
|
objectKey,
|
|
imageAlt,
|
|
selected = false,
|
|
primaryLabel,
|
|
onPrimaryClick,
|
|
thumbnailClassName,
|
|
metaClassName,
|
|
rowClassName,
|
|
primaryClassName,
|
|
actions,
|
|
titleNode,
|
|
previewNode,
|
|
previewOverlay,
|
|
footerNode,
|
|
draggable,
|
|
onDragStart,
|
|
onDragEnd,
|
|
onDragOver,
|
|
onDrop,
|
|
onPointerDown,
|
|
onPointerEnter,
|
|
onContextMenu,
|
|
}: SidebarMediaItemProps) {
|
|
return (
|
|
<div
|
|
className={`${rowClassName} ${selected ? `${rowClassName}--selected` : ''}`}
|
|
draggable={draggable}
|
|
onDragStart={onDragStart}
|
|
onDragEnd={onDragEnd}
|
|
onDragOver={onDragOver}
|
|
onDrop={onDrop}
|
|
onPointerDown={onPointerDown}
|
|
onPointerEnter={onPointerEnter}
|
|
onContextMenu={onContextMenu}
|
|
>
|
|
<button
|
|
type="button"
|
|
className={primaryClassName}
|
|
onClick={onPrimaryClick}
|
|
aria-label={primaryLabel}
|
|
draggable={draggable}
|
|
onDragStart={onDragStart}
|
|
onDragEnd={onDragEnd}
|
|
>
|
|
{previewNode ?? (
|
|
<PlatformMediaFrame
|
|
src={imageSrc}
|
|
objectKey={objectKey}
|
|
alt={imageAlt}
|
|
fallbackLabel={title}
|
|
aspect="square"
|
|
surface="none"
|
|
className={thumbnailClassName}
|
|
previewOverlay={previewOverlay}
|
|
/>
|
|
)}
|
|
</button>
|
|
<div className={metaClassName}>
|
|
{titleNode ?? <span>{title}</span>}
|
|
<span>{detail}</span>
|
|
{footerNode}
|
|
</div>
|
|
{actions}
|
|
</div>
|
|
);
|
|
}
|