balibabu
commited on
Commit
·
480ea1f
1
Parent(s):
9bf7e7d
fix: Cannot copy and paste text on agent page #3356 (#3357)
Browse files### What problem does this PR solve?
fix: Cannot copy and paste text on agent page #3356
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
web/src/pages/flow/hooks.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { useDebounceEffect } from 'ahooks';
|
|
| 23 |
import { FormInstance, message } from 'antd';
|
| 24 |
import dayjs from 'dayjs';
|
| 25 |
import { humanId } from 'human-id';
|
| 26 |
-
import { lowerFirst } from 'lodash';
|
| 27 |
import trim from 'lodash/trim';
|
| 28 |
import { useTranslation } from 'react-i18next';
|
| 29 |
import { useParams } from 'umi';
|
|
@@ -641,6 +641,8 @@ export const useCopyPaste = () => {
|
|
| 641 |
|
| 642 |
const onCopyCapture = useCallback(
|
| 643 |
(event: ClipboardEvent) => {
|
|
|
|
|
|
|
| 644 |
event.preventDefault();
|
| 645 |
const nodesStr = JSON.stringify(
|
| 646 |
nodes.filter((n) => n.selected && n.data.label !== Operator.Begin),
|
|
@@ -653,11 +655,12 @@ export const useCopyPaste = () => {
|
|
| 653 |
|
| 654 |
const onPasteCapture = useCallback(
|
| 655 |
(event: ClipboardEvent) => {
|
| 656 |
-
event.preventDefault();
|
| 657 |
const nodes = JSON.parse(
|
| 658 |
event.clipboardData?.getData('agent:nodes') || '[]',
|
| 659 |
) as Node[] | undefined;
|
| 660 |
-
|
|
|
|
|
|
|
| 661 |
nodes.forEach((n) => {
|
| 662 |
duplicateNode(n.id, n.data.label);
|
| 663 |
});
|
|
|
|
| 23 |
import { FormInstance, message } from 'antd';
|
| 24 |
import dayjs from 'dayjs';
|
| 25 |
import { humanId } from 'human-id';
|
| 26 |
+
import { get, lowerFirst } from 'lodash';
|
| 27 |
import trim from 'lodash/trim';
|
| 28 |
import { useTranslation } from 'react-i18next';
|
| 29 |
import { useParams } from 'umi';
|
|
|
|
| 641 |
|
| 642 |
const onCopyCapture = useCallback(
|
| 643 |
(event: ClipboardEvent) => {
|
| 644 |
+
if (get(event, 'srcElement.tagName') !== 'BODY') return;
|
| 645 |
+
|
| 646 |
event.preventDefault();
|
| 647 |
const nodesStr = JSON.stringify(
|
| 648 |
nodes.filter((n) => n.selected && n.data.label !== Operator.Begin),
|
|
|
|
| 655 |
|
| 656 |
const onPasteCapture = useCallback(
|
| 657 |
(event: ClipboardEvent) => {
|
|
|
|
| 658 |
const nodes = JSON.parse(
|
| 659 |
event.clipboardData?.getData('agent:nodes') || '[]',
|
| 660 |
) as Node[] | undefined;
|
| 661 |
+
|
| 662 |
+
if (Array.isArray(nodes) && nodes.length) {
|
| 663 |
+
event.preventDefault();
|
| 664 |
nodes.forEach((n) => {
|
| 665 |
duplicateNode(n.id, n.data.label);
|
| 666 |
});
|