fix: stackoverflow issue in empty page (#3518)
This commit is contained in:
@@ -12,7 +12,7 @@ import { useBlockSuitePagePreview } from '@toeverything/hooks/use-block-suite-pa
|
|||||||
import { useBlockSuiteWorkspacePage } from '@toeverything/hooks/use-block-suite-workspace-page';
|
import { useBlockSuiteWorkspacePage } from '@toeverything/hooks/use-block-suite-workspace-page';
|
||||||
import { useAtom, useAtomValue } from 'jotai';
|
import { useAtom, useAtomValue } from 'jotai';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { Suspense, useMemo } from 'react';
|
import { Suspense, useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { allPageModeSelectAtom } from '../../../atoms';
|
import { allPageModeSelectAtom } from '../../../atoms';
|
||||||
import { useBlockSuiteMetaHelper } from '../../../hooks/affine/use-block-suite-meta-helper';
|
import { useBlockSuiteMetaHelper } from '../../../hooks/affine/use-block-suite-meta-helper';
|
||||||
@@ -70,16 +70,20 @@ const PagePreview = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PageListEmpty = (props: {
|
const PageListEmpty = (props: {
|
||||||
createPage?: () => void;
|
createPage?: ReturnType<typeof usePageHelper>['createPage'];
|
||||||
listType: BlockSuitePageListProps['listType'];
|
listType: BlockSuitePageListProps['listType'];
|
||||||
}) => {
|
}) => {
|
||||||
const { listType, createPage } = props;
|
const { listType, createPage } = props;
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
|
|
||||||
|
const onCreatePage = useCallback(() => {
|
||||||
|
createPage?.();
|
||||||
|
}, [createPage]);
|
||||||
|
|
||||||
const getEmptyDescription = () => {
|
const getEmptyDescription = () => {
|
||||||
if (listType === 'all') {
|
if (listType === 'all') {
|
||||||
const CreateNewPageButton = () => (
|
const createNewPageButton = (
|
||||||
<button className={emptyDescButton} onClick={createPage}>
|
<button className={emptyDescButton} onClick={onCreatePage}>
|
||||||
New Page
|
New Page
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
@@ -87,7 +91,7 @@ const PageListEmpty = (props: {
|
|||||||
const shortcut = environment.isMacOs ? '⌘ + N' : 'Ctrl + N';
|
const shortcut = environment.isMacOs ? '⌘ + N' : 'Ctrl + N';
|
||||||
return (
|
return (
|
||||||
<Trans i18nKey="emptyAllPagesClient">
|
<Trans i18nKey="emptyAllPagesClient">
|
||||||
Click on the <CreateNewPageButton /> button Or press
|
Click on the {createNewPageButton} button Or press
|
||||||
<kbd className={emptyDescKbd}>{{ shortcut } as any}</kbd> to create
|
<kbd className={emptyDescKbd}>{{ shortcut } as any}</kbd> to create
|
||||||
your first page.
|
your first page.
|
||||||
</Trans>
|
</Trans>
|
||||||
@@ -96,7 +100,7 @@ const PageListEmpty = (props: {
|
|||||||
return (
|
return (
|
||||||
<Trans i18nKey="emptyAllPages">
|
<Trans i18nKey="emptyAllPages">
|
||||||
Click on the
|
Click on the
|
||||||
<CreateNewPageButton />
|
{createNewPageButton}
|
||||||
button to create your first page.
|
button to create your first page.
|
||||||
</Trans>
|
</Trans>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -199,7 +199,7 @@
|
|||||||
"Workspace description": "工作区是为个人和团队进行引用、创建和规划的虚拟空间。",
|
"Workspace description": "工作区是为个人和团队进行引用、创建和规划的虚拟空间。",
|
||||||
"Workspace Settings": "工作区设置",
|
"Workspace Settings": "工作区设置",
|
||||||
"Workspace Name": "工作区名称",
|
"Workspace Name": "工作区名称",
|
||||||
"emptyAllPages": "此工作区为空。创建新页面并开始编辑。",
|
"emptyAllPages": "此工作区为空。<1>$t(New Page)</1>并开始编辑。",
|
||||||
"emptyFavorite": "单击“添加到收藏夹”,页面将显示在此处。",
|
"emptyFavorite": "单击“添加到收藏夹”,页面将显示在此处。",
|
||||||
"emptyTrash": "单击“添加到垃圾箱”,页面将显示在此处。",
|
"emptyTrash": "单击“添加到垃圾箱”,页面将显示在此处。",
|
||||||
"login success": "登录成功",
|
"login success": "登录成功",
|
||||||
|
|||||||
Reference in New Issue
Block a user