mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
feat(editor): improve api for store, and add docs (#10941)
This commit is contained in:
@@ -67,7 +67,7 @@ export async function getNoteRect(page: Page, noteId: string) {
|
||||
const xywh: string | null = await page.evaluate(
|
||||
([noteId]) => {
|
||||
const doc = window.collection.getDoc('doc:home');
|
||||
const block = doc?.getBlockById(noteId);
|
||||
const block = doc?.getModelById(noteId);
|
||||
if (block?.flavour === 'affine:note') {
|
||||
return (block as NoteBlockModel).xywh;
|
||||
} else {
|
||||
@@ -85,7 +85,7 @@ export async function getNoteProps(page: Page, noteId: string) {
|
||||
const props = await page.evaluate(
|
||||
([id]) => {
|
||||
const doc = window.collection.getDoc('doc:home');
|
||||
const block = doc?.getBlockById(id);
|
||||
const block = doc?.getModelById(id);
|
||||
if (block?.flavour === 'affine:note') {
|
||||
return (block as NoteBlockModel).keys.reduce(
|
||||
(pre, key) => {
|
||||
|
||||
@@ -337,7 +337,7 @@ export async function initEmptyDatabaseState(page: Page, rootId?: string) {
|
||||
},
|
||||
noteId
|
||||
);
|
||||
const model = doc.getBlockById(databaseId) as DatabaseBlockModel;
|
||||
const model = doc.getModelById(databaseId) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(model);
|
||||
datasource.viewManager.viewAdd('table');
|
||||
@@ -373,7 +373,7 @@ export async function initKanbanViewState(
|
||||
},
|
||||
noteId
|
||||
);
|
||||
const model = doc.getBlockById(databaseId) as DatabaseBlockModel;
|
||||
const model = doc.getModelById(databaseId) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(model);
|
||||
const rowIds = config.rows.map(rowText => {
|
||||
@@ -432,7 +432,7 @@ export async function initEmptyDatabaseWithParagraphState(
|
||||
},
|
||||
noteId
|
||||
);
|
||||
const model = doc.getBlockById(databaseId) as DatabaseBlockModel;
|
||||
const model = doc.getModelById(databaseId) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(model);
|
||||
datasource.viewManager.viewAdd('table');
|
||||
|
||||
Reference in New Issue
Block a user