fix: cannot convert to edgeless mode
This commit is contained in:
@@ -15,8 +15,10 @@ import {
|
|||||||
import { EdgelessIcon, PageIcon } from '@blocksuite/icons';
|
import { EdgelessIcon, PageIcon } from '@blocksuite/icons';
|
||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
import { useTheme } from '@mui/material';
|
import { useTheme } from '@mui/material';
|
||||||
|
import { useAtom } from 'jotai';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import { workspacePreferredModeAtom } from '../../../../atoms';
|
||||||
import { useCurrentPageId } from '../../../../hooks/current/use-current-page-id';
|
import { useCurrentPageId } from '../../../../hooks/current/use-current-page-id';
|
||||||
import { useCurrentWorkspace } from '../../../../hooks/current/use-current-workspace';
|
import { useCurrentWorkspace } from '../../../../hooks/current/use-current-workspace';
|
||||||
import {
|
import {
|
||||||
@@ -37,8 +39,10 @@ export const EditorOptionMenu = () => {
|
|||||||
const pageMeta = usePageMeta(blockSuiteWorkspace).find(
|
const pageMeta = usePageMeta(blockSuiteWorkspace).find(
|
||||||
meta => meta.id === pageId
|
meta => meta.id === pageId
|
||||||
);
|
);
|
||||||
|
const [record, set] = useAtom(workspacePreferredModeAtom);
|
||||||
|
const mode = record[pageId] ?? 'page';
|
||||||
assertExists(pageMeta);
|
assertExists(pageMeta);
|
||||||
const { mode = 'page', favorite, trash } = pageMeta;
|
const { favorite, trash } = pageMeta;
|
||||||
const { setPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
|
const { setPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
@@ -68,9 +72,10 @@ export const EditorOptionMenu = () => {
|
|||||||
iconSize={[20, 20]}
|
iconSize={[20, 20]}
|
||||||
data-testid="editor-option-menu-edgeless"
|
data-testid="editor-option-menu-edgeless"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPageMeta(pageId, {
|
set(record => ({
|
||||||
mode: mode === 'page' ? 'edgeless' : 'page',
|
...record,
|
||||||
});
|
[pageId]: mode === 'page' ? 'edgeless' : 'page',
|
||||||
|
}));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('Convert to ')}
|
{t('Convert to ')}
|
||||||
|
|||||||
Reference in New Issue
Block a user