feat: add read only mode for page in trash (#3440)

This commit is contained in:
JimmFly
2023-07-28 23:01:10 +08:00
committed by GitHub
parent ed8b2d9927
commit d96263fde9
2 changed files with 11 additions and 3 deletions

View File

@@ -10,7 +10,8 @@ import { useReferenceLinkHelper } from './use-reference-link-helper';
export function useBlockSuiteMetaHelper(
blockSuiteWorkspace: BlockSuiteWorkspace
) {
const { setPageMeta, getPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
const { setPageMeta, getPageMeta, setPageReadonly } =
usePageMetaHelper(blockSuiteWorkspace);
const { addReferenceLink } = useReferenceLinkHelper(blockSuiteWorkspace);
const metas = useBlockSuitePageMeta(blockSuiteWorkspace);
@@ -56,8 +57,9 @@ export function useBlockSuiteMetaHelper(
trashDate: +new Date(),
trashRelate: isRoot ? parentMeta?.id : undefined,
});
setPageReadonly(pageId, true);
},
[getPageMeta, metas, setPageMeta]
[getPageMeta, metas, setPageMeta, setPageReadonly]
);
const restoreFromTrash = useCallback(
@@ -73,11 +75,12 @@ export function useBlockSuiteMetaHelper(
trashDate: undefined,
trashRelate: undefined,
});
setPageReadonly(pageId, false);
subpageIds.forEach(id => {
restoreFromTrash(id);
});
},
[addReferenceLink, getPageMeta, setPageMeta]
[addReferenceLink, getPageMeta, setPageMeta, setPageReadonly]
);
const permanentlyDeletePage = useCallback(