diff --git a/package.json b/package.json index 279283980..d95acdcf5 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "draft-js-image-plugin": "^2.0.0-rc2", "draft-js-link-plugin": "^1.2.2", "draft-js-plugins-editor": "^2.0.0-rc2", - "draft-js-mention-plugin": "^2.0.0-rc2", "draft-js-utils": "^0.1.7", "fbemitter": "^2.1.1", "fbjs": "^0.8.12", diff --git a/src/components/Feed/NewPost.jsx b/src/components/Feed/NewPost.jsx index 96c5751d5..7b499c2a3 100644 --- a/src/components/Feed/NewPost.jsx +++ b/src/components/Feed/NewPost.jsx @@ -11,7 +11,7 @@ class NewPost extends React.Component { } render() { - const {currentUser, allMembers, titlePlaceholder, isCreating, hasError} = this.props + const {currentUser, titlePlaceholder, isCreating, hasError} = this.props let authorName = currentUser.firstName if (authorName && currentUser.lastName) { authorName += ' ' + currentUser.lastName @@ -33,7 +33,6 @@ class NewPost extends React.Component { hasError={hasError} avatarUrl={currentUser.photoURL} authorName={authorName} - allMembers={allMembers} /> ) } @@ -42,7 +41,6 @@ class NewPost extends React.Component { NewPost.propTypes = { currentUser: PropTypes.object.isRequired, - allMembers: PropTypes.object.isRequired, onPost: PropTypes.func.isRequired, onNewPostChange: PropTypes.func.isRequired, hasError: PropTypes.bool, diff --git a/src/components/RichTextArea/RichTextArea.jsx b/src/components/RichTextArea/RichTextArea.jsx index 46ccb5f00..0c31407d4 100644 --- a/src/components/RichTextArea/RichTextArea.jsx +++ b/src/components/RichTextArea/RichTextArea.jsx @@ -18,19 +18,14 @@ import stateToMarkdown from '../../helpers/stateToMarkdown' import 'draft-js-link-plugin/lib/plugin.css' import EditorIcons from './EditorIcons' import './RichTextArea.scss' -import 'draft-js-mention-plugin/lib/plugin.css' -import createMentionPlugin, { defaultSuggestionsFilter } from 'draft-js-mention-plugin' -import _ from 'lodash' const linkPlugin = createLinkPlugin() const blockDndPlugin = createBlockDndPlugin() -const mentionPlugin = createMentionPlugin({mentionPrefix: '@'}) - const decorator = composeDecorators( blockDndPlugin.decorator ) const allowImages = false -const plugins = [linkPlugin, blockDndPlugin, mentionPlugin] +const plugins = [linkPlugin, blockDndPlugin] if (allowImages){ const imagePlugin = createImagePlugin({ decorator }) plugins.push(handleDropPlugin) @@ -56,8 +51,7 @@ const blocks = [ class RichTextArea extends React.Component { constructor(props) { super(props) - this.mentions = _.map(_.values(this.props.allMembers), (e) => { return {name: e.firstName + ' ' + e.lastName, handle: e.handle, userId: e.userId} }) - this.state = {editorExpanded: false, editorState: EditorState.createEmpty(), titleValue: '', suggestions: this.mentions, mentions: []} + this.state = {editorExpanded: false, editorState: EditorState.createEmpty(), titleValue: ''} this.onTitleChange = this.onTitleChange.bind(this) this.onEditorChange = this.onEditorChange.bind(this) this.handleKeyCommand = this.handleKeyCommand.bind(this) @@ -207,42 +201,12 @@ class RichTextArea extends React.Component { return } const title = this.state.titleValue - - var that = this - const replaceMentionWithUserID = (content) => - { - const encodeContent = (text) => { - return text.replace(/[*_`]/g, '\\$&') - } - - const userIdMap = _.reduce(that.mentions, (obj, item) => { - obj[encodeContent(item.name)] = encodeContent(item.handle) - return obj - }, {}) - - for (var item in userIdMap) - { - content = content.replace('@' + item, '@' + userIdMap[item]) - } - return content - } - - const content = replaceMentionWithUserID(this.state.currentMDContent) - + const content = this.state.currentMDContent if ((this.props.disableTitle || title) && content) { this.props.onPost({title, content}) } } - onSearchChange = ({ value }) => { - this.setState({ - suggestions: defaultSuggestionsFilter(value, this.mentions), - }); - }; - - onAddMention = (mention) => { - } - cancelEdit() { this.props.cancelEdit() } @@ -256,7 +220,6 @@ class RichTextArea extends React.Component { this.setState({uploading}) } render() { - const {MentionSuggestions} = mentionPlugin const {className, avatarUrl, authorName, titlePlaceholder, contentPlaceholder, editMode, isCreating, isGettingComment, disableTitle} = this.props const {editorExpanded, editorState, titleValue, oldMDContent, currentMDContent, uploading} = this.state let canSubmit = (disableTitle || titleValue.trim()) @@ -269,28 +232,6 @@ class RichTextArea extends React.Component { const currentEntity = getCurrentEntity(editorState) const disableForCodeBlock = blockType === 'code-block' - const Entry = (props) => { - const { - mention, - theme, - searchValue, // eslint-disable-line no-unused-vars - isFocused, // eslint-disable-line no-unused-vars - ...parentProps - } = props; - - return ( -