From a88dcc09514057a37bc33b50c7f9f83d65841f49 Mon Sep 17 00:00:00 2001 From: yoyoyohamapi <8338436+yoyoyohamapi@users.noreply.github.com> Date: Tue, 3 Jun 2025 06:09:44 +0000 Subject: [PATCH] fix(core): copy & paste ai message failed (#12655) ### TL;DR * fix: ai message copy bug * Select a section of content in the Page * Choose the user's question from the AI chat conversation history and copy it * The copied (pasted) content will be the selected section from the Page * fix: ai message paste bug * Select a section of content in the Page * Choose the user's question from the AI chat conversation history and copy it * Paste it into the AI Input, and the content will be pasted back into the original Page text > CLOSE AF-2683 ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of copy and paste events in chat components to prevent unintended interactions with surrounding elements. - Enhanced test stability by adding error handling during embedding progress checks. --- .../core/src/blocksuite/ai/chat-panel/content/pure-text.ts | 7 ++++++- .../ai/components/ai-chat-input/ai-chat-input.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/content/pure-text.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/content/pure-text.ts index 167f14adf..610c39019 100644 --- a/packages/frontend/core/src/blocksuite/ai/chat-panel/content/pure-text.ts +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/content/pure-text.ts @@ -40,9 +40,14 @@ export class ChatContentPureText extends ShadowlessElement { @property({ attribute: 'data-testid', reflect: true }) accessor testId = 'chat-content-pure-text'; + stopPropagation(event: Event) { + event.stopPropagation(); + } + protected override render() { return this.text.length > 0 - ? html`
${this.text}
` + ? // prettier-ignore + html`
${this.text}
` : nothing; } } diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/ai-chat-input.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/ai-chat-input.ts index af9ca2529..2c5b9acfe 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/ai-chat-input.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/ai-chat-input.ts @@ -492,6 +492,7 @@ export class AIChatInput extends SignalWatcher( }; private readonly _handlePaste = (event: ClipboardEvent) => { + event.stopPropagation(); const items = event.clipboardData?.items; if (!items) return;