|
|
|
|
|
|
|
|
import { FormInstance, message } from 'antd'; |
|
|
import { FormInstance, message } from 'antd'; |
|
|
import dayjs from 'dayjs'; |
|
|
import dayjs from 'dayjs'; |
|
|
import { humanId } from 'human-id'; |
|
|
import { humanId } from 'human-id'; |
|
|
import { lowerFirst } from 'lodash'; |
|
|
|
|
|
|
|
|
import { get, lowerFirst } from 'lodash'; |
|
|
import trim from 'lodash/trim'; |
|
|
import trim from 'lodash/trim'; |
|
|
import { useTranslation } from 'react-i18next'; |
|
|
import { useTranslation } from 'react-i18next'; |
|
|
import { useParams } from 'umi'; |
|
|
import { useParams } from 'umi'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onCopyCapture = useCallback( |
|
|
const onCopyCapture = useCallback( |
|
|
(event: ClipboardEvent) => { |
|
|
(event: ClipboardEvent) => { |
|
|
|
|
|
if (get(event, 'srcElement.tagName') !== 'BODY') return; |
|
|
|
|
|
|
|
|
event.preventDefault(); |
|
|
event.preventDefault(); |
|
|
const nodesStr = JSON.stringify( |
|
|
const nodesStr = JSON.stringify( |
|
|
nodes.filter((n) => n.selected && n.data.label !== Operator.Begin), |
|
|
nodes.filter((n) => n.selected && n.data.label !== Operator.Begin), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onPasteCapture = useCallback( |
|
|
const onPasteCapture = useCallback( |
|
|
(event: ClipboardEvent) => { |
|
|
(event: ClipboardEvent) => { |
|
|
event.preventDefault(); |
|
|
|
|
|
const nodes = JSON.parse( |
|
|
const nodes = JSON.parse( |
|
|
event.clipboardData?.getData('agent:nodes') || '[]', |
|
|
event.clipboardData?.getData('agent:nodes') || '[]', |
|
|
) as Node[] | undefined; |
|
|
) as Node[] | undefined; |
|
|
if (nodes) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(nodes) && nodes.length) { |
|
|
|
|
|
event.preventDefault(); |
|
|
nodes.forEach((n) => { |
|
|
nodes.forEach((n) => { |
|
|
duplicateNode(n.id, n.data.label); |
|
|
duplicateNode(n.id, n.data.label); |
|
|
}); |
|
|
}); |