feat(mobile): all docs page ui impl (#7976)

This commit is contained in:
CatsJuice
2024-08-29 06:09:48 +00:00
parent db76780bc9
commit 3ce92f2abc
45 changed files with 1064 additions and 42 deletions
@@ -18,6 +18,31 @@ type GroupOption = {
label: string;
};
export function getGroupOptions(t: ReturnType<typeof useI18n>) {
return [
{
value: 'createDate',
label: t['Created'](),
},
{
value: 'updatedDate',
label: t['Updated'](),
},
{
value: 'tag',
label: t['com.affine.page.display.grouping.group-by-tag'](),
},
{
value: 'favourites',
label: t['com.affine.page.display.grouping.group-by-favourites'](),
},
{
value: 'none',
label: t['com.affine.page.display.grouping.no-grouping'](),
},
] satisfies GroupOption[];
}
export const PageDisplayMenu = () => {
const t = useI18n();
const [workspaceProperties, setProperties] = useAllDocDisplayProperties();
@@ -66,28 +91,7 @@ export const PageDisplayMenu = () => {
}, [handleSetDocDisplayProperties, t]);
const items = useMemo(() => {
const groupOptions: GroupOption[] = [
{
value: 'createDate',
label: t['Created'](),
},
{
value: 'updatedDate',
label: t['Updated'](),
},
{
value: 'tag',
label: t['com.affine.page.display.grouping.group-by-tag'](),
},
{
value: 'favourites',
label: t['com.affine.page.display.grouping.group-by-favourites'](),
},
{
value: 'none',
label: t['com.affine.page.display.grouping.no-grouping'](),
},
];
const groupOptions: GroupOption[] = getGroupOptions(t);
const subItems = groupOptions.map(option => (
<MenuItem
@@ -19,6 +19,10 @@ export const getPagePreviewText = (page: Doc) => {
let count = MAX_SEARCH_BLOCK_COUNT;
while (queue.length && previewLenNeeded > 0 && count-- > 0) {
const block = queue.shift();
// if preview length is enough, skip the rest of the blocks
if (preview.join(' ').trim().length >= MAX_PREVIEW_LENGTH) {
break;
}
if (!block) {
console.error('Unexpected empty block');
break;
@@ -51,7 +55,7 @@ export const getPagePreviewText = (page: Doc) => {
}
}
}
return preview.join(' ').slice(0, MAX_PREVIEW_LENGTH);
return preview.join(' ').trim().slice(0, MAX_PREVIEW_LENGTH);
};
const emptyAtom = atom<string>('');