From 1393a8eff0be7da71dfdba8d585888e47c70b84d Mon Sep 17 00:00:00 2001 From: liujuping Date: Mon, 15 Jan 2024 10:02:26 +0800 Subject: [PATCH] fix(canvas): clipboard init error --- packages/designer/src/designer/clipboard.ts | 8 +++++++- packages/types/src/shell/api/material.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/designer/src/designer/clipboard.ts b/packages/designer/src/designer/clipboard.ts index 941f91442..7fab9cb2c 100644 --- a/packages/designer/src/designer/clipboard.ts +++ b/packages/designer/src/designer/clipboard.ts @@ -69,7 +69,13 @@ class Clipboard implements IClipboard { } const copyPaster = document.createElement<'textarea'>('textarea'); copyPaster.style.cssText = 'position: absolute;left: -9999px;top:-100px'; - document.body.appendChild(copyPaster); + if (document.body) { + document.body.appendChild(copyPaster); + } else { + document.addEventListener('DOMContentLoaded', () => { + document.body.appendChild(copyPaster); + }); + } const dispose = this.initCopyPaster(copyPaster); return () => { dispose(); diff --git a/packages/types/src/shell/api/material.ts b/packages/types/src/shell/api/material.ts index 6354c7fa0..89b2b39ad 100644 --- a/packages/types/src/shell/api/material.ts +++ b/packages/types/src/shell/api/material.ts @@ -15,7 +15,7 @@ export interface IPublicApiMaterial { * set data for Assets * @returns void */ - setAssets(assets: IPublicTypeAssetsJson): void; + setAssets(assets: IPublicTypeAssetsJson): Promise; /** * 获取「资产包」结构