🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
feat: Import from notion (#10948)
René Wangbda2d76fdffe
diff --git a/src/features/PageExplorer/PageExplorerPlaceholder.tsx b/src/features/PageExplorer/PageExplorerPlaceholder.tsxindex 8b3a83caccf..e983b9aeb9b 100644--- a/src/features/PageExplorer/PageExplorerPlaceholder.tsx+++ b/src/features/PageExplorer/PageExplorerPlaceholder.tsx@@ -1,3 +1,4 @@+import { Notion } from '@lobehub/icons';import { Center, FileTypeIcon, Flexbox, Icon, Text } from '@lobehub/ui';import { Upload } from 'antd';import { createStyles, useTheme } from 'antd-style';@@ -5,11 +6,15 @@ import { ArrowUpIcon, PlusIcon } from 'lucide-react';import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';+import GuideModal from '@/components/GuideModal';+import GuideVideo from '@/components/GuideVideo';import NavHeader from '@/features/NavHeader';+import useNotionImport from '@/features/ResourceManager/components/Header/hooks/useNotionImport';import { useFileStore } from '@/store/file';import { DocumentSourceType } from '@/types/document';const ICON_SIZE = 80;+const NOTION_GUIDE_VIDEO_SRC = 'https://hub-apac-1.lobeobjects.space/assets/notion.mp4';const useStyles = createStyles(({ css, token }) => ({actionTitle: css`@@ -79,14 +84,37 @@ const PageExplorerPlaceholder = memo<PageExplorerPlaceholderProps>(createOptimisticDocument,replaceTempDocumentWithReal,setSelectedPageId,+ refreshFileList,+ fetchDocuments,] = useFileStore((s) => [s.createNewPage,s.createDocument,s.createOptimisticDocument,s.replaceTempDocumentWithReal,s.setSelectedPageId,+ s.refreshFileList,+ s.fetchDocuments,]);+ const notionImport = useNotionImport({+ createDocument,+ currentFolderId: null,+ libraryId: knowledgeBaseId ?? null,+ refreshFileList,+ t,+ });++ // Wrap handleNotionImport to ensure UI updates+ const handleNotionImportWithLocalUpdate = async (+ event: React.ChangeEvent<HTMLInputElement>,+ ) => {+ await notionImport.handleNotionImport(event);+ // Fetch documents to update the UI immediately+ // The hook calls refreshFileList which invalidates SWR cache,+ // but we need to explicitly fetch to update the zustand store+ await fetchDocuments({ pageOnly: true });+ };+const handleCreateDocument = async (content: string, title: string) => {if (!content) {// For empty pages, use createNewPage which handles optimistic updates@@ -210,8 +238,42 @@ const PageExplorerPlaceholder = memo<PageExplorerPlaceholderProps>(/></Flexbox></Upload>++ {/* Import from Notion */}+ <Flexbox+ className={styles.card}+ onClick={notionImport.handleOpenNotionGuide}+ padding={16}+ >+ <span className={styles.actionTitle}>{t('pageEditor.empty.importNotion')}</span>+ <div className={styles.glow} style={{ background: theme.geekblue }} />+ <FileTypeIcon+ className={styles.icon}+ color={theme.geekblue}+ icon={<Notion color={'#fff'} />}+ size={ICON_SIZE}+ type={'file'}+ />+ </Flexbox></Flexbox></Center>+ <GuideModal+ cancelText={t('header.actions.notionGuide.cancel')}+ cover={<GuideVideo height={269} src={NOTION_GUIDE_VIDEO_SRC} width={358} />}+ desc={t('header.actions.notionGuide.desc')}+ okText={t('header.actions.notionGuide.ok')}+ onCancel={notionImport.handleCloseNotionGuide}+ onOk={notionImport.handleStartNotionImport}+ open={notionImport.notionGuideOpen}+ title={t('header.actions.notionGuide.title')}+ />+ <input+ accept=".zip"+ onChange={handleNotionImportWithLocalUpdate}+ ref={notionImport.notionInputRef}+ style={{ display: 'none' }}+ type="file"+ /></>);},diff --git a/src/locales/default/file.ts b/src/locales/default/file.tsindex a7183516802..1b49ded55ce 100644--- a/src/locales/default/file.ts+++ b/src/locales/default/file.ts@@ -75,6 +75,7 @@ export default {"pageEditor.editedBy": "Last edited by {{name}}","pageEditor.editorPlaceholder": "Start writing your page. Press / to open the command menu","pageEditor.empty.createNewDocument": "Create New Page",+ "pageEditor.empty.importNotion": "Import from Notion","pageEditor.empty.title": "Select a page to get started","pageEditor.empty.uploadMarkdown": "Upload Markdown File","pageEditor.linkCopied": "Link copied",