From e0c6d23691db967282ba2ac17d9adbdc662a181f Mon Sep 17 00:00:00 2001 From: regischen <58546692+regischen@users.noreply.github.com> Date: Thu, 20 Jun 2024 07:48:10 +0000 Subject: [PATCH] feat: ai onboarding (#7279) --- .../blocksuite/presets/ai/_common/icons.ts | 103 ++++++++++++++++++ .../ai/chat-panel/chat-panel-messages.ts | 47 ++++++++ .../presets/ai/chat-panel/preload-config.ts | 35 ++++++ .../experimental-features/index.tsx | 1 + 4 files changed, 186 insertions(+) create mode 100644 packages/frontend/core/src/blocksuite/presets/ai/chat-panel/preload-config.ts diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.ts index 8acf92d977..9ce9666965 100644 --- a/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.ts +++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.ts @@ -1062,6 +1062,109 @@ export const MoreIcon = html` `; +export const ArticleIcon = html` + + + + + + + + + `; + +export const MindmapIcon = html` + + + + + + + + + `; + +export const PreloadImageIcon = html` + + + + + + + + + `; + +export const PreloadPenIcon = html` + + `; + +export const CommunicateIcon = html` + + + + + + + + + `; + export const CommentIcon = html` + ${repeat( + AIPreloadConfig, + config => config.text, + config => { + return html`
config.handler()} + style=${styleMap({ + display: 'flex', + height: '28px', + gap: '8px', + width: '85%', + alignItems: 'center', + justifyContent: 'start', + })} + > + ${config.icon} +
+ ${config.text} +
+
`; + } + )} + `; + } + protected override render() { const { items } = this.chatContextValue; const { isLoading } = this; @@ -229,6 +275,7 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) { ? 'AFFiNE AI is loading history...' : 'What can I help you with?'} + ${this._renderAIOnboarding()} ${cache( this.showChatCards diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/preload-config.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/preload-config.ts new file mode 100644 index 0000000000..cae6e6b1cd --- /dev/null +++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/preload-config.ts @@ -0,0 +1,35 @@ +import { + ArticleIcon, + CommunicateIcon, + MindmapIcon, + PreloadImageIcon, + PreloadPenIcon, +} from '../_common/icons.js'; + +export const AIPreloadConfig = [ + { + icon: ArticleIcon, + text: 'Read a foreign language article with AI', + handler: () => {}, //waiting for implementation + }, + { + icon: MindmapIcon, + text: 'Tidy a article with AI MindMap Action', + handler: () => {}, + }, + { + icon: PreloadImageIcon, + text: 'Add illustrations to the article', + handler: () => {}, + }, + { + icon: PreloadPenIcon, + text: 'Complete writing with AI', + handler: () => {}, + }, + { + icon: CommunicateIcon, + text: 'Freely communicate with AI', + handler: () => {}, + }, +]; diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/experimental-features/index.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/experimental-features/index.tsx index 0ba7cf638b..361cf1c365 100644 --- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/experimental-features/index.tsx +++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/experimental-features/index.tsx @@ -127,6 +127,7 @@ const blocksuiteFeatureFlags: Partial> = { enable_database_statistics: 'Enable Database Block Statistics', enable_block_query: 'Enable Todo Block Query', enable_edgeless_text: 'Enable New Edgeless Text', + enable_ai_onboarding: 'Enable AI Onboarding', }; const BlocksuiteFeatureFlagSettings = () => {