I have been using CKEditor for some time and it has worked great. I've pretty much gotten rid of any problems that ive had but this one i cant seem to figure out. When i add inline attributes to elements for instance style = "color: #ff0;"
on a <p></p>
tag they are stripped out when i switch from wysiwyg to source view. No saving or submission is done and ckeditor is has been added to my site which is my own script. Any ideas as to what would cause this. All of the search results i can find correspond to this happening in Drupal but Drupal seems to be the problem not the editor in all instances. Thanks again!
This means that inline editors ignore default CKEditor content styles provided through the CKEDITOR.config.contentsCss configuration option and use the styles from the page that CKEditor is rendered on. Inline Editing is enabled directly on HTML elements through the HTML5 contenteditable attribute.
When you call the CKEDITOR.inline method on a <textarea>, an additional <div> element with inline editing enabled will replace the original <textarea>. There is also an optional Div Editing Area plugin that allows to mimic the classic, <iframe> -based editor’s UI with inline editing.
The command for the placeholder feature will insert a <placeholder> element (if allowed by the schema) at the selection. The command will accept the options.value parameter (other CKEditor 5 commands also use this pattern) to set the placeholder name. Import the created command and add it to the editor commands:
Go to "Admin >> Configuration >> CKEditor"; under Profiles, choose your profile (e.g. Full). Edit that profile, and on "Advanced Options >> Custom JavaScript configuration" add config.allowedContent = true;. Show activity on this post. Since CKEditor v4.1, you can do this in config.js of CKEditor:
It feels like you're using CKEditor 4.1+ that comes with Advanced Content Filter (ACF). If so, you need to specify config.allowedContent
and configure it to get your things working. You may also be interested in config.extraAllowedContent
.
See this answer for more details.
For anyone looking for a simple sample on how to enabled additional markup in CKEditor without disabling ACF completely, here is a short snippet:
CKEDITOR.replace( 'editor1', {
extraAllowedContent: 'style;*[id,rel](*){*}'
} );
extraAllowedContent here enables the <style>
element, allows two additional attributes (in square brackets) for all (*
is a wildcard) already allowed elements, allows usage of any class names (*)
for them and allows usage of any inline styles {*}
hi you can stop ACF easily . by default your configaration is---
function ckeditor($name,$value='',$height=300){
return '<textarea name="'.addslashes($name).'">'.htmlspecialchars($value).'</textarea>
<script>$(function(){CKEDITOR.replace("'.addslashes($name).'",{});});</script>';
}
just add this in the curly brackets:
allowedContent: true
now your configuration will be:
function ckeditor($name,$value='',$height=300){
return '<textarea name="'.addslashes($name).'">'.htmlspecialchars($value).'</textarea>
<script>$(function(){CKEDITOR.replace("'.addslashes($name).'",{allowedContent: true});});</script>';
}
I faced the same issue and below answer solved my problem:
config.allowedContent = true;
config.extraAllowedContent = '*(*);*{*}';
config.extraAllowedContent = 'span;ul;li;table;td;style;*[id];*(*);*{*}';
I had the same problem, that ck was stripping not only some attributes, but whole elements when pasting a block element, inside a block element (div with some attributes pasted inside a p) while using this method:
editor.insertHtml(html);
what solved the problem was using this workaround instead:
editor.insertElement(CKEDITOR.dom.element.createFromHtml(html));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With