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

View File

@@ -17,7 +17,7 @@ export const imageSlashMenuConfig: SlashMenuConfig = {
},
group: '4_Content & Media@1',
when: ({ model }) =>
model.doc.schema.flavourSchemaMap.has('affine:image'),
model.store.schema.flavourSchemaMap.has('affine:image'),
action: ({ std }) => {
const [success, ctx] = std.command
.chain()

View File

@@ -23,9 +23,9 @@ export class ImageResizeManager {
}
const dragModel = getModelByElement(this._activeComponent);
dragModel?.doc.captureSync();
dragModel?.store.captureSync();
const { width, height } = this._imageContainer.getBoundingClientRect();
dragModel?.doc.updateBlock(dragModel, {
dragModel?.store.updateBlock(dragModel, {
width: width / this._zoom,
height: height / this._zoom,
});

View File

@@ -13,7 +13,7 @@ const flavour = ImageBlockSchema.model.flavour;
export const ImageBlockSpec: ExtensionType[] = [
FlavourExtension(flavour),
BlockViewExtension(flavour, model => {
const parent = model.doc.getParent(model.id);
const parent = model.store.getParent(model.id);
if (parent?.flavour === 'affine:surface') {
return literal`affine-edgeless-image`;

View File

@@ -36,7 +36,7 @@ async function getImageBlob(model: ImageBlockModel) {
const sourceId = model.props.sourceId$.peek();
if (!sourceId) return null;
const doc = model.doc;
const doc = model.store;
let blob = await doc.blobSync.get(sourceId);
if (!blob) return null;
@@ -419,15 +419,15 @@ export function duplicate(block: ImageBlockComponent) {
...duplicateProps
} = blockProps;
const { doc } = model;
const parent = doc.getParent(model);
const { store } = model;
const parent = store.getParent(model);
if (!parent) {
console.error(`Parent not found for block(${model.flavour}) ${model.id}`);
return;
}
const index = parent?.children.indexOf(model);
const duplicateId = doc.addBlock(
const duplicateId = store.addBlock(
model.flavour,
duplicateProps,
parent,