From a72b95a86846faa4691626bc0deb2ead0752c32e Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Thu, 6 Jul 2017 02:49:12 +0300 Subject: [PATCH] Fix compose focus/cursor --- dev/View/Popup/Contacts.js | 2 +- vendors/ckeditor-plugins/plain/plugin.js | 79 +++++++++++++------- vendors/ckeditor-plugins/signature/plugin.js | 16 ++-- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index c6646479c..efc9008fe 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -280,7 +280,7 @@ class ContactsPopupView extends AbstractViewNext { this.bBackToCompose = false; - hideScreenPopup(require('View/Popup/Contacts')); + hideScreenPopup(ContactsPopupView); switch (this.sLastComposeFocusedField) { diff --git a/vendors/ckeditor-plugins/plain/plugin.js b/vendors/ckeditor-plugins/plain/plugin.js index f3510ace7..635779af0 100644 --- a/vendors/ckeditor-plugins/plain/plugin.js +++ b/vendors/ckeditor-plugins/plain/plugin.js @@ -2,6 +2,26 @@ (function() { var + selectRange = function (el, start, end) { + if (!el) { + return; + } + if(end === undefined) { + end = start; + } + if('selectionStart' in el) { + el.selectionStart = start; + el.selectionEnd = end; + } else if(el.setSelectionRange) { + el.setSelectionRange(start, end); + } else if(el.createTextRange) { + var range = el.createTextRange(); + range.collapse(true); + range.moveEnd('character', end); + range.moveStart('character', start); + range.select(); + } + }, simplePlainToHtml = function (sPlain) { return sPlain .replace(/&/g, '&') @@ -50,10 +70,11 @@ hidpi: true, init: function(editor) { - if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) + if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) { return; + } - editor.__plainUtils = { + editor.__textUtils = { plainToHtml: function(data) { return window.rainloop_Utils_plainToHtml ? window.rainloop_Utils_plainToHtml(data, true) : simplePlainToHtml(data); @@ -94,11 +115,8 @@ editable.setData(editor.getData(1)); editor.__plain = editable; + editor.__textarea = textarea.$; - // Having to make