mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
feat(mobile): all docs page ui impl (#7976)
This commit is contained in:
@@ -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>('');
|
||||
|
||||
Reference in New Issue
Block a user