Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert rocketchat-emoji to main module structure #12603

Merged
merged 5 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/rocketchat-emoji/client/emojiButton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals Template chatMessages*/
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Template } from 'meteor/templating';

Template.messageBox.events({
'click .emoji-picker-icon'(event) {
Expand All @@ -14,7 +15,7 @@ Template.messageBox.events({
RocketChat.EmojiPicker.close();
} else {
RocketChat.EmojiPicker.open(event.currentTarget, (emoji) => {
const { input } = chatMessages[RocketChat.openedRoom];
const { input } = window.chatMessages[RocketChat.openedRoom];

const emojiValue = `:${ emoji }:`;

Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-emoji/client/emojiParser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals isSetNotNull */
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { isSetNotNull } from './function-isSet';
import s from 'underscore.string';

/*
Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-emoji/client/emojiPicker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* globals Template, isSetNotNull */
import { ReactiveVar } from 'meteor/reactive-var';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { isSetNotNull } from './function-isSet';

const emojiCategories = {};
/**
Expand Down
7 changes: 2 additions & 5 deletions packages/rocketchat-emoji/client/function-isSet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* globals isSet:true, isSetNotNull:true */
// http://stackoverflow.com/a/26990347 function isSet() from Gajus
isSet = function(fn) {
export const isSet = function(fn) {
let value;
try {
value = fn();
Expand All @@ -11,7 +10,7 @@ isSet = function(fn) {
}
};

isSetNotNull = function(fn) {
export const isSetNotNull = function(fn) {
let value;
try {
value = fn();
Expand All @@ -21,5 +20,3 @@ isSetNotNull = function(fn) {
return value !== null && value !== undefined;
}
};

/* exported isSet, isSetNotNull */
12 changes: 12 additions & 0 deletions packages/rocketchat-emoji/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '../lib/rocketchat';
import './emojiParser';
import './emojiPicker.html';
import './emojiPicker';
import './lib/EmojiPicker';
import { renderEmoji } from './lib/emojiRenderer';
import './emojiButton';
import './keyboardFix';

export {
renderEmoji,
};
1 change: 1 addition & 0 deletions packages/rocketchat-emoji/client/keyboardFix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global device */
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

if (Meteor.isCordova) {
window.addEventListener('native.keyboardshow', function() {
Expand Down
5 changes: 4 additions & 1 deletion packages/rocketchat-emoji/client/lib/EmojiPicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* globals Blaze, Template */
import { RocketChat } from 'meteor/rocketchat:lib';
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';

import _ from 'underscore';

RocketChat.EmojiPicker = {
Expand Down
8 changes: 4 additions & 4 deletions packages/rocketchat-emoji/client/lib/emojiRenderer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* globals HTML, isSetNotNull, renderEmoji:true */
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';
import { isSetNotNull } from '../function-isSet';
import { HTML } from 'meteor/htmljs';

renderEmoji = function(emoji) {
export const renderEmoji = function(emoji) {
if (isSetNotNull(() => RocketChat.emoji.list[emoji].emojiPackage)) {
const { emojiPackage } = RocketChat.emoji.list[emoji];
return RocketChat.emoji.packages[emojiPackage].render(emoji);
Expand All @@ -22,5 +24,3 @@ Template.registerHelper('renderEmoji', new Template('renderEmoji', function() {

return '';
}));

/* exported renderEmoji */
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.emoji = {
packages: {
base: {
Expand Down
17 changes: 3 additions & 14 deletions packages/rocketchat-emoji/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,9 @@ Package.onUse(function(api) {
'rocketchat:lib',
'rocketchat:theme',
'rocketchat:ui-message',
'htmljs',
]);

api.addFiles('client/function-isSet.js', 'client');
api.addFiles('client/rocketchat.js');

api.addFiles('client/emojiParser.js', 'client');

api.addFiles('client/emojiPicker.html', 'client');
api.addFiles('client/emojiPicker.js', 'client');

api.addFiles('client/lib/emojiRenderer.js', 'client');
api.addFiles('client/lib/EmojiPicker.js', 'client');
api.addFiles('client/emojiButton.js', 'client');
api.addFiles('client/keyboardFix.js', 'client');

api.export('renderEmoji');
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});
1 change: 1 addition & 0 deletions packages/rocketchat-emoji/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../lib/rocketchat';
2 changes: 1 addition & 1 deletion packages/rocketchat-ui/client/lib/chatMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Meteor.startup(() => {
});
});

this.ChatMessages = class ChatMessages {
ChatMessages = class ChatMessages { //eslint-disable-line
constructor() {

this.saveTextMessageBox = _.debounce((rid, value) => { // eslint
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,6 @@ Package.onUse(function(api) {
api.export('ChatRoom', 'client');
api.export('ChatSubscription', 'client');
api.export('RoomRoles', 'client');
api.export('ChatMessages', 'client');
api.export('RoomManager', 'client');
});