How to create a default margin in the ckeditor?

8

I started using CKEditor

And when initializing it, it comes as follows:

And I would like it to come with a standard margin (I want it to look like A4 sheet)

How could you make it come with a spacing?

    
asked by anonymous 12.02.2015 / 21:07

1 answer

5

CKEditor allows you to pass styles into the editor, if you are using version 3 you should use the following javascript code to add styles:

CKEDITOR.stylesSet.add( 'estilos-personalizados',
[
    { name : 'MarginA4', element : 'body', styles : { 'margin' : 'suamargin' } },
    { name : 'TamanhoDoTitulo' , element : 'h1', styles : { 'font-size' : 'tamanho da fonte' } },
]);

This creates a "Style Sheet", now you need to set this style sheet in your editor, for this you use the following code:

config.stylesSet = 'estilos-personalizados';

Where estilos-personalizados represents the name of the style created in stylesSet.add

You can also put this in an external file as explained on this site: Developer Guides - Style

In version 4 of CKEditor there is a new API that uses a style object to var style = new CKEDITOR.style( { element : 'body', attributes: { 'style' : 'margin: 10em' } } ); and this should be applied editor.applyStyle( style );

More information about this can be found in the documentation located at Dev # styles

I hope this answers your question.

    
19.02.2015 / 22:15