md commands undo

pull/7748/head
Guilherme Gazzo 8 years ago
parent adc6e6933e
commit a3c5472662
  1. 7
      packages/rocketchat-ui-message/client/messageBox.js

@ -19,7 +19,6 @@ function katexSyntax() {
return false;
}
function applyMd(e, t) {
e.preventDefault();
const box = t.find('.js-input-message');
@ -40,8 +39,12 @@ function applyMd(e, t) {
apply pattern
restore selection
*/
box.value = initText + this.pattern.replace('{{text}}', text) + finalText;
box.focus();
if (document.execCommand) {
document.execCommand('insertText', false, this.pattern.replace('{{text}}', text));
} else {
box.value = initText + this.pattern.replace('{{text}}', text) + finalText;
}
box.selectionStart = selectionStart + this.pattern.indexOf('{{text}}');
box.selectionEnd = box.selectionStart + text.length;
$(box).change();

Loading…
Cancel
Save