fix(core): title could not be changed when creating a new doc (#8203)

Before change, the title could not be modified from outside the editor without refreshing:

https://github.com/user-attachments/assets/536acba1-4e31-418a-bc1a-8578e3128bba

after:

https://github.com/user-attachments/assets/30a4b270-b8b1-4787-acef-0ab2a72a8f74
This commit is contained in:
JimmFly
2024-09-12 07:55:22 +00:00
parent cc5a6e6d40
commit 2cba8a4ccd
27 changed files with 138 additions and 145 deletions
@@ -7,6 +7,7 @@ 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';
@@ -14,6 +15,7 @@ import { WorkbenchService } from '@affine/core/modules/workbench';
import { useI18n } from '@affine/i18n';
import {
DeleteIcon,
DuplicateIcon,
InformationIcon,
LinkedPageIcon,
OpenInNewIcon,
@@ -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();
@@ -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: (
@@ -230,6 +245,7 @@ export const useExplorerDocNodeOperations = (
enableMultiView,
favorite,
handleAddLinkedPage,
handleDuplicate,
handleMoveToTrash,
handleOpenInNewTab,
handleOpenInSplitView,