feat: make import button visible

This commit is contained in:
tzhangchi
2023-01-14 10:05:40 +08:00
parent 7de8ac53d1
commit e629aac0ad

View File

@@ -29,15 +29,22 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
currentWorkspace?.blocksuiteWorkspace?.setPageMeta(page.id, { title }); currentWorkspace?.blocksuiteWorkspace?.setPageMeta(page.id, { title });
if (page && page.root === null) { if (page && page.root === null) {
setTimeout(() => { setTimeout(() => {
try {
const editor = document.querySelector('editor-container'); const editor = document.querySelector('editor-container');
if (editor) { if (editor) {
page.addBlock({ flavour: 'affine:surface' }, null); page.addBlock({ flavour: 'affine:surface' }, null);
const frameId = page.addBlock({ flavour: 'affine:frame' }, pageId); const frameId = page.addBlock(
{ flavour: 'affine:frame' },
pageId
);
// TODO blocksuite should offer a method to import markdown from store // TODO blocksuite should offer a method to import markdown from store
editor.clipboard.importMarkdown(template.source, `${frameId}`); editor.clipboard.importMarkdown(template.source, `${frameId}`);
page.resetHistory(); page.resetHistory();
editor.requestUpdate(); editor.requestUpdate();
} }
} catch (e) {
console.error(e);
}
}, 300); }, 300);
} }
} }
@@ -98,13 +105,13 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
> >
Markdown Markdown
</Button> </Button>
{/* <Button <Button
onClick={() => { onClick={() => {
_handleAppleTemplateFromFilePicker(); _handleAppleTemplateFromFilePicker();
}} }}
> >
HTML HTML
</Button> */} </Button>
</StyledButtonWrapper> </StyledButtonWrapper>
)} )}