mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
refactor(editor): reduce dependency to doc collection (#9492)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user