fix(core): add mobile edit button (#7996)
This commit is contained in:
@@ -1099,7 +1099,7 @@ export const PagePropertiesTable = ({ docId }: { docId: string }) => {
|
|||||||
// if the given page is not in the current workspace, then we don't render anything
|
// if the given page is not in the current workspace, then we don't render anything
|
||||||
// eg. when it is in history modal
|
// eg. when it is in history modal
|
||||||
|
|
||||||
if (!manager.page || manager.readonly) {
|
if (!manager.page) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ export const BlocksuiteDocEditor = forwardRef<
|
|||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
) : null}
|
) : null}
|
||||||
{!page.readonly && settings.displayBiDirectionalLink ? (
|
{!shared && settings.displayBiDirectionalLink ? (
|
||||||
<BiDirectionalLinkPanel />
|
<BiDirectionalLinkPanel />
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { useEnableCloud } from '@affine/core/hooks/affine/use-enable-cloud';
|
|||||||
import { useExportPage } from '@affine/core/hooks/affine/use-export-page';
|
import { useExportPage } from '@affine/core/hooks/affine/use-export-page';
|
||||||
import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper';
|
import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper';
|
||||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||||
|
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||||
import { track } from '@affine/core/mixpanel';
|
import { track } from '@affine/core/mixpanel';
|
||||||
import { EditorService } from '@affine/core/modules/editor';
|
import { EditorService } from '@affine/core/modules/editor';
|
||||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||||
@@ -35,6 +36,7 @@ import {
|
|||||||
InformationIcon,
|
InformationIcon,
|
||||||
OpenInNewIcon,
|
OpenInNewIcon,
|
||||||
PageIcon,
|
PageIcon,
|
||||||
|
SaveIcon,
|
||||||
ShareIcon,
|
ShareIcon,
|
||||||
SplitViewIcon,
|
SplitViewIcon,
|
||||||
TocIcon,
|
TocIcon,
|
||||||
@@ -83,6 +85,9 @@ export const PageHeaderMenuButton = ({
|
|||||||
const { importFile } = usePageHelper(docCollection);
|
const { importFile } = usePageHelper(docCollection);
|
||||||
const { setTrashModal } = useTrashModalHelper(docCollection);
|
const { setTrashModal } = useTrashModalHelper(docCollection);
|
||||||
|
|
||||||
|
const [isEditing, setEditing] = useState(!page.readonly);
|
||||||
|
const { setDocReadonly } = useDocMetaHelper(docCollection);
|
||||||
|
|
||||||
const view = useService(ViewService).view;
|
const view = useService(ViewService).view;
|
||||||
|
|
||||||
const openSidePanel = useCallback(
|
const openSidePanel = useCallback(
|
||||||
@@ -196,6 +201,21 @@ export const PageHeaderMenuButton = ({
|
|||||||
toggleFavorite();
|
toggleFavorite();
|
||||||
}, [toggleFavorite]);
|
}, [toggleFavorite]);
|
||||||
|
|
||||||
|
const handleToggleEdit = useCallback(() => {
|
||||||
|
setDocReadonly(page.id, !page.readonly);
|
||||||
|
setEditing(!isEditing);
|
||||||
|
}, [isEditing, page.id, page.readonly, setDocReadonly]);
|
||||||
|
|
||||||
|
const isMobile = environment.isBrowser && environment.isMobile;
|
||||||
|
const mobileEditMenuItem = (
|
||||||
|
<MenuItem
|
||||||
|
prefixIcon={isEditing ? <SaveIcon /> : <EditIcon />}
|
||||||
|
onSelect={handleToggleEdit}
|
||||||
|
>
|
||||||
|
{t[isEditing ? 'Save' : 'Edit']()}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
|
||||||
const showResponsiveMenu = hideShare;
|
const showResponsiveMenu = hideShare;
|
||||||
const ResponsiveMenuItems = (
|
const ResponsiveMenuItems = (
|
||||||
<>
|
<>
|
||||||
@@ -235,6 +255,7 @@ export const PageHeaderMenuButton = ({
|
|||||||
const EditMenu = (
|
const EditMenu = (
|
||||||
<>
|
<>
|
||||||
{showResponsiveMenu ? ResponsiveMenuItems : null}
|
{showResponsiveMenu ? ResponsiveMenuItems : null}
|
||||||
|
{isMobile && mobileEditMenuItem}
|
||||||
{!isJournal && (
|
{!isJournal && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
prefixIcon={<EditIcon />}
|
prefixIcon={<EditIcon />}
|
||||||
|
|||||||
Reference in New Issue
Block a user