diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2016-02-13 03:12:01 +0100 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2016-03-17 16:26:14 +0100 |
commit | 90601eacae616c3bca46d6dcb643aa94b1fd05c6 (patch) | |
tree | 764e2aa0b91e392cdb1ef9faa92ff6c9ffe7efd1 /client/components/main/editor.js | |
parent | b8aefedcc3dcaf62d1b45f1e4ffb1dc4fdc55f63 (diff) | |
download | wekan-90601eacae616c3bca46d6dcb643aa94b1fd05c6.tar.gz wekan-90601eacae616c3bca46d6dcb643aa94b1fd05c6.tar.bz2 wekan-90601eacae616c3bca46d6dcb643aa94b1fd05c6.zip |
Upgrade ESLint to v2
This commit also tweak the code style following backward-incompatible v2 rules.
Diffstat (limited to 'client/components/main/editor.js')
-rw-r--r-- | client/components/main/editor.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/client/components/main/editor.js b/client/components/main/editor.js index a30a5e1d..bf92e9a0 100644 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -61,18 +61,20 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() { const mentionRegex = /\B@(\w*)/gi; let content = Blaze.toHTML(view.templateContentBlock); - let currentMention, knowedUser, linkClass, linkValue, link; - while (Boolean(currentMention = mentionRegex.exec(content))) { - - knowedUser = _.findWhere(knowedUsers, { username: currentMention[1] }); - if (!knowedUser) + let currentMention; + while ((currentMention = mentionRegex.exec(content)) !== null) { + const [fullMention, username] = currentMention; + const knowedUser = _.findWhere(knowedUsers, { username }); + if (!knowedUser) { continue; + } - linkValue = [' ', at, knowedUser.username]; - linkClass = 'atMention js-open-member'; - if (knowedUser.userId === Meteor.userId()) + const linkValue = [' ', at, knowedUser.username]; + let linkClass = 'atMention js-open-member'; + if (knowedUser.userId === Meteor.userId()) { linkClass += ' me'; - link = HTML.A({ + } + const link = HTML.A({ 'class': linkClass, // XXX Hack. Since we stringify this render function result below with // `Blaze.toHTML` we can't rely on blaze data contexts to pass the @@ -81,7 +83,7 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() { 'data-userId': knowedUser.userId, }, linkValue); - content = content.replace(currentMention[0], Blaze.toHTML(link)); + content = content.replace(fullMention, Blaze.toHTML(link)); } return HTML.Raw(content); |