mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
feat: seperate createDoc and createStore (#11182)
This commit is contained in:
@@ -159,7 +159,7 @@ test.describe('Embed synced doc', () => {
|
||||
const noteId = doc.addBlock('affine:note', {}, rootId);
|
||||
doc.addBlock('affine:paragraph', {}, noteId);
|
||||
|
||||
const doc2 = collection.createDoc({ id: 'doc2' });
|
||||
const doc2 = collection.createDoc('doc2').getStore();
|
||||
doc2.load();
|
||||
const rootId2 = doc2.addBlock('affine:page', {
|
||||
title: new window.$blocksuite.store.Text('Doc 2'),
|
||||
@@ -174,7 +174,7 @@ test.describe('Embed synced doc', () => {
|
||||
noteId2
|
||||
);
|
||||
|
||||
const doc3 = collection.createDoc({ id: 'doc3' });
|
||||
const doc3 = collection.createDoc('doc3').getStore();
|
||||
doc3.load();
|
||||
const rootId3 = doc3.addBlock('affine:page', {
|
||||
title: new window.$blocksuite.store.Text('Doc 3'),
|
||||
@@ -260,7 +260,7 @@ test.describe('Embed synced doc', () => {
|
||||
// go back to previous doc
|
||||
await page.evaluate(() => {
|
||||
const { collection, editor } = window;
|
||||
editor.doc = collection.getDoc('doc:home')!;
|
||||
editor.doc = collection.getDoc('doc:home')!.getStore();
|
||||
});
|
||||
|
||||
const databaseFirstCell = page.locator(
|
||||
|
||||
@@ -92,7 +92,7 @@ export async function switchToPage(page: Page, docId?: string) {
|
||||
docId = docMetas[0].id;
|
||||
}
|
||||
|
||||
const doc = collection.getDoc(docId);
|
||||
const doc = collection.getDoc(docId)?.getStore();
|
||||
if (!doc) return;
|
||||
editor.doc = doc;
|
||||
}, docId);
|
||||
|
||||
@@ -66,7 +66,7 @@ export enum ConnectorMode {
|
||||
export async function getNoteRect(page: Page, noteId: string) {
|
||||
const xywh: string | null = await page.evaluate(
|
||||
([noteId]) => {
|
||||
const doc = window.collection.getDoc('doc:home');
|
||||
const doc = window.collection.getDoc('doc:home')?.getStore();
|
||||
const block = doc?.getModelById(noteId);
|
||||
if (block?.flavour === 'affine:note') {
|
||||
return (block as NoteBlockModel).xywh;
|
||||
@@ -84,7 +84,7 @@ export async function getNoteRect(page: Page, noteId: string) {
|
||||
export async function getNoteProps(page: Page, noteId: string) {
|
||||
const props = await page.evaluate(
|
||||
([id]) => {
|
||||
const doc = window.collection.getDoc('doc:home');
|
||||
const doc = window.collection.getDoc('doc:home')?.getStore();
|
||||
const block = doc?.getModelById(id);
|
||||
if (block?.flavour === 'affine:note') {
|
||||
return (block as NoteBlockModel).keys.reduce(
|
||||
|
||||
Reference in New Issue
Block a user