mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
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:
@@ -27,8 +27,8 @@ import {
|
||||
import type { Store } from '@blocksuite/affine/store';
|
||||
import type { TemplateResult } from 'lit';
|
||||
|
||||
import type { ChatMessage } from '../../../blocks';
|
||||
import { insertFromMarkdown } from '../../_common';
|
||||
import { insertFromMarkdown } from '../../utils';
|
||||
import type { ChatMessage } from '../blocks';
|
||||
import { AIProvider, type AIUserInfo } from '../provider';
|
||||
import { reportResponse } from '../utils/action-reporter';
|
||||
import { insertBelow, replace } from '../utils/editor-actions';
|
||||
@@ -15,12 +15,12 @@ import {
|
||||
textTones,
|
||||
translateLangs,
|
||||
} from '../actions/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||
import type {
|
||||
AIItemGroupConfig,
|
||||
AISubItemConfig,
|
||||
} from './components/ai-item/types';
|
||||
} from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||
import {
|
||||
AIDoneIcon,
|
||||
AIImageIcon,
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { EditorHost } from '@blocksuite/affine/block-std';
|
||||
import type { MindmapElementModel } from '@blocksuite/affine/blocks';
|
||||
|
||||
import { createTextRenderer } from '../../_common';
|
||||
import { createTextRenderer } from '../components/text-renderer';
|
||||
import {
|
||||
createMindmapExecuteRenderer,
|
||||
createMindmapRenderer,
|
||||
@@ -7,16 +7,13 @@ import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import { flip, offset } from '@floating-ui/dom';
|
||||
import { html, type TemplateResult } from 'lit';
|
||||
|
||||
import type {
|
||||
AIError,
|
||||
AIItemGroupConfig,
|
||||
} from '../_common/components/ai-item/types';
|
||||
import {
|
||||
buildCopyConfig,
|
||||
buildErrorConfig,
|
||||
buildFinishConfig,
|
||||
buildGeneratingConfig,
|
||||
} from '../ai-panel';
|
||||
import type { AIError, AIItemGroupConfig } from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { reportResponse } from '../utils/action-reporter';
|
||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||
@@ -18,9 +18,9 @@ import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import { Slice } from '@blocksuite/affine/store';
|
||||
import type { TemplateResult } from 'lit';
|
||||
|
||||
import { AIChatBlockModel } from '../../../blocks';
|
||||
import { getContentFromSlice } from '../../_common';
|
||||
import type { AIError } from '../_common/components/ai-item/types';
|
||||
import { getContentFromSlice } from '../../utils';
|
||||
import { AIChatBlockModel } from '../blocks';
|
||||
import type { AIError } from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { reportResponse } from '../utils/action-reporter';
|
||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||
@@ -26,9 +26,9 @@ import { assertExists, Bound } from '@blocksuite/affine/global/utils';
|
||||
import { html, type TemplateResult } from 'lit';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
|
||||
import { insertFromMarkdown } from '../../_common';
|
||||
import type { AIItemConfig } from '../_common/components/ai-item/types';
|
||||
import { insertFromMarkdown } from '../../utils';
|
||||
import { AIPenIcon, ChatWithAIIcon } from '../_common/icons';
|
||||
import type { AIItemConfig } from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { reportResponse } from '../utils/action-reporter';
|
||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||
@@ -12,8 +12,7 @@ import { assertExists, Bound } from '@blocksuite/affine/global/utils';
|
||||
import type { FrameworkProvider } from '@toeverything/infra';
|
||||
import type { TemplateResult } from 'lit';
|
||||
|
||||
import { createTextRenderer, insertFromMarkdown } from '../_common';
|
||||
import type { AIItemConfig } from './_common/components/ai-item/types';
|
||||
import { insertFromMarkdown } from '../utils';
|
||||
import {
|
||||
AIPenIcon,
|
||||
AIStarIconWithAnimation,
|
||||
@@ -33,6 +32,8 @@ import {
|
||||
pageResponseHandler,
|
||||
replaceWithMarkdown,
|
||||
} from './actions/page-response';
|
||||
import type { AIItemConfig } from './components/ai-item/types';
|
||||
import { createTextRenderer } from './components/text-renderer';
|
||||
import { AIProvider } from './provider';
|
||||
import { reportResponse } from './utils/action-reporter';
|
||||
import { getAIPanelWidget } from './utils/ai-widgets';
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TextRendererOptions } from '@affine/core/blocksuite/presets';
|
||||
import type { AffineAIPanelState } from '@affine/core/blocksuite/presets/ai/widgets/ai-panel/type';
|
||||
import type { TextRendererOptions } from '@affine/core/blocksuite/ai/components/text-renderer';
|
||||
import type { AffineAIPanelState } from '@affine/core/blocksuite/ai/widgets/ai-panel/type';
|
||||
import type { EditorHost } from '@blocksuite/affine/block-std';
|
||||
import { css, html, LitElement } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
@@ -3,7 +3,6 @@ import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
||||
import { property, state } from 'lit/decorators.js';
|
||||
|
||||
import { createTextRenderer } from '../../../_common';
|
||||
import {
|
||||
ActionIcon,
|
||||
AIChangeToneIcon,
|
||||
@@ -23,6 +22,7 @@ import {
|
||||
ArrowDownIcon,
|
||||
ArrowUpIcon,
|
||||
} from '../../_common/icons';
|
||||
import { createTextRenderer } from '../../components/text-renderer';
|
||||
import type { ChatAction } from '../chat-context';
|
||||
import { renderImages } from '../components/images';
|
||||
import { HISTORY_IMAGE_ACTIONS } from '../const';
|
||||
@@ -7,7 +7,7 @@ import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import { html, nothing } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
|
||||
import { createTextRenderer } from '../../../_common';
|
||||
import { createTextRenderer } from '../../components/text-renderer';
|
||||
import { renderImages } from '../components/images';
|
||||
|
||||
export class ChatText extends WithDisposable(ShadowlessElement) {
|
||||
@@ -6,7 +6,7 @@ import { css, html, LitElement } from 'lit';
|
||||
import { property } from 'lit/decorators.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';
|
||||
|
||||
export class ActionText extends WithDisposable(LitElement) {
|
||||
@@ -1,6 +1,6 @@
|
||||
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 = {
|
||||
id: string;
|
||||
@@ -7,13 +7,13 @@ import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query, state } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
|
||||
import type { AIError } from '../_common/components/ai-item/types';
|
||||
import {
|
||||
ChatAbortIcon,
|
||||
ChatClearIcon,
|
||||
ChatSendIcon,
|
||||
CloseIcon,
|
||||
} from '../_common/icons';
|
||||
import type { AIError } from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { reportResponse } from '../utils/action-reporter';
|
||||
import { readBlobAsURL } from '../utils/image';
|
||||
@@ -18,12 +18,12 @@ import {
|
||||
EdgelessEditorActions,
|
||||
PageEditorActions,
|
||||
} from '../_common/chat-actions-handle';
|
||||
import { AffineAvatarIcon, AffineIcon, DownArrowIcon } from '../_common/icons';
|
||||
import {
|
||||
type AIError,
|
||||
PaymentRequiredError,
|
||||
UnauthorizedError,
|
||||
} from '../_common/components/ai-item/types';
|
||||
import { AffineAvatarIcon, AffineIcon, DownArrowIcon } from '../_common/icons';
|
||||
} from '../components/ai-item/types';
|
||||
import { AIChatErrorRenderer } from '../messages/error';
|
||||
import { AIProvider } from '../provider';
|
||||
import {
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
PreloadImageIcon,
|
||||
PreloadPenIcon,
|
||||
} from '../_common/icons.js';
|
||||
import { AIProvider } from '../provider.js';
|
||||
import { AIProvider } from '../provider/ai-provider.js';
|
||||
import completeWritingWithAI from './templates/completeWritingWithAI.zip';
|
||||
import freelyCommunicateWithAI from './templates/freelyCommunicateWithAI.zip';
|
||||
import readAforeign from './templates/readAforeign.zip';
|
||||
@@ -9,10 +9,10 @@ import { flip, offset } from '@floating-ui/dom';
|
||||
import { css, html, LitElement } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
|
||||
import { AIProvider } from '../../provider';
|
||||
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
||||
import { extractSelectedContent } from '../../utils/extract';
|
||||
import type { AffineAIPanelWidgetConfig } from '../../widgets/ai-panel/type';
|
||||
import { AIProvider } from '../provider';
|
||||
import { getAIPanelWidget } from '../utils/ai-widgets';
|
||||
import { extractSelectedContent } from '../utils/extract';
|
||||
import type { AffineAIPanelWidgetConfig } from '../widgets/ai-panel/type';
|
||||
import type { AIItemGroupConfig } from './ai-item/types';
|
||||
|
||||
export class AskAIToolbarButton extends WithDisposable(LitElement) {
|
||||
@@ -12,8 +12,8 @@ import { property } from 'lit/decorators.js';
|
||||
import { classMap } from 'lit/directives/class-map.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
|
||||
import { insertBelow } from '../../utils/editor-actions';
|
||||
import type { ChatAction } from '../chat-actions-handle';
|
||||
import type { ChatAction } from '../_common/chat-actions-handle';
|
||||
import { insertBelow } from '../utils/editor-actions';
|
||||
|
||||
export class ChatActionList extends LitElement {
|
||||
static override styles = css`
|
||||
@@ -15,8 +15,8 @@ import { css, html, LitElement, nothing, type PropertyValues } from 'lit';
|
||||
import { property, query, state } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
|
||||
import { type ChatAction } from '../../_common/chat-actions-handle';
|
||||
import { copyText } from '../../utils/editor-actions';
|
||||
import type { ChatAction } from '../_common/chat-actions-handle';
|
||||
import { copyText } from '../utils/editor-actions';
|
||||
|
||||
noop(Tooltip);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
BlockStdScope,
|
||||
BlockViewIdentifier,
|
||||
type EditorHost,
|
||||
ShadowlessElement,
|
||||
} from '@blocksuite/affine/block-std';
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
InlineDeltaToMarkdownAdapterExtensions,
|
||||
ListBlockComponent,
|
||||
MarkdownInlineToDeltaAdapterExtensions,
|
||||
PageEditorBlockSpecs,
|
||||
ParagraphBlockComponent,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
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 { classMap } from 'lit/directives/class-map.js';
|
||||
import { keyed } from 'lit/directives/keyed.js';
|
||||
import { literal } from 'lit/static-html.js';
|
||||
|
||||
import { markDownToDoc } from '../../utils';
|
||||
import type {
|
||||
AffineAIPanelState,
|
||||
AffineAIPanelWidgetConfig,
|
||||
} from '../../ai/widgets/ai-panel/type';
|
||||
import { CustomPageEditorBlockSpecs } from '../utils/custom-specs';
|
||||
import { markDownToDoc } from '../utils/markdown-utils';
|
||||
} from '../widgets/ai-panel/type';
|
||||
|
||||
const textBlockStyles = css`
|
||||
${ParagraphBlockComponent.styles}
|
||||
@@ -90,6 +92,18 @@ export type TextRendererOptions = {
|
||||
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?
|
||||
export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
static override styles = css`
|
||||
@@ -1,68 +1,69 @@
|
||||
import { AIChatBlockComponent } from '../blocks/ai-chat-block/ai-chat-block';
|
||||
import { EdgelessAIChatBlockComponent } from '../blocks/ai-chat-block/ai-chat-edgeless-block';
|
||||
import { AIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-block';
|
||||
import { EdgelessAIChatBlockComponent } from './blocks/ai-chat-block/ai-chat-edgeless-block';
|
||||
import {
|
||||
AIChatMessage,
|
||||
AIChatMessages,
|
||||
} from '../blocks/ai-chat-block/components/ai-chat-messages';
|
||||
} from './blocks/ai-chat-block/components/ai-chat-messages';
|
||||
import {
|
||||
ChatImage,
|
||||
ChatImages,
|
||||
} from '../blocks/ai-chat-block/components/chat-images';
|
||||
import { ImagePlaceholder } from '../blocks/ai-chat-block/components/image-placeholder';
|
||||
import { UserInfo } from '../blocks/ai-chat-block/components/user-info';
|
||||
import { TextRenderer } from './_common/components/text-renderer';
|
||||
import { effects as componentAiItemEffects } from './ai/_common/components/ai-item';
|
||||
import { AskAIButton } from './ai/_common/components/ask-ai-button';
|
||||
import { AskAIIcon } from './ai/_common/components/ask-ai-icon';
|
||||
import { AskAIPanel } from './ai/_common/components/ask-ai-panel';
|
||||
import { AskAIToolbarButton } from './ai/_common/components/ask-ai-toolbar';
|
||||
import { ChatActionList } from './ai/_common/components/chat-action-list';
|
||||
import { ChatCopyMore } from './ai/_common/components/copy-more';
|
||||
import { ImagePreviewGrid } from './ai/_common/components/image-preview-grid';
|
||||
import { ChatPanel } from './ai/chat-panel';
|
||||
import { ActionWrapper } from './ai/chat-panel/actions/action-wrapper';
|
||||
import { ChatText } from './ai/chat-panel/actions/chat-text';
|
||||
import { ActionImage } from './ai/chat-panel/actions/image';
|
||||
import { ActionImageToText } from './ai/chat-panel/actions/image-to-text';
|
||||
import { ActionMakeReal } from './ai/chat-panel/actions/make-real';
|
||||
import { ActionMindmap } from './ai/chat-panel/actions/mindmap';
|
||||
import { ActionSlides } from './ai/chat-panel/actions/slides';
|
||||
import { ActionText } from './ai/chat-panel/actions/text';
|
||||
import { AILoading } from './ai/chat-panel/ai-loading';
|
||||
import { ChatPanelChips } from './ai/chat-panel/chat-panel-chips';
|
||||
import { ChatPanelInput } from './ai/chat-panel/chat-panel-input';
|
||||
import { ChatPanelMessages } from './ai/chat-panel/chat-panel-messages';
|
||||
import { ChatPanelAddPopover } from './ai/chat-panel/components/add-popover';
|
||||
import { ChatPanelChip } from './ai/chat-panel/components/chip';
|
||||
import { ChatPanelDocChip } from './ai/chat-panel/components/doc-chip';
|
||||
import { ChatPanelFileChip } from './ai/chat-panel/components/file-chip';
|
||||
import { AIErrorWrapper } from './ai/messages/error';
|
||||
import { AISlidesRenderer } from './ai/messages/slides-renderer';
|
||||
import { AIAnswerWrapper } from './ai/messages/wrapper';
|
||||
import { registerMiniMindmapBlocks } from './ai/mini-mindmap';
|
||||
import { ChatBlockInput } from './ai/peek-view/chat-block-input';
|
||||
import { AIChatBlockPeekView } from './ai/peek-view/chat-block-peek-view';
|
||||
import { DateTime } from './ai/peek-view/date-time';
|
||||
} from './blocks/ai-chat-block/components/chat-images';
|
||||
import { ImagePlaceholder } from './blocks/ai-chat-block/components/image-placeholder';
|
||||
import { UserInfo } from './blocks/ai-chat-block/components/user-info';
|
||||
import { ChatPanel } from './chat-panel';
|
||||
import { ActionWrapper } from './chat-panel/actions/action-wrapper';
|
||||
import { ChatText } from './chat-panel/actions/chat-text';
|
||||
import { ActionImage } from './chat-panel/actions/image';
|
||||
import { ActionImageToText } from './chat-panel/actions/image-to-text';
|
||||
import { ActionMakeReal } from './chat-panel/actions/make-real';
|
||||
import { ActionMindmap } from './chat-panel/actions/mindmap';
|
||||
import { ActionSlides } from './chat-panel/actions/slides';
|
||||
import { ActionText } from './chat-panel/actions/text';
|
||||
import { AILoading } from './chat-panel/ai-loading';
|
||||
import { ChatPanelChips } from './chat-panel/chat-panel-chips';
|
||||
import { ChatPanelInput } from './chat-panel/chat-panel-input';
|
||||
import { ChatPanelMessages } from './chat-panel/chat-panel-messages';
|
||||
import { ChatPanelAddPopover } from './chat-panel/components/add-popover';
|
||||
import { ChatPanelChip } from './chat-panel/components/chip';
|
||||
import { ChatPanelDocChip } from './chat-panel/components/doc-chip';
|
||||
import { ChatPanelFileChip } from './chat-panel/components/file-chip';
|
||||
import { effects as componentAiItemEffects } from './components/ai-item';
|
||||
import { AskAIButton } from './components/ask-ai-button';
|
||||
import { AskAIIcon } from './components/ask-ai-icon';
|
||||
import { AskAIPanel } from './components/ask-ai-panel';
|
||||
import { AskAIToolbarButton } from './components/ask-ai-toolbar';
|
||||
import { ChatActionList } from './components/chat-action-list';
|
||||
import { ChatCopyMore } from './components/copy-more';
|
||||
import { ImagePreviewGrid } from './components/image-preview-grid';
|
||||
import { TextRenderer } from './components/text-renderer';
|
||||
import { AIErrorWrapper } from './messages/error';
|
||||
import { AISlidesRenderer } from './messages/slides-renderer';
|
||||
import { AIAnswerWrapper } from './messages/wrapper';
|
||||
import { registerMiniMindmapBlocks } from './mini-mindmap';
|
||||
import { ChatBlockInput } from './peek-view/chat-block-input';
|
||||
import { AIChatBlockPeekView } from './peek-view/chat-block-peek-view';
|
||||
import { DateTime } from './peek-view/date-time';
|
||||
import {
|
||||
AFFINE_AI_PANEL_WIDGET,
|
||||
AffineAIPanelWidget,
|
||||
} from './ai/widgets/ai-panel/ai-panel';
|
||||
} from './widgets/ai-panel/ai-panel';
|
||||
import {
|
||||
AIPanelAnswer,
|
||||
AIPanelDivider,
|
||||
AIPanelError,
|
||||
AIPanelGenerating,
|
||||
AIPanelInput,
|
||||
} from './ai/widgets/ai-panel/components';
|
||||
import { AIFinishTip } from './ai/widgets/ai-panel/components/finish-tip';
|
||||
import { GeneratingPlaceholder } from './ai/widgets/ai-panel/components/generating-placeholder';
|
||||
} from './widgets/ai-panel/components';
|
||||
import { AIFinishTip } from './widgets/ai-panel/components/finish-tip';
|
||||
import { GeneratingPlaceholder } from './widgets/ai-panel/components/generating-placeholder';
|
||||
import {
|
||||
AFFINE_EDGELESS_COPILOT_WIDGET,
|
||||
EdgelessCopilotWidget,
|
||||
} from './ai/widgets/edgeless-copilot';
|
||||
import { EdgelessCopilotPanel } from './ai/widgets/edgeless-copilot-panel';
|
||||
import { EdgelessCopilotToolbarEntry } from './ai/widgets/edgeless-copilot-panel/toolbar-entry';
|
||||
export function registerBlocksuitePresetsCustomComponents() {
|
||||
} from './widgets/edgeless-copilot';
|
||||
import { EdgelessCopilotPanel } from './widgets/edgeless-copilot-panel';
|
||||
import { EdgelessCopilotToolbarEntry } from './widgets/edgeless-copilot-panel/toolbar-entry';
|
||||
|
||||
export function registerAIEffects() {
|
||||
registerMiniMindmapBlocks();
|
||||
componentAiItemEffects();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../_common/components/ask-ai-button';
|
||||
import '../../components/ask-ai-button';
|
||||
|
||||
import type { AffineCodeToolbarWidget } from '@blocksuite/affine/blocks';
|
||||
import { html } from 'lit';
|
||||
@@ -11,8 +11,8 @@ const buttonOptions: AskAIButtonOptions = {
|
||||
|
||||
import { BlockSelection } from '@blocksuite/affine/block-std';
|
||||
|
||||
import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button';
|
||||
import { buildAICodeItemGroups } from '../../_common/config';
|
||||
import type { AskAIButtonOptions } from '../../components/ask-ai-button';
|
||||
|
||||
export function setupCodeToolbarAIEntry(codeToolbar: AffineCodeToolbarWidget) {
|
||||
codeToolbar.addPrimaryItems([
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
TextElementModel,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
|
||||
import type { AIItemGroupConfig } from '../../_common/components/ai-item/types';
|
||||
import {
|
||||
AIExpandMindMapIcon,
|
||||
AIImageIcon,
|
||||
@@ -44,6 +43,7 @@ import {
|
||||
textTones,
|
||||
translateLangs,
|
||||
} from '../../actions/types';
|
||||
import type { AIItemGroupConfig } from '../../components/ai-item/types';
|
||||
import { AIProvider } from '../../provider';
|
||||
import { getAIPanelWidget } from '../../utils/ai-widgets';
|
||||
import { mindMapToMarkdown } from '../../utils/edgeless';
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
import { noop } from '@blocksuite/affine/global/utils';
|
||||
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 { getAIPanelWidget } from '../../utils/ai-widgets';
|
||||
import { getEdgelessCopilotWidget } from '../../utils/edgeless';
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../_common/components/ask-ai-button';
|
||||
import '../../components/ask-ai-button';
|
||||
|
||||
import {
|
||||
type AffineFormatBarWidget,
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../_common/components/ask-ai-button';
|
||||
import '../../components/ask-ai-button';
|
||||
|
||||
import {
|
||||
type AffineImageToolbarWidget,
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { html } from 'lit';
|
||||
|
||||
import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button';
|
||||
import { buildAIImageItemGroups } from '../../_common/config';
|
||||
import type { AskAIButtonOptions } from '../../components/ask-ai-button';
|
||||
|
||||
const AIImageItemGroups = buildAIImageItemGroups();
|
||||
const buttonOptions: AskAIButtonOptions = {
|
||||
@@ -11,9 +11,9 @@ import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import { MoreHorizontalIcon } from '@blocksuite/icons/lit';
|
||||
import { html } from 'lit';
|
||||
|
||||
import type { AIItemConfig } from '../../_common/components/ai-item/types';
|
||||
import { pageAIGroups } from '../../_common/config';
|
||||
import { handleInlineAskAIAction } from '../../actions/doc-handler';
|
||||
import type { AIItemConfig } from '../../components/ai-item/types';
|
||||
import { AIProvider } from '../../provider';
|
||||
import {
|
||||
AFFINE_AI_PANEL_WIDGET,
|
||||
@@ -7,12 +7,12 @@ import { baseTheme } from '@toeverything/theme';
|
||||
import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
|
||||
import { ErrorTipIcon } from '../_common/icons';
|
||||
import {
|
||||
type AIError,
|
||||
PaymentRequiredError,
|
||||
UnauthorizedError,
|
||||
} from '../_common/components/ai-item/types';
|
||||
import { ErrorTipIcon } from '../_common/icons';
|
||||
} from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
|
||||
export class AIErrorWrapper extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
@@ -6,14 +6,14 @@ import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query, state } from 'lit/decorators.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 type { ChatMessage } from '../blocks';
|
||||
import type { AINetworkSearchConfig } from '../chat-panel/chat-config';
|
||||
import {
|
||||
PROMPT_NAME_AFFINE_AI,
|
||||
PROMPT_NAME_NETWORK_SEARCH,
|
||||
} from '../chat-panel/const';
|
||||
import type { AIError } from '../components/ai-item/types';
|
||||
import { AIProvider } from '../provider';
|
||||
import { reportResponse } from '../utils/action-reporter';
|
||||
import { readBlobAsURL } from '../utils/image';
|
||||
@@ -14,20 +14,20 @@ import { property, query, state } from 'lit/decorators.js';
|
||||
import { classMap } from 'lit/directives/class-map.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 {
|
||||
ChatBlockPeekViewActions,
|
||||
constructUserInfoWithMessages,
|
||||
queryHistoryMessages,
|
||||
} from '../_common/chat-actions-handle';
|
||||
import type { AIError } from '../_common/components/ai-item/types';
|
||||
import { SmallHintIcon } from '../_common/icons';
|
||||
import {
|
||||
type AIChatBlockModel,
|
||||
type ChatMessage,
|
||||
ChatMessagesSchema,
|
||||
} from '../blocks';
|
||||
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 { AIProvider } from '../provider';
|
||||
import { PeekViewStyles } from './styles';
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ChatMessage } from '../../../blocks';
|
||||
import type { AIError } from '../_common/components/ai-item/types';
|
||||
import type { ChatMessage } from '../blocks';
|
||||
import type { AIError } from '../components/ai-item/types';
|
||||
|
||||
export type ChatStatus =
|
||||
| 'success'
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
type AIChatBlockModel,
|
||||
CHAT_BLOCK_HEIGHT,
|
||||
CHAT_BLOCK_WIDTH,
|
||||
} from '../../../blocks';
|
||||
} from '../blocks';
|
||||
|
||||
/**
|
||||
* Calculates the bounding box for a child block
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user