import React, { PropsWithChildren, useState } from 'react';
import {
StyledHeader,
StyledHeaderRightSide,
StyledHeaderContainer,
StyledBrowserWarning,
StyledCloseButton,
} from './styles';
import {
ExportIcon,
EdgelessIcon,
PaperIcon,
ExportToHtmlIcon,
ExportToMarkdownIcon,
MoreVerticalIcon,
FavouritesIcon,
FavouritedIcon,
TrashIcon,
} from '@blocksuite/icons';
import { useEditor } from '@/providers/editor-provider';
import ThemeModeSwitch from '@/components/theme-mode-switch';
import { IconButton, Button } from '@/ui/button';
import CloseIcon from '@mui/icons-material/Close';
import { getWarningMessage, shouldShowWarning } from './utils';
import { Menu, MenuItem } from '@/ui/menu';
import { useRouter } from 'next/router';
import { useConfirm } from '@/providers/confirm-provider';
import { SyncIcon } from './sync-icon';
import { toast } from '@/components/toast';
const PopoverContent = () => {
const {
editor,
mode,
setMode,
getPageMeta,
page,
toggleFavoritePage,
toggleDeletePage,
} = useEditor();
const { confirm } = useConfirm();
const { id, favorite, title } = getPageMeta(page?.id) ?? {
id: '',
favorite: false,
title: '',
};
return (
<>
: }
onClick={() => {
setMode(mode === 'page' ? 'edgeless' : 'page');
}}
>
Convert to {mode === 'page' ? 'Edgeless' : 'Page'}
>
);
};
const BrowserWarning = ({
show,
onClose,
}: {
show: boolean;
onClose: () => void;
}) => {
return (
{getWarningMessage()}
);
};
const HeaderRight = () => {
const { pageList, toggleDeletePage, permanentlyDeletePage } = useEditor();
const { confirm } = useConfirm();
const router = useRouter();
const currentPageMeta = pageList.find(p => p.id === router.query.pageId);
const isTrash = !!currentPageMeta?.trash;
if (isTrash) {
const { id } = currentPageMeta;
return (
<>
>
);
}
return (
<>
} placement="bottom-end">
>
);
};
export const Header = ({ children }: PropsWithChildren<{}>) => {
const [showWarning, setShowWarning] = useState(shouldShowWarning());
return (
{
setShowWarning(false);
}}
/>
{children}
);
};
export default Header;