Reputation: 1287
I am using CK Editor to display some string with html formatting like bold. I have created this string in C# and displaying in CKEditor. PFB my code
string abc = "<div><h1>Test Text</h1>abcd \n efgh\n <b>ijkl</b> </div>";
this.CKEditor2.Text = abc;
In my CKEditor it displays as follows Test Text abcdefghijkl
It clearly doesn't allow \n as line breaks. I am trying to set up the custom linebreaks for my CKEditor. I am not sure why its not working. PFB my config.js file for the CKEditor.
CKEDITOR.editorConfig = function (config) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
config.removePlugins = 'toolbar,elementspath,resize';
config.allowedContent = true;
config.ignoreEmptyParagraph = false;
var writer = new CKEDITOR.htmlWriter();
// The character sequence to use for every indentation step.
writer.indentationChars = '\t';
// The way to close self closing tags, like <br />.
writer.selfClosingEnd = ' />';
// The character sequence to be used for line breaks.
writer.lineBreakChars = '\n';
};
Any inputs on this one please.
Upvotes: 0
Views: 2501
Reputation: 3572
Since you are using html, why not just make
string abc = "<div><h1>Test Text</h1>abcd </br> efgh</br> <b>ijkl</b> </div>";
and replace \t with either
,  
,  
, or &emsp
;
You could also use the <pre>
when displaying pre-formatted text, which preserves both spaces and line breaks.
Ideally with tabs if you can use CSS padding-left:5em
or margin-left:5em
that would be ideal.
Upvotes: 1