From dfb4d377d04367478b7d3508a5489f0c1929dde3 Mon Sep 17 00:00:00 2001 From: tlartem Date: Wed, 16 Jul 2025 19:07:20 +0300 Subject: [PATCH] =?UTF-8?q?=D1=85=D0=BE=D0=BB=D1=81=D1=82=20=D1=84=D0=B8?= =?UTF-8?q?=D0=B3=D1=83=D1=80=D1=8B=20=D0=BC=D0=B5=D0=BD=D1=8F=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TemplateManager/VisualLayoutEditor.tsx | 118 +++++++++++++++--- 1 file changed, 98 insertions(+), 20 deletions(-) diff --git a/src/components/TemplateManager/VisualLayoutEditor.tsx b/src/components/TemplateManager/VisualLayoutEditor.tsx index 499887c..6e3a86b 100644 --- a/src/components/TemplateManager/VisualLayoutEditor.tsx +++ b/src/components/TemplateManager/VisualLayoutEditor.tsx @@ -15,6 +15,8 @@ import React, { useCallback, useMemo, useState } from 'react'; import { Rnd } from 'react-rnd'; import { ElementLayout, ElementType, FormLayoutSettings, TemplateElement } from '../../types/template'; import { Button } from '../ui/button'; +import { Input } from '../ui/input'; +import { Textarea } from '../ui/textarea'; interface VisualLayoutEditorProps { elements: TemplateElement[]; @@ -65,7 +67,6 @@ const DraggableElement: React.FC = React.memo(({ gridSize, }) => { const layout = element.layout || { x: 50, y: 50, width: 300, height: 80, zIndex: 1 }; - const elementColor = ELEMENT_COLORS[element.type]; const handleDragStop = useCallback((_e: any, d: { x: number; y: number }) => { // Вызываем onUpdate только если позиция действительно изменилась, @@ -95,6 +96,57 @@ const DraggableElement: React.FC = React.memo(({ onEdit?.(); }, [onEdit]); + /* + * Render a lightweight, disabled preview of the element so that the user can + * see how the real control looks directly on the canvas instead of a plain + * colored square. Keeping the elements disabled and wrapped with + * `pointer-events-none` guarantees that they do not interfere with the drag + * behaviour of Rnd and keeps rendering costs minimal. + */ + const previewControl = useMemo(() => { + switch (element.type) { + case 'text': + return ; + case 'textarea': + return