mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
refactor(editor): rename model.doc to store (#12172)
This commit is contained in:
@@ -78,7 +78,7 @@ export class FrameBlockModel
|
||||
for (const key of this.childIds) {
|
||||
const element =
|
||||
this.surface.getElementById(key) ||
|
||||
(this.surface.doc.getModelById(key) as GfxBlockElementModel);
|
||||
(this.surface.store.getModelById(key) as GfxBlockElementModel);
|
||||
|
||||
element && elements.push(element);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ export class FrameBlockModel
|
||||
addChild(element: GfxModel) {
|
||||
if (!canSafeAddToContainer(this, element)) return;
|
||||
|
||||
this.doc.transact(() => {
|
||||
this.store.transact(() => {
|
||||
this.props.childElementIds = {
|
||||
...this.props.childElementIds,
|
||||
[element.id]: true,
|
||||
@@ -118,7 +118,7 @@ export class FrameBlockModel
|
||||
newChildren[id] = true;
|
||||
}
|
||||
|
||||
this.doc.transact(() => {
|
||||
this.store.transact(() => {
|
||||
this.props.childElementIds = {
|
||||
...this.props.childElementIds,
|
||||
...newChildren,
|
||||
@@ -153,7 +153,7 @@ export class FrameBlockModel
|
||||
}
|
||||
|
||||
removeChild(element: GfxModel): void {
|
||||
this.doc.transact(() => {
|
||||
this.store.transact(() => {
|
||||
this.props.childElementIds &&
|
||||
delete this.props.childElementIds[element.id];
|
||||
});
|
||||
|
||||
@@ -14,15 +14,17 @@ export class RootBlockModel extends BlockModel<RootBlockProps> {
|
||||
super();
|
||||
const createdSubscription = this.created.subscribe(() => {
|
||||
createdSubscription.unsubscribe();
|
||||
this.doc.slots.rootAdded.subscribe(id => {
|
||||
const model = this.doc.getModelById(id);
|
||||
this.store.slots.rootAdded.subscribe(id => {
|
||||
const model = this.store.getModelById(id);
|
||||
if (model instanceof RootBlockModel) {
|
||||
const newDocMeta = this.doc.workspace.meta.getDocMeta(model.doc.id);
|
||||
const newDocMeta = this.store.workspace.meta.getDocMeta(
|
||||
model.store.id
|
||||
);
|
||||
if (
|
||||
!newDocMeta ||
|
||||
newDocMeta.title !== model.props.title.toString()
|
||||
) {
|
||||
this.doc.workspace.meta.setDocMeta(model.doc.id, {
|
||||
this.store.workspace.meta.setDocMeta(model.store.id, {
|
||||
title: model.props.title.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user