Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using ck editor to to create html document i want to add css from the style sheet can anyone tell me how do i achieve it
Posted

i thing you cant you have to do formatting or applycss before copying it to editor
 
Share this answer
 
Comments
surajemo 16-Jul-13 8:16am    
i cant do that i want style sheet to be applied
Dholakiya Ankit 16-Jul-13 8:17am    
ok then try by adding sourceview and add url
surajemo 16-Jul-13 8:51am    
i didnt understood
To achieve this.. Switch to source view and add ur stylesheet
 
Share this answer
 
Comments
surajemo 16-Jul-13 8:17am    
i tried that it does not work when i add the style sheet and then again switch to html view
link tag dissapears ckeditor ignores it
[no name] 17-Jul-13 0:45am    
If u need static declaration, u can edit a line in config.js or ckeditor.js

from:
contentsCss : CKEDITOR.basePath + 'contents.css',
to:
contentsCss : 'http://www.Site.org/css/UseThisStylesheet.css',(provide full path)

If u want different stylesheet for different content u can add it in source view inside paragraph tag
Ex: <p><link rel="stylesheet" type="text/css" href="theme.css"></p>
surajemo 17-Jul-13 0:58am    
hey karthik static declaration, works out pretty well style are getting applied

Can u tell me how do i get background color of html document i added a color picker
and when we select the color i have written jquery to set the background of the document of the html within ckeditor


<script type="text/javascript">

$(document).ready(function() {
// Events demo cp1 is texbox ans #title is h1 tag
$('#cp1').colorpicker({ color: '#8db3e2' })
.on('change.color', function(evt, color) {

$('#title').attr('style', 'background-color:' + color);

CKEDITOR.instances.editor1.document.getBody().setStyle('background-color', color);
//add this were i am adding the div to the document within the ckeditor to get color //background color within document
var oEditor = CKEDITOR.instances.editor1;
var dat = CKEDITOR.instances.editor1.getData(); //get the data from the editor
var tg = "<div style='background-color:" + color + "'>" + dat + "</div>";

oEditor.insertHtml(tg);
})
.on('mouseover.color', function(evt, color) {
//$('#title').attr('style', 'background-color:' + color);
// CKEDITOR.instances.editor1.document.getBody().setStyle('background-color', color);




})
});

</script>

but this one <p><link rel="stylesheet" type="text/css" href="theme.css"></p> does not work out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900