mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 09:30:01 +08:00
feat(editor): improve api for store, and add docs (#10941)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user