From b1a39fa2e77a02c7f9b7a29a43df66c0b734b20c Mon Sep 17 00:00:00 2001 From: x1a0t <405028157@qq.com> Date: Fri, 6 Jan 2023 15:03:42 +0800 Subject: [PATCH] feat: compatiable with async importMarkdown() --- packages/app/src/hooks/use-props-updated.ts | 2 +- packages/app/src/pages/playground/templates.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/app/src/hooks/use-props-updated.ts b/packages/app/src/hooks/use-props-updated.ts index ad6fc2525a..f0df6ffd49 100644 --- a/packages/app/src/hooks/use-props-updated.ts +++ b/packages/app/src/hooks/use-props-updated.ts @@ -26,7 +26,7 @@ export const usePropsUpdated: UsePropsUpdated = () => { return () => { callbackQueue.current = []; - editor?.model?.propsUpdated.dispose(); + editor?.model?.propsUpdated?.dispose(); }; }, [editor]); diff --git a/packages/app/src/pages/playground/templates.tsx b/packages/app/src/pages/playground/templates.tsx index d32cbaa3f5..a83d25e516 100644 --- a/packages/app/src/pages/playground/templates.tsx +++ b/packages/app/src/pages/playground/templates.tsx @@ -43,13 +43,16 @@ const All = () => { if (page) { currentWorkspace?.setPageMeta(page.id, { title }); if (page && page.root === null) { - setTimeout(() => { + setTimeout(async () => { const editor = document.querySelector('editor-container'); if (editor) { page.addBlock({ flavour: 'affine:surface' }, null); const frameId = page.addBlock({ flavour: 'affine:frame' }, pageId); // TODO blocksuite should offer a method to import markdown from store - editor.clipboard.importMarkdown(template.source, `${frameId}`); + await editor.clipboard.importMarkdown( + template.source, + `${frameId}` + ); page.resetHistory(); editor.requestUpdate(); }