Skip to content

Commit

Permalink
feat(core): add duplicate operation to doc node
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmFly committed Sep 11, 2024
1 parent ca93526 commit cb0ddf5
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
} from '@affine/component';
import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils';
import { IsFavoriteIcon } from '@affine/core/components/pure/icons';
import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { track } from '@affine/core/mixpanel';
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/properties';
import { WorkbenchService } from '@affine/core/modules/workbench';
import { useI18n } from '@affine/i18n';
import {
DeleteIcon,
DuplicateIcon,
InformationIcon,
LinkedPageIcon,
OpenInNewIcon,
Expand Down Expand Up @@ -69,6 +71,11 @@ export const useExplorerDocNodeOperations = (
}, [docId, compatibleFavoriteItemsAdapter])
);

const { duplicate } = useBlockSuiteMetaHelper();
const handleDuplicate = useCallback(() => {
duplicate(docId, true);
track.$.navigationPanel.docs.createDoc();
}, [docId, duplicate]);
const handleOpenInfoModal = useCallback(() => {
track.$.docInfoPanel.$.open();
options.openInfoModal();
Expand Down Expand Up @@ -173,6 +180,14 @@ export const useExplorerDocNodeOperations = (
</MenuItem>
),
},
{
index: 99,
view: (
<MenuItem prefixIcon={<DuplicateIcon />} onClick={handleDuplicate}>
{t['com.affine.header.option.duplicate']()}
</MenuItem>
),
},
{
index: 99,
view: (
Expand Down Expand Up @@ -230,6 +245,7 @@ export const useExplorerDocNodeOperations = (
enableMultiView,
favorite,
handleAddLinkedPage,
handleDuplicate,
handleMoveToTrash,
handleOpenInNewTab,
handleOpenInSplitView,
Expand Down

0 comments on commit cb0ddf5

Please sign in to comment.