Merge branch 'feat/cloud-sync-saika' into feat/poc

This commit is contained in:
DiamondThree
2023-01-09 11:00:57 +08:00
64 changed files with 2545 additions and 2241 deletions
+13 -13
View File
@@ -24,19 +24,19 @@ export default function DevPage() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [inviteData, setInviteData] = useState<any>(null);
useEffect(() => {
getDataCenter()
.then(dc =>
dc.apis.acceptInviting({
invitingCode: router.query.invite_code as string,
})
)
.then(data => {
setSuccessInvited(true);
setInviteData(data);
})
.catch(err => {
console.log('err: ', err);
});
// getDataCenter()
// .then(dc =>
// dc.apis.acceptInviting({
// invitingCode: router.query.invite_code as string,
// })
// )
// .then(data => {
// setSuccessInvited(true);
// setInviteData(data);
// })
// .catch(err => {
// console.log('err: ', err);
// });
}, [router.query.invite_code]);
return (
@@ -43,12 +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) {
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
editor.clipboard.importMarkdown(template.source, `${groupId}`);
await editor.clipboard.importMarkdown(
template.source,
`${frameId}`
);
page.resetHistory();
editor.requestUpdate();
}
+18
View File
@@ -0,0 +1,18 @@
import { useEffect } from 'react';
import { getDataCenter } from '@affine/datacenter';
/**
* testing only when development
*/
const Page = () => {
useEffect(() => {
getDataCenter().then(dc => {
// @ts-expect-error global variable
window.dc = dc;
});
}, []);
return <div>Testing only</div>;
};
export default Page;
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import {
useRef,
useEffect,
useState,
ReactElement,
PropsWithChildren,
ReactElement,
useEffect,
useRef,
useState,
} from 'react';
import { styled } from '@/styles';
import { EditorHeader } from '@/components/header';
@@ -16,9 +16,11 @@ import type { NextPageWithLayout } from '../..//_app';
import WorkspaceLayout from '@/components/workspace-layout';
import { useRouter } from 'next/router';
import { usePageHelper } from '@/hooks/use-page-helper';
const StyledEditorContainer = styled('div')(() => {
return {
height: 'calc(100vh - 60px)',
padding: '0 32px',
};
});
@@ -54,15 +56,20 @@ const Page: NextPageWithLayout = () => {
flavour: 'affine:page',
title,
});
const groupId = currentPage!.addBlock(
{ flavour: 'affine:group' },
currentPage!.addBlock({ flavour: 'affine:surface' }, null);
const frameId = currentPage!.addBlock(
{ flavour: 'affine:frame' },
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 (isFirstPage) {
editor.clipboard.importMarkdown(exampleMarkdown, `${groupId}`);
currentWorkspace!.setPageMeta(currentPage!.id, { title });
editor.clipboard
.importMarkdown(exampleMarkdown, `${frameId}`)
.then(() => {
currentWorkspace!.setPageMeta(currentPage!.id, { title });
currentPage!.resetHistory();
});
}
currentPage!.resetHistory();
}