From f5818817e98277c4d8a06979b8b506aa4f6f7fde Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 27 Oct 2020 14:27:52 +1100 Subject: [PATCH] remove references to old emoji-panel package --- js/views/conversation_view.js | 62 +---------- package.json | 3 - preload.js | 2 - stylesheets/_emoji.scss | 30 ------ stylesheets/_session.scss | 2 +- .../conversation/SessionCompositionBox.tsx | 10 +- ts/util/emoji.ts | 12 --- ts/util/lint/exceptions.json | 102 ------------------ yarn.lock | 11 -- 9 files changed, 12 insertions(+), 222 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index aabeaaeb7..fb9f6df44 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -1,8 +1,6 @@ /* global $, _, - emojiData, - EmojiPanel, extension, i18n, Signal, @@ -372,7 +370,6 @@ this.$('.send-message').focus(this.focusBottomBar.bind(this)); this.$('.send-message').blur(this.unfocusBottomBar.bind(this)); - this.$emojiPanelContainer = this.$('.emoji-panel-container'); this.model.updateTextInputState(); this.selectMember = this.selectMember.bind(this); @@ -414,7 +411,6 @@ 'click .bottom-bar': 'focusMessageField', 'click .capture-audio .microphone': 'captureAudio', 'click .module-scroll-down': 'scrollToBottom', - 'click button.emoji': 'toggleEmojiPanel', 'focus .send-message': 'focusBottomBar', 'change .file-input': 'toggleMicrophone', 'blur .send-message': 'unfocusBottomBar', @@ -484,9 +480,10 @@ }, onDisableInput(disable) { - this.$( - 'button.emoji, button.microphone, button.paperclip, .send-message' - ).attr('disabled', disable); + this.$('button.microphone, button.paperclip, .send-message').attr( + 'disabled', + disable + ); }, onChangePlaceholder(type) { @@ -1497,14 +1494,6 @@ this.model.resetMessageSelection(); }, - toggleEmojiPanel(e) { - e.preventDefault(); - if (!this.emojiPanel) { - this.openEmojiPanel(); - } else { - this.closeEmojiPanel(); - } - }, onKeyDown(event) { if (event.key !== 'Escape') { return; @@ -1516,44 +1505,6 @@ // Up and down arrows should scroll // Alt + up and down should swap between conversations / setting categories this.model.resetMessageSelection(); - this.closeEmojiPanel(); - }, - openEmojiPanel() { - this.$emojiPanelContainer.outerHeight(200); - this.emojiPanel = new EmojiPanel(this.$emojiPanelContainer[0], { - onClick: this.insertEmoji.bind(this), - }); - this.view.resetScrollPosition(); - this.updateMessageFieldSize({}); - }, - closeEmojiPanel() { - if (this.emojiPanel === null) { - return; - } - - this.$emojiPanelContainer.empty().outerHeight(0); - this.emojiPanel = null; - this.view.resetScrollPosition(); - this.updateMessageFieldSize({}); - }, - insertEmoji(e) { - const colons = `:${emojiData[e.index].short_name}:`; - - const textarea = this.$messageField[0]; - if (textarea.selectionStart || textarea.selectionStart === 0) { - const startPos = textarea.selectionStart; - const endPos = textarea.selectionEnd; - - textarea.value = - textarea.value.substring(0, startPos) + - colons + - textarea.value.substring(endPos, textarea.value.length); - textarea.selectionStart = startPos + colons.length; - textarea.selectionEnd = startPos + colons.length; - } else { - textarea.value += colons; - } - this.focusMessageField(); }, async setQuoteMessage(message) { @@ -1621,13 +1572,11 @@ async sendMessage(e) { this.removeLastSeenIndicator(); - this.closeEmojiPanel(); this.model.clearTypingTimers(); const input = this.$messageField; - let message = this.memberView.replaceMentions(input.val()); - message = window.Signal.Emoji.replaceColons(message).trim(); + const message = this.memberView.replaceMentions(input.val()); const toastOptions = { type: 'info' }; // let it pass if we're still trying to read it or it's false... @@ -2275,7 +2224,6 @@ const height = this.$messageField.outerHeight() + $attachmentPreviews.outerHeight() + - this.$emojiPanelContainer.outerHeight() + quoteHeight + parseInt($bottomBar.css('min-height'), 10); diff --git a/package.json b/package.json index 2390fbe98..651bad162 100644 --- a/package.json +++ b/package.json @@ -78,11 +78,8 @@ "electron-is-dev": "^1.1.0", "electron-localshortcut": "^3.2.1", "electron-updater": "^4.2.2", - "emoji-datasource": "4.0.0", - "emoji-datasource-apple": "4.0.0", "emoji-js": "3.4.0", "emoji-mart": "^2.11.2", - "emoji-panel": "https://github.com/scottnonnenberg-signal/emoji-panel.git#v0.5.5", "filesize": "3.6.1", "firstline": "1.2.1", "form-data": "^3.0.0", diff --git a/preload.js b/preload.js index 21455b364..e1bfa012f 100644 --- a/preload.js +++ b/preload.js @@ -372,8 +372,6 @@ const { autoOrientImage } = require('./js/modules/auto_orient_image'); window.autoOrientImage = autoOrientImage; window.dataURLToBlobSync = require('blueimp-canvas-to-blob'); -window.emojiData = require('emoji-datasource'); -window.EmojiPanel = require('emoji-panel'); window.filesize = require('filesize'); window.loadImage = require('blueimp-load-image'); window.getGuid = require('uuid/v4'); diff --git a/stylesheets/_emoji.scss b/stylesheets/_emoji.scss index 052fd0175..143b7f180 100644 --- a/stylesheets/_emoji.scss +++ b/stylesheets/_emoji.scss @@ -102,33 +102,3 @@ button.emoji { opacity: 1; } } - -// Import emoji panel css and override paths -@import '../node_modules/emoji-panel/lib/emoji-panel-apple-32.css'; -@font-face { - font-family: 'apple-category'; - src: url(../node_modules/emoji-panel/lib/asset/apple.ttf) format('truetype'); - font-weight: normal; - font-style: normal; -} - -.emoji-panel-container { - height: 0px; - - .ep-emojies { - background-color: $color-white; - } - - .ep-categories { - background-color: $color-light-10; - margin-bottom: 6px; - } - - .ep-e { - background-image: url('../node_modules/emoji-datasource-apple/img/apple/sheets/64.png'); - background-size: 1734px; - } - .ep-slide { - background-color: $blue; - } -} diff --git a/stylesheets/_session.scss b/stylesheets/_session.scss index 9feb31022..f86e1e3df 100644 --- a/stylesheets/_session.scss +++ b/stylesheets/_session.scss @@ -756,7 +756,7 @@ label { .react-contexify { z-index: 3; min-width: 200px; - box-shadow: 0 10px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19) !important; + box-shadow: 0 10px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19) !important; .react-contexify__item:not(.react-contexify__item--disabled):hover > .react-contexify__item__content { diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index f8fc0351e..aa516b655 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -243,10 +243,12 @@ export class SessionCompositionBox extends React.Component { onKeyDown={this.onKeyDown} role="button" > - + {showEmojiPanel && ( + + )} ); diff --git a/ts/util/emoji.ts b/ts/util/emoji.ts index 3d9377b7f..9593aa625 100644 --- a/ts/util/emoji.ts +++ b/ts/util/emoji.ts @@ -24,18 +24,6 @@ export function findImage(value: string, variation?: string) { return instance.find_image(value, variation); } -export function replaceColons(str: string) { - return str.replace(instance.rx_colons, m => { - const name = m.substr(1, m.length - 2).toLowerCase(); - const code = instance.map.colons[name]; - if (code) { - return instance.data[code][0][0]; - } - - return m; - }); -} - function getCountOfAllMatches(str: string, regex: RegExp) { let match = regex.exec(str); let count = 0; diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index ba92de6e0..df731cdb0 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -2734,108 +2734,6 @@ "updated": "2018-09-18T19:19:27.699Z", "reasonDetail": "It's setting the html of the element to the previous HTML, just with the emoji replaced" }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/dist/emoji-panel.js", - "line": "\t el.innerHTML = '';", - "lineNumber": 94, - "reasonCategory": "usageTrusted", - "updated": "2018-09-15T00:38:04.183Z", - "reasonDetail": "Hard-coded value" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/dist/emoji-panel.js", - "line": "\t panelEl.innerHTML = _template2.default;", - "lineNumber": 154, - "reasonCategory": "usageTrusted", - "updated": "2018-09-18T19:19:27.699Z", - "reasonDetail": "In this file, _template2.default is a hardcoded string generated from emoji data" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/dist/example.js", - "line": "\t codeEl.innerHTML = codeEl.innerHTML.replace(/dist\\/emoji-panel-.*-.*.min.css/g, newHref);", - "lineNumber": 67, - "reasonCategory": "exampleCode", - "updated": "2018-09-15T00:38:04.183Z" - }, - { - "rule": "jQuery-$(", - "path": "node_modules/emoji-panel/dist/example.js", - "line": "\t$('#example-4-btn').click(function (e) {", - "lineNumber": 101, - "reasonCategory": "exampleCode", - "updated": "2018-09-19T21:59:32.770Z" - }, - { - "rule": "jQuery-$(", - "path": "node_modules/emoji-panel/dist/example.js", - "line": "\t $('#example-4').dialog({", - "lineNumber": 102, - "reasonCategory": "exampleCode", - "updated": "2018-09-19T21:59:32.770Z" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/lib/emoji-panel.js", - "line": "\t el.innerHTML = '';", - "lineNumber": 103, - "reasonCategory": "usageTrusted", - "updated": "2018-09-15T00:38:04.183Z", - "reasonDetail": "Hard-coded value" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/lib/emoji-panel.js", - "line": "\t panelEl.innerHTML = _template2.default;", - "lineNumber": 163, - "reasonCategory": "usageTrusted", - "updated": "2018-09-18T19:19:27.699Z", - "reasonDetail": "In this file, _template2.default is a hardcoded string generated from emoji data" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/lib/example.js", - "line": "\t codeEl.innerHTML = codeEl.innerHTML.replace(/dist\\/emoji-panel-.*-.*.min.css/g, newHref);", - "lineNumber": 76, - "reasonCategory": "exampleCode", - "updated": "2018-09-18T19:19:27.699Z" - }, - { - "rule": "jQuery-$(", - "path": "node_modules/emoji-panel/lib/example.js", - "line": "\t$('#example-4-btn').click(function (e) {", - "lineNumber": 110, - "reasonCategory": "exampleCode", - "updated": "2018-09-19T21:59:32.770Z" - }, - { - "rule": "jQuery-$(", - "path": "node_modules/emoji-panel/lib/example.js", - "line": "\t $('#example-4').dialog({", - "lineNumber": 111, - "reasonCategory": "exampleCode", - "updated": "2018-09-19T21:59:32.770Z" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/src/create-panel.js", - "line": " panelEl.innerHTML = panelTemplate;", - "lineNumber": 7, - "reasonCategory": "usageTrusted", - "updated": "2018-09-18T19:19:27.699Z", - "reasonDetail": "In this file, panelTemplate is a hardcoded string generated from emoji data" - }, - { - "rule": "DOM-innerHTML", - "path": "node_modules/emoji-panel/src/emoji-panel.js", - "line": " el.innerHTML = '';", - "lineNumber": 25, - "reasonCategory": "usageTrusted", - "updated": "2018-09-15T00:38:04.183Z", - "reasonDetail": "Hard-coded value" - }, { "rule": "thenify-multiArgs", "path": "node_modules/es6-promisify/dist/promisify.js", diff --git a/yarn.lock b/yarn.lock index 89d22da9b..f7047a8ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3432,11 +3432,6 @@ emoji-annotation-to-unicode@^0.3.0: resolved "https://registry.yarnpkg.com/emoji-annotation-to-unicode/-/emoji-annotation-to-unicode-0.3.0.tgz#b76d18823e1d70a95a017c438c168eda12902f3b" integrity sha1-t20Ygj4dcKlaAXxDjBaO2hKQLzs= -emoji-datasource-apple@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/emoji-datasource-apple/-/emoji-datasource-apple-4.0.0.tgz#f31a2cbf9295c66b5cc1e78635ee7b617430a08b" - integrity sha1-8xosv5KVxmtcweeGNe57YXQwoIs= - emoji-datasource@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/emoji-datasource/-/emoji-datasource-4.0.0.tgz#3fc9c0c2f4fb321d9291138819f6d100603d3e2f" @@ -3461,12 +3456,6 @@ emoji-mart@^2.11.2: dependencies: prop-types "^15.6.0" -"emoji-panel@https://github.com/scottnonnenberg-signal/emoji-panel.git#v0.5.5": - version "0.5.5" - resolved "https://github.com/scottnonnenberg-signal/emoji-panel.git#81e236e03458a44d4a174ab5f367cb4b9b1b2f97" - dependencies: - emoji-datasource "4.0.0" - "emoji-regex@>=6.0.0 <=6.1.1": version "6.1.1" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.1.1.tgz#c6cd0ec1b0642e2a3c67a1137efc5e796da4f88e"