18 lines
448 B
TypeScript
18 lines
448 B
TypeScript
import { useState, useCallback } from 'react';
|
|
import { mindmapCommandBus } from '@/lib/mindmap/command/MindmapCommandBus';
|
|
|
|
export function useMindmapTextEdit(nodeId: string) {
|
|
const [value, setValue] = useState('');
|
|
|
|
const handleChange = useCallback(
|
|
(next: string) => {
|
|
setValue(next);
|
|
mindmapCommandBus.emit('SET_NODE_TEXT', { nodeId, text: next });
|
|
},
|
|
[nodeId],
|
|
);
|
|
|
|
return { value, setValue, handleChange };
|
|
}
|
|
|