Skip to content

Commit

Permalink
fix(core): selected content should not be activated when executing op…
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jun 21, 2024
1 parent cd9205a commit 8d602d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>) => {
Expand Down

0 comments on commit 8d602d4

Please sign in to comment.