mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
fix(core): ai chat opening and append card (#7322)
Closes: [BS-642](https://linear.app/affine-design/issue/BS-642/continue-with-ai-:-侧边栏关闭的情况下,先唤起-侧边栏,同时插入选中的内容) https://github.com/toeverything/AFFiNE/assets/27926/3022d808-d560-4bc8-8a04-735b76056121
This commit is contained in:
@@ -4,6 +4,7 @@ export type SidebarTabName = 'outline' | 'frame' | 'chat' | 'journal';
|
||||
|
||||
export interface SidebarTabProps {
|
||||
editor: AffineEditorContainer | null;
|
||||
onLoad: ((component: HTMLElement) => void) | null;
|
||||
}
|
||||
|
||||
export interface SidebarTab {
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { SidebarTab, SidebarTabProps } from '../sidebar-tab';
|
||||
import * as styles from './chat.css';
|
||||
|
||||
// A wrapper for CopilotPanel
|
||||
const EditorChatPanel = ({ editor }: SidebarTabProps) => {
|
||||
const EditorChatPanel = ({ editor, onLoad }: SidebarTabProps) => {
|
||||
const chatPanelRef = useRef<ChatPanel | null>(null);
|
||||
|
||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||
@@ -17,6 +17,16 @@ const EditorChatPanel = ({ editor }: SidebarTabProps) => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (onLoad && chatPanelRef.current) {
|
||||
(chatPanelRef.current as ChatPanel).updateComplete
|
||||
.then(() => {
|
||||
onLoad(chatPanelRef.current as HTMLElement);
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
}, [onLoad]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editor) return;
|
||||
const pageService = editor.host.spec.getService('affine:page');
|
||||
|
||||
Reference in New Issue
Block a user