diff --git a/package.json b/package.json index c259700c927..cc4da1f7315 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,14 @@ }, "dependencies": { "classnames": "^2.1.2", + "emojione": "^2.1.3", "favico.js": "^0.3.10", "filesize": "^3.1.2", "flux": "^2.0.3", "glob": "^5.0.14", "highlight.js": "^8.9.1", "linkifyjs": "^2.0.0-beta.4", + "lodash": "^4.7.0", "marked": "^0.3.5", "matrix-js-sdk": "matrix-org/matrix-js-sdk#develop", "optimist": "^0.6.1", @@ -41,9 +43,9 @@ "velocity-ui-pack": "^1.2.2" }, "//babelversion": [ - "brief experiments with babel6 seems to show that it generates source ", - "maps which confuse chrome and make setting breakpoints tricky. So ", - "let's stick with v5 for now." + "brief experiments with babel6 seems to show that it generates source ", + "maps which confuse chrome and make setting breakpoints tricky. So ", + "let's stick with v5 for now." ], "devDependencies": { "babel": "^5.8.23", diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index dbcb59a20a3..82aea0bb764 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -27,7 +27,7 @@ var sanitizeHtmlParams = { 'del', // for markdown // deliberately no h1/h2 to stop people shouting. 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', - 'nl', 'li', 'b', 'i', 'u', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', + 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre' ], allowedAttributes: { diff --git a/src/TabCompleteEntries.js b/src/TabCompleteEntries.js index a23050063f4..0d633bafdcd 100644 --- a/src/TabCompleteEntries.js +++ b/src/TabCompleteEntries.js @@ -15,6 +15,7 @@ limitations under the License. */ var React = require("react"); var sdk = require("./index"); +var emojione = require('emojione'); class Entry { constructor(text) { @@ -91,6 +92,32 @@ CommandEntry.fromCommands = function(commandArray) { }); } +class EmojiEntry extends Entry { + constructor(shortname) { + super(shortname); + this.shortname = shortname; + } + + getFillText() { + return emojione.shortnameToUnicode(this.shortname); + } + + getKey() { + return this.shortname; + } + + getImageJsx() { + var image = emojione.shortnameToImage(this.shortname); + return ; + } + + getSuffix(isFirstWord) { + return " "; // force a space after the command. + } +} + +EmojiEntry.entries = Object.keys(emojione.emojioneList).map((shortname) => new EmojiEntry(shortname)); + class MemberEntry extends Entry { constructor(member) { super(member.name || member.userId); @@ -139,3 +166,4 @@ MemberEntry.fromMemberList = function(members) { module.exports.Entry = Entry; module.exports.MemberEntry = MemberEntry; module.exports.CommandEntry = CommandEntry; +module.exports.EmojiEntry = EmojiEntry; diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 7128faf3d7e..33799a7696c 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -33,6 +33,7 @@ var CallHandler = require('../../CallHandler'); var TabComplete = require("../../TabComplete"); var MemberEntry = require("../../TabCompleteEntries").MemberEntry; var CommandEntry = require("../../TabCompleteEntries").CommandEntry; +var EmojiEntry = require("../../TabCompleteEntries").EmojiEntry; var Resend = require("../../Resend"); var SlashCommands = require("../../SlashCommands"); var dis = require("../../dispatcher"); @@ -469,7 +470,7 @@ module.exports = React.createClass({ this.tabComplete.setCompletionList( MemberEntry.fromMemberList(members).concat( CommandEntry.fromCommands(SlashCommands.getCommandList()) - ) + ).concat(EmojiEntry.entries) ); }, 500),