0
votes

By default, TinyMCE allows the h1--h6 elements to include a <strong> element, but it's problematic, since with some fonts the default strong weight of the header tags is then added by extra weight, which looks terrible.

I've tried using the valid_children option:

valid_children : '-h1[strong],-h2[strong],-h3[strong],-h4[strong],-h5[strong],-h6[strong]'

However, while this prevents implementing <strong> on h1--h6, it resolves existing cases by removing the h1-h6 elements and replacing those with p elements:

<h3><strong>Subtitle goes here</strong></h3>

Is converted into:

<p><strong>Subtitle goes here</strong></p>

The desired behaviour, however, is:

<h3>Subtitle goes here</h3>

How can that be achieved?

1

1 Answers

0
votes

I tried to add these codes:

  formats: {
    h1: { block : 'h1', styles: { fontSize: '40px', 'font-weight': 'normal' }},
    h2: { block : 'h2', styles: { fontSize: '32px', 'font-weight': 'normal' }},
    h3: { block : 'h3', styles: { fontSize: '28px', 'font-weight': 'normal' }},
    h4: { block : 'h4', styles: { fontSize: '24px', 'font-weight': 'normal' }},
    h5: { block : 'h5', styles: { fontSize: '20px', 'font-weight': 'normal' }},
    h6: { block : 'h6', styles: { fontSize: '16px', 'font-weight': 'normal' }},
  },

and it works with;

<h3><strong>Subtitle goes here</strong></h3>

It can be solve your problem.