mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 13:02:21 +08:00
feat: compat with surface block structure
This commit is contained in:
@@ -31,9 +31,10 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const editor = document.querySelector('editor-container');
|
const editor = document.querySelector('editor-container');
|
||||||
if (editor) {
|
if (editor) {
|
||||||
const groupId = page.addBlock({ flavour: 'affine:group' }, pageId);
|
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
|
// TODO blocksuite should offer a method to import markdown from store
|
||||||
editor.clipboard.importMarkdown(template.source, `${groupId}`);
|
editor.clipboard.importMarkdown(template.source, `${frameId}`);
|
||||||
page.resetHistory();
|
page.resetHistory();
|
||||||
editor.requestUpdate();
|
editor.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const usePropsUpdated: UsePropsUpdated = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
editor.model?.propsUpdated.on(() => {
|
editor.pageBlockModel?.propsUpdated.on(() => {
|
||||||
callbackQueue.current.forEach(callback => {
|
callbackQueue.current.forEach(callback => {
|
||||||
callback(editor);
|
callback(editor);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ const All = () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const editor = document.querySelector('editor-container');
|
const editor = document.querySelector('editor-container');
|
||||||
if (editor) {
|
if (editor) {
|
||||||
const groupId = page.addBlock({ flavour: 'affine:group' }, pageId);
|
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
|
// TODO blocksuite should offer a method to import markdown from store
|
||||||
editor.clipboard.importMarkdown(template.source, `${groupId}`);
|
editor.clipboard.importMarkdown(template.source, `${frameId}`);
|
||||||
page.resetHistory();
|
page.resetHistory();
|
||||||
editor.requestUpdate();
|
editor.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,14 +55,15 @@ const Page: NextPageWithLayout = () => {
|
|||||||
flavour: 'affine:page',
|
flavour: 'affine:page',
|
||||||
title,
|
title,
|
||||||
});
|
});
|
||||||
const groupId = currentPage!.addBlock(
|
currentPage!.addBlock({ flavour: 'affine:surface' }, null);
|
||||||
{ flavour: 'affine:group' },
|
const frameId = currentPage!.addBlock(
|
||||||
|
{ flavour: 'affine:frame' },
|
||||||
pageId
|
pageId
|
||||||
);
|
);
|
||||||
currentPage!.addBlock({ flavour: 'affine:group' }, pageId);
|
currentPage!.addBlock({ flavour: 'affine:frame' }, pageId);
|
||||||
// If this is a first page in workspace, init an introduction markdown
|
// If this is a first page in workspace, init an introduction markdown
|
||||||
if (isFirstPage) {
|
if (isFirstPage) {
|
||||||
editor.clipboard.importMarkdown(exampleMarkdown, `${groupId}`);
|
editor.clipboard.importMarkdown(exampleMarkdown, `${frameId}`);
|
||||||
currentWorkspace!.setPageMeta(currentPage!.id, { title });
|
currentWorkspace!.setPageMeta(currentPage!.id, { title });
|
||||||
}
|
}
|
||||||
currentPage!.resetHistory();
|
currentPage!.resetHistory();
|
||||||
|
|||||||
Reference in New Issue
Block a user