From 8ba2357d91fb33bb9cc6eb1031677b1ac2bc517e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Dec 2025 22:14:05 +0200 Subject: [PATCH] feat(layout/file): upload new revision button --- .../src/widgets/react/FormFileUpload.tsx | 30 +++++++++++-- .../src/widgets/ribbon/FilePropertiesTab.tsx | 42 ++++++++++--------- .../client/src/widgets/ribbon/NoteActions.tsx | 17 ++++++-- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/apps/client/src/widgets/react/FormFileUpload.tsx b/apps/client/src/widgets/react/FormFileUpload.tsx index 83db15ebb..e97e73184 100644 --- a/apps/client/src/widgets/react/FormFileUpload.tsx +++ b/apps/client/src/widgets/react/FormFileUpload.tsx @@ -1,7 +1,9 @@ import { Ref } from "preact"; -import Button, { ButtonProps } from "./Button"; import { useEffect, useRef } from "preact/hooks"; +import ActionButton, { ActionButtonProps } from "./ActionButton"; +import Button, { ButtonProps } from "./Button"; + interface FormFileUploadProps { name?: string; onChange: (files: FileList | null) => void; @@ -26,7 +28,7 @@ export default function FormFileUpload({ inputRef, name, onChange, multiple, hid multiple={multiple} onChange={e => onChange((e.target as HTMLInputElement).files)} /> - ) + ); } /** @@ -49,5 +51,27 @@ export function FormFileUploadButton({ onChange, ...buttonProps }: Omit - ) + ); +} + +/** + * Similar to {@link FormFileUploadButton}, but uses an {@link ActionButton} instead of a normal {@link Button}. + * @param param the change listener for the file upload and the properties for the button. + */ +export function FormFileUploadActionButton({ onChange, ...buttonProps }: Omit & Pick) { + const inputRef = useRef(null); + + return ( + <> + inputRef.current?.click()} + /> +