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

@@ -239,10 +239,10 @@ class PasteTr {
linkToDocId,
parseDocUrlService
);
const model = this.std.doc.getBlock(blockSnapshot.id)?.model;
const model = this.std.store.getBlock(blockSnapshot.id)?.model;
if (transformed && model) {
this.std.doc.captureSync();
this.std.doc.transact(() => {
this.std.store.captureSync();
this.std.store.transact(() => {
const text = model.text as Text;
text.clear();
text.applyDelta(delta);
@@ -263,8 +263,8 @@ class PasteTr {
if (!transformed) {
return;
}
this.std.doc.captureSync();
this.std.doc.transact(() => {
this.std.store.captureSync();
this.std.store.transact(() => {
fromPointStateText.clear();
fromPointStateText.applyDelta(delta);
});
@@ -275,8 +275,8 @@ class PasteTr {
const cursorBlock =
this.pointState.model.flavour === 'affine:code' || !this.lastSnapshot
? this.std.doc.getBlock(this.pointState.model.id)
: this.std.doc.getBlock(this.lastSnapshot.id);
? this.std.store.getBlock(this.pointState.model.id)
: this.std.store.getBlock(this.lastSnapshot.id);
if (!cursorBlock) {
return;
}
@@ -323,22 +323,22 @@ class PasteTr {
}
if (this.lastSnapshot) {
const lastModel = this.std.doc.getBlock(this.lastSnapshot.id)?.model;
const lastModel = this.std.store.getBlock(this.lastSnapshot.id)?.model;
if (!lastModel) {
return;
}
this.std.doc.moveBlocks(this.pointState.model.children, lastModel);
this.std.store.moveBlocks(this.pointState.model.children, lastModel);
}
this.std.doc.moveBlocks(
this.std.doc
this.std.store.moveBlocks(
this.std.store
.getNexts(this.pointState.model.id)
.slice(0, this.pasteStartModelChildrenCount),
this.pointState.model
);
if (!this.firstSnapshotIsPlainText && this.pointState.text.length == 0) {
this.std.doc.deleteBlock(this.pointState.model);
this.std.store.deleteBlock(this.pointState.model);
}
};

View File

@@ -14,7 +14,7 @@ export const getBlockIndexCommand: Command<
'`path` is required, you need to pass it in args or ctx before adding this command to the pipeline.'
);
const parentModel = ctx.std.doc.getParent(path);
const parentModel = ctx.std.store.getParent(path);
if (!parentModel) return;
const parent = ctx.std.view.getBlock(parentModel.id);

View File

@@ -5,7 +5,7 @@ import { getNextContentBlock } from '../../utils/index.js';
function getNextBlock(std: BlockSuite.Std, path: string) {
const view = std.view;
const model = std.doc.getBlock(path)?.model;
const model = std.store.getBlock(path)?.model;
if (!model) return null;
const nextModel = getNextContentBlock(std.host, model);
if (!nextModel) return null;

View File

@@ -6,7 +6,7 @@ import { getPrevContentBlock } from '../../utils/index.js';
function getPrevBlock(std: BlockSuite.Std, path: string) {
const view = std.view;
const model = std.doc.getBlock(path)?.model;
const model = std.store.getBlock(path)?.model;
if (!model) return null;
const prevModel = getPrevContentBlock(std.host, model);
if (!prevModel) return null;

View File

@@ -51,7 +51,7 @@ export const getSelectedBlocksCommand: Command<
const blockSelections = ctx.blockSelections ?? ctx.currentBlockSelections;
if (types.includes('block') && blockSelections) {
const viewStore = ctx.std.view;
const doc = ctx.std.doc;
const doc = ctx.std.store;
const selectedBlockComponents = blockSelections.flatMap(selection => {
const el = viewStore.getBlock(selection.blockId);
if (!el) {

View File

@@ -15,7 +15,7 @@ export const copySelectedModelsCommand: Command<'draftedModels' | 'onCopy'> = (
models
.then(models => {
const slice = Slice.fromModels(ctx.std.doc, models);
const slice = Slice.fromModels(ctx.std.store, models);
return ctx.std.clipboard.copy(slice);
})

View File

@@ -14,7 +14,7 @@ export const deleteSelectedModelsCommand: Command<'selectedModels'> = (
}
models.forEach(model => {
ctx.std.doc.deleteBlock(model);
ctx.std.store.deleteBlock(model);
});
return next();

View File

@@ -9,17 +9,17 @@ export const duplicateSelectedModelsCommand: Command<
const model = selectedModels[selectedModels.length - 1];
const parentModel = std.doc.getParent(model.id);
const parentModel = std.store.getParent(model.id);
if (!parentModel) return;
const index = parentModel.children.findIndex(x => x.id === model.id);
draftedModels
.then(models => {
const slice = Slice.fromModels(std.doc, models);
const slice = Slice.fromModels(std.store, models);
return std.clipboard.duplicateSlice(
slice,
std.doc,
std.store,
parentModel.id,
index + 1
);

View File

@@ -35,7 +35,7 @@ export class DNDAPIExtension extends Extension {
}): SliceSnapshot | null {
const { docId, flavour = 'affine:embed-linked-doc', blockId } = options;
const slice = Slice.fromModels(this.std.doc, []);
const slice = Slice.fromModels(this.std.store, []);
const job = this.std.getJob();
const snapshot = job.sliceToSnapshot(slice);
if (!snapshot) {

View File

@@ -116,7 +116,7 @@ export class EditPropsStore extends LifeCycleWatcher {
}
private _getStorageKey<T extends StoragePropsKey>(key: T) {
const id = this.std.doc.id;
const id = this.std.store.id;
switch (key) {
case 'viewport':
return 'blocksuite:' + id + ':edgelessViewport';

View File

@@ -63,7 +63,7 @@ export class ThemeService extends Extension {
const extension = this.std.getOptional(ThemeExtensionIdentifier);
this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$;
this.edgeless$ =
extension?.getEdgelessTheme?.(this.std.doc.id) ||
extension?.getEdgelessTheme?.(this.std.store.id) ||
getThemeObserver().theme$;
}

View File

@@ -45,7 +45,7 @@ export function toNumberedList(
model: BlockModel,
order: number
) {
const { doc } = std;
const { store: doc } = std;
if (!model.text) return;
const parent = doc.getParent(model);
if (!parent) return;