Compare commits

...

1 Commits

Author SHA1 Message Date
李冠辰
aa312c3789 feat(comments): allow selecting multiple attachments 2026-05-27 10:07:59 +08:00
4 changed files with 10 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ interface FileUploadButtonProps {
disabled?: boolean;
className?: string;
size?: "sm" | "default";
multiple?: boolean;
}
function FileUploadButton({
@@ -18,16 +19,17 @@ function FileUploadButton({
disabled,
className,
size = "default",
multiple = false,
}: FileUploadButtonProps) {
const { t } = useTranslation("ui");
const inputRef = useRef<HTMLInputElement>(null);
const attachLabel = t(($) => $.attach_file);
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (!file) return;
const files = Array.from(e.target.files ?? []);
if (files.length === 0) return;
e.target.value = "";
onSelect(file);
for (const file of files) onSelect(file);
};
const iconSize = size === "sm" ? "h-3.5 w-3.5" : "h-4 w-4";
@@ -52,6 +54,7 @@ function FileUploadButton({
<input
ref={inputRef}
type="file"
multiple={multiple}
className="hidden"
onChange={handleChange}
/>

View File

@@ -434,6 +434,7 @@ function CommentRow({
)}
<FileUploadButton
size="sm"
multiple
onSelect={(file) => editEditorRef.current?.uploadFile(file)}
/>
</div>
@@ -760,6 +761,7 @@ function CommentCardImpl({
)}
<FileUploadButton
size="sm"
multiple
onSelect={(file) => editEditorRef.current?.uploadFile(file)}
/>
</div>

View File

@@ -135,6 +135,7 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {
</Tooltip>
<FileUploadButton
size="sm"
multiple
onSelect={(file) => editorRef.current?.uploadFile(file)}
/>
<SubmitButton

View File

@@ -166,6 +166,7 @@ function ReplyInput({
</Tooltip>
<FileUploadButton
size="sm"
multiple
onSelect={(file) => editorRef.current?.uploadFile(file)}
/>
<button