refactor(editor): rename model.doc to store (#12172)

This commit is contained in:
Saul-Mirone
2025-05-07 09:17:01 +00:00
parent eb62d0e853
commit 95b9e4b3d0
95 changed files with 264 additions and 246 deletions
@@ -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(),
});
}