Skip to content

Commit

Permalink
fix: upgrade richtext mention
Browse files Browse the repository at this point in the history
  • Loading branch information
renrizzolo committed May 6, 2022
1 parent 20724b4 commit 299ca6a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 30 deletions.
53 changes: 27 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
},
"dependencies": {
"@draft-js-plugins/editor": "^4.1.0",
"@draft-js-plugins/mention": "^4.6.1",
"@draft-js-plugins/mention": "^5.2.1",
"@popperjs/core": "^2.4.0",
"@types/draft-js": "^0.11.8",
"@types/react-datepicker": "^4.3.4",
Expand Down
21 changes: 20 additions & 1 deletion src/components/RichTextEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import MentionAction from './MentionAction';
import FileUploadAction from './FileUploadAction';
import MentionEntry from './MentionEntry';
import FilePreviewList from './FilePreviewList';
import Popover from '../Popover';
import './styles.scss';

const { EditorState, Modifier, convertToRaw, RichUtils } = draftJs;
Expand Down Expand Up @@ -52,9 +53,15 @@ const RichTextEditor = ({
placement: 'bottom-start',
strategy: 'fixed',
modifiers: [
{ name: 'flip', enabled: false },
{ name: 'flip', enabled: true },
{ name: 'preventOverflow', enabled: false },
{ name: 'hide', enabled: false },
{
name: 'offset',
options: {
offset: [-12, 12],
},
},
],
},
theme: {
Expand Down Expand Up @@ -147,6 +154,18 @@ const RichTextEditor = ({
suggestions={suggestions}
onSearchChange={handleMentionSearchChange}
entryComponent={MentionEntry}
popoverContainer={({ children, ...rest }) => {
const { popperOptions, store } = rest;
return (
<Popover.WithRef
popoverClassNames="aui--mention"
refElement={store.getReferenceElement()}
{...popperOptions}
popoverContent={children}
isOpen={true}
/>
);
}}
/>
)}
</div>
Expand Down
17 changes: 15 additions & 2 deletions src/components/RichTextEditor/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@
}
}

.aui--mention {
.popover-content {
padding: 0;
overflow-y: auto;
max-height: 250px;
}
}

.aui--mention-entry {
background-color: $color-white;
width: 350px;
width: auto;
min-width: 250px;

&__is-focused {
background: $color-blue-light;
Expand All @@ -103,7 +112,11 @@
align-items: center;

&__left {
margin: 5px 20px;
margin: 5px 10px 5px 20px;
}

&__right {
margin: 0 10px;
}

.mention-entry--title,
Expand Down

0 comments on commit 299ca6a

Please sign in to comment.