Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying style to parent element in TinyMCE

I have a requirement to add a class to a p-tag if it has an a-tag child, like this:

<p class="read-more-link">
  <a href="#">Link</a>
</p>

I've tried the following without success (this is C# in EPiServer):

new {title="Read more link", selector="p", classes="read-more-link" } // this allows user to add class to any p
new {title="Read more link", selector="p > a", classes="read-more-link" } // this adds class to a tag
new {title="Read more link", selector="p > a", classes="read-more-link", wrapper="true" } // this does nothing
new {title="Read more link", selector="p > a", block="p", classes="read-more-link", wrapper="true" } // this does nothing
new {title="Read more link", selector="a", block="p", classes="read-more-link", wrapper="true" } // this does nothing

Anyone know how to solve this?

like image 675
peter3 Avatar asked Feb 03 '26 10:02

peter3


1 Answers

You should be using a wrapper, see https://www.tiny.cloud/docs/configure/content-formatting/#wrapper

like image 153
Eric Herlitz Avatar answered Feb 06 '26 05:02

Eric Herlitz