feat: compatiable with async importMarkdown()

This commit is contained in:
x1a0t
2023-01-06 15:03:42 +08:00
parent cc13bf8265
commit b1a39fa2e7
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ export const usePropsUpdated: UsePropsUpdated = () => {
return () => { return () => {
callbackQueue.current = []; callbackQueue.current = [];
editor?.model?.propsUpdated.dispose(); editor?.model?.propsUpdated?.dispose();
}; };
}, [editor]); }, [editor]);
@@ -43,13 +43,16 @@ const All = () => {
if (page) { if (page) {
currentWorkspace?.setPageMeta(page.id, { title }); currentWorkspace?.setPageMeta(page.id, { title });
if (page && page.root === null) { if (page && page.root === null) {
setTimeout(() => { setTimeout(async () => {
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}`); await editor.clipboard.importMarkdown(
template.source,
`${frameId}`
);
page.resetHistory(); page.resetHistory();
editor.requestUpdate(); editor.requestUpdate();
} }