diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts index 8cf61b6d33..e271384cc2 100644 --- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts +++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts @@ -116,6 +116,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard }); this._usmToHtml = new USMToHtmlService(); this._copyContentCache = new CopyContentCache(); + + this.disposeWithMe(this._htmlToUSM); } copyContentCache(): CopyContentCache { diff --git a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts index 5cd3b80a79..08a19dcb22 100644 --- a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts +++ b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts @@ -383,6 +383,10 @@ export class HtmlToUSMService { } } } + + dispose() { + document.body.removeChild(this.htmlElement); + } } /** diff --git a/packages/ui/src/views/App.tsx b/packages/ui/src/views/App.tsx index 5ed2365ffc..9a862f2c3f 100644 --- a/packages/ui/src/views/App.tsx +++ b/packages/ui/src/views/App.tsx @@ -83,6 +83,9 @@ export function App(props: IUniverAppProps) { return () => { // batch unsubscribe subscriptions.forEach((subscription) => subscription.unsubscribe()); + + // cleanup + document.body.removeChild(portalContainer); }; }, [localeService, messageService, mountContainer, portalContainer, themeService.currentTheme$]);