diff --git a/components/canvas/canvas-with-tools.tsx b/components/canvas/canvas-with-tools.tsx index 6dc909d..f1aff0b 100644 --- a/components/canvas/canvas-with-tools.tsx +++ b/components/canvas/canvas-with-tools.tsx @@ -202,6 +202,24 @@ export function CanvasWithTools() { return; } + // Text tool + if (activeTool === 'text') { + const activeLayer = getActiveLayer(); + if (!activeLayer || !activeLayer.canvas || activeLayer.locked) return; + + const newPointer: PointerState = { + isDown: true, + x: canvasPos.x, + y: canvasPos.y, + prevX: canvasPos.x, + prevY: canvasPos.y, + pressure: e.pressure || 1, + }; + + tools.text.onPointerDown(newPointer, {} as any, settings); + return; + } + // Selection tools const selectionTools = ['select', 'rectangular-select', 'elliptical-select', 'lasso-select', 'magic-wand']; if (e.button === 0 && !e.shiftKey && selectionTools.includes(activeTool)) { diff --git a/components/editor/tool-options.tsx b/components/editor/tool-options.tsx index f557f5c..3a1a231 100644 --- a/components/editor/tool-options.tsx +++ b/components/editor/tool-options.tsx @@ -3,11 +3,13 @@ import { useToolStore } from '@/store'; import { useShapeStore } from '@/store/shape-store'; import { useSelectionStore } from '@/store/selection-store'; +import { useTextStore } from '@/store/text-store'; export function ToolOptions() { const { activeTool, settings, setSize, setOpacity, setHardness, setColor, setFlow } = useToolStore(); const { settings: shapeSettings, setShapeType } = useShapeStore(); const { selectionType, setSelectionType } = useSelectionStore(); + const { settings: textSettings, setFontFamily, setFontSize, setColor: setTextColor } = useTextStore(); // Drawing tools: brush, pencil, eraser const isDrawingTool = ['brush', 'eraser', 'pencil'].includes(activeTool); @@ -24,8 +26,11 @@ export function ToolOptions() { // Selection tool const isSelectionTool = activeTool === 'select'; + // Text tool + const isTextTool = activeTool === 'text'; + // Don't show options bar if no options available - if (!isDrawingTool && !isFillTool && !isShapeTool && !isSelectionTool) { + if (!isDrawingTool && !isFillTool && !isShapeTool && !isSelectionTool && !isTextTool) { return null; } @@ -208,6 +213,66 @@ export function ToolOptions() { )} + + {/* Text Tool Options */} + {isTextTool && ( + <> +