diff --git a/packages/client/package.json b/packages/client/package.json index 7d00bb8f..4d25991c 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -13,6 +13,9 @@ "@douyinfe/semi-ui": "^2.3.1", "@excalidraw/excalidraw": "^0.12.0", "@hocuspocus/provider": "^1.0.0-alpha.29", + "@react-pdf-viewer/core": "3.7.0", + "@react-pdf-viewer/default-layout": "3.7.0", + "@react-pdf-viewer/locales": "^1.0.0", "@think/config": "workspace:^1.0.0", "@think/constants": "workspace:^1.0.0", "@think/domains": "workspace:^1.0.0", @@ -69,6 +72,7 @@ "katex": "^0.15.2", "kity": "^2.0.4", "lib0": "^0.2.47", + "lodash.pick": "^4.4.0", "lowlight": "^2.5.0", "markdown-it": "^12.3.2", "markdown-it-anchor": "^8.4.1", @@ -78,6 +82,7 @@ "markdown-it-sup": "^1.0.0", "next": "12.1.0", "next-pwa": "^5.5.2", + "pdfjs-dist": "2.15.349", "prosemirror-codemark": "^0.3.6", "prosemirror-commands": "^1.3.0", "prosemirror-markdown": "^1.7.0", @@ -93,7 +98,6 @@ "react-full-screen": "^1.1.1", "react-helmet": "^6.1.0", "react-lazy-load-image-component": "^1.5.4", - "react-pdf": "^5.7.2", "react-query": "^3.39.0", "react-split-pane": "^0.1.92", "react-visibility-sensor": "^5.1.1", diff --git a/packages/client/src/components/organization/setting/base/index.tsx b/packages/client/src/components/organization/setting/base/index.tsx index d4b1915b..6e39487b 100644 --- a/packages/client/src/components/organization/setting/base/index.tsx +++ b/packages/client/src/components/organization/setting/base/index.tsx @@ -1,13 +1,11 @@ -import { Avatar, Button, Form, Toast, Typography } from '@douyinfe/semi-ui'; +import { Avatar, Button, Form, Toast } from '@douyinfe/semi-ui'; import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; import { ORGANIZATION_LOGOS } from '@think/constants'; import { IOrganization } from '@think/domains'; import { DataRender } from 'components/data-render'; import { ImageUploader } from 'components/image-uploader'; -import { useCreateOrganization, useOrganizationDetail } from 'data/organization'; +import { useOrganizationDetail } from 'data/organization'; import { useToggle } from 'hooks/use-toggle'; -import { SingleColumnLayout } from 'layouts/single-column'; -import Router from 'next/router'; import { useCallback, useEffect, useRef, useState } from 'react'; import styles from './index.module.scss'; diff --git a/packages/client/src/components/wiki/setting/base/index.tsx b/packages/client/src/components/wiki/setting/base/index.tsx index 3adf4e67..11cbc7c3 100644 --- a/packages/client/src/components/wiki/setting/base/index.tsx +++ b/packages/client/src/components/wiki/setting/base/index.tsx @@ -3,7 +3,8 @@ import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; import { WIKI_AVATARS } from '@think/constants'; import type { IWiki } from '@think/domains'; import { ImageUploader } from 'components/image-uploader'; -import { useEffect, useRef, useState } from 'react'; +import { pick } from 'helpers/pick'; +import { useCallback, useEffect, useRef, useState } from 'react'; import styles from './index.module.scss'; @@ -22,32 +23,36 @@ interface IProps { update: (arg: IUpdateWIKI) => Promise; } +const getFormValueFromWiki = (wiki) => { + return pick(wiki, ['name', 'description', 'avatar']); +}; + export const Base: React.FC = ({ wiki, update }) => { const $form = useRef(); const [currentCover, setCurrentCover] = useState(''); - const onSubmit = () => { + const onSubmit = useCallback(() => { $form.current.validate().then((values) => { update(values).then(() => { Toast.success('操作成功'); }); }); - }; + }, [update]); - const setCover = (url) => { + const setCover = useCallback((url) => { $form.current.setValue('avatar', url); setCurrentCover(url); - }; + }, []); useEffect(() => { if (!wiki) return; - $form.current.setValues(wiki); + $form.current.setValues(getFormValueFromWiki(wiki)); setCurrentCover(wiki.avatar); }, [wiki]); return (
($form.current = formApi)} onSubmit={onSubmit} diff --git a/packages/client/src/helpers/pick.ts b/packages/client/src/helpers/pick.ts new file mode 100644 index 00000000..ad49c161 --- /dev/null +++ b/packages/client/src/helpers/pick.ts @@ -0,0 +1,3 @@ +import pick from 'lodash.pick'; + +export { pick }; diff --git a/packages/client/src/pages/_app.tsx b/packages/client/src/pages/_app.tsx index a25b73bf..7b6ecd79 100644 --- a/packages/client/src/pages/_app.tsx +++ b/packages/client/src/pages/_app.tsx @@ -2,7 +2,10 @@ import 'tiptap/fix-match-nodes'; import 'viewerjs/dist/viewer.css'; import 'styles/globals.scss'; import 'tiptap/core/styles/index.scss'; +import '@react-pdf-viewer/core/lib/styles/index.css'; +import '@react-pdf-viewer/default-layout/lib/styles/index.css'; +import { Worker } from '@react-pdf-viewer/core'; import { isMobile } from 'helpers/env'; import { DocumentVersionControl } from 'hooks/use-document-version'; import { IsOnMobile } from 'hooks/use-on-mobile'; @@ -84,17 +87,19 @@ class MyApp extends App<{ isMobile: boolean }> { ))} - - - - - - - - - - - + + + + + + + + + + + + + ); } diff --git a/packages/client/src/tiptap/core/extensions/status.ts b/packages/client/src/tiptap/core/extensions/status.ts index df043664..2edca440 100644 --- a/packages/client/src/tiptap/core/extensions/status.ts +++ b/packages/client/src/tiptap/core/extensions/status.ts @@ -47,7 +47,7 @@ export const Status = Node.create({ parseHTML: getDatasetAttribute('borderColor'), }, text: { - default: '请设置状态内容', + default: '', parseHTML: getDatasetAttribute('text'), }, }; diff --git a/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx b/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx index d8ac58a4..62459b19 100644 --- a/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx +++ b/packages/client/src/tiptap/core/menus/excalidraw/bubble.tsx @@ -52,7 +52,7 @@ export const ExcalidrawBubbleMenu = ({ editor }) => { diff --git a/packages/client/src/tiptap/core/menus/insert/index.tsx b/packages/client/src/tiptap/core/menus/insert/index.tsx index 1de8fd72..c86fa585 100644 --- a/packages/client/src/tiptap/core/menus/insert/index.tsx +++ b/packages/client/src/tiptap/core/menus/insert/index.tsx @@ -17,7 +17,10 @@ export const Insert: React.FC<{ editor: Editor }> = ({ editor }) => { const [visible, toggleVisible] = useToggle(false); const renderedCommands = useMemo( - () => (recentUsed.length ? [{ title: '最近使用' }, ...recentUsed, ...COMMANDS] : COMMANDS), + () => + (recentUsed.length ? [{ title: '最近使用' }, ...recentUsed, ...COMMANDS] : COMMANDS).filter((command) => { + return command.label === '表格' || command.label === '布局' ? 'custom' in command : true; + }), [recentUsed] ); diff --git a/packages/client/src/tiptap/core/menus/redo/index.tsx b/packages/client/src/tiptap/core/menus/redo/index.tsx index f69f432a..35d73ff1 100644 --- a/packages/client/src/tiptap/core/menus/redo/index.tsx +++ b/packages/client/src/tiptap/core/menus/redo/index.tsx @@ -8,7 +8,7 @@ export const Redo: React.FC<{ editor: Editor }> = ({ editor }) => { const redo = useCallback(() => editor.chain().focus().redo().run(), [editor]); return ( - +