views:

51

answers:

2

I'm trying all day to set up a peristant style attribute to the body tag of the ckeditor instance. I could not find something like bodyStyle in ckeditor.config api (only bodyId and bodyClass). So I was trying it myself, with the following solution (jQuery is used):

$(this).find('textarea.editor').ckeditor().ckeditorGet().on( 'instanceReady', function( e ){
  var documentWrapper = e.editor.document,
    documentNode = documentWrapper.$,
    inh = $(documentNode.body);
    inh.css('background', inheritParentBackground);
});

Wich is working quite well, but after I call .updateElement() or if i click the source button twice, it will removes all the styles again and 'instanceReady' is not called again. I tried to fire it manually, but then it runs the style update first and gets directly overwritten from ckeditor.

What I'm actual trying to do: I want to edit a Div in an homepage, after klicking edit a ajax popup apears with the ckeditor and i want the Editor to have the same height, width and Background and i can not handle this over bodyId or bodyClass, so I guess I need a bodyStyle or somebody has a diffrent idea.

A: 

Is http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#.style what you're looking for?

ryan
no you can only define styles with this static method, but i dont't see where I could attach it to an intance. The closed is: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#addCss But this doent add a style attribute and it has the lowest priority, so the rule is overwirtten by everything
XzenTorXz
A: 

I found out a dirty hack:

$(this).find('textarea.editor').ckeditor({
        bodyId: Id+'" style="'+style,
    });

not very nice but it works ;-)

XzenTorXz