diff --git a/includes/ckeditor.utils.js b/includes/ckeditor.utils.js
index 90ee058..6787005 100644
--- a/includes/ckeditor.utils.js
+++ b/includes/ckeditor.utils.js
@@ -9,6 +9,9 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
Drupal.ckeditor = (typeof(CKEDITOR) != 'undefined');
Drupal.ckeditor_ver = false;
+ // State of textareas.
+ Drupal.ckeditorInitialized = {};
+
Drupal.ckeditorToggle = function(textarea_ids, TextTextarea, TextRTE){
if (!CKEDITOR.env.isCompatible) {
return;
@@ -145,6 +148,12 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
Drupal.ckeditorOn = function(textarea_id, run_filter) {
+ // Convert \n to
in case it is not done before.
+ if (typeof(Drupal.ckeditorInitialized[textarea_id]) == 'undefined') {
+ Drupal.ckeditorInitialized[textarea_id] = true;
+ $("#" + textarea_id).val(Drupal.ckeditorLinebreakConvert($("#" + textarea_id).val()));
+ }
+
run_filter = typeof(run_filter) != 'undefined' ? run_filter : true;
if (typeof(textarea_id) == 'undefined' || textarea_id.length == 0 || $("#" + textarea_id).length == 0) {
@@ -259,6 +268,17 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
};
/**
+ * Converts \n to
+ * It in no way tries to compete with Line break converter filter
+ */
+ Drupal.ckeditorLinebreakConvert = function(text) {
+ if (!text.match(/<(p|br)\s*\/?>/) && text) {
+ text = '
' + text.replace(/\r\n|\n\r/g, '\n').replace(/\n\n/g, '
').replace(/\n/g, '
') + '