Merge branch 'main' into 652-bug---broadcastchannel-duplicate-tab

This commit is contained in:
yassinedorbozgithub
2025-01-31 08:17:50 +01:00
13 changed files with 208 additions and 47 deletions

View File

@@ -3,5 +3,5 @@
right: 25px !important;
bottom: 25px !important;
z-index: 999 !important;
box-shadow: 0 0 8px #0003 !important;
box-shadow: 0 0 8px #c4c4c4 !important;
}

View File

@@ -1,14 +1,15 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import React, { ChangeEvent } from "react";
import React, { ChangeEvent, useMemo } from "react";
import { useChat } from "../../providers/ChatProvider";
import { MIME_TYPES } from "../../utils/attachment";
import FileInputIcon from "../icons/FileInputIcon";
import "./FileButton.scss";
@@ -23,12 +24,17 @@ const FileButton: React.FC = () => {
setFile && setFile(e.target.files[0]);
}
};
const acceptedMimeTypes = useMemo(
() => Object.values(MIME_TYPES).flat().join(","),
[],
);
return (
<div className="sc-user-input--file-wrapper">
<button className="sc-user-input--file-icon-wrapper" type="button">
<FileInputIcon />
<input
accept={acceptedMimeTypes}
type="file"
id="file-input"
onChange={handleChange}

View File

@@ -1,11 +1,12 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { FileType } from "../types/message.types";
export function getFileType(mimeType: string): FileType {
@@ -19,3 +20,41 @@ export function getFileType(mimeType: string): FileType {
return FileType.file;
}
}
export const MIME_TYPES = {
images: ["image/jpeg", "image/png", "image/webp", "image/bmp"],
videos: [
"video/mp4",
"video/webm",
"video/ogg",
"video/quicktime", // common in apple devices
"video/x-msvideo", // AVI
"video/x-matroska", // MKV
],
audios: [
"audio/mpeg", // MP3
"audio/mp3", // Explicit MP3 type
"audio/ogg",
"audio/wav",
"audio/aac", // common in apple devices
"audio/x-wav",
],
documents: [
"application/pdf",
"application/msword", // older ms Word format
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", // newer ms word format
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.ms-excel", // older excel format
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // newer excel format
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"text/plain",
"application/rtf",
"application/epub+zip",
"application/x-7z-compressed",
"application/zip",
"application/x-rar-compressed",
"application/json",
"text/csv",
],
};