mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
feat(core): add doc info modal (#7409)
close AF-1038 close AF-1039 close AF-1040 close AF-1046 A popup window has been added to facilitate viewing of this doc's info in edgeless mode and other modes. https://github.com/toeverything/AFFiNE/assets/102217452/d7f94cb6-7e32-4ce7-8ff4-8aba1309b331
This commit is contained in:
+24
-3
@@ -1,4 +1,5 @@
|
||||
import { toast } from '@affine/component';
|
||||
import { openInfoModalAtom } from '@affine/core/atoms';
|
||||
import {
|
||||
PreconditionStrategy,
|
||||
registerAffineCommand,
|
||||
@@ -36,6 +37,7 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
const trash = useLiveData(doc.trash$);
|
||||
|
||||
const setPageHistoryModalState = useSetAtom(pageHistoryModalAtom);
|
||||
const setInfoModalState = useSetAtom(openInfoModalAtom);
|
||||
|
||||
const openHistoryModal = useCallback(() => {
|
||||
setPageHistoryModalState(() => ({
|
||||
@@ -44,8 +46,11 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
}));
|
||||
}, [docId, setPageHistoryModalState]);
|
||||
|
||||
const { restoreFromTrash, duplicate } =
|
||||
useBlockSuiteMetaHelper(docCollection);
|
||||
const openInfoModal = useCallback(() => {
|
||||
setInfoModalState(true);
|
||||
}, [setInfoModalState]);
|
||||
|
||||
const { duplicate } = useBlockSuiteMetaHelper(docCollection);
|
||||
const exportHandler = useExportPage(doc.blockSuiteDoc);
|
||||
const { setTrashModal } = useTrashModalHelper(docCollection);
|
||||
const onClickDelete = useCallback(
|
||||
@@ -89,6 +94,22 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
// })
|
||||
// );
|
||||
|
||||
unsubs.push(
|
||||
registerAffineCommand({
|
||||
id: `editor:${mode}-view-info`,
|
||||
preconditionStrategy: () =>
|
||||
PreconditionStrategy.InPaperOrEdgeless &&
|
||||
!trash &&
|
||||
runtimeConfig.enableInfoModal,
|
||||
category: `editor:${mode}`,
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['com.affine.page-properties.page-info.view'](),
|
||||
run() {
|
||||
openInfoModal();
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
unsubs.push(
|
||||
registerAffineCommand({
|
||||
id: `editor:${mode}-${favorite ? 'remove-from' : 'add-to'}-favourites`,
|
||||
@@ -270,7 +291,6 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
mode,
|
||||
onClickDelete,
|
||||
exportHandler,
|
||||
restoreFromTrash,
|
||||
t,
|
||||
trash,
|
||||
isCloudWorkspace,
|
||||
@@ -280,5 +300,6 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
docId,
|
||||
doc,
|
||||
telemetry,
|
||||
openInfoModal,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user