fixes mm-1250 mention highlights should now align in textbox

Этот коммит содержится в:
JoramWilander
2015-06-17 09:23:19 -04:00
родитель 5a8f839716
Коммит f1a2e48354
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@@ -14,7 +14,7 @@ module.exports = React.createClass({
PostStore.addMentionDataChangeListener(this._onChange); PostStore.addMentionDataChangeListener(this._onChange);
var self = this; var self = this;
$('#'+this.props.id).on('keypress.mentionlist', $('body').on('keypress.mentionlist', '#'+this.props.id,
function(e) { function(e) {
if (!self.isEmpty() && self.state.mentionText != '-1' && e.which === 13) { if (!self.isEmpty() && self.state.mentionText != '-1' && e.which === 13) {
e.stopPropagation(); e.stopPropagation();
@@ -26,7 +26,7 @@ module.exports = React.createClass({
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
PostStore.removeMentionDataChangeListener(this._onChange); PostStore.removeMentionDataChangeListener(this._onChange);
$('#'+this.props.id).off('keypress.mentionlist'); $('body').off('keypress.mentionlist', '#'+this.props.id);
}, },
_onChange: function(id, mentionText, excludeList) { _onChange: function(id, mentionText, excludeList) {
if (id !== this.props.id) return; if (id !== this.props.id) return;

Просмотреть файл

@@ -78,6 +78,8 @@ module.exports = React.createClass({
var re = new RegExp('( |^)@' + m + '( |$|\n)', 'm'); var re = new RegExp('( |^)@' + m + '( |$|\n)', 'm');
html = html.replace(re, '$1<span class="mention">@'+m+'</span>$2'); html = html.replace(re, '$1<span class="mention">@'+m+'</span>$2');
} }
var re2 = new RegExp('(^$)(?![.\n])', 'gm');
html = html.replace(re2, '<br/><br/>');
$(this.refs.textdiv.getDOMNode()).html(html); $(this.refs.textdiv.getDOMNode()).html(html);
}, },
handleChange: function() { handleChange: function() {
@@ -262,6 +264,8 @@ module.exports = React.createClass({
$(d).css({'height':'auto','overflow-y':'scroll'}).height(167); $(d).css({'height':'auto','overflow-y':'scroll'}).height(167);
$(w).css({'height':'auto'}).height(167); $(w).css({'height':'auto'}).height(167);
} }
$(d).scrollTop($(e).scrollTop());
}, },
handleFocus: function() { handleFocus: function() {
var elm = this.refs.message.getDOMNode(); var elm = this.refs.message.getDOMNode();