mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-23 15:26:04 +03:00
feat(core): close the floating sidebar when creating and opening a doc (#8535)
close AF-1478 https://github.com/user-attachments/assets/5a2a27f3-7df3-4119-9a1a-1372353e4413
This commit is contained in:
parent
bfb8d582ed
commit
2f2e03d3f9
@ -1,4 +1,5 @@
|
||||
import { toast } from '@affine/component';
|
||||
import { AppSidebarService } from '@affine/core/modules/app-sidebar';
|
||||
import { EditorSettingService } from '@affine/core/modules/editor-settting';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import type { DocMode } from '@blocksuite/affine/blocks';
|
||||
@ -7,16 +8,24 @@ import { type DocProps, DocsService, useServices } from '@toeverything/infra';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
export const usePageHelper = (docCollection: DocCollection) => {
|
||||
const { docsService, workbenchService, editorSettingService } = useServices({
|
||||
const {
|
||||
docsService,
|
||||
workbenchService,
|
||||
editorSettingService,
|
||||
appSidebarService,
|
||||
} = useServices({
|
||||
DocsService,
|
||||
WorkbenchService,
|
||||
EditorSettingService,
|
||||
AppSidebarService,
|
||||
});
|
||||
const workbench = workbenchService.workbench;
|
||||
const docRecordList = docsService.list;
|
||||
const appSidebar = appSidebarService.sidebar;
|
||||
|
||||
const createPageAndOpen = useCallback(
|
||||
(mode?: DocMode, open?: boolean | 'new-tab') => {
|
||||
appSidebar.setHovering(false);
|
||||
const docProps: DocProps = {
|
||||
note: editorSettingService.editorSetting.get('affine:note'),
|
||||
};
|
||||
@ -31,7 +40,13 @@ export const usePageHelper = (docCollection: DocCollection) => {
|
||||
});
|
||||
return page;
|
||||
},
|
||||
[docRecordList, docsService, editorSettingService, workbench]
|
||||
[
|
||||
appSidebar,
|
||||
docRecordList,
|
||||
docsService,
|
||||
editorSettingService.editorSetting,
|
||||
workbench,
|
||||
]
|
||||
);
|
||||
|
||||
const createEdgelessAndOpen = useCallback(
|
||||
|
Loading…
Reference in New Issue
Block a user