From e629aac0ad64f71d2ebaf05a3486f86acb818f2c Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Sat, 14 Jan 2023 10:05:40 +0800 Subject: [PATCH] feat: make import button visible --- packages/app/src/components/import/index.tsx | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/app/src/components/import/index.tsx b/packages/app/src/components/import/index.tsx index 1116481389..a594b08e35 100644 --- a/packages/app/src/components/import/index.tsx +++ b/packages/app/src/components/import/index.tsx @@ -29,14 +29,21 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => { currentWorkspace?.blocksuiteWorkspace?.setPageMeta(page.id, { title }); if (page && page.root === null) { setTimeout(() => { - 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}`); - page.resetHistory(); - editor.requestUpdate(); + try { + 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}`); + page.resetHistory(); + editor.requestUpdate(); + } + } catch (e) { + console.error(e); } }, 300); } @@ -98,13 +105,13 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => { > Markdown - {/* */} + )}