From a1b1836f8bdfa1ad21cb2d46f22153a940b2f0ac Mon Sep 17 00:00:00 2001 From: Damian Czepierga Date: Thu, 29 Mar 2012 10:51:37 +0200 Subject: [PATCH] [#1497184] by dczepierga: Style changes lost after saving --- ckeditor.module | 9 +++++++++ includes/ckeditor.page.inc | 4 ++-- includes/ckeditor.utils.js | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ckeditor.module b/ckeditor.module index c220f98..74c9122 100644 --- a/ckeditor.module +++ b/ckeditor.module @@ -196,6 +196,8 @@ function ckeditor_process_form(&$form) { } } + $field['#format'] = $format; + //No filters assigned, remove xss class if (empty($ckeditor_filters[$textarea_id])) { $field['#attributes']['class'] = preg_replace("/checkxss(1|2)/", "", $field['#attributes']['class']); @@ -469,6 +471,10 @@ function ckeditor_process_textarea($element) { return $element; } + if (!isset($element['#format'])) { + $element['#format'] = variable_get('filter_default_format', 1); + } + if (isset($processed_ids[$element['#id']])) { //statement for node preview purpose, when second textarea element with the same id is processing to add class which ckeditor behavior must process if (empty($element['#attributes']['class'])) { @@ -1067,6 +1073,9 @@ function ckeditor_process_textarea($element) { } } + //set input format for textarea + $settings[$textarea_id]['input_format'] = $element['#format']; + drupal_add_js(array('ckeditor' => array( 'theme' => $theme )), 'setting'); if (!empty($settings)) { $_SESSION['cke_get_settings'] = $settings; diff --git a/includes/ckeditor.page.inc b/includes/ckeditor.page.inc index 85e1bab..cedf06c 100644 --- a/includes/ckeditor.page.inc +++ b/includes/ckeditor.page.inc @@ -284,7 +284,7 @@ function ckeditor_filter_xss() { $GLOBALS['devel_shutdown'] = FALSE; - if (!isset($_POST['text']) || !is_string($_POST['text']) || !isset($_POST['textarea_id']) || !is_string($_POST['textarea_id']) || !isset($_POST['query']) || !is_string($_POST['query']) || !isset($_POST['theme']) || !is_string($_POST['theme']) || !isset($_POST['token']) || !drupal_valid_token($_POST['token'], 'ckeditorAjaxCall', TRUE)) { + if (!isset($_POST['text']) || !is_string($_POST['text']) || !isset($_POST['textarea_id']) || !is_string($_POST['textarea_id']) || !isset($_POST['query']) || !is_string($_POST['query']) || !isset($_POST['theme']) || !is_string($_POST['theme']) || !isset($_POST['input_format']) || !is_string($_POST['input_format']) || !isset($_POST['token']) || !drupal_valid_token($_POST['token'], 'ckeditorAjaxCall', TRUE)) { exit; } @@ -308,7 +308,7 @@ function ckeditor_filter_xss() { $filter = new stdClass(); $filter->module = strtok($module_delta, "/"); $filter->delta = strtok("/"); - $filter->format = strtok("/"); + $filter->format = (int) $_POST['input_format']; if (!module_hook($filter->module, 'filter')) { continue; diff --git a/includes/ckeditor.utils.js b/includes/ckeditor.utils.js index 6c93a8e..967f625 100644 --- a/includes/ckeditor.utils.js +++ b/includes/ckeditor.utils.js @@ -90,7 +90,7 @@ Drupal.ckeditorInit = function(textarea_id) { } Drupal.ckeditorInstance = CKEDITOR.replace(textarea_id, textarea_settings); -} +}; Drupal.ckeditorOn = function(textarea_id) { if ((typeof(Drupal.settings.ckeditor.load_timeout) == 'undefined') && (typeof(CKEDITOR.instances[textarea_id]) != 'undefined')) { @@ -133,7 +133,8 @@ Drupal.ckeditorOn = function(textarea_id) { 'token': Drupal.settings.ckeditor.ajaxToken, 'textarea_id': textarea_id, 'query': Drupal.settings.ckeditor.query, - 'theme' : Drupal.settings.ckeditor.theme + 'theme': Drupal.settings.ckeditor.theme, + 'input_format': Drupal.settings.ckeditor.settings[textarea_id].input_format }, function(text){ $("#" + textarea_id).val(text); Drupal.ckeditorInit(textarea_id); -- 1.7.9.msysgit.0