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
@@ -162,7 +162,7 @@ function addAIChatBlock(
const { doc } = host;
const surfaceBlock = doc
.getStore()
.getAllModels()
.find(block => block.flavour === 'affine:surface');
if (!surfaceBlock) {
return;
@@ -520,7 +520,7 @@ const CREATE_AS_LINKED_DOC = {
const { doc } = host;
const surfaceBlock = doc
.getStore()
.getAllModels()
.find(block => block.flavour === 'affine:surface');
if (!surfaceBlock) {
return false;
@@ -236,7 +236,7 @@ function getEdgelessContentBound(host: EditorHost) {
const elements = (
host.doc
.getStore()
.getAllModels()
.filter(
model =>
model instanceof GfxBlockElementModel &&
@@ -106,7 +106,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {
const doc = collection.createDoc({ id: 'doc:home' }).load();
const rootId = doc.addBlock('affine:page', {});
const surfaceId = doc.addBlock('affine:surface', {}, rootId);
const surface = doc.getBlockById(surfaceId) as SurfaceBlockModel;
const surface = doc.getModelById(surfaceId) as SurfaceBlockModel;
doc.resetHistory();
return {
@@ -163,7 +163,7 @@ export class AIChatBlockPeekView extends LitElement {
const { doc } = this.host;
// create a new AI chat block
const surfaceBlock = doc
.getStore()
.getAllModels()
.find(block => block.flavour === 'affine:surface');
if (!surfaceBlock) {
return;
@@ -44,7 +44,7 @@ function processSnapshot(
text: TextSelection,
host: EditorHost
) {
const model = host.doc.getBlockById(snapshot.id);
const model = host.doc.getModelById(snapshot.id);
if (!model) {
return;
}