text component

This commit is contained in:
hamid zarghami
2025-11-20 08:35:50 +03:30
parent 3b47e29ba4
commit 3454129dca
7 changed files with 321 additions and 13 deletions
@@ -1,6 +1,7 @@
import { useState, useRef, useEffect } from "react";
import Konva from "konva";
import { useEditorStore, type EditorObject } from "@/pages/editor/store/editorStore";
import { useTextDefaultsStore } from "@/pages/editor/store/textDefaultsStore";
import { createDrawingObject } from "./drawingUtils";
export const useDrawingHandlers = () => {
@@ -10,6 +11,7 @@ export const useDrawingHandlers = () => {
const transformerRef = useRef<Konva.Transformer>(null);
const { tool, addObject, updateObject, setSelectedObjectId, selectedObjectId } = useEditorStore();
const { defaults } = useTextDefaultsStore();
useEffect(() => {
setTempObject(null);
@@ -59,8 +61,13 @@ export const useDrawingHandlers = () => {
x: pointerPos.x,
y: pointerPos.y,
text: "متن جدید",
fontSize: 24,
fill: "#000000",
fontSize: defaults.fontSize,
fontFamily: defaults.fontFamily,
fontWeight: defaults.fontWeight,
fill: defaults.fill,
opacity: defaults.opacity,
letterSpacing: defaults.letterSpacing,
wordSpacing: defaults.wordSpacing,
};
addObject(newText);
setSelectedObjectId(newText.id);