简体   繁体   中英

CKEditor multiple span tags

In ckeditor, instead of styles, I want to have classes for all styles. So I have used the following configuration.

config.coreStyles_bold = {
    element: 'span',
            attributes: { 'class': 'Bold' },
};
config.coreStyles_italic = {
    element: 'span',
    attributes: { 'class': 'Italic' },
};

The Bold and Italic classes are defined in my contentsCss file.

But suppose I have following text in my editor

Sky is blue.

If I apply Bold and then Italic on this. Then generated output is :

<span class = 'Italic'> <span class = 'Bold'> Sky is blue </span> <span>

ie two different tags for Bold and Italic are being generated.

Whereas I would like to have the following output :

<span class= 'Bold Italic' > Sky is blue </span>

Is it possible ?
Note : I am using CKeditor 4.4.1

Maybe something like this?

// Only one core style for both elements
config.coreStyles_myStyle = {
element: 'span',
        attributes: { 'class': 'my-style' },
};

Then in the css

.my-style{
   font-weight:bold;
   font-style:italic;
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM