|
|
@@ -1,8 +1,10 @@
|
|
|
import { Field, FieldRenderProps } from '@flowgram.ai/free-layout-editor';
|
|
|
+import { useClientContext, CommandService } from '@flowgram.ai/free-layout-editor';
|
|
|
import { Typography, Button } from '@douyinfe/semi-ui';
|
|
|
import { IconSmallTriangleDown, IconSmallTriangleLeft } from '@douyinfe/semi-icons';
|
|
|
|
|
|
import { Feedback } from '../feedback';
|
|
|
+import { FlowCommandId } from '../../shortcuts';
|
|
|
import { useIsSidebar, useNodeRenderContext } from '../../hooks';
|
|
|
import { NodeMenu } from '../../components/node-menu';
|
|
|
import { getIcon } from './utils';
|
|
|
@@ -11,12 +13,16 @@ import { Header, Operators, Title } from './styles';
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
export function FormHeader() {
|
|
|
- const { node, expanded, toggleExpand, readonly, deleteNode } = useNodeRenderContext();
|
|
|
+ const { node, expanded, toggleExpand, readonly } = useNodeRenderContext();
|
|
|
+ const ctx = useClientContext();
|
|
|
const isSidebar = useIsSidebar();
|
|
|
const handleExpand = (e: React.MouseEvent) => {
|
|
|
toggleExpand();
|
|
|
e.stopPropagation(); // Disable clicking prevents the sidebar from opening
|
|
|
};
|
|
|
+ const handleDelete = () => {
|
|
|
+ ctx.get<CommandService>(CommandService).executeCommand(FlowCommandId.DELETE, [node]);
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<Header>
|
|
|
@@ -42,7 +48,7 @@ export function FormHeader() {
|
|
|
)}
|
|
|
{readonly ? undefined : (
|
|
|
<Operators>
|
|
|
- <NodeMenu node={node} deleteNode={deleteNode} />
|
|
|
+ <NodeMenu node={node} deleteNode={handleDelete} />
|
|
|
</Operators>
|
|
|
)}
|
|
|
</Header>
|