mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-22 13:04:19 +08:00
Fix compose focus/cursor
This commit is contained in:
parent
ab374bbb71
commit
a72b95a868
3 changed files with 60 additions and 37 deletions
|
@ -280,7 +280,7 @@ class ContactsPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
this.bBackToCompose = false;
|
this.bBackToCompose = false;
|
||||||
|
|
||||||
hideScreenPopup(require('View/Popup/Contacts'));
|
hideScreenPopup(ContactsPopupView);
|
||||||
|
|
||||||
switch (this.sLastComposeFocusedField)
|
switch (this.sLastComposeFocusedField)
|
||||||
{
|
{
|
||||||
|
|
79
vendors/ckeditor-plugins/plain/plugin.js
vendored
79
vendors/ckeditor-plugins/plain/plugin.js
vendored
|
@ -2,6 +2,26 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var
|
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) {
|
simplePlainToHtml = function (sPlain) {
|
||||||
return sPlain
|
return sPlain
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
|
@ -50,10 +70,11 @@
|
||||||
hidpi: true,
|
hidpi: true,
|
||||||
init: function(editor)
|
init: function(editor)
|
||||||
{
|
{
|
||||||
if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE)
|
if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
editor.__plainUtils = {
|
editor.__textUtils = {
|
||||||
plainToHtml: function(data) {
|
plainToHtml: function(data) {
|
||||||
return window.rainloop_Utils_plainToHtml ?
|
return window.rainloop_Utils_plainToHtml ?
|
||||||
window.rainloop_Utils_plainToHtml(data, true) : simplePlainToHtml(data);
|
window.rainloop_Utils_plainToHtml(data, true) : simplePlainToHtml(data);
|
||||||
|
@ -94,11 +115,8 @@
|
||||||
|
|
||||||
editable.setData(editor.getData(1));
|
editable.setData(editor.getData(1));
|
||||||
editor.__plain = editable;
|
editor.__plain = editable;
|
||||||
|
editor.__textarea = textarea.$;
|
||||||
|
|
||||||
// Having to make <textarea> fixed sized to conquer the following bugs:
|
|
||||||
// 1. The textarea height/width='100%' doesn't constraint to the 'td' in IE6/7.
|
|
||||||
// 2. Unexpected vertical-scrolling behavior happens whenever focus is moving out of editor
|
|
||||||
// if text content within it has overflowed. (#4762)
|
|
||||||
if (CKEDITOR.env.ie) {
|
if (CKEDITOR.env.ie) {
|
||||||
editable.attachListener(editor, 'resize', onResize, editable);
|
editable.attachListener(editor, 'resize', onResize, editable);
|
||||||
editable.attachListener(CKEDITOR.document.getWindow(), 'resize', onResize, editable);
|
editable.attachListener(CKEDITOR.document.getWindow(), 'resize', onResize, editable);
|
||||||
|
@ -122,6 +140,12 @@
|
||||||
editor.on('mode', function() {
|
editor.on('mode', function() {
|
||||||
editor.getCommand('plain').setState(editor.mode === 'plain' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF);
|
editor.getCommand('plain').setState(editor.mode === 'plain' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF);
|
||||||
editor.editable().addClass('cke_enable_context_menu');
|
editor.editable().addClass('cke_enable_context_menu');
|
||||||
|
|
||||||
|
editor.focus();
|
||||||
|
|
||||||
|
if (editor.mode === 'plain') {
|
||||||
|
selectRange(editor.__textarea, 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function onResize() {
|
function onResize() {
|
||||||
|
@ -137,7 +161,7 @@
|
||||||
base: CKEDITOR.editable,
|
base: CKEDITOR.editable,
|
||||||
proto: {
|
proto: {
|
||||||
setData: function(data) {
|
setData: function(data) {
|
||||||
this.setValue(this.editor.__plainUtils.htmlToPlain(data));
|
this.setValue(this.editor.__textUtils.htmlToPlain(data));
|
||||||
this.editor.fire('dataReady');
|
this.editor.fire('dataReady');
|
||||||
},
|
},
|
||||||
setRawData: function(data) {
|
setRawData: function(data) {
|
||||||
|
@ -145,7 +169,7 @@
|
||||||
this.editor.fire('dataReady');
|
this.editor.fire('dataReady');
|
||||||
},
|
},
|
||||||
getData: function() {
|
getData: function() {
|
||||||
return this.editor.__plainUtils.plainToHtml(this.getValue());
|
return this.editor.__textUtils.plainToHtml(this.getValue());
|
||||||
},
|
},
|
||||||
getRawData: function() {
|
getRawData: function() {
|
||||||
return this.getValue();
|
return this.getValue();
|
||||||
|
@ -163,25 +187,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
|
||||||
|
|
||||||
CKEDITOR.plugins.plain = {
|
CKEDITOR.plugins.plain = {
|
||||||
commands: {
|
commands: {
|
||||||
plain: {
|
plain: {
|
||||||
modes: {
|
modes: {
|
||||||
wysiwyg: 1, plain: 1
|
wysiwyg: 1, plain: 1
|
||||||
},
|
},
|
||||||
editorFocus: false,
|
editorFocus: true,
|
||||||
readOnly: 1,
|
readOnly: false,
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
if (editor.mode === 'wysiwyg') {
|
if (editor.mode === 'wysiwyg') {
|
||||||
editor.fire('saveSnapshot');
|
editor.fire('saveSnapshot');
|
||||||
}
|
}
|
||||||
|
editor.getCommand('plain').setState(CKEDITOR.TRISTATE_DISABLED);
|
||||||
editor.getCommand('plain').setState(CKEDITOR.TRISTATE_DISABLED);
|
editor.setMode(editor.mode === 'plain' ? 'wysiwyg' : 'plain');
|
||||||
editor.setMode(editor.mode === 'plain' ? 'wysiwyg' : 'plain');
|
},
|
||||||
},
|
canUndo: false
|
||||||
canUndo: false
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
}());
|
||||||
|
|
16
vendors/ckeditor-plugins/signature/plugin.js
vendored
16
vendors/ckeditor-plugins/signature/plugin.js
vendored
|
@ -10,7 +10,7 @@
|
||||||
isEmptyText = false,
|
isEmptyText = false,
|
||||||
newLine = (isHtml ? '<br />' : "\n"),
|
newLine = (isHtml ? '<br />' : "\n"),
|
||||||
clearHtmlLine = function(html) {
|
clearHtmlLine = function(html) {
|
||||||
return $.trim(editor.__plainUtils.htmlToPlain(html));
|
return $.trim(editor.__textUtils.htmlToPlain(html));
|
||||||
};
|
};
|
||||||
|
|
||||||
isEmptyText = '' === $.trim(text);
|
isEmptyText = '' === $.trim(text);
|
||||||
|
@ -23,12 +23,12 @@
|
||||||
{
|
{
|
||||||
if (isHtml && !editor.__previos_signature_is_html)
|
if (isHtml && !editor.__previos_signature_is_html)
|
||||||
{
|
{
|
||||||
editor.__previos_signature = editor.__plainUtils.plainToHtml(editor.__previos_signature);
|
editor.__previos_signature = editor.__textUtils.plainToHtml(editor.__previos_signature);
|
||||||
editor.__previos_signature_is_html = true;
|
editor.__previos_signature_is_html = true;
|
||||||
}
|
}
|
||||||
else if (!isHtml && editor.__previos_signature_is_html)
|
else if (!isHtml && editor.__previos_signature_is_html)
|
||||||
{
|
{
|
||||||
editor.__previos_signature = editor.__plainUtils.htmlToPlain(editor.__previos_signature);
|
editor.__previos_signature = editor.__textUtils.htmlToPlain(editor.__previos_signature);
|
||||||
editor.__previos_signature_is_html = false;
|
editor.__previos_signature_is_html = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,13 +104,13 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ('plain' === editor.mode && editor.__plain && editor.__plainUtils)
|
if ('plain' === editor.mode && editor.__plain && editor.__textUtils)
|
||||||
{
|
{
|
||||||
if (editor.__plainUtils && editor.__plainUtils.htmlToPlain)
|
if (editor.__textUtils && editor.__textUtils.htmlToPlain)
|
||||||
{
|
{
|
||||||
if (bIsHtml)
|
if (bIsHtml)
|
||||||
{
|
{
|
||||||
sResultSignature = editor.__plainUtils.htmlToPlain(sResultSignature);
|
sResultSignature = editor.__textUtils.htmlToPlain(sResultSignature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +120,11 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (editor.__plainUtils && editor.__plainUtils.plainToHtml)
|
if (editor.__textUtils && editor.__textUtils.plainToHtml)
|
||||||
{
|
{
|
||||||
if (!bIsHtml)
|
if (!bIsHtml)
|
||||||
{
|
{
|
||||||
sResultSignature = editor.__plainUtils.plainToHtml(sResultSignature);
|
sResultSignature = editor.__textUtils.plainToHtml(sResultSignature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue