mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 09:52:49 +08:00
refactor(editor): rename model.doc to store (#12172)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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`;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user