(function() {
var
simplePlainToHtml = function (sPlain) {
return sPlain
.replace(/&/g, '&')
.replace(/>/g, '>').replace(/')
.replace(/\n/g, '
')
.replace(/ /g, ' ')
;
},
simpleHtmlToPlain = function (sHtml) {
var sText = sHtml
.replace(/[\s]+/gm, ' ')
.replace(/
]*>/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(/
]*>/gmi, '\n') .replace(/<\/blockquote>/gi, '\n') .replace(/
]*>/gmi, '\n_______________________________\n\n') .replace(/ /gi, ' ') .replace(/"/gi, '"') .replace(/<[^>]*>/gm, '') ; sText = $('').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.__plainUtils = { 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; // Having to make