feat(editor): merge store and blocks (#9591)

This commit is contained in:
Saul-Mirone
2025-01-08 13:01:19 +00:00
parent a0cba55a5b
commit 5842d45ab1
124 changed files with 362 additions and 414 deletions
@@ -2,7 +2,7 @@ import { type Disposable, Slot } from '@blocksuite/global/utils';
import { computed, type Signal, signal } from '@preact/signals-core';
import type { Text } from '../../reactive/index.js';
import type { Blocks } from '../blocks/blocks.js';
import type { Store } from '../store/store.js';
import type { YBlock } from './types.js';
import type { RoleType } from './zod.js';
@@ -38,7 +38,7 @@ export class BlockModel<
/**
* @deprecated use doc instead
*/
page!: Blocks;
page!: Store;
private readonly _childModels = computed(() => {
const value: BlockModel[] = [];
@@ -102,7 +102,7 @@ export class BlockModel<
return this.page;
}
set doc(doc: Blocks) {
set doc(doc: Store) {
this.page = doc;
}
@@ -1,5 +1,5 @@
import type { Schema } from '../../schema/index.js';
import type { Blocks } from '../blocks/blocks.js';
import type { Store } from '../store/store.js';
import { SyncController } from './sync-controller.js';
import type { BlockOptions, YBlock } from './types.js';
@@ -37,7 +37,7 @@ export class Block {
constructor(
readonly schema: Schema,
readonly yBlock: YBlock,
readonly doc?: Blocks,
readonly doc?: Store,
readonly options: BlockOptions = {}
) {
const onChange = !options.onChange
@@ -11,7 +11,7 @@ import {
y2Native,
} from '../../reactive/index.js';
import type { Schema } from '../../schema/schema.js';
import type { Blocks } from '../blocks/blocks.js';
import type { Store } from '../store/store.js';
import { BlockModel } from './block-model.js';
import type { YBlock } from './types.js';
import { internalPrimitives } from './zod.js';
@@ -104,7 +104,7 @@ export class SyncController {
constructor(
readonly schema: Schema,
readonly yBlock: YBlock,
readonly doc?: Blocks,
readonly doc?: Store,
readonly onChange?: (key: string, value: unknown) => void
) {
const { id, flavour, version, yChildren, props } = this._parseYBlock();