mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 09:36:17 +08:00
refactor(editor): rename model.doc to store (#12172)
This commit is contained in:
@@ -66,7 +66,7 @@ export class AudioAttachmentBlock extends Entity<AttachmentBlockModel> {
|
||||
computed(() => {
|
||||
// find the last transcription block
|
||||
for (const key of [...this.props.childMap.value.keys()].reverse()) {
|
||||
const block = this.props.doc.getBlock$(key);
|
||||
const block = this.props.store.getBlock$(key);
|
||||
if (block?.flavour === TranscriptionBlockFlavour) {
|
||||
return block.model as unknown as TranscriptionBlockModel;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export class AudioAttachmentBlock extends Entity<AttachmentBlockModel> {
|
||||
|
||||
if (!transcriptionBlockProps) {
|
||||
// transcription block is not created yet, we need to create it
|
||||
this.props.doc.addBlock(
|
||||
this.props.store.addBlock(
|
||||
'affine:transcription',
|
||||
{
|
||||
transcription: {},
|
||||
@@ -179,14 +179,14 @@ export class AudioAttachmentBlock extends Entity<AttachmentBlockModel> {
|
||||
title: string,
|
||||
collapsed: boolean = false
|
||||
) => {
|
||||
const calloutId = this.props.doc.addBlock(
|
||||
const calloutId = this.props.store.addBlock(
|
||||
'affine:callout',
|
||||
{
|
||||
emoji,
|
||||
},
|
||||
this.transcriptionBlock$.value?.id
|
||||
);
|
||||
this.props.doc.addBlock(
|
||||
this.props.store.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
type: 'h6',
|
||||
@@ -223,7 +223,7 @@ export class AudioAttachmentBlock extends Entity<AttachmentBlockModel> {
|
||||
insert: ': ' + sanitizeText(segment.transcription),
|
||||
},
|
||||
];
|
||||
this.props.doc.addBlock(
|
||||
this.props.store.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
text: new Text(deltaInserts),
|
||||
@@ -238,7 +238,7 @@ export class AudioAttachmentBlock extends Entity<AttachmentBlockModel> {
|
||||
await insertFromMarkdown(
|
||||
undefined,
|
||||
summary,
|
||||
this.props.doc,
|
||||
this.props.store,
|
||||
calloutId,
|
||||
1
|
||||
);
|
||||
@@ -252,7 +252,7 @@ export class AudioAttachmentBlock extends Entity<AttachmentBlockModel> {
|
||||
await insertFromMarkdown(
|
||||
undefined,
|
||||
actions ?? '',
|
||||
this.props.doc,
|
||||
this.props.store,
|
||||
calloutId,
|
||||
1
|
||||
);
|
||||
|
||||
@@ -28,8 +28,8 @@ export class AudioAttachmentService extends Service {
|
||||
const key = attachmentBlockAudioMediaKey({
|
||||
blobId: model.props.sourceId,
|
||||
blockId: model.id,
|
||||
docId: model.doc.id,
|
||||
workspaceId: model.doc.rootDoc.guid,
|
||||
docId: model.store.id,
|
||||
workspaceId: model.store.rootDoc.guid,
|
||||
});
|
||||
let exists = this.pool.get(key);
|
||||
if (!exists) {
|
||||
|
||||
@@ -308,8 +308,8 @@ export class AudioMediaManagerService extends Service {
|
||||
key: attachmentBlockAudioMediaKey({
|
||||
blobId: input.props.sourceId,
|
||||
blockId: input.id,
|
||||
docId: input.doc.id,
|
||||
workspaceId: input.doc.rootDoc.guid,
|
||||
docId: input.store.id,
|
||||
workspaceId: input.store.rootDoc.guid,
|
||||
}),
|
||||
name: input.props.name,
|
||||
size: input.props.size,
|
||||
|
||||
@@ -60,7 +60,7 @@ export async function downloadBlobToBuffer(model: AttachmentBlockModel) {
|
||||
throw new Error('Attachment not found');
|
||||
}
|
||||
|
||||
const blob = await model.doc.blobSync.get(sourceId);
|
||||
const blob = await model.store.blobSync.get(sourceId);
|
||||
if (!blob) {
|
||||
throw new Error('Attachment not found');
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ function resolvePeekInfoFromPeekTarget(
|
||||
// refModel can be null if the reference is invalid
|
||||
if (refModel) {
|
||||
const docId =
|
||||
'doc' in refModel ? refModel.doc.id : refModel.surface.doc.id;
|
||||
'store' in refModel ? refModel.store.id : refModel.surface.store.id;
|
||||
return {
|
||||
type: 'doc',
|
||||
docRef: {
|
||||
@@ -179,7 +179,7 @@ function resolvePeekInfoFromPeekTarget(
|
||||
return {
|
||||
type: 'attachment',
|
||||
docRef: {
|
||||
docId: blockModel.doc.id,
|
||||
docId: blockModel.store.id,
|
||||
blockIds: [blockModel.id],
|
||||
filetype: blockModel.props.type,
|
||||
},
|
||||
@@ -188,7 +188,7 @@ function resolvePeekInfoFromPeekTarget(
|
||||
return {
|
||||
type: 'image',
|
||||
docRef: {
|
||||
docId: blockModel.doc.id,
|
||||
docId: blockModel.store.id,
|
||||
blockIds: [blockModel.id],
|
||||
},
|
||||
};
|
||||
@@ -196,7 +196,7 @@ function resolvePeekInfoFromPeekTarget(
|
||||
return {
|
||||
type: 'ai-chat-block',
|
||||
docRef: {
|
||||
docId: blockModel.doc.id,
|
||||
docId: blockModel.store.id,
|
||||
blockIds: [blockModel.id],
|
||||
},
|
||||
model: blockModel,
|
||||
|
||||
@@ -362,7 +362,7 @@ const ImagePreviewModalImpl = ({
|
||||
index,
|
||||
url: blobUrl,
|
||||
caption: blockModel.props.caption,
|
||||
onDelete: !blockModel.doc.readonly
|
||||
onDelete: !blockModel.store.readonly
|
||||
? () => {
|
||||
handleDelete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user