mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Fix signature adding
This commit is contained in:
parent
b8e0303fc4
commit
6b1fd1239f
3 changed files with 37 additions and 14 deletions
|
|
@ -58,10 +58,23 @@ class HtmlEditor
|
||||||
return this.editor ? 'wysiwyg' === this.editor.mode : false;
|
return this.editor ? 'wysiwyg' === this.editor.mode : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clearCachedSignature() {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
this.editor.execCommand('insertSignature', {
|
||||||
|
clearCache: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} signature
|
* @param {string} signature
|
||||||
* @param {bool} html
|
* @param {bool} html
|
||||||
* @param {bool} insertBefore
|
* @param {bool} insertBefore
|
||||||
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
setSignature(signature, html, insertBefore) {
|
setSignature(signature, html, insertBefore) {
|
||||||
if (this.editor)
|
if (this.editor)
|
||||||
|
|
@ -163,6 +176,8 @@ class HtmlEditor
|
||||||
setHtml(html, focus) {
|
setHtml(html, focus) {
|
||||||
if (this.editor && this.__inited)
|
if (this.editor && this.__inited)
|
||||||
{
|
{
|
||||||
|
this.clearCachedSignature();
|
||||||
|
|
||||||
this.modeToggle(true);
|
this.modeToggle(true);
|
||||||
|
|
||||||
html = html.replace(/<p[^>]*><\/p>/ig, '');
|
html = html.replace(/<p[^>]*><\/p>/ig, '');
|
||||||
|
|
@ -193,6 +208,8 @@ class HtmlEditor
|
||||||
setPlain(plain, focus) {
|
setPlain(plain, focus) {
|
||||||
if (this.editor && this.__inited)
|
if (this.editor && this.__inited)
|
||||||
{
|
{
|
||||||
|
this.clearCachedSignature();
|
||||||
|
|
||||||
this.modeToggle(false);
|
this.modeToggle(false);
|
||||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -869,13 +869,13 @@ class ComposePopupView extends AbstractViewNext
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSignatureFromIdentity(oIdentity) {
|
setSignatureFromIdentity(identity) {
|
||||||
if (oIdentity)
|
if (identity)
|
||||||
{
|
{
|
||||||
this.editor((editor) => {
|
this.editor((editor) => {
|
||||||
let
|
let
|
||||||
isHtml = false,
|
isHtml = false,
|
||||||
signature = oIdentity.signature();
|
signature = identity.signature();
|
||||||
|
|
||||||
if ('' !== signature)
|
if ('' !== signature)
|
||||||
{
|
{
|
||||||
|
|
@ -886,7 +886,7 @@ class ComposePopupView extends AbstractViewNext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.setSignature(this.converSignature(signature), isHtml, !!oIdentity.signatureInsertBefore());
|
editor.setSignature(this.converSignature(signature), isHtml, !!identity.signatureInsertBefore());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
vendors/ckeditor-plugins/signature/plugin.js
vendored
24
vendors/ckeditor-plugins/signature/plugin.js
vendored
|
|
@ -32,14 +32,14 @@
|
||||||
editor.__previos_signature_is_html = false;
|
editor.__previos_signature_is_html = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
skipInsert = true;
|
skipInsert = false;
|
||||||
if (isHtml)
|
if (isHtml)
|
||||||
{
|
{
|
||||||
var clearSig = clearHtmlLine(editor.__previos_signature);
|
var clearSig = clearHtmlLine(editor.__previos_signature);
|
||||||
text = text.replace(/<signature>([\s\S]*)<\/signature>/igm, function(all){
|
text = text.replace(/<signature>([\s\S]*)<\/signature>/igm, function(all){
|
||||||
var c = clearSig === clearHtmlLine(all);
|
var c = clearSig === clearHtmlLine(all);
|
||||||
if (c) {
|
if (!c) {
|
||||||
skipInsert = false;
|
skipInsert = true;
|
||||||
}
|
}
|
||||||
return c ? '' : all;
|
return c ? '' : all;
|
||||||
});
|
});
|
||||||
|
|
@ -51,9 +51,9 @@
|
||||||
.replace('' + editor.__previos_signature, '')
|
.replace('' + editor.__previos_signature, '')
|
||||||
.replace('' + editor.__previos_signature, '');
|
.replace('' + editor.__previos_signature, '');
|
||||||
|
|
||||||
if (textLen > text.length)
|
if (textLen === text.length)
|
||||||
{
|
{
|
||||||
skipInsert = false;
|
skipInsert = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,15 +81,21 @@
|
||||||
CKEDITOR.plugins.add('signature', {
|
CKEDITOR.plugins.add('signature', {
|
||||||
init: function(editor) {
|
init: function(editor) {
|
||||||
editor.addCommand('insertSignature', {
|
editor.addCommand('insertSignature', {
|
||||||
modes: { wysiwyg: 1, plain: 1 },
|
modes: {wysiwyg: 1, plain: 1},
|
||||||
exec: function (editor, cfg)
|
exec: function(editor, cfg) {
|
||||||
|
|
||||||
|
if (cfg && cfg.clearCache)
|
||||||
{
|
{
|
||||||
|
editor.__previos_signature = undefined;
|
||||||
|
editor.__previos_signature_is_html = undefined;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var
|
var
|
||||||
bIsHtml = false,
|
bIsHtml = false,
|
||||||
bInsertBefore = false,
|
bInsertBefore = false,
|
||||||
sSignature = '',
|
sSignature = '',
|
||||||
sResultSignature = ''
|
sResultSignature = '';
|
||||||
;
|
|
||||||
|
|
||||||
if (cfg)
|
if (cfg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue