chore(editor): rename std.doc to std.store (#9596)

This commit is contained in:
Saul-Mirone
2025-01-09 04:16:28 +00:00
parent 58ce86533e
commit d21ef47ae8
89 changed files with 359 additions and 348 deletions

View File

@@ -350,7 +350,7 @@ export class UIEventDispatcher extends LifeCycleWatcher {
);
const flavourHandlers = blockIds
.map(blockId => this.std.doc.getBlock(blockId)?.flavour)
.map(blockId => this.std.store.getBlock(blockId)?.flavour)
.filter((flavour): flavour is string => {
if (!flavour) return false;
if (flavourSeen[flavour]) return false;
@@ -364,7 +364,7 @@ export class UIEventDispatcher extends LifeCycleWatcher {
events.push(...idHandlers, ...flavourHandlers);
blockIds = blockIds
.map(blockId => {
const parent = this.std.doc.getParent(blockId);
const parent = this.std.store.getParent(blockId);
return parent?.id;
})
.filter((id): id is string => !!id);

View File

@@ -34,7 +34,7 @@ export abstract class BlockService extends Extension {
}
get doc() {
return this.std.doc;
return this.std.store;
}
get host() {

View File

@@ -50,7 +50,7 @@ export class GfxController extends LifeCycleWatcher {
readonly viewport: Viewport = new Viewport();
get doc() {
return this.std.doc;
return this.std.store;
}
get elementsBound() {

View File

@@ -316,7 +316,7 @@ export class GfxSelectionManager extends GfxExtension {
}
const { blocks = [], elements = [] } = groupBy(selection.elements, id => {
return this.std.doc.getBlockById(id) ? 'blocks' : 'elements';
return this.std.store.getBlockById(id) ? 'blocks' : 'elements';
});
let instances: (SurfaceSelection | CursorSelection)[] = [];

View File

@@ -51,7 +51,7 @@ export class SurfaceMiddlewareExtension extends LifeCycleWatcher {
this.std.provider.getAll(SurfaceMiddlewareBuilderIdentifier).values()
);
const dispose = onSurfaceAdded(this.std.doc, surface => {
const dispose = onSurfaceAdded(this.std.store, surface => {
if (surface) {
surface.applyMiddlewares(builders.map(builder => builder.middleware));
queueMicrotask(() => dispose());

View File

@@ -107,7 +107,7 @@ export class ViewManager extends GfxExtension {
updateViewOnElementChange(this.gfx.surface);
} else {
this._disposable.add(
onSurfaceAdded(this.std.doc, surface => {
onSurfaceAdded(this.std.store, surface => {
if (surface) {
updateViewOnElementChange(surface);
}

View File

@@ -16,7 +16,7 @@ export class RangeBinding {
| null = null;
private readonly _computePath = (modelId: string) => {
const block = this.host.std.doc.getBlock(modelId)?.model;
const block = this.host.std.store.getBlock(modelId)?.model;
if (!block) return [];
const path: string[] = [];

View File

@@ -74,16 +74,12 @@ export class BlockStdScope {
return this.provider.getAll(LifeCycleWatcherIdentifier);
}
get doc() {
return this.store;
}
get clipboard() {
return this.get(Clipboard);
}
get workspace() {
return this.doc.workspace;
return this.store.workspace;
}
get command() {
@@ -198,7 +194,7 @@ export class BlockStdScope {
render() {
const element = new EditorHost();
element.std = this;
element.doc = this.doc;
element.doc = this.store;
this._getHost = () => element;
this._lifeCycleWatchers.forEach(watcher => {
watcher.rendered.call(watcher);

View File

@@ -76,7 +76,7 @@ export class SelectionManager extends LifeCycleWatcher {
constructor(std: BlockStdScope) {
super(std);
this._id = `${this.std.doc.id}:${nanoid()}`;
this._id = `${this.std.store.id}:${nanoid()}`;
this._setupDefaultSelections();
this._store.awareness.on(
'change',
@@ -100,7 +100,7 @@ export class SelectionManager extends LifeCycleWatcher {
if (id === this._store.awareness.clientID) return;
// selection id starts with the same block collection id from others clients would be considered as remote selections
const selection = Object.entries(state.selectionV2)
.filter(([key]) => key.startsWith(this.std.doc.id))
.filter(([key]) => key.startsWith(this.std.store.id))
.flatMap(([_, selection]) => selection);
const selections = selection
@@ -191,8 +191,8 @@ export class SelectionManager extends LifeCycleWatcher {
if (this.disposables.disposed) {
this.disposables = new DisposableGroup();
}
this.std.doc.history.on('stack-item-added', this._itemAdded);
this.std.doc.history.on('stack-item-popped', this._itemPopped);
this.std.store.history.on('stack-item-added', this._itemAdded);
this.std.store.history.on('stack-item-popped', this._itemPopped);
this.disposables.add(
this._store.slots.update.on(({ id }) => {
if (id === this._store.awareness.clientID) {
@@ -224,8 +224,8 @@ export class SelectionManager extends LifeCycleWatcher {
}
override unmounted() {
this.std.doc.history.off('stack-item-added', this._itemAdded);
this.std.doc.history.off('stack-item-popped', this._itemPopped);
this.std.store.history.off('stack-item-added', this._itemAdded);
this.std.store.history.off('stack-item-popped', this._itemPopped);
this.slots.changed.dispose();
this.disposables.dispose();
this.clear();

View File

@@ -218,7 +218,7 @@ export class BlockComponent<
this.std.view.setBlock(this);
const disposable = this.std.doc.slots.blockUpdated.on(({ type, id }) => {
const disposable = this.std.store.slots.blockUpdated.on(({ type, id }) => {
if (id === this.model.id && type === 'delete') {
this.std.view.deleteBlock(this);
disposable.dispose();

View File

@@ -9,7 +9,7 @@ export class ViewStore extends LifeCycleWatcher {
private readonly _fromId = (
blockId: string | undefined | null
): BlockComponent | null => {
const id = blockId ?? this.std.doc.root?.id;
const id = blockId ?? this.std.store.root?.id;
if (!id) {
return null;
}