From bd5bf852fc839b42a6eb97440a9b939c90a1f70c Mon Sep 17 00:00:00 2001 From: liujuping Date: Fri, 12 Jan 2024 15:51:18 +0800 Subject: [PATCH] fix: fix clipboard.setData fial in workspace mode --- packages/designer/src/designer/clipboard.ts | 4 ++++ packages/designer/src/designer/designer-view.tsx | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/designer/src/designer/clipboard.ts b/packages/designer/src/designer/clipboard.ts index 941f91442..26f57f811 100644 --- a/packages/designer/src/designer/clipboard.ts +++ b/packages/designer/src/designer/clipboard.ts @@ -36,6 +36,10 @@ class Clipboard implements IClipboard { private waitFn?: (data: any, e: ClipboardEvent) => void; + constructor() { + this.injectCopyPaster(document); + } + isCopyPasteEvent(e: Event) { this.isCopyPaster(e.target); } diff --git a/packages/designer/src/designer/designer-view.tsx b/packages/designer/src/designer/designer-view.tsx index 0db2a3fa3..aaf0c9583 100644 --- a/packages/designer/src/designer/designer-view.tsx +++ b/packages/designer/src/designer/designer-view.tsx @@ -4,7 +4,6 @@ import BuiltinDragGhostComponent from './drag-ghost'; import { Designer, DesignerProps } from './designer'; import { ProjectView } from '../project'; import './designer.less'; -import { clipboard } from './clipboard'; type IProps = DesignerProps & { designer?: Designer; @@ -44,7 +43,6 @@ export class DesignerView extends Component { if (onMount) { onMount(this.designer); } - clipboard.injectCopyPaster(document); this.designer.postEvent('mount', this.designer); }