mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
feat(core): add onOpenDoc handler for AFFiNE Intelligence page (#13118)
Close [AI-240](https://linear.app/affine-design/issue/AI-240) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enabled opening specific documents directly from the chat toolbar, automatically displaying the document in the workbench and focusing the chat tab in the sidebar. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -17,7 +17,9 @@ import {
|
|||||||
ViewBody,
|
ViewBody,
|
||||||
ViewHeader,
|
ViewHeader,
|
||||||
ViewIcon,
|
ViewIcon,
|
||||||
|
ViewService,
|
||||||
ViewTitle,
|
ViewTitle,
|
||||||
|
WorkbenchService,
|
||||||
} from '@affine/core/modules/workbench';
|
} from '@affine/core/modules/workbench';
|
||||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
@@ -212,6 +214,14 @@ export const Component = () => {
|
|||||||
await togglePin();
|
await togglePin();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tool.onOpenDoc = (docId: string, sessionId: string) => {
|
||||||
|
const { workbench } = framework.get(WorkbenchService);
|
||||||
|
const viewService = framework.get(ViewService);
|
||||||
|
workbench.open(`/${docId}?sessionId=${sessionId}`, { at: 'active' });
|
||||||
|
workbench.openSidebar();
|
||||||
|
viewService.view.activeSidebarTab('chat');
|
||||||
|
};
|
||||||
|
|
||||||
// initial props
|
// initial props
|
||||||
if (!chatTool) {
|
if (!chatTool) {
|
||||||
// mount
|
// mount
|
||||||
@@ -228,6 +238,7 @@ export const Component = () => {
|
|||||||
togglePin,
|
togglePin,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
confirmModal,
|
confirmModal,
|
||||||
|
framework,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onChatContainerRef = useCallback((node: HTMLDivElement) => {
|
const onChatContainerRef = useCallback((node: HTMLDivElement) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user