summaryrefslogtreecommitdiffstats
path: root/client/components/main/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/main/editor.js')
-rw-r--r--client/components/main/editor.js57
1 files changed, 29 insertions, 28 deletions
diff --git a/client/components/main/editor.js b/client/components/main/editor.js
index 7966ff60..c34539b3 100644
--- a/client/components/main/editor.js
+++ b/client/components/main/editor.js
@@ -1,7 +1,7 @@
-var dropdownMenuIsOpened = false;
+let dropdownMenuIsOpened = false;
-Template.editor.onRendered(function() {
- var $textarea = this.$('textarea');
+Template.editor.onRendered(() => {
+ const $textarea = this.$('textarea');
autosize($textarea);
@@ -9,39 +9,40 @@ Template.editor.onRendered(function() {
// Emojies
{
match: /\B:([\-+\w]*)$/,
- search: function(term, callback) {
- callback($.map(Emoji.values, function(emoji) {
+ search(term, callback) {
+ callback($.map(Emoji.values, (emoji) => {
return emoji.indexOf(term) === 0 ? emoji : null;
}));
},
- template: function(value) {
- var image = '<img src="' + Emoji.baseImagePath + value + '.png"></img>';
+ template(value) {
+ const imgSrc = Emoji.baseImagePath + value;
+ const image = `<img src="${imgSrc}.png" />`;
return image + value;
},
- replace: function(value) {
- return ':' + value + ':';
+ replace(value) {
+ return `:${value}:`;
},
- index: 1
+ index: 1,
},
// User mentions
{
match: /\B@(\w*)$/,
- search: function(term, callback) {
- var currentBoard = Boards.findOne(Session.get('currentBoard'));
- callback($.map(currentBoard.members, function(member) {
- var username = Users.findOne(member.userId).username;
+ search(term, callback) {
+ const currentBoard = Boards.findOne(Session.get('currentBoard'));
+ callback($.map(currentBoard.members, (member) => {
+ const username = Users.findOne(member.userId).username;
return username.indexOf(term) === 0 ? username : null;
}));
},
- template: function(value) {
+ template(value) {
return value;
},
- replace: function(username) {
- return '@' + username + ' ';
+ replace(username) {
+ return `@${username} `;
},
- index: 1
- }
+ index: 1,
+ },
]);
// Since commit d474017 jquery-textComplete automatically closes a potential
@@ -51,27 +52,27 @@ Template.editor.onRendered(function() {
// 'open' and 'hide' events, and create a ghost escapeAction when the dropdown
// is opened (and rely on textComplete to execute the actual action).
$textarea.on({
- 'textComplete:show': function() {
+ 'textComplete:show'() {
dropdownMenuIsOpened = true;
},
- 'textComplete:hide': function() {
- Tracker.afterFlush(function() {
+ 'textComplete:hide'() {
+ Tracker.afterFlush(() => {
dropdownMenuIsOpened = false;
});
- }
+ },
});
});
EscapeActions.register('textcomplete',
- function() {},
- function() { return dropdownMenuIsOpened; }
+ () => {},
+ () => dropdownMenuIsOpened
);
Template.viewer.events({
// Viewer sometimes have click-able wrapper around them (for instance to edit
// the corresponding text). Clicking a link shouldn't fire these actions, stop
// we stop these event at the viewer component level.
- 'click a': function(evt) {
+ 'click a'(evt) {
evt.stopPropagation();
// XXX We hijack the build-in browser action because we currently don't have
@@ -79,7 +80,7 @@ Template.viewer.events({
// handled by a third party package that we can't configure easily. Fix that
// by using directly `_blank` attribute in the rendered HTML.
evt.preventDefault();
- let href = evt.currentTarget.href;
+ const href = evt.currentTarget.href;
window.open(href, '_blank');
- }
+ },
});