I'm trying to insert a link into an instance of CKEditor using the following line: -
CKEDITOR.instances.CKInstance.insertHtml('My Text');
All that happens though is that 'MyText' is inserted without the link. Anyone know how to insert the link properly?
PS. I know that CKEditor comes with a plugin to insert links but I'm doing my own one
Thanks
Shazoo
I guess that you're using CKEditor 4.1 or newer. And since you don't use the official link plugin, your editor discards all <a> tags. You need to properly configure Allowed Content Filter so your editor accepts <a> tags back again.
You can do it when defining your command, like this:
// Assuming you want a dialog-driven command...
editor.addCommand( 'yourCommand', new CKEDITOR.dialogCommand( 'link', {
allowedContent: 'a[!href]', // Allow <a> in the editor with mandatory href attr.
requiredContent: 'a[href]' // This command requires <a> with href to be enabled.
} ) );
Or in editor's config with config.extraAllowedContent = 'a[!href]'. This is not recommended though as you develop a plugin (right?), which should bring a custom command.
Related
I've implemented a PlaceholderField outside my CMS and it works fine but Text copied from MS-Word keeps all dirty markup (like <font face="Times New Roman, serif"><font size="3">) which I want to get rid of. When I copy the same Text in a normal CKEditor field it works as explained in djangocms-text-ckeditor source (settings.TEXT_HTML_SANITIZE using html5lib).
Is there a parameter I can add to settings.CMS_PLACEHOLDER_CONF in order to make it work? Or any idea to implement it?
You may ask "Why not using directly HTMLField with djangocms-text-ckeditor?" Because I want to have access to Filer-File and Filer-Image plugins available in PlaceholderField.
The following setting is not part of the placeholder config, they are separate settings in the settings.py file:
TEXT_HTML_SANITIZE = True
CKEDITOR_SETTINGS = {
...
'basicEntities': True,
'entities': True,
...
}
Taken from: https://github.com/django-cms/djangocms-text-ckeditor#configurable-sanitizer
Question: I would like add custom styles to the dropdown in ckeditor, e.g. to show a Button style adding an a tag with class btn. Is there a way to do so within Bolt CMS?
(source: jonathanschmid.de)
Attempt: I was hoping to be able to add styles via the general.wysiwyg.ck config key, but there doesn't seem to be a suitable option. I managed to achieve what I wanted by editing bolt-public/view/js/ckeditor/styles.js – but I guess it's not update-safe.
Does anyone know of a safe way to achieve this within Bolt CMS? If not, I'll try forking to suggest adding general.wysiwyg.ck.styles to config.
There's an official guide about styles.
CKEDITOR.stylesSet.add( 'my_styles', [
{ name: 'Button', element: 'a', attributes: { 'class': 'btn' } }
] );
and
config.stylesSet = 'my_styles';
Then if you put the selection into a link, you can apply the style.
However, if you'd like to create a link from scratch, use CKEDITOR.editor.insertHtml within a custom command and expose it as a button in the toolbar. Styles combo does not insert new elements.
I am working with CKEditor 4.0.1.1 in an intranet and try to validate my code with W3C markup validation service.
The validation markup service find this error :
Error Line 547, Column 2455: there is no attribute "data-cke-saved-src"
<img alt="" data-cke-saved-src="http://portail-rep/Contents/images/Java…
How can i disable this functionnality of ckeditor protecting code to make my code ok for W3C validation ?
CKEditor uses many special attributes and elements to implement some of its features. However, they are used only internally and should be stripped out when getting data by editor.getData(). Therefore editor produces valid markup.
E.g. open http://ckeditor.com/demo, switch to source mode and you'll see that the image doesn't have the data-cke-saved-src attribute. However, if you'll use Firebug or Webkit's dev tools you'll find that the image has this attribute.
PS. In fact, data-cke-saved-src is a valid attribute in HTML5.
I had same problem now. This problem has been solved by using CKEDITOR config on blur event.
I'am using inline editing on element.
My ck config contain on blur event which have destroy method.
CKEDITOR.config.on = {
blur: function() {
this.destroy();
}
}
Using is simply:
On element click will create instance of new editor and it enable inline editing.
Now if user click outside of editor and on blur event invoked, editor destroy it self and if no editor instance exist, the content of the data is cleaned from data-cke attributes.
We have a Magento Shop with some products that have custom options as radio buttons. Every non required option has the first button checked by default but not the required ones. How can I make them checked?
I've allready installed the extension Dependent Custom Options (gallery). That gives me the option to set which custom option should be checked by default but that doesn't update the price to the right value.
Thanks for evey help
This solution may not be the best for you, but I had this same problem, and just fixed it.
First I had to use a convoluted method for installing jQuery correctly in Magento. Part of the problem, I believe comes from the Spriptaculous Effects file being outdated with the latest Magento build. So I went to the site www.script.aculo.us and downloaded the latest version. I then pulled out the effects.js file and used it to overwrite the effects.js in:
[Magento]/js/scriptaculous
Then I downloaded jQuery from the jQuery site and made a folder called jquery in:
[Magento]/js/
And dumped the jquery file in there.
Then I opened the file:
[Magento]/app/design/frontend/default/default/layout/page.xml
And found a list of lines that look like this:
<action method="addJs"><script>scriptaculous/effects.js</script></action>
I copied one of these and replaced the path to that of the jquery file like this.
<action method="addJs"><script>jquery/jquery-1.6.1.min.js</script></action>
Now jQuery will be included in all your pages.
Important! You have to run jQuery in noConflict() mode. So this is what the JS looks like that (for me) worked to select the first radio button on any page with custom options.
var $j = jQuery.noConflict();
$j(document).ready(function(){
// auto selects the first input with radio class
$j('.options-list input.radio:first').attr('checked','checked');
});
I saved that file into my jquery folder and linked to it the same way I linked to the jQ library.
Flushed my cache, and voila!
I hope this helps!
You can use jQuery, as Gordon says, but to update the price you need to run opConfig.reloadPrice() function when check. So the code will be something like this:
var $j = jQuery.noConflict();
$j(document).ready(function(){
// auto selects the first input with radio class
$j('.options-list input.radio:first').attr('checked','checked');
opConfig.reloadPrice();
});
There is a javascript function named something like optionsConfig.reloadPrice() which, when called, updates the price according to options. You probably need to have this triggered during the dom:loaded event.
Go to app\code\core\Mage\Catalog\Block\Product\View\Options\Type\select.php
You can find here your custom option title and set if condition with your title.
For example, my custom option title is price:
if($this->htmlEscape($_option->getTitle()=='Price'))
I am trying to edit an entire html using fck editor. So that should contain tags like html, body ,DOCTYPE etc. But my problem is when I submit the data, fckeditor forcefully remove the above tags from the content. I want to avoid this. Is there any configuration issue there.
-Arun
look at this config option. CKEDITOR.config.fullPage. I believe it will permit you to edit the full page (and will preserve the contents) (i haven't used it.)
'ckEditor' (as it's now known) shouldn't allow html/script tags directly within the content. However if you have the latest version there is a 'source' view which allows all the source to be edited directly and may give you what you want.
Arun User this one .This is best solution for you.
var CKcontent = false ;
$(document).ready(function(){
// setup ckeditor and its configurtion
CKEDITOR.replace( 'content1',
{
//fullPage : true,
customConfig : 'config.js' ,
toolbar : 'BasicToolbar' ,
height : "300"
});
});
Set only fullpage : false if not show HTML content otherwise set true
Note: it implemented by me in our development