diff --git a/eduaid_web/src/pages/Text_Input.jsx b/eduaid_web/src/pages/Text_Input.jsx index e341d331..e1b7fcb9 100644 --- a/eduaid_web/src/pages/Text_Input.jsx +++ b/eduaid_web/src/pages/Text_Input.jsx @@ -3,7 +3,7 @@ import "../index.css"; import logo_trans from "../assets/aossie_logo_transparent.png" import stars from "../assets/stars.png"; import cloud from "../assets/cloud.png"; -import { FaClipboard } from "react-icons/fa"; +import { FaClipboard, FaTrashAlt } from "react-icons/fa"; import Switch from "react-switch"; import { Link,useNavigate } from "react-router-dom"; import apiClient from "../utils/apiClient"; @@ -15,6 +15,7 @@ const Text_Input = () => { const [numQuestions, setNumQuestions] = useState(10); const [loading, setLoading] = useState(false); const fileInputRef = useRef(null); + const textareaRef = useRef(null); const [fileContent, setFileContent] = useState(""); const [docUrl, setDocUrl] = useState(""); const [isToggleOn, setIsToggleOn] = useState(0); @@ -23,6 +24,27 @@ const Text_Input = () => { setIsToggleOn((isToggleOn + 1) % 2); }; + const handlePaste = async () => { + try { + const clipboardText = await navigator.clipboard.readText(); + setText(clipboardText); + } catch (err) { + console.error("Failed to read clipboard:", err); + } + }; + + const handleClearText = () => { + setText(""); + setFileContent(""); + setDocUrl(""); + if (fileInputRef.current) { + fileInputRef.current.value = ""; + } + if (textareaRef.current) { + textareaRef.current.focus(); + } + }; + const handleFileUpload = async (event) => { const file = event.target.files[0]; if (file) { @@ -167,11 +189,30 @@ const Text_Input = () => { {/* Textarea */}