diff --git a/packages/client/src/tiptap/extensions/mention.ts b/packages/client/src/tiptap/extensions/mention.ts index 51b43f5f..660fa80b 100644 --- a/packages/client/src/tiptap/extensions/mention.ts +++ b/packages/client/src/tiptap/extensions/mention.ts @@ -8,7 +8,7 @@ const suggestion = { items: async ({ query }) => { const res = await getUsers(); const data = res.map((item) => item.name); - return data.filter((item) => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5); + return data.filter((item) => item.toLowerCase().startsWith(query.toLowerCase())); }, render: () => { diff --git a/packages/client/src/tiptap/wrappers/mention-list/index.tsx b/packages/client/src/tiptap/wrappers/mention-list/index.tsx index 09e5484e..80edcc5b 100644 --- a/packages/client/src/tiptap/wrappers/mention-list/index.tsx +++ b/packages/client/src/tiptap/wrappers/mention-list/index.tsx @@ -1,11 +1,7 @@ import React, { useState, useEffect, forwardRef, useImperativeHandle, useRef } from 'react'; -import { Modal, Typography } from '@douyinfe/semi-ui'; -import { useRouter } from 'next/router'; import { Editor } from '@tiptap/core'; import cls from 'classnames'; import scrollIntoView from 'scroll-into-view-if-needed'; -import { useUser } from 'data/user'; -import { useCollaborationDocument } from 'data/document'; import styles from './index.module.scss'; interface IProps { @@ -14,64 +10,14 @@ interface IProps { command: any; } -const { Title, Text } = Typography; - export const MentionList: React.FC = forwardRef((props, ref) => { const $container = useRef(); - const router = useRouter(); - const { user: currentUser } = useUser(); - const { users, addUser, updateUser } = useCollaborationDocument(router.query.documentId); const [selectedIndex, setSelectedIndex] = useState(0); const selectItem = (index) => { const userName = props.items[index]; if (!userName) return; props.command({ id: userName }); - - // const currentUserAuth = users.find((user) => { - // return user.user.name === currentUser.name; - // }); - // const isCurrentUserCreateUser = currentUserAuth.auth.createUserId === currentUser.id; - - // const target = users.find((user) => { - // return user.user.name === userName; - // }); - - // if (isCurrentUserCreateUser) { - // if (!target) { - // Modal.confirm({ - // title: 权限操作, - // content: 当前用户尚未加入该文档,是否添加他?, - // onCancel: () => {}, - // onOk: async () => { - // addUser(userName).then((res) => { - // console.log('用户已经添加', res); - // props.command({ id: userName }); - // }); - // }, - // }); - // } else { - // if (!target.auth.readable) { - // Modal.confirm({ - // title: 权限操作, - // content: 当前用户无法阅读该文档,是否添加阅读权限?, - // onCancel: () => {}, - // onOk: async () => { - // updateUser({ - // userName, - // readable: true, - // editable: target.auth.editable, - // }).then((res) => { - // props.command({ id: userName }); - // }); - // }, - // }); - // } else { - // props.command({ id: userName }); - // } - // } - // } else { - // } }; const upHandler = () => {