import { Button } from "../ui/Button"; import { X } from "lucide-react"; import { ScrollArea } from "../ui/scroll-area"; import { useContext, useEffect, useState } from "react"; import CanvasContext from "../Context/canvasContext/CanvasContext"; import ActiveObjectContext from "../Context/activeObject/ObjectContext"; import { fabric } from "fabric"; import CommonPanel from "./CommonPanel"; export default function TextPanel() { const { canvas, setSelectedPanel } = useContext(CanvasContext); const { activeObject, setActiveObject } = useContext(ActiveObjectContext); const [open, setOpen] = useState(false); useEffect(() => { if (activeObject) { setOpen(true); } else { setOpen(false); } }, [activeObject]); const addText = () => { if (canvas) { const text = new fabric.IText("Editable Text", { left: 100, top: 100, fontFamily: "Poppins", fontSize: 16, stroke: "", // empty string for no stroke color strokeWidth: 0, // set stroke width to 0 }); // Add the text to the canvas and re-render canvas.add(text); // canvas.clipPath = text; canvas.setActiveObject(text); setActiveObject(text); canvas.renderAll(); } }; return (

Text

{!open ? (

No active object found

) : (
)}
); }