refactor(editor): reduce dependency to doc collection (#9492)

This commit is contained in:
Saul-Mirone
2025-01-03 01:59:25 +00:00
parent eb15b3cb39
commit 8b6c81f76d
70 changed files with 185 additions and 210 deletions

View File

@@ -12,8 +12,7 @@ import {
} from '@blocksuite/block-std/gfx';
import type { IVec, PointLocation } from '@blocksuite/global/utils';
import { Bound, keys, linePolygonIntersects } from '@blocksuite/global/utils';
import type { Y } from '@blocksuite/store';
import { DocCollection } from '@blocksuite/store';
import * as Y from 'yjs';
type GroupElementProps = BaseElementProps & {
children: Y.Map<boolean>;
@@ -37,12 +36,12 @@ export class GroupElementModel extends GfxGroupLikeElementModel<GroupElementProp
}
static override propsToY(props: Record<string, unknown>) {
if ('title' in props && !(props.title instanceof DocCollection.Y.Text)) {
props.title = new DocCollection.Y.Text(props.title as string);
if ('title' in props && !(props.title instanceof Y.Text)) {
props.title = new Y.Text(props.title as string);
}
if (props.children && !(props.children instanceof DocCollection.Y.Map)) {
const children = new DocCollection.Y.Map() as Y.Map<boolean>;
if (props.children && !(props.children instanceof Y.Map)) {
const children = new Y.Map() as Y.Map<boolean>;
keys(props.children).forEach(key => {
children.set(key as string, true);
@@ -112,13 +111,13 @@ export class GroupElementModel extends GfxGroupLikeElementModel<GroupElementProp
}
)
@field()
accessor children: Y.Map<boolean> = new DocCollection.Y.Map<boolean>();
accessor children: Y.Map<boolean> = new Y.Map<boolean>();
@local()
accessor showTitle: boolean = true;
@field()
accessor title: Y.Text = new DocCollection.Y.Text();
accessor title: Y.Text = new Y.Text();
}
declare global {