mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 14:08:55 +08:00
Merge branch 'develop' into feat/quick-search
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
"@toeverything/pathfinder-logger": "workspace:@pathfinder/logger@*",
|
"@toeverything/pathfinder-logger": "workspace:@pathfinder/logger@*",
|
||||||
"cmdk": "^0.1.20",
|
"cmdk": "^0.1.20",
|
||||||
"css-spring": "^4.1.0",
|
"css-spring": "^4.1.0",
|
||||||
|
"dayjs": "^1.11.7",
|
||||||
"lit": "^2.3.1",
|
"lit": "^2.3.1",
|
||||||
"next": "13.0.1",
|
"next": "13.0.1",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
|
|||||||
@@ -75,16 +75,18 @@ const toolbarList2 = [
|
|||||||
const UndoRedo = () => {
|
const UndoRedo = () => {
|
||||||
const [canUndo, setCanUndo] = useState(false);
|
const [canUndo, setCanUndo] = useState(false);
|
||||||
const [canRedo, setCanRedo] = useState(false);
|
const [canRedo, setCanRedo] = useState(false);
|
||||||
const { editor } = useEditor();
|
const { currentPage } = useEditor();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editor) return;
|
if (!currentPage) return;
|
||||||
const { space } = editor;
|
|
||||||
|
|
||||||
space.signals.historyUpdated.on(() => {
|
currentPage.signals.historyUpdated.on(() => {
|
||||||
setCanUndo(space.canUndo);
|
setCanUndo(currentPage.canUndo);
|
||||||
setCanRedo(space.canRedo);
|
setCanRedo(currentPage.canRedo);
|
||||||
});
|
});
|
||||||
}, [editor]);
|
return () => {
|
||||||
|
currentPage.signals.historyUpdated.dispose();
|
||||||
|
};
|
||||||
|
}, [currentPage]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledToolbarWrapper>
|
<StyledToolbarWrapper>
|
||||||
@@ -92,7 +94,7 @@ const UndoRedo = () => {
|
|||||||
<StyledToolbarItem
|
<StyledToolbarItem
|
||||||
disable={!canUndo}
|
disable={!canUndo}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
editor?.space?.undo();
|
currentPage?.undo();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<UndoIcon />
|
<UndoIcon />
|
||||||
@@ -102,7 +104,7 @@ const UndoRedo = () => {
|
|||||||
<StyledToolbarItem
|
<StyledToolbarItem
|
||||||
disable={!canRedo}
|
disable={!canRedo}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
editor?.space?.redo();
|
currentPage?.redo();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RedoIcon />
|
<RedoIcon />
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './header';
|
export * from './header';
|
||||||
export * from './page-header';
|
export * from './page-header';
|
||||||
|
export { StyledTitle as HeaderWrapper } from './styles';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
|
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
|
||||||
import { StyledButtonWrapper, StyledTitle } from './styles';
|
import { StyledButtonWrapper, StyledTitle } from './styles';
|
||||||
import { Button } from '@/ui/button';
|
import { Button } from '@/ui/button';
|
||||||
import { Wrapper } from '@/ui/layout';
|
import { Wrapper, Content } from '@/ui/layout';
|
||||||
import { Loading } from '@/components/loading';
|
import { Loading } from '@/components/loading';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
type ImportModalProps = {
|
type ImportModalProps = {
|
||||||
@@ -9,21 +9,19 @@ type ImportModalProps = {
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
};
|
};
|
||||||
export const ImportModal = ({ open, onClose }: ImportModalProps) => {
|
export const ImportModal = ({ open, onClose }: ImportModalProps) => {
|
||||||
const [status, setStatus] = useState<'unImported' | 'importing'>(
|
const [status, setStatus] = useState<'unImported' | 'importing'>('importing');
|
||||||
'unImported'
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === 'importing') {
|
if (status === 'importing') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setStatus('unImported');
|
setStatus('unImported');
|
||||||
}, 3000);
|
}, 1500);
|
||||||
}
|
}
|
||||||
}, [status]);
|
}, [status]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose}>
|
<Modal open={open} onClose={onClose}>
|
||||||
<ModalWrapper width={460} height={240}>
|
<ModalWrapper width={460} minHeight={240}>
|
||||||
<ModalCloseButton onClick={onClose} />
|
<ModalCloseButton onClick={onClose} />
|
||||||
<StyledTitle>Import</StyledTitle>
|
<StyledTitle>Import</StyledTitle>
|
||||||
|
|
||||||
@@ -47,8 +45,16 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{status === 'importing' && (
|
{status === 'importing' && (
|
||||||
<Wrapper justifyContent="center" style={{ marginTop: 22 }}>
|
<Wrapper
|
||||||
|
wrap={true}
|
||||||
|
justifyContent="center"
|
||||||
|
style={{ marginTop: 22, paddingBottom: '32px' }}
|
||||||
|
>
|
||||||
<Loading size={25}></Loading>
|
<Loading size={25}></Loading>
|
||||||
|
<Content align="center" weight="500">
|
||||||
|
OOOOPS! Sorry forgot to remind you that we are working on the
|
||||||
|
import function
|
||||||
|
</Content>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
)}
|
)}
|
||||||
</ModalWrapper>
|
</ModalWrapper>
|
||||||
|
|||||||
@@ -23,8 +23,3 @@ export const StyledButtonWrapper = styled.div(() => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const StyledLoadingWrapper = styled.div(() => {
|
|
||||||
return {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { PageMeta } from '@/providers/editor-provider';
|
||||||
|
import { TableCell } from '@/ui/table';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
dayjs.extend(localizedFormat);
|
||||||
|
|
||||||
|
export const DateCell = ({
|
||||||
|
pageMeta,
|
||||||
|
dateKey,
|
||||||
|
}: {
|
||||||
|
pageMeta: PageMeta;
|
||||||
|
dateKey: keyof PageMeta;
|
||||||
|
}) => {
|
||||||
|
// dayjs().format('L LT');
|
||||||
|
return (
|
||||||
|
<TableCell ellipsis={true}>
|
||||||
|
{dayjs(pageMeta[dateKey] as string).format('YYYY-MM-DD HH:MM')}
|
||||||
|
</TableCell>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DateCell;
|
||||||
@@ -12,6 +12,7 @@ import { OperationCell, TrashOperationCell } from './operation-cell';
|
|||||||
import Empty from './empty';
|
import Empty from './empty';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import DateCell from '@/components/page-list/date-cell';
|
||||||
const FavoriteTag = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
const FavoriteTag = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||||
const { toggleFavoritePage } = useEditor();
|
const { toggleFavoritePage } = useEditor();
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ export const PageList = ({
|
|||||||
if (pageList.length === 0) {
|
if (pageList.length === 0) {
|
||||||
return <Empty />;
|
return <Empty />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledTableContainer>
|
<StyledTableContainer>
|
||||||
<Table>
|
<Table>
|
||||||
@@ -48,7 +50,7 @@ export const PageList = ({
|
|||||||
<TableCell proportion={0.5}>Documents</TableCell>
|
<TableCell proportion={0.5}>Documents</TableCell>
|
||||||
<TableCell proportion={0.2}>Created</TableCell>
|
<TableCell proportion={0.2}>Created</TableCell>
|
||||||
<TableCell proportion={0.2}>
|
<TableCell proportion={0.2}>
|
||||||
{isTrash ? 'Uploaded' : 'Moved to Trash'}
|
{isTrash ? 'Moved to Trash' : 'Uploaded'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell proportion={0.1}></TableCell>
|
<TableCell proportion={0.1}></TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -69,9 +71,12 @@ export const PageList = ({
|
|||||||
{showFavoriteTag && <FavoriteTag pageMeta={pageMeta} />}
|
{showFavoriteTag && <FavoriteTag pageMeta={pageMeta} />}
|
||||||
</StyledTitleWrapper>
|
</StyledTitleWrapper>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell ellipsis={true}>{pageMeta.createDate}</TableCell>
|
<DateCell pageMeta={pageMeta} dateKey="createDate" />
|
||||||
<TableCell ellipsis={true}>{pageMeta.createDate}</TableCell>
|
<DateCell
|
||||||
<TableCell>
|
pageMeta={pageMeta}
|
||||||
|
dateKey={isTrash ? 'trashDate' : 'createDate'}
|
||||||
|
/>
|
||||||
|
<TableCell style={{ padding: 0 }}>
|
||||||
{isTrash ? (
|
{isTrash ? (
|
||||||
<TrashOperationCell pageMeta={pageMeta} />
|
<TrashOperationCell pageMeta={pageMeta} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -3,7 +3,15 @@ import { useConfirm } from '@/providers/confirm-provider';
|
|||||||
import { Menu, MenuItem } from '@/ui/menu';
|
import { Menu, MenuItem } from '@/ui/menu';
|
||||||
import { Wrapper } from '@/ui/layout';
|
import { Wrapper } from '@/ui/layout';
|
||||||
import { IconButton } from '@/ui/button';
|
import { IconButton } from '@/ui/button';
|
||||||
import { MoreVerticalIcon, RestoreIcon, DeleteIcon } from '@blocksuite/icons';
|
import {
|
||||||
|
MoreVerticalIcon,
|
||||||
|
RestoreIcon,
|
||||||
|
DeleteIcon,
|
||||||
|
FavouritesIcon,
|
||||||
|
FavouritedIcon,
|
||||||
|
OpenInNewIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from '@blocksuite/icons';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||||
@@ -17,6 +25,7 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
toggleFavoritePage(id);
|
toggleFavoritePage(id);
|
||||||
}}
|
}}
|
||||||
|
icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />}
|
||||||
>
|
>
|
||||||
{favorite ? 'Remove' : 'Add'} to favourites
|
{favorite ? 'Remove' : 'Add'} to favourites
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
@@ -24,6 +33,7 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPage(id);
|
openPage(id);
|
||||||
}}
|
}}
|
||||||
|
icon={<OpenInNewIcon />}
|
||||||
>
|
>
|
||||||
Open in new tab
|
Open in new tab
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
@@ -39,6 +49,7 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
|||||||
confirm && toggleDeletePage(id);
|
confirm && toggleDeletePage(id);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
icon={<TrashIcon />}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Command, useCommandState } from 'cmdk';
|
import { Command, useCommandState } from 'cmdk';
|
||||||
|
|
||||||
const NoResult = (props: { query: string }) => {
|
const NoResult = () => {
|
||||||
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
|
||||||
const search = useCommandState(state => state.search);
|
const search = useCommandState(state => state.search);
|
||||||
|
// eslint-disable-next-line react/no-unescaped-entities
|
||||||
return <Command.Empty>No results found for "{search}".</Command.Empty>;
|
return <Command.Empty>No results found for "{search}".</Command.Empty>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ const isMac = () => {
|
|||||||
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const { triggerQuickSearchModal } = useModal();
|
const { triggerQuickSearchModal } = useModal();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const down = (e: KeyboardEvent) => {
|
const down = (e: KeyboardEvent) => {
|
||||||
if (e.key === 'k' && e.metaKey) {
|
if (e.key === 'k' && e.metaKey) {
|
||||||
@@ -38,7 +37,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
};
|
};
|
||||||
document.addEventListener('keydown', down);
|
document.addEventListener('keydown', down);
|
||||||
return () => document.removeEventListener('keydown', down);
|
return () => document.removeEventListener('keydown', down);
|
||||||
}, [open]);
|
}, [open, triggerQuickSearchModal]);
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose} wrapperPosition={['top', 'center']}>
|
<Modal open={open} onClose={onClose} wrapperPosition={['top', 'center']}>
|
||||||
<ModalWrapper
|
<ModalWrapper
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import {
|
import {
|
||||||
StyledArrowButton,
|
StyledArrowButton,
|
||||||
|
StyledLink,
|
||||||
StyledListItem,
|
StyledListItem,
|
||||||
StyledNewPageButton,
|
StyledNewPageButton,
|
||||||
StyledSliderBar,
|
StyledSliderBar,
|
||||||
@@ -9,7 +10,15 @@ import {
|
|||||||
} from './style';
|
} from './style';
|
||||||
import { Arrow } from './icons';
|
import { Arrow } from './icons';
|
||||||
import Collapse from '@mui/material/Collapse';
|
import Collapse from '@mui/material/Collapse';
|
||||||
import { ArrowDownIcon } from '@blocksuite/icons';
|
import {
|
||||||
|
ArrowDownIcon,
|
||||||
|
SearchIcon,
|
||||||
|
AllPagesIcon,
|
||||||
|
FavouritesIcon,
|
||||||
|
ImportIcon,
|
||||||
|
TrashIcon,
|
||||||
|
AddIcon,
|
||||||
|
} from '@blocksuite/icons';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useEditor } from '@/providers/editor-provider';
|
import { useEditor } from '@/providers/editor-provider';
|
||||||
import { useModal } from '@/providers/global-modal-provider';
|
import { useModal } from '@/providers/global-modal-provider';
|
||||||
@@ -20,7 +29,7 @@ const FavoriteList = ({ showList }: { showList: boolean }) => {
|
|||||||
const { pageList, openPage } = useEditor();
|
const { pageList, openPage } = useEditor();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const favoriteList = pageList.filter(p => p.favorite);
|
const favoriteList = pageList.filter(p => p.favorite && !p.trash);
|
||||||
return (
|
return (
|
||||||
<Collapse in={showList}>
|
<Collapse in={showList}>
|
||||||
{favoriteList.map((pageMeta, index) => {
|
{favoriteList.map((pageMeta, index) => {
|
||||||
@@ -61,20 +70,18 @@ export const WorkSpaceSliderBar = () => {
|
|||||||
triggerQuickSearchModal();
|
triggerQuickSearchModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Quick search
|
<SearchIcon /> Quick search
|
||||||
</StyledListItem>
|
</StyledListItem>
|
||||||
<Link href={{ pathname: '/page-list/all' }}>
|
<Link href={{ pathname: '/page-list/all' }}>
|
||||||
<StyledListItem active={router.pathname === '/page-list/all'}>
|
<StyledListItem active={router.pathname === '/page-list/all'}>
|
||||||
All pages
|
<AllPagesIcon /> All pages
|
||||||
</StyledListItem>
|
</StyledListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<StyledListItem active={router.pathname === '/page-list/favorite'}>
|
<StyledListItem active={router.pathname === '/page-list/favorite'}>
|
||||||
<Link
|
<StyledLink href={{ pathname: '/page-list/favorite' }}>
|
||||||
href={{ pathname: '/page-list/favorite' }}
|
<FavouritesIcon />
|
||||||
style={{ flexGrow: 1, textAlign: 'left', color: 'inherit' }}
|
|
||||||
>
|
|
||||||
Favourites
|
Favourites
|
||||||
</Link>
|
</StyledLink>
|
||||||
<IconButton
|
<IconButton
|
||||||
hoverBackground="#E0E6FF"
|
hoverBackground="#E0E6FF"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -95,12 +102,12 @@ export const WorkSpaceSliderBar = () => {
|
|||||||
triggerImportModal();
|
triggerImportModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Import
|
<ImportIcon /> Import
|
||||||
</StyledListItem>
|
</StyledListItem>
|
||||||
|
|
||||||
<Link href={{ pathname: '/page-list/trash' }}>
|
<Link href={{ pathname: '/page-list/trash' }}>
|
||||||
<StyledListItem active={router.pathname === '/page-list/trash'}>
|
<StyledListItem active={router.pathname === '/page-list/trash'}>
|
||||||
Trash
|
<TrashIcon /> Trash
|
||||||
</StyledListItem>
|
</StyledListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<StyledNewPageButton
|
<StyledNewPageButton
|
||||||
@@ -110,7 +117,7 @@ export const WorkSpaceSliderBar = () => {
|
|||||||
pageMeta && openPage(pageMeta.id);
|
pageMeta && openPage(pageMeta.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
New Page
|
<AddIcon /> New Page
|
||||||
</StyledNewPageButton>
|
</StyledNewPageButton>
|
||||||
</StyledSliderBar>
|
</StyledSliderBar>
|
||||||
<StyledArrowButton
|
<StyledArrowButton
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { displayFlex, styled, textEllipsis } from '@/styles';
|
import { displayFlex, styled, textEllipsis } from '@/styles';
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
export const StyledSliderBar = styled.div<{ show: boolean }>(
|
export const StyledSliderBar = styled.div<{ show: boolean }>(
|
||||||
({ theme, show }) => {
|
({ theme, show }) => {
|
||||||
@@ -54,6 +55,10 @@ export const StyledListItem = styled.button<{ active?: boolean }>(
|
|||||||
paddingLeft: '12px',
|
paddingLeft: '12px',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
...displayFlex('flex-start', 'center'),
|
...displayFlex('flex-start', 'center'),
|
||||||
|
'>svg': {
|
||||||
|
fontSize: '20px',
|
||||||
|
marginRight: '12px',
|
||||||
|
},
|
||||||
':hover': {
|
':hover': {
|
||||||
color: theme.colors.primaryColor,
|
color: theme.colors.primaryColor,
|
||||||
backgroundColor: theme.colors.hoverBackground,
|
backgroundColor: theme.colors.hoverBackground,
|
||||||
@@ -62,6 +67,21 @@ export const StyledListItem = styled.button<{ active?: boolean }>(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const StyledLink = styled(Link)(({ theme }) => {
|
||||||
|
return {
|
||||||
|
flexGrow: 1,
|
||||||
|
textAlign: 'left',
|
||||||
|
color: 'inherit',
|
||||||
|
...displayFlex('flex-start', 'center'),
|
||||||
|
':visited': {
|
||||||
|
color: 'inherit',
|
||||||
|
},
|
||||||
|
'>svg': {
|
||||||
|
fontSize: '20px',
|
||||||
|
marginRight: '12px',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
export const StyledNewPageButton = styled(StyledListItem)(({ theme }) => {
|
export const StyledNewPageButton = styled(StyledListItem)(({ theme }) => {
|
||||||
return {
|
return {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
import { Header } from '@/components/header';
|
import { Header } from '@/components/header';
|
||||||
import { useEditor } from '@/providers/editor-provider';
|
import { useEditor } from '@/providers/editor-provider';
|
||||||
import { PageList } from '@/components/page-list';
|
import { PageList } from '@/components/page-list';
|
||||||
|
import { StyledWrapper } from '@/pages/page-list/styles';
|
||||||
|
import { AllPagesIcon } from '@blocksuite/icons';
|
||||||
|
|
||||||
export const All = () => {
|
export const All = () => {
|
||||||
const { pageList: allPageList } = useEditor();
|
const { pageList: allPageList } = useEditor();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header>
|
||||||
|
<StyledWrapper>
|
||||||
|
<AllPagesIcon />
|
||||||
|
All Pages
|
||||||
|
</StyledWrapper>
|
||||||
|
</Header>
|
||||||
<PageList
|
<PageList
|
||||||
pageList={allPageList.filter(p => !p.trash)}
|
pageList={allPageList.filter(p => !p.trash)}
|
||||||
showFavoriteTag={true}
|
showFavoriteTag={true}
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
import { Header } from '@/components/header';
|
import { Header } from '@/components/header';
|
||||||
import { useEditor } from '@/providers/editor-provider';
|
import { useEditor } from '@/providers/editor-provider';
|
||||||
import { PageList } from '@/components/page-list';
|
import { PageList } from '@/components/page-list';
|
||||||
|
import { StyledWrapper } from '@/pages/page-list/styles';
|
||||||
|
import { FavouritesIcon } from '@blocksuite/icons';
|
||||||
|
|
||||||
export const Favorite = () => {
|
export const Favorite = () => {
|
||||||
const { pageList: allPageList } = useEditor();
|
const { pageList: allPageList } = useEditor();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header>
|
||||||
|
<StyledWrapper>
|
||||||
|
<FavouritesIcon />
|
||||||
|
Favorites
|
||||||
|
</StyledWrapper>
|
||||||
|
</Header>
|
||||||
<PageList pageList={allPageList.filter(p => p.favorite && !p.trash)} />
|
<PageList pageList={allPageList.filter(p => p.favorite && !p.trash)} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { HeaderWrapper } from '@/components/header';
|
||||||
|
import { styled } from '@/styles';
|
||||||
|
|
||||||
|
export const StyledWrapper = styled(HeaderWrapper)(({ theme }) => {
|
||||||
|
return {
|
||||||
|
fontSize: theme.font.sm,
|
||||||
|
color: theme.colors.textColor,
|
||||||
|
'>svg': {
|
||||||
|
fontSize: '20px',
|
||||||
|
marginRight: '12px',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
import { Header } from '@/components/header';
|
import { Header } from '@/components/header';
|
||||||
import { useEditor } from '@/providers/editor-provider';
|
import { useEditor } from '@/providers/editor-provider';
|
||||||
import { PageList } from '@/components/page-list';
|
import { PageList } from '@/components/page-list';
|
||||||
|
import { StyledWrapper } from './styles';
|
||||||
|
import { TrashIcon } from '@blocksuite/icons';
|
||||||
export const Trash = () => {
|
export const Trash = () => {
|
||||||
const { pageList: allPageList } = useEditor();
|
const { pageList: allPageList } = useEditor();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header>
|
||||||
|
<StyledWrapper>
|
||||||
|
<TrashIcon />
|
||||||
|
Trash
|
||||||
|
</StyledWrapper>
|
||||||
|
</Header>
|
||||||
<PageList pageList={allPageList.filter(p => p.trash)} isTrash={true} />
|
<PageList pageList={allPageList.filter(p => p.trash)} isTrash={true} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ export type EditorHandlers = {
|
|||||||
query?: { [key: string]: string }
|
query?: { [key: string]: string }
|
||||||
) => Promise<boolean>;
|
) => Promise<boolean>;
|
||||||
getPageMeta: (pageId: string) => PageMeta | void;
|
getPageMeta: (pageId: string) => PageMeta | void;
|
||||||
deletePage: (pageId: string) => void;
|
|
||||||
recyclePage: (pageId: string) => void;
|
|
||||||
toggleDeletePage: (pageId: string) => void;
|
toggleDeletePage: (pageId: string) => void;
|
||||||
favoritePage: (pageId: string) => void;
|
favoritePage: (pageId: string) => void;
|
||||||
unFavoritePage: (pageId: string) => void;
|
unFavoritePage: (pageId: string) => void;
|
||||||
|
|||||||
@@ -26,15 +26,10 @@ export const useEditorHandler = (workspace?: Workspace): EditorHandlers => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deletePage: pageId => {
|
|
||||||
workspace!.setPageMeta(pageId, { trash: true });
|
|
||||||
},
|
|
||||||
recyclePage: pageId => {
|
|
||||||
workspace!.setPageMeta(pageId, { trash: false });
|
|
||||||
},
|
|
||||||
toggleDeletePage: pageId => {
|
toggleDeletePage: pageId => {
|
||||||
const pageMeta = workspace!.meta.pageMetas.find(p => p.id === pageId);
|
const pageMeta = workspace!.meta.pageMetas.find(p => p.id === pageId);
|
||||||
if (pageMeta) {
|
if (pageMeta) {
|
||||||
|
workspace!.meta.setPage(pageId, { trashDate: new Date().getTime() });
|
||||||
workspace!.setPageMeta(pageId, { trash: !pageMeta.trash });
|
workspace!.setPageMeta(pageId, { trash: !pageMeta.trash });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import { styled, textEllipsis } from '@/styles';
|
|||||||
export type ContentProps = {
|
export type ContentProps = {
|
||||||
width?: CSSProperties['width'];
|
width?: CSSProperties['width'];
|
||||||
maxWidth?: CSSProperties['maxWidth'];
|
maxWidth?: CSSProperties['maxWidth'];
|
||||||
|
align?: CSSProperties['textAlign'];
|
||||||
color?: CSSProperties['color'];
|
color?: CSSProperties['color'];
|
||||||
fontSize?: CSSProperties['fontSize'];
|
fontSize?: CSSProperties['fontSize'];
|
||||||
fontWeight?: CSSProperties['fontWeight'];
|
weight?: CSSProperties['fontWeight'];
|
||||||
lineHeight?: CSSProperties['lineHeight'];
|
lineHeight?: CSSProperties['lineHeight'];
|
||||||
ellipsis?: boolean;
|
ellipsis?: boolean;
|
||||||
lineNum?: number;
|
lineNum?: number;
|
||||||
@@ -19,20 +20,22 @@ export const Content = styled.div<ContentProps>(
|
|||||||
theme,
|
theme,
|
||||||
color,
|
color,
|
||||||
fontSize,
|
fontSize,
|
||||||
fontWeight,
|
weight,
|
||||||
lineHeight,
|
lineHeight,
|
||||||
ellipsis,
|
ellipsis,
|
||||||
lineNum,
|
lineNum,
|
||||||
width,
|
width,
|
||||||
maxWidth,
|
maxWidth,
|
||||||
|
align,
|
||||||
}) => {
|
}) => {
|
||||||
return {
|
return {
|
||||||
width,
|
width,
|
||||||
maxWidth,
|
maxWidth,
|
||||||
|
textAlign: align,
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
color: color ?? theme.colors.textColor,
|
color: color ?? theme.colors.textColor,
|
||||||
fontSize: fontSize ?? theme.font.base,
|
fontSize: fontSize ?? theme.font.base,
|
||||||
fontWeight: fontWeight ?? 400,
|
fontWeight: weight ?? 400,
|
||||||
lineHeight: lineHeight ?? 1.5,
|
lineHeight: lineHeight ?? 1.5,
|
||||||
...(ellipsis ? textEllipsis(lineNum) : {}),
|
...(ellipsis ? textEllipsis(lineNum) : {}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ export type WrapperProps = {
|
|||||||
flexDirection?: CSSProperties['flexDirection'];
|
flexDirection?: CSSProperties['flexDirection'];
|
||||||
justifyContent?: CSSProperties['justifyContent'];
|
justifyContent?: CSSProperties['justifyContent'];
|
||||||
alignItems?: CSSProperties['alignItems'];
|
alignItems?: CSSProperties['alignItems'];
|
||||||
flexWrap?: CSSProperties['flexWrap'];
|
wrap?: boolean;
|
||||||
flexShrink?: CSSProperties['flexShrink'];
|
flexShrink?: CSSProperties['flexShrink'];
|
||||||
flexGrow?: CSSProperties['flexGrow'];
|
flexGrow?: CSSProperties['flexGrow'];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sometimes we just want to wrap a component with a div to set flex or other styles, but we don't want to create a new component for it.
|
// Sometimes we just want to wrap a component with a div to set flex or other styles, but we don't want to create a new component for it.
|
||||||
export const Wrapper = styled('button', {
|
export const Wrapper = styled('div', {
|
||||||
shouldForwardProp: prop => {
|
shouldForwardProp: prop => {
|
||||||
return ![
|
return ![
|
||||||
'display',
|
'display',
|
||||||
'justifyContent',
|
'justifyContent',
|
||||||
'alignItems',
|
'alignItems',
|
||||||
'flexWrap',
|
'wrap',
|
||||||
'flexDirection',
|
'flexDirection',
|
||||||
'flexShrink',
|
'flexShrink',
|
||||||
'flexGrow',
|
'flexGrow',
|
||||||
@@ -29,7 +29,7 @@ export const Wrapper = styled('button', {
|
|||||||
display = 'flex',
|
display = 'flex',
|
||||||
justifyContent = 'flex-start',
|
justifyContent = 'flex-start',
|
||||||
alignItems = 'center',
|
alignItems = 'center',
|
||||||
flexWrap = 'nowrap',
|
wrap = false,
|
||||||
flexDirection = 'row',
|
flexDirection = 'row',
|
||||||
flexShrink = '0',
|
flexShrink = '0',
|
||||||
flexGrow = '0',
|
flexGrow = '0',
|
||||||
@@ -38,7 +38,7 @@ export const Wrapper = styled('button', {
|
|||||||
display,
|
display,
|
||||||
justifyContent,
|
justifyContent,
|
||||||
alignItems,
|
alignItems,
|
||||||
flexWrap,
|
flexWrap: wrap ? 'wrap' : 'nowrap',
|
||||||
flexDirection,
|
flexDirection,
|
||||||
flexShrink,
|
flexShrink,
|
||||||
flexGrow,
|
flexGrow,
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import { styled } from '@/styles';
|
|||||||
export const ModalWrapper = styled.div<{
|
export const ModalWrapper = styled.div<{
|
||||||
width?: CSSProperties['width'];
|
width?: CSSProperties['width'];
|
||||||
height?: CSSProperties['height'];
|
height?: CSSProperties['height'];
|
||||||
}>(({ theme, width, height }) => {
|
minHeight?: CSSProperties['minHeight'];
|
||||||
|
}>(({ theme, width, height, minHeight }) => {
|
||||||
return {
|
return {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
minHeight,
|
||||||
backgroundColor: theme.colors.popoverBackground,
|
backgroundColor: theme.colors.popoverBackground,
|
||||||
borderRadius: '12px',
|
borderRadius: '12px',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
|
|||||||
Generated
+8
-2
@@ -41,6 +41,7 @@ importers:
|
|||||||
'@types/react-dom': 18.0.6
|
'@types/react-dom': 18.0.6
|
||||||
cmdk: ^0.1.20
|
cmdk: ^0.1.20
|
||||||
css-spring: ^4.1.0
|
css-spring: ^4.1.0
|
||||||
|
dayjs: ^1.11.7
|
||||||
eslint: 8.22.0
|
eslint: 8.22.0
|
||||||
eslint-config-next: 12.3.1
|
eslint-config-next: 12.3.1
|
||||||
eslint-config-prettier: ^8.5.0
|
eslint-config-prettier: ^8.5.0
|
||||||
@@ -70,6 +71,7 @@ importers:
|
|||||||
'@toeverything/pathfinder-logger': link:../logger
|
'@toeverything/pathfinder-logger': link:../logger
|
||||||
cmdk: 0.1.20_7ey2zzynotv32rpkwno45fsx4e
|
cmdk: 0.1.20_7ey2zzynotv32rpkwno45fsx4e
|
||||||
css-spring: 4.1.0
|
css-spring: 4.1.0
|
||||||
|
dayjs: 1.11.7
|
||||||
lit: 2.4.0
|
lit: 2.4.0
|
||||||
next: 13.0.1_biqbaboplfbrettd7655fr4n2y
|
next: 13.0.1_biqbaboplfbrettd7655fr4n2y
|
||||||
prettier: 2.7.1
|
prettier: 2.7.1
|
||||||
@@ -1579,6 +1581,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}
|
resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/dayjs/1.11.7:
|
||||||
|
resolution: {integrity: sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/debug/2.6.9:
|
/debug/2.6.9:
|
||||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -1877,7 +1883,7 @@ packages:
|
|||||||
eslint-import-resolver-webpack:
|
eslint-import-resolver-webpack:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/parser': 5.38.0_eslint@8.22.0
|
'@typescript-eslint/parser': 5.38.0_76twfck5d7crjqrmw4yltga7zm
|
||||||
debug: 3.2.7
|
debug: 3.2.7
|
||||||
eslint: 8.22.0
|
eslint: 8.22.0
|
||||||
eslint-import-resolver-node: 0.3.6
|
eslint-import-resolver-node: 0.3.6
|
||||||
@@ -1896,7 +1902,7 @@ packages:
|
|||||||
'@typescript-eslint/parser':
|
'@typescript-eslint/parser':
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/parser': 5.38.0_eslint@8.22.0
|
'@typescript-eslint/parser': 5.38.0_76twfck5d7crjqrmw4yltga7zm
|
||||||
array-includes: 3.1.5
|
array-includes: 3.1.5
|
||||||
array.prototype.flat: 1.3.0
|
array.prototype.flat: 1.3.0
|
||||||
debug: 2.6.9
|
debug: 2.6.9
|
||||||
|
|||||||
Reference in New Issue
Block a user