How to create a default margin in the ckeditor?

Asked

Viewed 579 times

8

I started using Ckeditor

And by initializing it, it comes in the following way:

inserir a descrição da imagem aqui

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

How could I make him come already with a spacing?

  • I am trying to formulate an answer, but does the doubt come, the margin you want is internal (margin of the content of CK editor) or external? I was clear in my question?

  • @Samueldiogo margin interna

1 answer

5


The 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 "Stylesheet", now you need to set this stylesheet in your editor, for this you use the following code:

config.stylesSet = 'estilos-personalizados';

Where estilos-personalizadosrepresents the style name created in stylesSet.add

There is also how to put this in external file as explained on this site: Developer Guides - Style

In version 4 of Ckeditor there is a new API that uses an a style object 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.