ajout du bouton suppression
This commit is contained in:
@@ -80,6 +80,7 @@ interface StoryNodeProps {
|
||||
onSetEditing: (id: string | null) => void;
|
||||
onToggleColorPicker: (id: string) => void;
|
||||
onSaveColor: (color: string) => void;
|
||||
onDelete: (id: string, e: React.MouseEvent) => void;
|
||||
onNavigateToEntity: (id: string) => void;
|
||||
|
||||
onInputFocus: (e: React.FocusEvent) => void;
|
||||
@@ -90,7 +91,7 @@ interface StoryNodeProps {
|
||||
const StoryNode = React.memo(({
|
||||
node, isSelected, isEditing, isDragging, activeColorPickerId, entities, savedColors,
|
||||
onMouseDown, onMouseUp, onStartConnection, onUpdate, onSetEditing,
|
||||
onToggleColorPicker, onSaveColor, onNavigateToEntity,
|
||||
onToggleColorPicker, onSaveColor, onDelete, onNavigateToEntity,
|
||||
onInputFocus, onInputCheckAutocomplete, onKeyDownInInput
|
||||
}: StoryNodeProps) => {
|
||||
const { t } = useLanguage();
|
||||
@@ -199,6 +200,16 @@ const StoryNode = React.memo(({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="absolute bottom-2 left-2 z-20">
|
||||
<button
|
||||
className="p-1.5 rounded-full bg-white/70 hover:bg-red-50 hover:text-red-500 shadow-sm border border-slate-100 hover:border-red-200 transition-all opacity-0 group-hover:opacity-100 text-slate-400"
|
||||
onClick={(e) => onDelete(node.id, e)}
|
||||
title={t('sw.delete')}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="absolute bottom-2 right-2 z-20">
|
||||
{showTypePicker && (
|
||||
<div className="absolute bottom-full mb-2 right-0 bg-white shadow-xl border border-slate-200 rounded-lg p-1 flex gap-1 animate-in zoom-in-95 duration-100 w-max" onMouseDown={(e) => e.stopPropagation()}>
|
||||
@@ -590,6 +601,19 @@ const StoryWorkflow: React.FC<StoryWorkflowProps> = ({ data, onUpdate, entities,
|
||||
setSelectedNodeIds(new Set());
|
||||
};
|
||||
|
||||
const handleDeleteNode = (id: string, e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
pushHistory();
|
||||
const newNodes = internalNodes.filter(n => n.id !== id);
|
||||
const newConnections = data.connections.filter(c => c.source !== id && c.target !== id);
|
||||
onUpdate({ nodes: newNodes, connections: newConnections });
|
||||
setSelectedNodeIds(prev => {
|
||||
const next = new Set(prev);
|
||||
next.delete(id);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const handleAddNodeCenter = () => {
|
||||
pushHistory();
|
||||
const scrollLeft = containerRef.current?.scrollLeft || 0;
|
||||
@@ -689,6 +713,7 @@ const StoryWorkflow: React.FC<StoryWorkflowProps> = ({ data, onUpdate, entities,
|
||||
onSetEditing={setEditingNodeId}
|
||||
onToggleColorPicker={handleToggleColorPicker}
|
||||
onSaveColor={handleSaveColor}
|
||||
onDelete={handleDeleteNode}
|
||||
onNavigateToEntity={onNavigateToEntity}
|
||||
onInputFocus={handleInputFocus}
|
||||
onInputCheckAutocomplete={handleInputWithAutocomplete}
|
||||
|
||||
Reference in New Issue
Block a user