mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
es5 -> es2015 (last stage)
Signature plugin fixes Add view decorator A large number of fixes
This commit is contained in:
parent
e88c193334
commit
17669b7be0
153 changed files with 21193 additions and 21115 deletions
260
vendors/ckeditor-plugins/signature/plugin.js
vendored
260
vendors/ckeditor-plugins/signature/plugin.js
vendored
|
|
@ -1,121 +1,139 @@
|
|||
|
||||
(function (CKEDITOR, $, undefined) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var rl_signature_replacer = function (editor, sText, sSignature, bHtml, bInsertBefore)
|
||||
{
|
||||
if (!bHtml)
|
||||
{
|
||||
sText = sText
|
||||
.replace(/\u200C([\s\S]*)\u200C/g, '\u0002$1\u0002')
|
||||
.replace(/\u200C/g, '')
|
||||
;
|
||||
}
|
||||
|
||||
var
|
||||
sP = '~~~~@~~~~',
|
||||
bEmptyText = false,
|
||||
sNewLine = (bHtml ? '<br />' : "\n")
|
||||
;
|
||||
|
||||
sText = sText.replace(/\u0002([\s\S]*)\u0002/gm, sP + '$1' + sP);
|
||||
|
||||
if (editor.__previos_signature)
|
||||
{
|
||||
sText = sText
|
||||
.replace(sP + editor.__previos_signature + sP, '')
|
||||
.replace(sP + editor.__previos_signature + sP, '')
|
||||
.replace(sP + editor.__previos_signature + sP, '')
|
||||
;
|
||||
}
|
||||
|
||||
sText = sText.replace(sP, '').replace(sP, '').replace(sP, '').replace(sP, '');
|
||||
|
||||
bEmptyText = '' === $.trim(sText);
|
||||
if (!bEmptyText && bHtml)
|
||||
{
|
||||
bEmptyText = '' !== $.trim(editor.__plainUtils.htmlToPlain(sText));
|
||||
}
|
||||
|
||||
if (bInsertBefore)
|
||||
{
|
||||
sText = "\u0002" + sSignature + (bEmptyText ? '' : sNewLine) + "\u0002" + sText;
|
||||
editor.__previos_signature = sSignature + (bEmptyText ? '' : sNewLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
sText = sText + "\u0002" + (bEmptyText ? '' : sNewLine) + sSignature + "\u0002";
|
||||
editor.__previos_signature = (bEmptyText ? '' : sNewLine) + sSignature;
|
||||
}
|
||||
|
||||
if (!bHtml)
|
||||
{
|
||||
sText = sText
|
||||
.replace(/\u0002([\s\S]*)\u0002/g, '\u200C$1\u200C')
|
||||
.replace(/\u0002/g, '')
|
||||
;
|
||||
}
|
||||
|
||||
return sText;
|
||||
};
|
||||
|
||||
CKEDITOR.plugins.add('signature', {
|
||||
init: function(editor) {
|
||||
editor.addCommand('insertSignature', {
|
||||
modes: { wysiwyg: 1, plain: 1 },
|
||||
exec: function (editor, cfg)
|
||||
{
|
||||
var
|
||||
bIsHtml = false,
|
||||
bInsertBefore = false,
|
||||
sSignature = '',
|
||||
sResultSignature = ''
|
||||
;
|
||||
|
||||
if (cfg)
|
||||
{
|
||||
bIsHtml = undefined === cfg.isHtml ? false : !!cfg.isHtml;
|
||||
bInsertBefore = undefined === cfg.insertBefore ? false : !!cfg.insertBefore;
|
||||
sSignature = undefined === cfg.signature ? '' : cfg.signature;
|
||||
}
|
||||
|
||||
sResultSignature = sSignature;
|
||||
|
||||
try
|
||||
{
|
||||
if ('plain' === editor.mode && editor.__plain && editor.__plainUtils)
|
||||
{
|
||||
if (editor.__plainUtils && editor.__plainUtils.htmlToPlain)
|
||||
{
|
||||
if (bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__plainUtils.htmlToPlain(sResultSignature);
|
||||
}
|
||||
}
|
||||
|
||||
editor.__plain.setRawData(
|
||||
rl_signature_replacer(editor, editor.__plain.getRawData(), sResultSignature, false, bInsertBefore));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (editor.__plainUtils && editor.__plainUtils.plainToHtml)
|
||||
{
|
||||
if (!bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__plainUtils.plainToHtml(sResultSignature);
|
||||
}
|
||||
}
|
||||
|
||||
editor.setData(
|
||||
rl_signature_replacer(editor, editor.getData(), sResultSignature, true, bInsertBefore));
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}(CKEDITOR, $));
|
||||
|
||||
(function(CKEDITOR, $, undefined) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var rl_signature_replacer = function(editor, text, signature, isHtml, insertBefore) {
|
||||
|
||||
var
|
||||
skipInsert = false,
|
||||
isEmptyText = false,
|
||||
newLine = (isHtml ? '<br />' : "\n"),
|
||||
clearHtmlLine = function(html) {
|
||||
return $.trim(editor.__plainUtils.htmlToPlain(html));
|
||||
};
|
||||
|
||||
isEmptyText = '' === $.trim(text);
|
||||
if (!isEmptyText && isHtml)
|
||||
{
|
||||
isEmptyText = '' === clearHtmlLine(text);
|
||||
}
|
||||
|
||||
if (editor.__previos_signature && !isEmptyText)
|
||||
{
|
||||
if (isHtml && !editor.__previos_signature_is_html)
|
||||
{
|
||||
editor.__previos_signature = editor.__plainUtils.plainToHtml(editor.__previos_signature);
|
||||
editor.__previos_signature_is_html = true;
|
||||
}
|
||||
else if (!isHtml && editor.__previos_signature_is_html)
|
||||
{
|
||||
editor.__previos_signature = editor.__plainUtils.htmlToPlain(editor.__previos_signature);
|
||||
editor.__previos_signature_is_html = false;
|
||||
}
|
||||
|
||||
skipInsert = true;
|
||||
if (isHtml)
|
||||
{
|
||||
var clearSig = clearHtmlLine(editor.__previos_signature);
|
||||
text = text.replace(/<signature>([\s\S]*)<\/signature>/igm, function(all){
|
||||
var c = clearSig === clearHtmlLine(all);
|
||||
if (c) {
|
||||
skipInsert = false;
|
||||
}
|
||||
return c ? '' : all;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var textLen = text.length;
|
||||
text = text
|
||||
.replace('' + editor.__previos_signature, '')
|
||||
.replace('' + editor.__previos_signature, '');
|
||||
|
||||
if (textLen > text.length)
|
||||
{
|
||||
skipInsert = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipInsert)
|
||||
{
|
||||
signature = insertBefore ? signature + (isEmptyText ? '' : newLine) : (isEmptyText ? '' : newLine) + signature;
|
||||
if (isHtml)
|
||||
{
|
||||
signature = '<signature>' + signature + '</signature>';
|
||||
}
|
||||
|
||||
text = insertBefore ? signature + text : text + signature;
|
||||
|
||||
if (10 < signature.length)
|
||||
{
|
||||
editor.__previos_signature = signature;
|
||||
editor.__previos_signature_is_html = isHtml;
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
CKEDITOR.plugins.add('signature', {
|
||||
init: function(editor) {
|
||||
editor.addCommand('insertSignature', {
|
||||
modes: { wysiwyg: 1, plain: 1 },
|
||||
exec: function (editor, cfg)
|
||||
{
|
||||
var
|
||||
bIsHtml = false,
|
||||
bInsertBefore = false,
|
||||
sSignature = '',
|
||||
sResultSignature = ''
|
||||
;
|
||||
|
||||
if (cfg)
|
||||
{
|
||||
bIsHtml = undefined === cfg.isHtml ? false : !!cfg.isHtml;
|
||||
bInsertBefore = undefined === cfg.insertBefore ? false : !!cfg.insertBefore;
|
||||
sSignature = undefined === cfg.signature ? '' : cfg.signature;
|
||||
}
|
||||
|
||||
sResultSignature = sSignature;
|
||||
|
||||
try
|
||||
{
|
||||
if ('plain' === editor.mode && editor.__plain && editor.__plainUtils)
|
||||
{
|
||||
if (editor.__plainUtils && editor.__plainUtils.htmlToPlain)
|
||||
{
|
||||
if (bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__plainUtils.htmlToPlain(sResultSignature);
|
||||
}
|
||||
}
|
||||
|
||||
editor.__plain.setRawData(
|
||||
rl_signature_replacer(editor, editor.__plain.getRawData(), sResultSignature, false, bInsertBefore));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (editor.__plainUtils && editor.__plainUtils.plainToHtml)
|
||||
{
|
||||
if (!bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__plainUtils.plainToHtml(sResultSignature);
|
||||
}
|
||||
}
|
||||
|
||||
editor.setData(
|
||||
rl_signature_replacer(editor, editor.getData(), sResultSignature, true, bInsertBefore));
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}(CKEDITOR, $));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue