mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 05:05:52 +08:00
refactor(editor): move transcription block model to ai (#12010)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated and reorganized import paths for transcription block models and types to improve module structure and maintainability. - **Chores** - Removed deprecated transcription block schema and related exports from core libraries. - Registered transcription block schema directly within the workspace schema for improved schema management. - **Bug Fixes** - Ensured consistent registration and availability of transcription block features across relevant modules. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { TranscriptionBlockModel } from '@blocksuite/affine/model';
|
||||
import type { TranscriptionBlockModel } from '@affine/core/blocksuite/ai/blocks/transcription-block/model';
|
||||
import { BlockComponent, BlockViewExtension } from '@blocksuite/affine/std';
|
||||
import type { ExtensionType } from '@blocksuite/affine/store';
|
||||
import { css, type PropertyValues } from 'lit';
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
BlockModel,
|
||||
BlockSchemaExtension,
|
||||
defineBlockSchema,
|
||||
} from '@blocksuite/affine/store';
|
||||
|
||||
export const TranscriptionBlockFlavour = 'affine:transcription';
|
||||
|
||||
const defaultProps: TranscriptionBlockProps = {
|
||||
transcription: {},
|
||||
jobId: undefined,
|
||||
createdBy: undefined, // the user id of the creator
|
||||
};
|
||||
|
||||
export const TranscriptionBlockSchema = defineBlockSchema({
|
||||
flavour: TranscriptionBlockFlavour,
|
||||
props: () => defaultProps,
|
||||
metadata: {
|
||||
version: 1,
|
||||
role: 'attachment-viewer',
|
||||
parent: ['affine:attachment'],
|
||||
children: ['affine:callout'],
|
||||
},
|
||||
toModel: () => new TranscriptionBlockModel(),
|
||||
});
|
||||
|
||||
export type TranscriptionBlockProps = {
|
||||
transcription: Record<string, any>;
|
||||
jobId?: string;
|
||||
createdBy?: string;
|
||||
};
|
||||
|
||||
export class TranscriptionBlockModel extends BlockModel<TranscriptionBlockProps> {}
|
||||
|
||||
export const TranscriptionBlockSchemaExtension = BlockSchemaExtension(
|
||||
TranscriptionBlockSchema
|
||||
);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { createReactComponentFromLit } from '@affine/component';
|
||||
import { LitTranscriptionBlock } from '@affine/core/blocksuite/ai/blocks/ai-chat-block/ai-transcription-block';
|
||||
import type { TranscriptionBlockModel } from '@blocksuite/affine/model';
|
||||
import type { TranscriptionBlockModel } from '@affine/core/blocksuite/ai/blocks/transcription-block/model';
|
||||
import { LiveData, useLiveData } from '@toeverything/infra';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import { getInternalStoreExtensions } from '@blocksuite/affine/extensions/store';
|
||||
|
||||
import { AIChatBlockSchemaExtension } from '../ai/blocks/ai-chat-block/model';
|
||||
import { TranscriptionBlockSchemaExtension } from '../ai/blocks/transcription-block/model';
|
||||
|
||||
class MigratingAffineStoreExtension extends StoreExtensionProvider {
|
||||
override name = 'affine-store-extensions';
|
||||
@@ -13,6 +14,7 @@ class MigratingAffineStoreExtension extends StoreExtensionProvider {
|
||||
override setup(context: StoreExtensionContext) {
|
||||
super.setup(context);
|
||||
context.register(AIChatBlockSchemaExtension);
|
||||
context.register(TranscriptionBlockSchemaExtension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user