DeBoer
DeBoer

Reputation: 551

CKEditor add style on selection tag

I'm trying to add inline style directly into a selection text tag e.g. I'm selectingfoo within <a>foo</a> and click on the bold button. Currently I have my config done so:

coreStyles_bold: {
  element: 'b',
  overrides: 'span',
  styles: { 'font-weight': 'bold' },
  childRule: function() {
    return false;
  }
}

which will convert my <a>foo</a> into

<a><span style="font-weight: bold;">foo</span></a>

I would like to achieve:

<a style="font-weight: bold;">foo</a>

Is this possible in CKEditor?

Upvotes: 0

Views: 185

Answers (1)

Reinmar
Reinmar

Reputation: 22023

While it may be possible or not, it just does not make sense. Let's say a user was able to achieve this:

bar <a style="font-weight: bold;">foo</a> bar

Now, the user selects part of foo and part of bar and removes the bold...

bar <a style="font-weight: bold;">f[oo</a> ba]r

What would happen now?

bar <a style="font-weight: bold;">f</a><a>oo</a> bar

The end-user will think that there are two different links...

Upvotes: 1

Related Questions