动态添加内容样式到CKEditor 4实例

时间:2013-10-15 20:20:13

标签: javascript jquery css ckeditor

我已经使用contentsCss选项将CSS文件路径传递给了我的CKEditor实例,效果很好。但是,我需要能够动态添加更多我无法在CSS文件中添加的样式。在版本3中,看起来可以使用addCss函数(see this forum post)。不幸的是,这似乎不适用于版本4(see this forum post)。有没有人有其他选择?我正在使用jQuery适配器,因此使用任一API的解决方案都可以使用。

1 个答案:

答案 0 :(得分:0)

我认为你可以做点什么

$(window).on('print',function(e){
  e.preventDefault();
  var styles = '<style>'+/*calculation of styles*/+'</style>'
  $('head').append(styles);
  window.print();

});

$(window).on('load',function(e){
  var styles = '<style>'+/*calculation of media query print styles*/+'</style>'
  $('head').append(styles);

});