mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
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
|
||||
// eg. when it is in history modal
|
||||
|
||||
if (!manager.page || manager.readonly) {
|
||||
if (!manager.page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ export const BlocksuiteDocEditor = forwardRef<
|
||||
}}
|
||||
></div>
|
||||
) : null}
|
||||
{!page.readonly && settings.displayBiDirectionalLink ? (
|
||||
{!shared && settings.displayBiDirectionalLink ? (
|
||||
<BiDirectionalLinkPanel />
|
||||
) : null}
|
||||
</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 { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper';
|
||||
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 { EditorService } from '@affine/core/modules/editor';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
@@ -35,6 +36,7 @@ import {
|
||||
InformationIcon,
|
||||
OpenInNewIcon,
|
||||
PageIcon,
|
||||
SaveIcon,
|
||||
ShareIcon,
|
||||
SplitViewIcon,
|
||||
TocIcon,
|
||||
@@ -83,6 +85,9 @@ export const PageHeaderMenuButton = ({
|
||||
const { importFile } = usePageHelper(docCollection);
|
||||
const { setTrashModal } = useTrashModalHelper(docCollection);
|
||||
|
||||
const [isEditing, setEditing] = useState(!page.readonly);
|
||||
const { setDocReadonly } = useDocMetaHelper(docCollection);
|
||||
|
||||
const view = useService(ViewService).view;
|
||||
|
||||
const openSidePanel = useCallback(
|
||||
@@ -196,6 +201,21 @@ export const PageHeaderMenuButton = ({
|
||||
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 ResponsiveMenuItems = (
|
||||
<>
|
||||
@@ -235,6 +255,7 @@ export const PageHeaderMenuButton = ({
|
||||
const EditMenu = (
|
||||
<>
|
||||
{showResponsiveMenu ? ResponsiveMenuItems : null}
|
||||
{isMobile && mobileEditMenuItem}
|
||||
{!isJournal && (
|
||||
<MenuItem
|
||||
prefixIcon={<EditIcon />}
|
||||
|
||||
Reference in New Issue
Block a user