mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
chore: remove useEditor
This commit is contained in:
@@ -6,18 +6,19 @@ import {
|
||||
StyledTitleWrapper,
|
||||
} from './styles';
|
||||
import { Content } from '@/ui/layout';
|
||||
import { useEditor } from '@/providers/editor-provider';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
import EditorModeSwitch from '@/components/editor-mode-switch';
|
||||
import QuickSearchButton from './quick-search-button';
|
||||
import Header from './header';
|
||||
import usePropsUpdated from '@/hooks/use-props-updated';
|
||||
import useCurrentPageMeta from '@/hooks/use-current-page-meta';
|
||||
|
||||
export const EditorHeader = () => {
|
||||
const [title, setTitle] = useState('');
|
||||
const [isHover, setIsHover] = useState(false);
|
||||
const { getPageMeta, currentPage, editor } = useAppState();
|
||||
|
||||
const { onPropsUpdated } = useEditor();
|
||||
const { editor } = useAppState();
|
||||
const pageMeta = useCurrentPageMeta();
|
||||
const onPropsUpdated = usePropsUpdated();
|
||||
|
||||
useEffect(() => {
|
||||
onPropsUpdated(editor => {
|
||||
@@ -32,8 +33,6 @@ export const EditorHeader = () => {
|
||||
}, 300);
|
||||
}, [editor]);
|
||||
|
||||
const pageMeta = currentPage?.pageId ? getPageMeta(currentPage.pageId) : null;
|
||||
|
||||
return (
|
||||
<Header>
|
||||
{title && (
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
FavouritedIcon,
|
||||
TrashIcon,
|
||||
} from '@blocksuite/icons';
|
||||
import { useEditor } from '@/providers/editor-provider';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
import ThemeModeSwitch from '@/components/theme-mode-switch';
|
||||
import { IconButton, Button } from '@/ui/button';
|
||||
@@ -31,18 +30,16 @@ import { toast } from '@/components/toast';
|
||||
import useCurrentPageMeta from '@/hooks/use-current-page-meta';
|
||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||
const PopoverContent = () => {
|
||||
const { getPageMeta, editor, currentPage } = useAppState();
|
||||
const { editor } = useAppState();
|
||||
const { toggleFavoritePage, toggleDeletePage } = usePageHelper();
|
||||
const { mode, setMode } = useEditor();
|
||||
const { changePageMode } = usePageHelper();
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const { id, favorite, title } = (currentPage?.id
|
||||
? getPageMeta(currentPage.id)
|
||||
: null) ?? {
|
||||
id: '',
|
||||
favorite: false,
|
||||
title: '',
|
||||
};
|
||||
const {
|
||||
mode = 'page',
|
||||
id = '',
|
||||
favorite = false,
|
||||
title = '',
|
||||
} = useCurrentPageMeta() || {};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -58,7 +55,7 @@ const PopoverContent = () => {
|
||||
<MenuItem
|
||||
icon={mode === 'page' ? <EdgelessIcon /> : <PaperIcon />}
|
||||
onClick={() => {
|
||||
setMode(mode === 'page' ? 'edgeless' : 'page');
|
||||
changePageMode(id);
|
||||
}}
|
||||
>
|
||||
Convert to {mode === 'page' ? 'Edgeless' : 'Page'}
|
||||
@@ -128,11 +125,12 @@ const BrowserWarning = ({
|
||||
};
|
||||
|
||||
const HeaderRight = () => {
|
||||
const { pageList, permanentlyDeletePage } = useEditor();
|
||||
const { currentWorkspaceId, toggleDeletePage } = useAppState();
|
||||
const { permanentlyDeletePage } = usePageHelper();
|
||||
const { currentWorkspaceId } = useAppState();
|
||||
const { toggleDeletePage } = usePageHelper();
|
||||
const { confirm } = useConfirm();
|
||||
const router = useRouter();
|
||||
const currentPageMeta = pageList.find(p => p.id === router.query.pageId);
|
||||
const currentPageMeta = useCurrentPageMeta();
|
||||
const isTrash = !!currentPageMeta?.trash;
|
||||
|
||||
if (isTrash) {
|
||||
@@ -188,8 +186,6 @@ const HeaderRight = () => {
|
||||
|
||||
export const Header = ({ children }: PropsWithChildren<{}>) => {
|
||||
const [showWarning, setShowWarning] = useState(shouldShowWarning());
|
||||
const currentPageMeta = useCurrentPageMeta();
|
||||
console.log('currentPageMeta', currentPageMeta);
|
||||
return (
|
||||
<StyledHeaderContainer hasWarning={showWarning}>
|
||||
<BrowserWarning
|
||||
|
||||
Reference in New Issue
Block a user