Reputation: 2933
By default CKEditor assumes that text should be left aligned. If you enable text-align buttons, and select text and align it left, it doesn't change the content at all e.g.
Some text >> Some text
Whereas selecting center or right alignment adds the appropriate inline styles e.g.
Some text >> <div style="text-align:center">Some text</div>
The assumption that text is left-aligned by default is not always correct. For example the editor's output may be inside a table cell with align="center". In this case the text will never be left-align-able.
Is there anyway to set the default alignment of text in the CKEditor config prior to instantiating the editor?
Upvotes: 2
Views: 4005
Reputation: 596
Use this code: config.contentsLangDirection = 'ltr';
for Left To Right alignment and config.contentsLangDirection = 'rtl';
for Right To Left:
CKEDITOR.editorConfig = function (config) {
...
// Default language direction
config.contentsLangDirection = 'rtl';
...
};
Upvotes: 2
Reputation: 21
You can set the default alignment by changing the contents.css file.
body { text-align: center; }
Alignment buttons on the toolbar automatically recognize the style and toggle the correct button.
Upvotes: 2