Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): selected content should not be activated when executing open in chat (#7302)

fundon8d602d43986b
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.ts
index 2b428b1d2e..c8d671b96e 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.ts
@@ -2,6 +2,7 @@ import type { EditorHost } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/block-std';
import {
type ImageBlockModel,
+ isInsidePageEditor,
type NoteBlockModel,
NoteDisplayMode,
} from '@blocksuite/blocks';
@@ -467,6 +468,18 @@ export class ChatCards extends WithDisposable(LitElement) {
})
);
+ this._disposables.add(
+ AIProvider.slots.requestContinueInChat.on(async ({ host, show }) => {
+ if (show) {
+ if (isInsidePageEditor(host)) {
+ await this._extract();
+ } else {
+ await this._extractOnEdgeless();
+ }
+ }
+ })
+ );
+
this._disposables.add(
AIProvider.slots.toggleChatCards.on(({ visible, ok }) => {
if (visible && ok && this._selectedCardId > 0) {
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts
index 98d57820ae..fb6c350d9b 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts
@@ -212,19 +212,6 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
this._resetItems();
}
});
-
- AIProvider.slots.requestContinueInChat.on(async ({ show }) => {
- if (show) {
- const text = await getSelectedTextContent(this.host, 'plain-text');
- const markdown = await getSelectedTextContent(this.host, 'markdown');
- const images = await getSelectedImagesAsBlobs(this.host);
- this.updateContext({
- quote: text,
- markdown: markdown,
- images: images,
- });
- }
- });
}
updateContext = (context: Partial<ChatContextValue>) => {