Home Reference Source

application/components/common/simple-editor/decorator/mention.js

import React from 'react';

class MentionDecorator extends React.Component {
    constructor(props) {
        super(props);

        this.defaultStyles = {
            padding: '0 2px',
        };
    }

    componentWillUpdate(nextProps, nextState) {
        if (this.props.children[0].props.text != nextProps.children[0].props.text && nextProps.children[0].props.text.length >= 3) {
            this.props.store.actions.references.searchUsers(nextProps.children[0].props.text);
        } else {
            this.props.store.actions.references.resetUsers();
        }
    }

    render() {
        return (
            <span {...this.props}
                className='mention'
                style={this.defaultStyles}
                >{this.props.children}</span>
        );
    }
}

export default MentionDecorator;