Skip to content

Commit

Permalink
feat: @ mention user filter self
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxing9 committed Sep 19, 2024
1 parent abda5a3 commit 3648597
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const CommentEditor = (props: ICommentEditorProps) => {
blur: noop,
});
const { t } = useTranslation();
const collaborators = useCollaborators();
const { quoteId, setQuoteId, setEditorRef, editingCommentId, setEditingCommentId } =
useCommentStore();
const mentionUserRender = (element: TMentionElement) => {
Expand Down Expand Up @@ -155,12 +154,7 @@ export const CommentEditor = (props: ICommentEditorProps) => {
[MentionPlugin.key]: (props: React.ComponentProps<typeof MentionElement>) => (
<MentionElement {...props} render={mentionUserRender} />
),
[MentionInputPlugin.key]: (props: React.ComponentProps<typeof MentionInputElement>) => (
<MentionInputElement
{...props}
nodeProps={{ ...props.nodeProps, user: collaborators }}
/>
),
[MentionInputPlugin.key]: MentionInputElement,
[ImagePlugin.key]: ImageElement,
}),
[ParagraphPlugin.key]: ParagraphElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const MentionElement = withRef<
const element = useElement<TMentionElement>();
const selected = useSelected();
const focused = useFocused();
console.log('element', element);

return (
<PlateElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PlateElement } from '@udecode/plate-common/react';
import { getMentionOnSelectItem } from '@udecode/plate-mention';
import React, { useState } from 'react';
import { useTranslation } from '../../../../context/app/i18n';
import { useSession } from '../../../../hooks';
import { UserAvatar } from '../../../cell-value';
import { useCollaborators } from '../../hooks';
import {
Expand All @@ -19,7 +20,9 @@ export const MentionInputElement = withRef<typeof PlateElement>(({ className, ..
const { children, editor, element } = props;
const { t } = useTranslation();
const [search, setSearch] = useState('');
const { user } = useSession();
const collaborators = useCollaborators();
const mentionUsers = collaborators.filter((item) => item.userId !== user.id);

return (
<PlateElement
Expand Down Expand Up @@ -50,7 +53,7 @@ export const MentionInputElement = withRef<typeof PlateElement>(({ className, ..
<InlineComboboxContent className="my-1.5">
<InlineComboboxEmpty>{t('common.search.empty')}</InlineComboboxEmpty>

{collaborators.map((item) => (
{mentionUsers.map((item) => (
<InlineComboboxItem
key={item.userId}
onClick={() =>
Expand Down

0 comments on commit 3648597

Please sign in to comment.