feat(editor): improve api for store, and add docs (#10941)

This commit is contained in:
Saul-Mirone
2025-03-17 16:30:59 +00:00
parent b0aa2c90fd
commit 3de7d85eea
47 changed files with 1212 additions and 210 deletions

View File

@@ -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) => {

View File

@@ -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');