CK Editor styles not working - php

I am using CK Editor 4.5 as text editor in my form.
I have pasted my html code including "style" tags to the editor. But when saving the data it automatically removes the style tags from the code.
I have tried to turn off Automatic Content Filtering by add this to config file
config.allowedContent = true;
But it still remove the style tags. The editor also removes the text color, text align styles added.
How can i add style tags using CK Editor.?

My apologies. Its not the issue of ckeditor.
I am using codeigniter for server scripts. It removes inline style on form submit.

I'm using Rails and met the same issue, it turns out that I'm using sanitize to render content, which will remove the inline styles.

Related

Ckeditor not saving button tag

When I enter save html through ckeditor I miss tag from the html content. Is there any ckeditor configuration I have to do to allow html tags such as inside html content? Thanks.
You have to use the allowedContent property when instantiating ckeditor to allow specific tags, or allowedContent: true to allow everything
https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-allowedContent
Either using config.js, or in-page configuration for the specified textarea:
https://docs.ckeditor.com/ckeditor4/latest/guide/dev_configuration.html
In my case (I am using a Symfony ckeditor bundle) I also can set it via bundle configuration inside config.yml.

Codeigniter ckeditor add span tag

I am using ckeditor for codeigniter project, when i try to add span tags it's getting replaced with p tag.
Is there any way to add span tag using ckeditor?
Do you have XSS filter turned on in the config file? It removes some "illegal" tags from your POST input.
Try this

CKEditor outputting text doesn't match input when using htmlspecialchars_decode(stripslashes($variable))

I'm trying to use CKEditor to input rich text into my database, which works except the formatting is not the same when I try to output the rich text the user entered. The position of elements such as pictures is incorrect.
I currently have the following code:
Input:
$pitch = htmlspecialchars($_POST['editor1']);
$sql = mysql_query("UPDATE projects SET pitch='$pitch' WHERE id='$proj_id'");
Output:
$pitch = htmlspecialchars_decode(stripslashes($pitch));
The result is then echoed back which creates the incorrect formatting.
Does anyone know what I'm doing wrong?
This has nothing to do with PHP.
Contents of the framed editor (which you use) is styled by the contents.css file which you can find in the main CKEditor directory. However, this stylesheet is not used on your page, so content created in editor is not styled by the same rules.
The correct approach is - style content on your site and then copy (or somehow reuse, e.g. by setting config.bodyClass and config.contentsCss) these styles in editor contents.
Remember, that you also need to set styles available in styles drop down. They are by default configured as for the sample, but when you'll change available styles, you need to update styles.js file too.

htmlpurifier remove inline css

I am using htmlpurifier to clean up user content. I am trying to remove inline style attributes like
<div style="float:left">some text</div>
I want to remove the whole style attribute.
How to do it using htmlpurifier?
You can tweak the AllowedProperties configuration by passing it an array of valid css attributes that should not be removed (white-list approach).
However, the following should remove all css attributes
$config->set('CSS.AllowedProperties', array());
See this online demo of purifying your input html

Applying css to a text while showing in tinymce editor

I have a xml file with content
<ul>
<li><info>Some text here</info></li>
</ul>
I have parsed the xml file and show this in a page.info is a css class.In the page the text showing with css.When i am editing the content in tinymce editor how i can apply the css in the editor.In the editor the text is showing like <div mce_name="info">CSS text formatting </div>Thanks in advance.
Add the styles to the tinymce style sheet, they should appear in 'styles' the drop down.

Categories