refactor(editor): reorg blocksuite ai code (#10372)
### TL;DR Relocated AI-related code from `presets` directory to a dedicated `ai` directory for better organization and maintainability. ### What changed? - Moved AI-related code from `blocksuite/presets/ai` to `blocksuite/ai` - Relocated AI chat block code from `blocksuite/blocks` to `blocksuite/ai/blocks` - Updated imports across files to reflect new directory structure - Renamed `registerBlocksuitePresetsCustomComponents` to `registerAIEffects` - Fixed path references in GitHub workflow file ### How to test? 1. Build and run the application 2. Verify AI functionality works as expected: - Test AI chat blocks - Check AI panel functionality - Verify AI copilot features - Ensure AI-related UI components render correctly ### Why make this change? This restructuring improves code organization by: - Giving AI features a dedicated directory that better reflects their importance - Making the codebase more maintainable by grouping related AI functionality - Reducing confusion by removing AI code from the more general `presets` directory - Creating clearer boundaries between AI and non-AI related code
This commit is contained in:
233 files changed
+247
-279
No files matched your search
@@ -624,8 +624,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
filters: |
|
filters: |
|
||||||
changed:
|
changed:
|
||||||
- 'packages/frontend/core/src/blocksuite/presets/ai/**'
|
- 'packages/frontend/core/src/blocksuite/ai/**'
|
||||||
- 'packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/**'
|
|
||||||
- 'tests/affine-cloud-copilot/**'
|
- 'tests/affine-cloud-copilot/**'
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
|
|||||||
+2
-2
@@ -27,8 +27,8 @@ import {
|
|||||||
import type { Store } from '@blocksuite/affine/store';
|
import type { Store } from '@blocksuite/affine/store';
|
||||||
import type { TemplateResult } from 'lit';
|
import type { TemplateResult } from 'lit';
|
||||||
|
|
||||||
import type { ChatMessage } from '../../../blocks';
|
import { insertFromMarkdown } from '../../utils';
|
||||||
import { insertFromMarkdown } from '../../_common';
|
import type { ChatMessage } from '../blocks';
|
||||||
import { AIProvider, type AIUserInfo } from '../provider';
|
import { AIProvider, type AIUserInfo } from '../provider';
|
||||||
import { reportResponse } from '../utils/action-reporter';
|
import { reportResponse } from '../utils/action-reporter';
|
||||||
import { insertBelow, replace } from '../utils/editor-actions';
|
import { insertBelow, replace } from '../utils/editor-actions';
|
||||||
+3
-3
@@ -15,12 +15,12 @@ import {
|
|||||||
textTones,
|
textTones,
|
||||||
translateLangs,
|
translateLangs,
|
||||||
} from '../actions/types';
|
} from '../actions/types';
|
||||||
import { AIProvider } from '../provider';
|
|
||||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
|
||||||
import type {
|
import type {
|
||||||
AIItemGroupConfig,
|
AIItemGroupConfig,
|
||||||
AISubItemConfig,
|
AISubItemConfig,
|
||||||
} from './components/ai-item/types';
|
} from '../components/ai-item/types';
|
||||||
|
import { AIProvider } from '../provider';
|
||||||
|
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||||
import {
|
import {
|
||||||
AIDoneIcon,
|
AIDoneIcon,
|
||||||
AIImageIcon,
|
AIImageIcon,
|
||||||
File renamed without changes.
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import type { EditorHost } from '@blocksuite/affine/block-std';
|
import type { EditorHost } from '@blocksuite/affine/block-std';
|
||||||
import type { MindmapElementModel } from '@blocksuite/affine/blocks';
|
import type { MindmapElementModel } from '@blocksuite/affine/blocks';
|
||||||
|
|
||||||
import { createTextRenderer } from '../../_common';
|
import { createTextRenderer } from '../components/text-renderer';
|
||||||
import {
|
import {
|
||||||
createMindmapExecuteRenderer,
|
createMindmapExecuteRenderer,
|
||||||
createMindmapRenderer,
|
createMindmapRenderer,
|
||||||
File renamed without changes.
+1
-4
@@ -7,16 +7,13 @@ import { assertExists } from '@blocksuite/affine/global/utils';
|
|||||||
import { flip, offset } from '@floating-ui/dom';
|
import { flip, offset } from '@floating-ui/dom';
|
||||||
import { html, type TemplateResult } from 'lit';
|
import { html, type TemplateResult } from 'lit';
|
||||||
|
|
||||||
import type {
|
|
||||||
AIError,
|
|
||||||
AIItemGroupConfig,
|
|
||||||
} from '../_common/components/ai-item/types';
|
|
||||||
import {
|
import {
|
||||||
buildCopyConfig,
|
buildCopyConfig,
|
||||||
buildErrorConfig,
|
buildErrorConfig,
|
||||||
buildFinishConfig,
|
buildFinishConfig,
|
||||||
buildGeneratingConfig,
|
buildGeneratingConfig,
|
||||||
} from '../ai-panel';
|
} from '../ai-panel';
|
||||||
|
import type { AIError, AIItemGroupConfig } from '../components/ai-item/types';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { reportResponse } from '../utils/action-reporter';
|
import { reportResponse } from '../utils/action-reporter';
|
||||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||||
+3
-3
@@ -18,9 +18,9 @@ import { assertExists } from '@blocksuite/affine/global/utils';
|
|||||||
import { Slice } from '@blocksuite/affine/store';
|
import { Slice } from '@blocksuite/affine/store';
|
||||||
import type { TemplateResult } from 'lit';
|
import type { TemplateResult } from 'lit';
|
||||||
|
|
||||||
import { AIChatBlockModel } from '../../../blocks';
|
import { getContentFromSlice } from '../../utils';
|
||||||
import { getContentFromSlice } from '../../_common';
|
import { AIChatBlockModel } from '../blocks';
|
||||||
import type { AIError } from '../_common/components/ai-item/types';
|
import type { AIError } from '../components/ai-item/types';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { reportResponse } from '../utils/action-reporter';
|
import { reportResponse } from '../utils/action-reporter';
|
||||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||||
+2
-2
@@ -26,9 +26,9 @@ import { assertExists, Bound } from '@blocksuite/affine/global/utils';
|
|||||||
import { html, type TemplateResult } from 'lit';
|
import { html, type TemplateResult } from 'lit';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { insertFromMarkdown } from '../../_common';
|
import { insertFromMarkdown } from '../../utils';
|
||||||
import type { AIItemConfig } from '../_common/components/ai-item/types';
|
|
||||||
import { AIPenIcon, ChatWithAIIcon } from '../_common/icons';
|
import { AIPenIcon, ChatWithAIIcon } from '../_common/icons';
|
||||||
|
import type { AIItemConfig } from '../components/ai-item/types';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { reportResponse } from '../utils/action-reporter';
|
import { reportResponse } from '../utils/action-reporter';
|
||||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
-2
@@ -12,8 +12,7 @@ import { assertExists, Bound } from '@blocksuite/affine/global/utils';
|
|||||||
import type { FrameworkProvider } from '@toeverything/infra';
|
import type { FrameworkProvider } from '@toeverything/infra';
|
||||||
import type { TemplateResult } from 'lit';
|
import type { TemplateResult } from 'lit';
|
||||||
|
|
||||||
import { createTextRenderer, insertFromMarkdown } from '../_common';
|
import { insertFromMarkdown } from '../utils';
|
||||||
import type { AIItemConfig } from './_common/components/ai-item/types';
|
|
||||||
import {
|
import {
|
||||||
AIPenIcon,
|
AIPenIcon,
|
||||||
AIStarIconWithAnimation,
|
AIStarIconWithAnimation,
|
||||||
@@ -33,6 +32,8 @@ import {
|
|||||||
pageResponseHandler,
|
pageResponseHandler,
|
||||||
replaceWithMarkdown,
|
replaceWithMarkdown,
|
||||||
} from './actions/page-response';
|
} from './actions/page-response';
|
||||||
|
import type { AIItemConfig } from './components/ai-item/types';
|
||||||
|
import { createTextRenderer } from './components/text-renderer';
|
||||||
import { AIProvider } from './provider';
|
import { AIProvider } from './provider';
|
||||||
import { reportResponse } from './utils/action-reporter';
|
import { reportResponse } from './utils/action-reporter';
|
||||||
import { getAIPanelWidget } from './utils/ai-widgets';
|
import { getAIPanelWidget } from './utils/ai-widgets';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import type { TextRendererOptions } from '@affine/core/blocksuite/presets';
|
import type { TextRendererOptions } from '@affine/core/blocksuite/ai/components/text-renderer';
|
||||||
import type { AffineAIPanelState } from '@affine/core/blocksuite/presets/ai/widgets/ai-panel/type';
|
import type { AffineAIPanelState } from '@affine/core/blocksuite/ai/widgets/ai-panel/type';
|
||||||
import type { EditorHost } from '@blocksuite/affine/block-std';
|
import type { EditorHost } from '@blocksuite/affine/block-std';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -3,7 +3,6 @@ import { WithDisposable } from '@blocksuite/affine/global/utils';
|
|||||||
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
||||||
import { property, state } from 'lit/decorators.js';
|
import { property, state } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { createTextRenderer } from '../../../_common';
|
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
AIChangeToneIcon,
|
AIChangeToneIcon,
|
||||||
@@ -23,6 +22,7 @@ import {
|
|||||||
ArrowDownIcon,
|
ArrowDownIcon,
|
||||||
ArrowUpIcon,
|
ArrowUpIcon,
|
||||||
} from '../../_common/icons';
|
} from '../../_common/icons';
|
||||||
|
import { createTextRenderer } from '../../components/text-renderer';
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
import { renderImages } from '../components/images';
|
import { renderImages } from '../components/images';
|
||||||
import { HISTORY_IMAGE_ACTIONS } from '../const';
|
import { HISTORY_IMAGE_ACTIONS } from '../const';
|
||||||
+1
-1
@@ -7,7 +7,7 @@ import { WithDisposable } from '@blocksuite/affine/global/utils';
|
|||||||
import { html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { createTextRenderer } from '../../../_common';
|
import { createTextRenderer } from '../../components/text-renderer';
|
||||||
import { renderImages } from '../components/images';
|
import { renderImages } from '../components/images';
|
||||||
|
|
||||||
export class ChatText extends WithDisposable(ShadowlessElement) {
|
export class ChatText extends WithDisposable(ShadowlessElement) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -6,7 +6,7 @@ import { css, html, LitElement } from 'lit';
|
|||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { createTextRenderer } from '../../../_common';
|
import { createTextRenderer } from '../../components/text-renderer';
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
|
|
||||||
export class ActionText extends WithDisposable(LitElement) {
|
export class ActionText extends WithDisposable(LitElement) {
|
||||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import type { Signal } from '@preact/signals-core';
|
import type { Signal } from '@preact/signals-core';
|
||||||
|
|
||||||
import type { AIError } from '../_common/components/ai-item/types';
|
import type { AIError } from '../components/ai-item/types';
|
||||||
|
|
||||||
export type ChatMessage = {
|
export type ChatMessage = {
|
||||||
id: string;
|
id: string;
|
||||||
File renamed without changes.
+1
-1
@@ -7,13 +7,13 @@ import { css, html, LitElement, nothing } from 'lit';
|
|||||||
import { property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import type { AIError } from '../_common/components/ai-item/types';
|
|
||||||
import {
|
import {
|
||||||
ChatAbortIcon,
|
ChatAbortIcon,
|
||||||
ChatClearIcon,
|
ChatClearIcon,
|
||||||
ChatSendIcon,
|
ChatSendIcon,
|
||||||
CloseIcon,
|
CloseIcon,
|
||||||
} from '../_common/icons';
|
} from '../_common/icons';
|
||||||
|
import type { AIError } from '../components/ai-item/types';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { reportResponse } from '../utils/action-reporter';
|
import { reportResponse } from '../utils/action-reporter';
|
||||||
import { readBlobAsURL } from '../utils/image';
|
import { readBlobAsURL } from '../utils/image';
|
||||||
+2
-2
@@ -18,12 +18,12 @@ import {
|
|||||||
EdgelessEditorActions,
|
EdgelessEditorActions,
|
||||||
PageEditorActions,
|
PageEditorActions,
|
||||||
} from '../_common/chat-actions-handle';
|
} from '../_common/chat-actions-handle';
|
||||||
|
import { AffineAvatarIcon, AffineIcon, DownArrowIcon } from '../_common/icons';
|
||||||
import {
|
import {
|
||||||
type AIError,
|
type AIError,
|
||||||
PaymentRequiredError,
|
PaymentRequiredError,
|
||||||
UnauthorizedError,
|
UnauthorizedError,
|
||||||
} from '../_common/components/ai-item/types';
|
} from '../components/ai-item/types';
|
||||||
import { AffineAvatarIcon, AffineIcon, DownArrowIcon } from '../_common/icons';
|
|
||||||
import { AIChatErrorRenderer } from '../messages/error';
|
import { AIChatErrorRenderer } from '../messages/error';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import {
|
import {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -5,7 +5,7 @@ import {
|
|||||||
PreloadImageIcon,
|
PreloadImageIcon,
|
||||||
PreloadPenIcon,
|
PreloadPenIcon,
|
||||||
} from '../_common/icons.js';
|
} from '../_common/icons.js';
|
||||||
import { AIProvider } from '../provider.js';
|
import { AIProvider } from '../provider/ai-provider.js';
|
||||||
import completeWritingWithAI from './templates/completeWritingWithAI.zip';
|
import completeWritingWithAI from './templates/completeWritingWithAI.zip';
|
||||||
import freelyCommunicateWithAI from './templates/freelyCommunicateWithAI.zip';
|
import freelyCommunicateWithAI from './templates/freelyCommunicateWithAI.zip';
|
||||||
import readAforeign from './templates/readAforeign.zip';
|
import readAforeign from './templates/readAforeign.zip';
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4
-4
@@ -9,10 +9,10 @@ import { flip, offset } from '@floating-ui/dom';
|
|||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { AIProvider } from '../../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||||
import { extractSelectedContent } from '../../utils/extract';
|
import { extractSelectedContent } from '../utils/extract';
|
||||||
import type { AffineAIPanelWidgetConfig } from '../../widgets/ai-panel/type';
|
import type { AffineAIPanelWidgetConfig } from '../widgets/ai-panel/type';
|
||||||
import type { AIItemGroupConfig } from './ai-item/types';
|
import type { AIItemGroupConfig } from './ai-item/types';
|
||||||
|
|
||||||
export class AskAIToolbarButton extends WithDisposable(LitElement) {
|
export class AskAIToolbarButton extends WithDisposable(LitElement) {
|
||||||
+2
-2
@@ -12,8 +12,8 @@ import { property } from 'lit/decorators.js';
|
|||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import { insertBelow } from '../../utils/editor-actions';
|
import type { ChatAction } from '../_common/chat-actions-handle';
|
||||||
import type { ChatAction } from '../chat-actions-handle';
|
import { insertBelow } from '../utils/editor-actions';
|
||||||
|
|
||||||
export class ChatActionList extends LitElement {
|
export class ChatActionList extends LitElement {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
+2
-2
@@ -15,8 +15,8 @@ import { css, html, LitElement, nothing, type PropertyValues } from 'lit';
|
|||||||
import { property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import { type ChatAction } from '../../_common/chat-actions-handle';
|
import type { ChatAction } from '../_common/chat-actions-handle';
|
||||||
import { copyText } from '../../utils/editor-actions';
|
import { copyText } from '../utils/editor-actions';
|
||||||
|
|
||||||
noop(Tooltip);
|
noop(Tooltip);
|
||||||
|
|
||||||
File renamed without changes.
+17
-3
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
BlockStdScope,
|
BlockStdScope,
|
||||||
|
BlockViewIdentifier,
|
||||||
type EditorHost,
|
type EditorHost,
|
||||||
ShadowlessElement,
|
ShadowlessElement,
|
||||||
} from '@blocksuite/affine/block-std';
|
} from '@blocksuite/affine/block-std';
|
||||||
@@ -12,6 +13,7 @@ import {
|
|||||||
InlineDeltaToMarkdownAdapterExtensions,
|
InlineDeltaToMarkdownAdapterExtensions,
|
||||||
ListBlockComponent,
|
ListBlockComponent,
|
||||||
MarkdownInlineToDeltaAdapterExtensions,
|
MarkdownInlineToDeltaAdapterExtensions,
|
||||||
|
PageEditorBlockSpecs,
|
||||||
ParagraphBlockComponent,
|
ParagraphBlockComponent,
|
||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
||||||
@@ -27,13 +29,13 @@ import { css, html, nothing, type PropertyValues } from 'lit';
|
|||||||
import { property, query } from 'lit/decorators.js';
|
import { property, query } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { keyed } from 'lit/directives/keyed.js';
|
import { keyed } from 'lit/directives/keyed.js';
|
||||||
|
import { literal } from 'lit/static-html.js';
|
||||||
|
|
||||||
|
import { markDownToDoc } from '../../utils';
|
||||||
import type {
|
import type {
|
||||||
AffineAIPanelState,
|
AffineAIPanelState,
|
||||||
AffineAIPanelWidgetConfig,
|
AffineAIPanelWidgetConfig,
|
||||||
} from '../../ai/widgets/ai-panel/type';
|
} from '../widgets/ai-panel/type';
|
||||||
import { CustomPageEditorBlockSpecs } from '../utils/custom-specs';
|
|
||||||
import { markDownToDoc } from '../utils/markdown-utils';
|
|
||||||
|
|
||||||
const textBlockStyles = css`
|
const textBlockStyles = css`
|
||||||
${ParagraphBlockComponent.styles}
|
${ParagraphBlockComponent.styles}
|
||||||
@@ -90,6 +92,18 @@ export type TextRendererOptions = {
|
|||||||
additionalMiddlewares?: TransformerMiddleware[];
|
additionalMiddlewares?: TransformerMiddleware[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const CustomPageEditorBlockSpecs: ExtensionType[] = [
|
||||||
|
...PageEditorBlockSpecs,
|
||||||
|
{
|
||||||
|
setup: di => {
|
||||||
|
di.override(
|
||||||
|
BlockViewIdentifier('affine:page'),
|
||||||
|
() => literal`affine-page-root`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// todo: refactor it for more general purpose usage instead of AI only?
|
// todo: refactor it for more general purpose usage instead of AI only?
|
||||||
export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
+48
-47
@@ -1,68 +1,69 @@
|
|||||||
import { AIChatBlockComponent } from '../blocks/ai-chat-block/ai-chat-block';
|
import { AIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-block';
|
||||||
import { EdgelessAIChatBlockComponent } from '../blocks/ai-chat-block/ai-chat-edgeless-block';
|
import { EdgelessAIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-edgeless-block';
|
||||||
import {
|
import {
|
||||||
AIChatMessage,
|
AIChatMessage,
|
||||||
AIChatMessages,
|
AIChatMessages,
|
||||||
} from '../blocks/ai-chat-block/components/ai-chat-messages';
|
} from './blocks/ai-chat-block/components/ai-chat-messages';
|
||||||
import {
|
import {
|
||||||
ChatImage,
|
ChatImage,
|
||||||
ChatImages,
|
ChatImages,
|
||||||
} from '../blocks/ai-chat-block/components/chat-images';
|
} from './blocks/ai-chat-block/components/chat-images';
|
||||||
import { ImagePlaceholder } from '../blocks/ai-chat-block/components/image-placeholder';
|
import { ImagePlaceholder } from './blocks/ai-chat-block/components/image-placeholder';
|
||||||
import { UserInfo } from '../blocks/ai-chat-block/components/user-info';
|
import { UserInfo } from './blocks/ai-chat-block/components/user-info';
|
||||||
import { TextRenderer } from './_common/components/text-renderer';
|
import { ChatPanel } from './chat-panel';
|
||||||
import { effects as componentAiItemEffects } from './ai/_common/components/ai-item';
|
import { ActionWrapper } from './chat-panel/actions/action-wrapper';
|
||||||
import { AskAIButton } from './ai/_common/components/ask-ai-button';
|
import { ChatText } from './chat-panel/actions/chat-text';
|
||||||
import { AskAIIcon } from './ai/_common/components/ask-ai-icon';
|
import { ActionImage } from './chat-panel/actions/image';
|
||||||
import { AskAIPanel } from './ai/_common/components/ask-ai-panel';
|
import { ActionImageToText } from './chat-panel/actions/image-to-text';
|
||||||
import { AskAIToolbarButton } from './ai/_common/components/ask-ai-toolbar';
|
import { ActionMakeReal } from './chat-panel/actions/make-real';
|
||||||
import { ChatActionList } from './ai/_common/components/chat-action-list';
|
import { ActionMindmap } from './chat-panel/actions/mindmap';
|
||||||
import { ChatCopyMore } from './ai/_common/components/copy-more';
|
import { ActionSlides } from './chat-panel/actions/slides';
|
||||||
import { ImagePreviewGrid } from './ai/_common/components/image-preview-grid';
|
import { ActionText } from './chat-panel/actions/text';
|
||||||
import { ChatPanel } from './ai/chat-panel';
|
import { AILoading } from './chat-panel/ai-loading';
|
||||||
import { ActionWrapper } from './ai/chat-panel/actions/action-wrapper';
|
import { ChatPanelChips } from './chat-panel/chat-panel-chips';
|
||||||
import { ChatText } from './ai/chat-panel/actions/chat-text';
|
import { ChatPanelInput } from './chat-panel/chat-panel-input';
|
||||||
import { ActionImage } from './ai/chat-panel/actions/image';
|
import { ChatPanelMessages } from './chat-panel/chat-panel-messages';
|
||||||
import { ActionImageToText } from './ai/chat-panel/actions/image-to-text';
|
import { ChatPanelAddPopover } from './chat-panel/components/add-popover';
|
||||||
import { ActionMakeReal } from './ai/chat-panel/actions/make-real';
|
import { ChatPanelChip } from './chat-panel/components/chip';
|
||||||
import { ActionMindmap } from './ai/chat-panel/actions/mindmap';
|
import { ChatPanelDocChip } from './chat-panel/components/doc-chip';
|
||||||
import { ActionSlides } from './ai/chat-panel/actions/slides';
|
import { ChatPanelFileChip } from './chat-panel/components/file-chip';
|
||||||
import { ActionText } from './ai/chat-panel/actions/text';
|
import { effects as componentAiItemEffects } from './components/ai-item';
|
||||||
import { AILoading } from './ai/chat-panel/ai-loading';
|
import { AskAIButton } from './components/ask-ai-button';
|
||||||
import { ChatPanelChips } from './ai/chat-panel/chat-panel-chips';
|
import { AskAIIcon } from './components/ask-ai-icon';
|
||||||
import { ChatPanelInput } from './ai/chat-panel/chat-panel-input';
|
import { AskAIPanel } from './components/ask-ai-panel';
|
||||||
import { ChatPanelMessages } from './ai/chat-panel/chat-panel-messages';
|
import { AskAIToolbarButton } from './components/ask-ai-toolbar';
|
||||||
import { ChatPanelAddPopover } from './ai/chat-panel/components/add-popover';
|
import { ChatActionList } from './components/chat-action-list';
|
||||||
import { ChatPanelChip } from './ai/chat-panel/components/chip';
|
import { ChatCopyMore } from './components/copy-more';
|
||||||
import { ChatPanelDocChip } from './ai/chat-panel/components/doc-chip';
|
import { ImagePreviewGrid } from './components/image-preview-grid';
|
||||||
import { ChatPanelFileChip } from './ai/chat-panel/components/file-chip';
|
import { TextRenderer } from './components/text-renderer';
|
||||||
import { AIErrorWrapper } from './ai/messages/error';
|
import { AIErrorWrapper } from './messages/error';
|
||||||
import { AISlidesRenderer } from './ai/messages/slides-renderer';
|
import { AISlidesRenderer } from './messages/slides-renderer';
|
||||||
import { AIAnswerWrapper } from './ai/messages/wrapper';
|
import { AIAnswerWrapper } from './messages/wrapper';
|
||||||
import { registerMiniMindmapBlocks } from './ai/mini-mindmap';
|
import { registerMiniMindmapBlocks } from './mini-mindmap';
|
||||||
import { ChatBlockInput } from './ai/peek-view/chat-block-input';
|
import { ChatBlockInput } from './peek-view/chat-block-input';
|
||||||
import { AIChatBlockPeekView } from './ai/peek-view/chat-block-peek-view';
|
import { AIChatBlockPeekView } from './peek-view/chat-block-peek-view';
|
||||||
import { DateTime } from './ai/peek-view/date-time';
|
import { DateTime } from './peek-view/date-time';
|
||||||
import {
|
import {
|
||||||
AFFINE_AI_PANEL_WIDGET,
|
AFFINE_AI_PANEL_WIDGET,
|
||||||
AffineAIPanelWidget,
|
AffineAIPanelWidget,
|
||||||
} from './ai/widgets/ai-panel/ai-panel';
|
} from './widgets/ai-panel/ai-panel';
|
||||||
import {
|
import {
|
||||||
AIPanelAnswer,
|
AIPanelAnswer,
|
||||||
AIPanelDivider,
|
AIPanelDivider,
|
||||||
AIPanelError,
|
AIPanelError,
|
||||||
AIPanelGenerating,
|
AIPanelGenerating,
|
||||||
AIPanelInput,
|
AIPanelInput,
|
||||||
} from './ai/widgets/ai-panel/components';
|
} from './widgets/ai-panel/components';
|
||||||
import { AIFinishTip } from './ai/widgets/ai-panel/components/finish-tip';
|
import { AIFinishTip } from './widgets/ai-panel/components/finish-tip';
|
||||||
import { GeneratingPlaceholder } from './ai/widgets/ai-panel/components/generating-placeholder';
|
import { GeneratingPlaceholder } from './widgets/ai-panel/components/generating-placeholder';
|
||||||
import {
|
import {
|
||||||
AFFINE_EDGELESS_COPILOT_WIDGET,
|
AFFINE_EDGELESS_COPILOT_WIDGET,
|
||||||
EdgelessCopilotWidget,
|
EdgelessCopilotWidget,
|
||||||
} from './ai/widgets/edgeless-copilot';
|
} from './widgets/edgeless-copilot';
|
||||||
import { EdgelessCopilotPanel } from './ai/widgets/edgeless-copilot-panel';
|
import { EdgelessCopilotPanel } from './widgets/edgeless-copilot-panel';
|
||||||
import { EdgelessCopilotToolbarEntry } from './ai/widgets/edgeless-copilot-panel/toolbar-entry';
|
import { EdgelessCopilotToolbarEntry } from './widgets/edgeless-copilot-panel/toolbar-entry';
|
||||||
export function registerBlocksuitePresetsCustomComponents() {
|
|
||||||
|
export function registerAIEffects() {
|
||||||
registerMiniMindmapBlocks();
|
registerMiniMindmapBlocks();
|
||||||
componentAiItemEffects();
|
componentAiItemEffects();
|
||||||
|
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
import '../../_common/components/ask-ai-button';
|
import '../../components/ask-ai-button';
|
||||||
|
|
||||||
import type { AffineCodeToolbarWidget } from '@blocksuite/affine/blocks';
|
import type { AffineCodeToolbarWidget } from '@blocksuite/affine/blocks';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
@@ -11,8 +11,8 @@ const buttonOptions: AskAIButtonOptions = {
|
|||||||
|
|
||||||
import { BlockSelection } from '@blocksuite/affine/block-std';
|
import { BlockSelection } from '@blocksuite/affine/block-std';
|
||||||
|
|
||||||
import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button';
|
|
||||||
import { buildAICodeItemGroups } from '../../_common/config';
|
import { buildAICodeItemGroups } from '../../_common/config';
|
||||||
|
import type { AskAIButtonOptions } from '../../components/ask-ai-button';
|
||||||
|
|
||||||
export function setupCodeToolbarAIEntry(codeToolbar: AffineCodeToolbarWidget) {
|
export function setupCodeToolbarAIEntry(codeToolbar: AffineCodeToolbarWidget) {
|
||||||
codeToolbar.addPrimaryItems([
|
codeToolbar.addPrimaryItems([
|
||||||
+1
-1
@@ -6,7 +6,6 @@ import {
|
|||||||
TextElementModel,
|
TextElementModel,
|
||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
|
|
||||||
import type { AIItemGroupConfig } from '../../_common/components/ai-item/types';
|
|
||||||
import {
|
import {
|
||||||
AIExpandMindMapIcon,
|
AIExpandMindMapIcon,
|
||||||
AIImageIcon,
|
AIImageIcon,
|
||||||
@@ -44,6 +43,7 @@ import {
|
|||||||
textTones,
|
textTones,
|
||||||
translateLangs,
|
translateLangs,
|
||||||
} from '../../actions/types';
|
} from '../../actions/types';
|
||||||
|
import type { AIItemGroupConfig } from '../../components/ai-item/types';
|
||||||
import { AIProvider } from '../../provider';
|
import { AIProvider } from '../../provider';
|
||||||
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
||||||
import { mindMapToMarkdown } from '../../utils/edgeless';
|
import { mindMapToMarkdown } from '../../utils/edgeless';
|
||||||
+1
-1
@@ -6,7 +6,7 @@ import type {
|
|||||||
import { noop } from '@blocksuite/affine/global/utils';
|
import { noop } from '@blocksuite/affine/global/utils';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
|
|
||||||
import type { AIItemGroupConfig } from '../../_common/components/ai-item/types';
|
import type { AIItemGroupConfig } from '../../components/ai-item/types';
|
||||||
import { AIProvider } from '../../provider';
|
import { AIProvider } from '../../provider';
|
||||||
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
||||||
import { getEdgelessCopilotWidget } from '../../utils/edgeless';
|
import { getEdgelessCopilotWidget } from '../../utils/edgeless';
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import '../../_common/components/ask-ai-button';
|
import '../../components/ask-ai-button';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type AffineFormatBarWidget,
|
type AffineFormatBarWidget,
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
import '../../_common/components/ask-ai-button';
|
import '../../components/ask-ai-button';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type AffineImageToolbarWidget,
|
type AffineImageToolbarWidget,
|
||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
|
|
||||||
import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button';
|
|
||||||
import { buildAIImageItemGroups } from '../../_common/config';
|
import { buildAIImageItemGroups } from '../../_common/config';
|
||||||
|
import type { AskAIButtonOptions } from '../../components/ask-ai-button';
|
||||||
|
|
||||||
const AIImageItemGroups = buildAIImageItemGroups();
|
const AIImageItemGroups = buildAIImageItemGroups();
|
||||||
const buttonOptions: AskAIButtonOptions = {
|
const buttonOptions: AskAIButtonOptions = {
|
||||||
File renamed without changes.
+1
-1
@@ -11,9 +11,9 @@ import { assertExists } from '@blocksuite/affine/global/utils';
|
|||||||
import { MoreHorizontalIcon } from '@blocksuite/icons/lit';
|
import { MoreHorizontalIcon } from '@blocksuite/icons/lit';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
|
|
||||||
import type { AIItemConfig } from '../../_common/components/ai-item/types';
|
|
||||||
import { pageAIGroups } from '../../_common/config';
|
import { pageAIGroups } from '../../_common/config';
|
||||||
import { handleInlineAskAIAction } from '../../actions/doc-handler';
|
import { handleInlineAskAIAction } from '../../actions/doc-handler';
|
||||||
|
import type { AIItemConfig } from '../../components/ai-item/types';
|
||||||
import { AIProvider } from '../../provider';
|
import { AIProvider } from '../../provider';
|
||||||
import {
|
import {
|
||||||
AFFINE_AI_PANEL_WIDGET,
|
AFFINE_AI_PANEL_WIDGET,
|
||||||
File renamed without changes.
File renamed without changes.
+2
-2
@@ -7,12 +7,12 @@ import { baseTheme } from '@toeverything/theme';
|
|||||||
import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
|
import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
|
import { ErrorTipIcon } from '../_common/icons';
|
||||||
import {
|
import {
|
||||||
type AIError,
|
type AIError,
|
||||||
PaymentRequiredError,
|
PaymentRequiredError,
|
||||||
UnauthorizedError,
|
UnauthorizedError,
|
||||||
} from '../_common/components/ai-item/types';
|
} from '../components/ai-item/types';
|
||||||
import { ErrorTipIcon } from '../_common/icons';
|
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
|
|
||||||
export class AIErrorWrapper extends SignalWatcher(WithDisposable(LitElement)) {
|
export class AIErrorWrapper extends SignalWatcher(WithDisposable(LitElement)) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -6,14 +6,14 @@ import { css, html, LitElement, nothing } from 'lit';
|
|||||||
import { property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
|
|
||||||
import type { ChatMessage } from '../../../blocks';
|
|
||||||
import type { AIError } from '../_common/components/ai-item/types';
|
|
||||||
import { ChatAbortIcon, ChatClearIcon, ChatSendIcon } from '../_common/icons';
|
import { ChatAbortIcon, ChatClearIcon, ChatSendIcon } from '../_common/icons';
|
||||||
|
import type { ChatMessage } from '../blocks';
|
||||||
import type { AINetworkSearchConfig } from '../chat-panel/chat-config';
|
import type { AINetworkSearchConfig } from '../chat-panel/chat-config';
|
||||||
import {
|
import {
|
||||||
PROMPT_NAME_AFFINE_AI,
|
PROMPT_NAME_AFFINE_AI,
|
||||||
PROMPT_NAME_NETWORK_SEARCH,
|
PROMPT_NAME_NETWORK_SEARCH,
|
||||||
} from '../chat-panel/const';
|
} from '../chat-panel/const';
|
||||||
|
import type { AIError } from '../components/ai-item/types';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { reportResponse } from '../utils/action-reporter';
|
import { reportResponse } from '../utils/action-reporter';
|
||||||
import { readBlobAsURL } from '../utils/image';
|
import { readBlobAsURL } from '../utils/image';
|
||||||
+7
-7
@@ -14,20 +14,20 @@ import { property, query, state } from 'lit/decorators.js';
|
|||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import {
|
|
||||||
type AIChatBlockModel,
|
|
||||||
type ChatMessage,
|
|
||||||
ChatMessagesSchema,
|
|
||||||
} from '../../../blocks';
|
|
||||||
import type { TextRendererOptions } from '../../_common/components/text-renderer';
|
|
||||||
import {
|
import {
|
||||||
ChatBlockPeekViewActions,
|
ChatBlockPeekViewActions,
|
||||||
constructUserInfoWithMessages,
|
constructUserInfoWithMessages,
|
||||||
queryHistoryMessages,
|
queryHistoryMessages,
|
||||||
} from '../_common/chat-actions-handle';
|
} from '../_common/chat-actions-handle';
|
||||||
import type { AIError } from '../_common/components/ai-item/types';
|
|
||||||
import { SmallHintIcon } from '../_common/icons';
|
import { SmallHintIcon } from '../_common/icons';
|
||||||
|
import {
|
||||||
|
type AIChatBlockModel,
|
||||||
|
type ChatMessage,
|
||||||
|
ChatMessagesSchema,
|
||||||
|
} from '../blocks';
|
||||||
import type { AINetworkSearchConfig } from '../chat-panel/chat-config';
|
import type { AINetworkSearchConfig } from '../chat-panel/chat-config';
|
||||||
|
import type { AIError } from '../components/ai-item/types';
|
||||||
|
import type { TextRendererOptions } from '../components/text-renderer';
|
||||||
import { AIChatErrorRenderer } from '../messages/error';
|
import { AIChatErrorRenderer } from '../messages/error';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
import { PeekViewStyles } from './styles';
|
import { PeekViewStyles } from './styles';
|
||||||
File renamed without changes.
File renamed without changes.
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import type { ChatMessage } from '../../../blocks';
|
import type { ChatMessage } from '../blocks';
|
||||||
import type { AIError } from '../_common/components/ai-item/types';
|
import type { AIError } from '../components/ai-item/types';
|
||||||
|
|
||||||
export type ChatStatus =
|
export type ChatStatus =
|
||||||
| 'success'
|
| 'success'
|
||||||
Loaded 100 of 233 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user