mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 22:47:03 +03:00
CRLF to LF
This commit is contained in:
parent
4468d5bd22
commit
6e0d0b3b6e
209 changed files with 23729 additions and 22109 deletions
432
vendors/ckeditor-plugins/plain/plugin.js
vendored
432
vendors/ckeditor-plugins/plain/plugin.js
vendored
|
|
@ -1,216 +1,216 @@
|
|||
|
||||
(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();
|
||||
}
|
||||
},
|
||||
toTop = function (el) {
|
||||
selectRange(el, 0);
|
||||
if (el) {
|
||||
el.scrollTop = 0;
|
||||
}
|
||||
},
|
||||
simplePlainToHtml = function (sPlain) {
|
||||
return sPlain
|
||||
.replace(/&/g, '&')
|
||||
.replace(/>/g, '>').replace(/</g, '<')
|
||||
.replace(/[\-_~]{10,}/g, '<hr />')
|
||||
.replace(/\n/g, '<br />')
|
||||
.replace(/ /g, ' ')
|
||||
;
|
||||
},
|
||||
simpleHtmlToPlain = function (sHtml) {
|
||||
|
||||
var sText = sHtml
|
||||
.replace(/[\s]+/gm, ' ')
|
||||
.replace(/<br[^>]*>/gmi, '\n')
|
||||
.replace(/<\/h[\d]>/gi, '\n')
|
||||
.replace(/<\/p>/gi, '\n\n')
|
||||
.replace(/<\/li>/gi, '\n')
|
||||
.replace(/<\/td>/gi, '\n')
|
||||
.replace(/<\/tr>/gi, '\n')
|
||||
.replace(/<\/div>/gi, '\n')
|
||||
.replace(/<blockquote[^>]*>/gmi, '\n')
|
||||
.replace(/<\/blockquote>/gi, '\n')
|
||||
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/"/gi, '"')
|
||||
.replace(/<[^>]*>/gm, '')
|
||||
;
|
||||
|
||||
sText = $('<div></div>').html(sText).text();
|
||||
|
||||
sText = sText
|
||||
.replace(/\n[ \t]+/gm, '\n')
|
||||
.replace(/[\n]{3,}/gm, '\n\n')
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<')
|
||||
.replace(/&/gi, '&')
|
||||
;
|
||||
|
||||
return sText;
|
||||
}
|
||||
;
|
||||
|
||||
CKEDITOR.plugins.add('plain', {
|
||||
lang: '',
|
||||
icons: 'plain',
|
||||
hidpi: true,
|
||||
init: function(editor)
|
||||
{
|
||||
if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.__textUtils = {
|
||||
plainToHtml: function(data) {
|
||||
return window.rainloop_Utils_plainToHtml ?
|
||||
window.rainloop_Utils_plainToHtml(data, true) : simplePlainToHtml(data);
|
||||
},
|
||||
htmlToPlain: function(data) {
|
||||
return window.rainloop_Utils_htmlToPlain ?
|
||||
window.rainloop_Utils_htmlToPlain(data, true) : simpleHtmlToPlain(data);
|
||||
}
|
||||
};
|
||||
|
||||
var plain = CKEDITOR.plugins.plain;
|
||||
editor.addMode('plain', function(callback) {
|
||||
|
||||
var
|
||||
contentsSpace = editor.ui.space('contents'),
|
||||
textarea = contentsSpace.getDocument().createElement('textarea')
|
||||
;
|
||||
|
||||
textarea.setStyles(
|
||||
CKEDITOR.tools.extend({
|
||||
width: CKEDITOR.env.ie7Compat ? '99%' : '100%',
|
||||
height: '100%',
|
||||
resize: 'none',
|
||||
outline: 'none',
|
||||
'text-align': 'left'
|
||||
},
|
||||
CKEDITOR.tools.cssVendorPrefix('tab-size', 4)))
|
||||
;
|
||||
|
||||
textarea.setAttribute('dir', 'ltr');
|
||||
textarea.addClass('cke_plain');
|
||||
|
||||
CKEDITOR.plugins.clipboard.preventDefaultDropOnElement(textarea);
|
||||
|
||||
contentsSpace.append(textarea);
|
||||
|
||||
var editable = editor.editable(new plainEditable(editor, textarea));
|
||||
|
||||
editable.setData(editor.getData(1));
|
||||
editor.__plain = editable;
|
||||
editor.__textarea = textarea.$;
|
||||
|
||||
if (CKEDITOR.env.ie) {
|
||||
editable.attachListener(editor, 'resize', onResize, editable);
|
||||
editable.attachListener(CKEDITOR.document.getWindow(), 'resize', onResize, editable);
|
||||
CKEDITOR.tools.setTimeout(onResize, 0, editable);
|
||||
}
|
||||
|
||||
editor.fire('ariaWidget', this);
|
||||
callback();
|
||||
});
|
||||
|
||||
editor.addCommand('plain', plain.commands.plain);
|
||||
|
||||
if (editor.ui.addButton) {
|
||||
editor.ui.addButton('plain', {
|
||||
label: window.rl && window.rl.i18n ? window.rl.i18n('EDITOR/TEXT_SWITCHER_PLAINT_TEXT') : 'Plain',
|
||||
command: 'plain',
|
||||
toolbar: 'spec,10'
|
||||
});
|
||||
}
|
||||
|
||||
editor.on('mode', function() {
|
||||
editor.getCommand('plain').setState(editor.mode === 'plain' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF);
|
||||
editor.editable().addClass('cke_enable_context_menu');
|
||||
|
||||
editor.focus();
|
||||
|
||||
if (editor.mode === 'plain') {
|
||||
toTop(editor.__textarea);
|
||||
}
|
||||
});
|
||||
|
||||
function onResize() {
|
||||
this.hide();
|
||||
this.setStyle('height', this.getParent().$.clientHeight + 'px');
|
||||
this.setStyle('width', this.getParent().$.clientWidth + 'px');
|
||||
this.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var plainEditable = CKEDITOR.tools.createClass({
|
||||
base: CKEDITOR.editable,
|
||||
proto: {
|
||||
setData: function(data) {
|
||||
this.setValue(this.editor.__textUtils.htmlToPlain(data));
|
||||
this.editor.fire('dataReady');
|
||||
},
|
||||
setRawData: function(data) {
|
||||
this.setValue(data);
|
||||
this.editor.fire('dataReady');
|
||||
},
|
||||
getData: function() {
|
||||
return this.editor.__textUtils.plainToHtml(this.getValue());
|
||||
},
|
||||
getRawData: function() {
|
||||
return this.getValue();
|
||||
},
|
||||
insertHtml: function() {},
|
||||
insertElement: function() {},
|
||||
insertText: function() {},
|
||||
setReadOnly: function( isReadOnly ) {
|
||||
this[(isReadOnly ? 'set' : 'remove') + 'Attribute' ]('readOnly', 'readonly');
|
||||
},
|
||||
detach: function() {
|
||||
plainEditable.baseProto.detach.call( this );
|
||||
this.clearCustomData();
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CKEDITOR.plugins.plain = {
|
||||
commands: {
|
||||
plain: {
|
||||
modes: {
|
||||
wysiwyg: 1, plain: 1
|
||||
},
|
||||
editorFocus: true,
|
||||
readOnly: false,
|
||||
exec: function(editor) {
|
||||
if (editor.mode === 'wysiwyg') {
|
||||
editor.fire('saveSnapshot');
|
||||
}
|
||||
editor.getCommand('plain').setState(CKEDITOR.TRISTATE_DISABLED);
|
||||
editor.setMode(editor.mode === 'plain' ? 'wysiwyg' : 'plain');
|
||||
},
|
||||
canUndo: false
|
||||
}
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
(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();
|
||||
}
|
||||
},
|
||||
toTop = function (el) {
|
||||
selectRange(el, 0);
|
||||
if (el) {
|
||||
el.scrollTop = 0;
|
||||
}
|
||||
},
|
||||
simplePlainToHtml = function (sPlain) {
|
||||
return sPlain
|
||||
.replace(/&/g, '&')
|
||||
.replace(/>/g, '>').replace(/</g, '<')
|
||||
.replace(/[\-_~]{10,}/g, '<hr />')
|
||||
.replace(/\n/g, '<br />')
|
||||
.replace(/ /g, ' ')
|
||||
;
|
||||
},
|
||||
simpleHtmlToPlain = function (sHtml) {
|
||||
|
||||
var sText = sHtml
|
||||
.replace(/[\s]+/gm, ' ')
|
||||
.replace(/<br[^>]*>/gmi, '\n')
|
||||
.replace(/<\/h[\d]>/gi, '\n')
|
||||
.replace(/<\/p>/gi, '\n\n')
|
||||
.replace(/<\/li>/gi, '\n')
|
||||
.replace(/<\/td>/gi, '\n')
|
||||
.replace(/<\/tr>/gi, '\n')
|
||||
.replace(/<\/div>/gi, '\n')
|
||||
.replace(/<blockquote[^>]*>/gmi, '\n')
|
||||
.replace(/<\/blockquote>/gi, '\n')
|
||||
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/"/gi, '"')
|
||||
.replace(/<[^>]*>/gm, '')
|
||||
;
|
||||
|
||||
sText = $('<div></div>').html(sText).text();
|
||||
|
||||
sText = sText
|
||||
.replace(/\n[ \t]+/gm, '\n')
|
||||
.replace(/[\n]{3,}/gm, '\n\n')
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<')
|
||||
.replace(/&/gi, '&')
|
||||
;
|
||||
|
||||
return sText;
|
||||
}
|
||||
;
|
||||
|
||||
CKEDITOR.plugins.add('plain', {
|
||||
lang: '',
|
||||
icons: 'plain',
|
||||
hidpi: true,
|
||||
init: function(editor)
|
||||
{
|
||||
if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.__textUtils = {
|
||||
plainToHtml: function(data) {
|
||||
return window.rainloop_Utils_plainToHtml ?
|
||||
window.rainloop_Utils_plainToHtml(data, true) : simplePlainToHtml(data);
|
||||
},
|
||||
htmlToPlain: function(data) {
|
||||
return window.rainloop_Utils_htmlToPlain ?
|
||||
window.rainloop_Utils_htmlToPlain(data, true) : simpleHtmlToPlain(data);
|
||||
}
|
||||
};
|
||||
|
||||
var plain = CKEDITOR.plugins.plain;
|
||||
editor.addMode('plain', function(callback) {
|
||||
|
||||
var
|
||||
contentsSpace = editor.ui.space('contents'),
|
||||
textarea = contentsSpace.getDocument().createElement('textarea')
|
||||
;
|
||||
|
||||
textarea.setStyles(
|
||||
CKEDITOR.tools.extend({
|
||||
width: CKEDITOR.env.ie7Compat ? '99%' : '100%',
|
||||
height: '100%',
|
||||
resize: 'none',
|
||||
outline: 'none',
|
||||
'text-align': 'left'
|
||||
},
|
||||
CKEDITOR.tools.cssVendorPrefix('tab-size', 4)))
|
||||
;
|
||||
|
||||
textarea.setAttribute('dir', 'ltr');
|
||||
textarea.addClass('cke_plain');
|
||||
|
||||
CKEDITOR.plugins.clipboard.preventDefaultDropOnElement(textarea);
|
||||
|
||||
contentsSpace.append(textarea);
|
||||
|
||||
var editable = editor.editable(new plainEditable(editor, textarea));
|
||||
|
||||
editable.setData(editor.getData(1));
|
||||
editor.__plain = editable;
|
||||
editor.__textarea = textarea.$;
|
||||
|
||||
if (CKEDITOR.env.ie) {
|
||||
editable.attachListener(editor, 'resize', onResize, editable);
|
||||
editable.attachListener(CKEDITOR.document.getWindow(), 'resize', onResize, editable);
|
||||
CKEDITOR.tools.setTimeout(onResize, 0, editable);
|
||||
}
|
||||
|
||||
editor.fire('ariaWidget', this);
|
||||
callback();
|
||||
});
|
||||
|
||||
editor.addCommand('plain', plain.commands.plain);
|
||||
|
||||
if (editor.ui.addButton) {
|
||||
editor.ui.addButton('plain', {
|
||||
label: window.rl && window.rl.i18n ? window.rl.i18n('EDITOR/TEXT_SWITCHER_PLAINT_TEXT') : 'Plain',
|
||||
command: 'plain',
|
||||
toolbar: 'spec,10'
|
||||
});
|
||||
}
|
||||
|
||||
editor.on('mode', function() {
|
||||
editor.getCommand('plain').setState(editor.mode === 'plain' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF);
|
||||
editor.editable().addClass('cke_enable_context_menu');
|
||||
|
||||
editor.focus();
|
||||
|
||||
if (editor.mode === 'plain') {
|
||||
toTop(editor.__textarea);
|
||||
}
|
||||
});
|
||||
|
||||
function onResize() {
|
||||
this.hide();
|
||||
this.setStyle('height', this.getParent().$.clientHeight + 'px');
|
||||
this.setStyle('width', this.getParent().$.clientWidth + 'px');
|
||||
this.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var plainEditable = CKEDITOR.tools.createClass({
|
||||
base: CKEDITOR.editable,
|
||||
proto: {
|
||||
setData: function(data) {
|
||||
this.setValue(this.editor.__textUtils.htmlToPlain(data));
|
||||
this.editor.fire('dataReady');
|
||||
},
|
||||
setRawData: function(data) {
|
||||
this.setValue(data);
|
||||
this.editor.fire('dataReady');
|
||||
},
|
||||
getData: function() {
|
||||
return this.editor.__textUtils.plainToHtml(this.getValue());
|
||||
},
|
||||
getRawData: function() {
|
||||
return this.getValue();
|
||||
},
|
||||
insertHtml: function() {},
|
||||
insertElement: function() {},
|
||||
insertText: function() {},
|
||||
setReadOnly: function( isReadOnly ) {
|
||||
this[(isReadOnly ? 'set' : 'remove') + 'Attribute' ]('readOnly', 'readonly');
|
||||
},
|
||||
detach: function() {
|
||||
plainEditable.baseProto.detach.call( this );
|
||||
this.clearCustomData();
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CKEDITOR.plugins.plain = {
|
||||
commands: {
|
||||
plain: {
|
||||
modes: {
|
||||
wysiwyg: 1, plain: 1
|
||||
},
|
||||
editorFocus: true,
|
||||
readOnly: false,
|
||||
exec: function(editor) {
|
||||
if (editor.mode === 'wysiwyg') {
|
||||
editor.fire('saveSnapshot');
|
||||
}
|
||||
editor.getCommand('plain').setState(CKEDITOR.TRISTATE_DISABLED);
|
||||
editor.setMode(editor.mode === 'plain' ? 'wysiwyg' : 'plain');
|
||||
},
|
||||
canUndo: false
|
||||
}
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
|
|
|||
282
vendors/ckeditor-plugins/signature/plugin.js
vendored
282
vendors/ckeditor-plugins/signature/plugin.js
vendored
|
|
@ -1,141 +1,141 @@
|
|||
|
||||
(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.__textUtils.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.__textUtils.plainToHtml(editor.__previos_signature);
|
||||
editor.__previos_signature_is_html = true;
|
||||
}
|
||||
else if (!isHtml && editor.__previos_signature_is_html)
|
||||
{
|
||||
editor.__previos_signature = editor.__textUtils.htmlToPlain(editor.__previos_signature);
|
||||
editor.__previos_signature_is_html = false;
|
||||
}
|
||||
|
||||
skipInsert = false;
|
||||
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 = true;
|
||||
}
|
||||
return c ? '' : all;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var textLen = text.length;
|
||||
text = text
|
||||
.replace('' + editor.__previos_signature, '')
|
||||
.replace('' + editor.__previos_signature, '');
|
||||
|
||||
if (textLen === text.length)
|
||||
{
|
||||
skipInsert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipInsert)
|
||||
{
|
||||
signature = newLine + newLine + (isHtml ? '<signature>' : '') + signature + (isHtml ? '</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) {
|
||||
|
||||
if (cfg && cfg.clearCache)
|
||||
{
|
||||
editor.__previos_signature = undefined;
|
||||
editor.__previos_signature_is_html = undefined;
|
||||
return true;
|
||||
}
|
||||
|
||||
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.__textUtils)
|
||||
{
|
||||
if (editor.__textUtils && editor.__textUtils.htmlToPlain)
|
||||
{
|
||||
if (bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__textUtils.htmlToPlain(sResultSignature);
|
||||
}
|
||||
}
|
||||
|
||||
editor.__plain.setRawData(
|
||||
rl_signature_replacer(editor, editor.__plain.getRawData(), sResultSignature, false, bInsertBefore));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (editor.__textUtils && editor.__textUtils.plainToHtml)
|
||||
{
|
||||
if (!bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__textUtils.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.__textUtils.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.__textUtils.plainToHtml(editor.__previos_signature);
|
||||
editor.__previos_signature_is_html = true;
|
||||
}
|
||||
else if (!isHtml && editor.__previos_signature_is_html)
|
||||
{
|
||||
editor.__previos_signature = editor.__textUtils.htmlToPlain(editor.__previos_signature);
|
||||
editor.__previos_signature_is_html = false;
|
||||
}
|
||||
|
||||
skipInsert = false;
|
||||
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 = true;
|
||||
}
|
||||
return c ? '' : all;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var textLen = text.length;
|
||||
text = text
|
||||
.replace('' + editor.__previos_signature, '')
|
||||
.replace('' + editor.__previos_signature, '');
|
||||
|
||||
if (textLen === text.length)
|
||||
{
|
||||
skipInsert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipInsert)
|
||||
{
|
||||
signature = newLine + newLine + (isHtml ? '<signature>' : '') + signature + (isHtml ? '</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) {
|
||||
|
||||
if (cfg && cfg.clearCache)
|
||||
{
|
||||
editor.__previos_signature = undefined;
|
||||
editor.__previos_signature_is_html = undefined;
|
||||
return true;
|
||||
}
|
||||
|
||||
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.__textUtils)
|
||||
{
|
||||
if (editor.__textUtils && editor.__textUtils.htmlToPlain)
|
||||
{
|
||||
if (bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__textUtils.htmlToPlain(sResultSignature);
|
||||
}
|
||||
}
|
||||
|
||||
editor.__plain.setRawData(
|
||||
rl_signature_replacer(editor, editor.__plain.getRawData(), sResultSignature, false, bInsertBefore));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (editor.__textUtils && editor.__textUtils.plainToHtml)
|
||||
{
|
||||
if (!bIsHtml)
|
||||
{
|
||||
sResultSignature = editor.__textUtils.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