Fix emoji picker on firefox 👌

pull/7943/head
Karl Prieb 8 years ago
parent 66125de0df
commit 228408837b
  1. 6
      packages/rocketchat-emoji/client/emojiButton.js
  2. 10
      packages/rocketchat-ui-message/client/messageBox.js

@ -7,6 +7,7 @@ Template.messageBox.events({
RocketChat.EmojiPicker.close();
} else {
RocketChat.EmojiPicker.open(event.currentTarget, (emoji) => {
console.log('test');
const {input} = chatMessages[RocketChat.openedRoom];
const emojiValue = `:${ emoji }:`;
@ -14,9 +15,8 @@ Template.messageBox.events({
const caretPos = input.selectionStart;
const textAreaTxt = input.value;
input.focus();
if (document.execCommand) {
document.execCommand('insertText', false, emojiValue);
} else {
if (!document.execCommand || !document.execCommand('insertText', false, emojiValue)) {
// document.execCommand('insertText', false, emojiValue);
input.value = textAreaTxt.substring(0, caretPos) + emojiValue + textAreaTxt.substring(caretPos);
}

@ -51,11 +51,10 @@ function applyMd(e, t) {
box.selectionStart = selectionStart - startPattern.length;
box.selectionEnd = selectionEnd + endPattern.length;
if (document.execCommand) {
document.execCommand('insertText', false, selectedText);
} else {
if (!document.execCommand || !document.execCommand('insertText', false, selectedText)) {
box.value = initText.substr(0, initText.length - startPattern.length) + selectedText + finalText.substr(endPattern.length);
}
box.selectionStart = selectionStart - startPattern.length;
box.selectionEnd = box.selectionStart + selectedText.length;
$(box).change();
@ -68,11 +67,10 @@ function applyMd(e, t) {
apply pattern
restore selection
*/
if (document.execCommand) {
document.execCommand('insertText', false, this.pattern.replace('{{text}}', selectedText));
} else {
if (!document.execCommand || !document.execCommand('insertText', false, this.pattern.replace('{{text}}', selectedText))) {
box.value = initText + this.pattern.replace('{{text}}', selectedText) + finalText;
}
box.selectionStart = selectionStart + this.pattern.indexOf('{{text}}');
box.selectionEnd = box.selectionStart + selectedText.length;
$(box).change();

Loading…
Cancel
Save