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:
@@ -8,10 +8,7 @@ import {
|
|||||||
type StoreExtensionContext,
|
type StoreExtensionContext,
|
||||||
StoreExtensionProvider,
|
StoreExtensionProvider,
|
||||||
} from '@blocksuite/affine-ext-loader';
|
} from '@blocksuite/affine-ext-loader';
|
||||||
import {
|
import { RootBlockSchemaExtension } from '@blocksuite/affine-model';
|
||||||
RootBlockSchemaExtension,
|
|
||||||
TranscriptionBlockSchemaExtension,
|
|
||||||
} from '@blocksuite/affine-model';
|
|
||||||
import {
|
import {
|
||||||
HtmlAdapterFactoryExtension,
|
HtmlAdapterFactoryExtension,
|
||||||
ImageProxyService,
|
ImageProxyService,
|
||||||
@@ -69,7 +66,6 @@ function getNotionHtmlAdapterExtensions(): ExtensionType[] {
|
|||||||
|
|
||||||
const MigratingStoreExtensions: ExtensionType[] = [
|
const MigratingStoreExtensions: ExtensionType[] = [
|
||||||
RootBlockSchemaExtension,
|
RootBlockSchemaExtension,
|
||||||
TranscriptionBlockSchemaExtension,
|
|
||||||
|
|
||||||
BlockSelectionExtension,
|
BlockSelectionExtension,
|
||||||
TextSelectionExtension,
|
TextSelectionExtension,
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import {
|
|||||||
RootBlockSchema,
|
RootBlockSchema,
|
||||||
SurfaceRefBlockSchema,
|
SurfaceRefBlockSchema,
|
||||||
TableBlockSchema,
|
TableBlockSchema,
|
||||||
TranscriptionBlockSchema,
|
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import type { BlockSchema } from '@blocksuite/store';
|
import type { BlockSchema } from '@blocksuite/store';
|
||||||
import type { z } from 'zod';
|
import type { z } from 'zod';
|
||||||
@@ -57,5 +56,4 @@ export const AffineSchemas: z.infer<typeof BlockSchema>[] = [
|
|||||||
LatexBlockSchema,
|
LatexBlockSchema,
|
||||||
TableBlockSchema,
|
TableBlockSchema,
|
||||||
CalloutBlockSchema,
|
CalloutBlockSchema,
|
||||||
TranscriptionBlockSchema,
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -15,4 +15,3 @@ export * from './paragraph/index.js';
|
|||||||
export * from './root/index.js';
|
export * from './root/index.js';
|
||||||
export * from './surface-ref/index.js';
|
export * from './surface-ref/index.js';
|
||||||
export * from './table';
|
export * from './table';
|
||||||
export * from './transcription';
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export * from './transcription-model.js';
|
|
||||||
@@ -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 { BlockComponent, BlockViewExtension } from '@blocksuite/affine/std';
|
||||||
import type { ExtensionType } from '@blocksuite/affine/store';
|
import type { ExtensionType } from '@blocksuite/affine/store';
|
||||||
import { css, type PropertyValues } from 'lit';
|
import { css, type PropertyValues } from 'lit';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
BlockModel,
|
BlockModel,
|
||||||
BlockSchemaExtension,
|
BlockSchemaExtension,
|
||||||
defineBlockSchema,
|
defineBlockSchema,
|
||||||
} from '@blocksuite/store';
|
} from '@blocksuite/affine/store';
|
||||||
|
|
||||||
export const TranscriptionBlockFlavour = 'affine:transcription';
|
export const TranscriptionBlockFlavour = 'affine:transcription';
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { createReactComponentFromLit } from '@affine/component';
|
import { createReactComponentFromLit } from '@affine/component';
|
||||||
import { LitTranscriptionBlock } from '@affine/core/blocksuite/ai/blocks/ai-chat-block/ai-transcription-block';
|
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 { LiveData, useLiveData } from '@toeverything/infra';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
import { getInternalStoreExtensions } from '@blocksuite/affine/extensions/store';
|
import { getInternalStoreExtensions } from '@blocksuite/affine/extensions/store';
|
||||||
|
|
||||||
import { AIChatBlockSchemaExtension } from '../ai/blocks/ai-chat-block/model';
|
import { AIChatBlockSchemaExtension } from '../ai/blocks/ai-chat-block/model';
|
||||||
|
import { TranscriptionBlockSchemaExtension } from '../ai/blocks/transcription-block/model';
|
||||||
|
|
||||||
class MigratingAffineStoreExtension extends StoreExtensionProvider {
|
class MigratingAffineStoreExtension extends StoreExtensionProvider {
|
||||||
override name = 'affine-store-extensions';
|
override name = 'affine-store-extensions';
|
||||||
@@ -13,6 +14,7 @@ class MigratingAffineStoreExtension extends StoreExtensionProvider {
|
|||||||
override setup(context: StoreExtensionContext) {
|
override setup(context: StoreExtensionContext) {
|
||||||
super.setup(context);
|
super.setup(context);
|
||||||
context.register(AIChatBlockSchemaExtension);
|
context.register(AIChatBlockSchemaExtension);
|
||||||
|
context.register(TranscriptionBlockSchemaExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
import {
|
||||||
|
TranscriptionBlockFlavour,
|
||||||
|
type TranscriptionBlockModel,
|
||||||
|
} from '@affine/core/blocksuite/ai/blocks/transcription-block/model';
|
||||||
import { insertFromMarkdown } from '@affine/core/blocksuite/utils';
|
import { insertFromMarkdown } from '@affine/core/blocksuite/utils';
|
||||||
import { encodeAudioBlobToOpusSlices } from '@affine/core/utils/webm-encoding';
|
import { encodeAudioBlobToOpusSlices } from '@affine/core/utils/webm-encoding';
|
||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
import { AiJobStatus } from '@affine/graphql';
|
import { AiJobStatus } from '@affine/graphql';
|
||||||
import track from '@affine/track';
|
import track from '@affine/track';
|
||||||
import {
|
import type { AttachmentBlockModel } from '@blocksuite/affine/model';
|
||||||
type AttachmentBlockModel,
|
|
||||||
TranscriptionBlockFlavour,
|
|
||||||
type TranscriptionBlockModel,
|
|
||||||
} from '@blocksuite/affine/model';
|
|
||||||
import type { AffineTextAttributes } from '@blocksuite/affine/shared/types';
|
import type { AffineTextAttributes } from '@blocksuite/affine/shared/types';
|
||||||
import { type DeltaInsert, Text } from '@blocksuite/affine/store';
|
import { type DeltaInsert, Text } from '@blocksuite/affine/store';
|
||||||
import { computed } from '@preact/signals-core';
|
import { computed } from '@preact/signals-core';
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { shallowEqual } from '@affine/component';
|
import { shallowEqual } from '@affine/component';
|
||||||
|
import type { TranscriptionBlockProps } from '@affine/core/blocksuite/ai/blocks/transcription-block/model';
|
||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
import { UserFriendlyError } from '@affine/error';
|
import { UserFriendlyError } from '@affine/error';
|
||||||
import { AiJobStatus } from '@affine/graphql';
|
import { AiJobStatus } from '@affine/graphql';
|
||||||
import type { TranscriptionBlockProps } from '@blocksuite/affine/model';
|
|
||||||
import { Entity, LiveData } from '@toeverything/infra';
|
import { Entity, LiveData } from '@toeverything/infra';
|
||||||
|
|
||||||
import type { DefaultServerService, WorkspaceServerService } from '../../cloud';
|
import type { DefaultServerService, WorkspaceServerService } from '../../cloud';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { AIChatBlockSchema } from '@affine/core/blocksuite/ai/blocks/ai-chat-block/model';
|
import { AIChatBlockSchema } from '@affine/core/blocksuite/ai/blocks/ai-chat-block/model';
|
||||||
|
import { TranscriptionBlockSchema } from '@affine/core/blocksuite/ai/blocks/transcription-block/model';
|
||||||
import { AffineSchemas } from '@blocksuite/affine/schemas';
|
import { AffineSchemas } from '@blocksuite/affine/schemas';
|
||||||
import { Schema } from '@blocksuite/affine/store';
|
import { Schema } from '@blocksuite/affine/store';
|
||||||
|
|
||||||
@@ -7,7 +8,11 @@ export function getAFFiNEWorkspaceSchema() {
|
|||||||
if (!_schema) {
|
if (!_schema) {
|
||||||
_schema = new Schema();
|
_schema = new Schema();
|
||||||
|
|
||||||
_schema.register([...AffineSchemas, AIChatBlockSchema]);
|
_schema.register([
|
||||||
|
...AffineSchemas,
|
||||||
|
AIChatBlockSchema,
|
||||||
|
TranscriptionBlockSchema,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _schema;
|
return _schema;
|
||||||
|
|||||||
Reference in New Issue
Block a user