Documentation
Classes
tags
Type: Object
Default: false
This setting allows you to automatically add CSS classes to the specified tags.
RedactorX('#entry', {
classes: {
'p': 'my-paragraph',
'h2': 'my-heading my-heading-another-class'
}
});
Now the specified classes will be added to tags in the content inside the editor and in the output code.
Tags inside the editor have a reset of styles, so to specify them CSS rules, you need to set styles like this:
.rx-content .my-paragraph {}
.rx-content .my-heading {}
.rx-content .my-heading-another-class {}
blocks
Redactor X regards the content as certain blocks. Therefore, you can set up a class not only for individual tags but also for groups of tags that are combined into these blocks. Here are the blocks of content that Redactor X has:
- address
- cell (td / th tags)
- embed (iframe or figure tags with embed code)
- figcaption
- heading (h1..h6 tags)
- image (div, figure, or p tags with the image inside)
- line (hr tags)
- list (ul and ol tags)
- paragraph (p tags)
- pre (pre tags or figure with pre tags inside)
- quote (blockquote or figure with blockquote tags inside)
- quoteitem (p tags inside blockquote)
- row (tr tags)
- table
Here is how to specify for certain blocks the automatic adding a class when starting the editor, when pasting or inserting content and so on.
RedactorX('#entry', {
classes: {
blocks: {
'image': 'my-image',
'heading': 'my-heading'
}
}
});
In this example, all blocks with images and all headers will automatically receive the specified classes.
And here's how to set classes for both blocks and tags at the same time:
RedactorX('#entry', {
classes: {
blocks: {
'image': 'my-image',
'heading': 'my-heading'
},
tags: {
'p': 'my-paragraph'
}
}
});