@@ -18,19 +18,14 @@ import stateToMarkdown from '../../helpers/stateToMarkdown'
1818import 'draft-js-link-plugin/lib/plugin.css'
1919import EditorIcons from './EditorIcons'
2020import './RichTextArea.scss'
21- import 'draft-js-mention-plugin/lib/plugin.css'
22- import createMentionPlugin , { defaultSuggestionsFilter } from 'draft-js-mention-plugin'
23- import _ from 'lodash'
2421
2522const linkPlugin = createLinkPlugin ( )
2623const blockDndPlugin = createBlockDndPlugin ( )
27- const mentionPlugin = createMentionPlugin ( { mentionPrefix : '@' } )
28-
2924const decorator = composeDecorators (
3025 blockDndPlugin . decorator
3126)
3227const allowImages = false
33- const plugins = [ linkPlugin , blockDndPlugin , mentionPlugin ]
28+ const plugins = [ linkPlugin , blockDndPlugin ]
3429if ( allowImages ) {
3530 const imagePlugin = createImagePlugin ( { decorator } )
3631 plugins . push ( handleDropPlugin )
@@ -56,8 +51,7 @@ const blocks = [
5651class RichTextArea extends React . Component {
5752 constructor ( props ) {
5853 super ( props )
59- this . mentions = _ . map ( _ . values ( this . props . allMembers ) , ( e ) => { return { name : e . firstName + ' ' + e . lastName , handle : e . handle , userId : e . userId } } )
60- this . state = { editorExpanded : false , editorState : EditorState . createEmpty ( ) , titleValue : '' , suggestions : this . mentions , mentions : [ ] }
54+ this . state = { editorExpanded : false , editorState : EditorState . createEmpty ( ) , titleValue : '' }
6155 this . onTitleChange = this . onTitleChange . bind ( this )
6256 this . onEditorChange = this . onEditorChange . bind ( this )
6357 this . handleKeyCommand = this . handleKeyCommand . bind ( this )
@@ -207,42 +201,12 @@ class RichTextArea extends React.Component {
207201 return
208202 }
209203 const title = this . state . titleValue
210-
211- var that = this
212- const replaceMentionWithUserID = ( content ) =>
213- {
214- const encodeContent = ( text ) => {
215- return text . replace ( / [ * _ ` ] / g, '\\$&' )
216- }
217-
218- const userIdMap = _ . reduce ( that . mentions , ( obj , item ) => {
219- obj [ encodeContent ( item . name ) ] = encodeContent ( item . handle )
220- return obj
221- } , { } )
222-
223- for ( var item in userIdMap )
224- {
225- content = content . replace ( '@' + item , '@' + userIdMap [ item ] )
226- }
227- return content
228- }
229-
230- const content = replaceMentionWithUserID ( this . state . currentMDContent )
231-
204+ const content = this . state . currentMDContent
232205 if ( ( this . props . disableTitle || title ) && content ) {
233206 this . props . onPost ( { title, content} )
234207 }
235208 }
236209
237- onSearchChange = ( { value } ) => {
238- this . setState ( {
239- suggestions : defaultSuggestionsFilter ( value , this . mentions ) ,
240- } ) ;
241- } ;
242-
243- onAddMention = ( mention ) => {
244- }
245-
246210 cancelEdit ( ) {
247211 this . props . cancelEdit ( )
248212 }
@@ -256,7 +220,6 @@ class RichTextArea extends React.Component {
256220 this . setState ( { uploading} )
257221 }
258222 render ( ) {
259- const { MentionSuggestions} = mentionPlugin
260223 const { className, avatarUrl, authorName, titlePlaceholder, contentPlaceholder, editMode, isCreating, isGettingComment, disableTitle} = this . props
261224 const { editorExpanded, editorState, titleValue, oldMDContent, currentMDContent, uploading} = this . state
262225 let canSubmit = ( disableTitle || titleValue . trim ( ) )
@@ -269,28 +232,6 @@ class RichTextArea extends React.Component {
269232 const currentEntity = getCurrentEntity ( editorState )
270233 const disableForCodeBlock = blockType === 'code-block'
271234
272- const Entry = ( props ) => {
273- const {
274- mention,
275- theme,
276- searchValue, // eslint-disable-line no-unused-vars
277- isFocused, // eslint-disable-line no-unused-vars
278- ...parentProps
279- } = props ;
280-
281- return (
282- < div { ...parentProps } >
283- < div className = { theme . mentionSuggestionsEntryContainer } >
284- < div className = { theme . mentionSuggestionsEntryContainerRight } >
285- < div className = { theme . mentionSuggestionsEntryText } >
286- { mention . get ( 'handle' ) }
287- </ div >
288- </ div >
289- </ div >
290- </ div >
291- ) ;
292- } ;
293-
294235 return (
295236 < div className = { cn ( className , 'rich-editor' , { expanded : editorExpanded || editMode } ) } ref = "richEditor" >
296237 { ( isCreating || isGettingComment ) &&
@@ -317,23 +258,15 @@ class RichTextArea extends React.Component {
317258 />
318259 < div className = "draftjs-editor tc-textarea" >
319260 { ! isGettingComment &&
320- < div >
321- < Editor
322- ref = "editor"
323- placeholder = { contentPlaceholder }
324- editorState = { editorState }
325- onChange = { this . onEditorChange }
326- handleKeyCommand = { this . handleKeyCommand }
327- plugins = { plugins }
328- setUploadState = { this . setUploadState }
329- />
330- < MentionSuggestions
331- onSearchChange = { this . onSearchChange }
332- suggestions = { this . state . suggestions }
333- onAddMention = { this . onAddMention }
334- entryComponent = { Entry }
335- />
336- </ div >
261+ < Editor
262+ ref = "editor"
263+ placeholder = { contentPlaceholder }
264+ editorState = { editorState }
265+ onChange = { this . onEditorChange }
266+ handleKeyCommand = { this . handleKeyCommand }
267+ plugins = { plugins }
268+ setUploadState = { this . setUploadState }
269+ />
337270 }
338271 < div className = "textarea-footer" >
339272 < div className = "textarea-buttons" >
@@ -425,8 +358,7 @@ RichTextArea.propTypes = {
425358 oldTitle : PropTypes . string ,
426359 oldContent : PropTypes . string ,
427360 title : PropTypes . string ,
428- content : PropTypes . string ,
429- allMembers : PropTypes . object
361+ content : PropTypes . string
430362}
431363
432364export default RichTextArea
0 commit comments