carlcs / craft-redactorcustomstyles

Redactor Custom Styles plugin for Craft CMS
MIT License
61 stars 13 forks source link

Parent Tag #19

Open controlnocontrol opened 6 years ago

controlnocontrol commented 6 years ago

Is it possible to specify a parent tag?

E.g. something like:

"example": {
    "args": {
        "parentClass": "parent"
        "tag": "div",
        "class": "child"
    }
}

will produce

<div class="parent">
    <div class="child">text</div>
    <div class="child">text</div>
    <div class="child">text</div>
</div>
controlnocontrol commented 6 years ago

This syntax might be cleaner and allow choice of tags and classes as well as multiple nesting:

"example": {
    "args": {
        "tag": "div",
        "class": "parent",
        "args": {
            "tag": "p",
            "class": "child"
        }
    }
}
jasonmckinney66 commented 6 years ago

This would also be helpful for customizing unordered lists:

"check bullet": {
    "args": {
        "tag": "ul",
        "class": "checked",
        "args": {
            "tag": "li"
        }
    }
}
carlcs commented 6 years ago

@ohbiko thanks for the interesting suggestion. Do you know if Redactor allows nested block level elements at all, and how the Formatting feature (h1, p, etc.) behaves when a nested element, for example div in div, is selected? I have a feeling that the API doesn’t really support it.

carlcs commented 6 years ago

@jasonmckinney66 I also came across this issue recently that you can’t configure a button to add classes to a ul tag. According to docs this should work, but it does not.

"specialList": {
  "api": "module.block.format",
  "args": {
    "tag": "ul",
    "class": "align-right"
  }
}

You can also replicate with a formattingAdd configuration, which uses the same API.

https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd https://imperavi.com/redactor/docs/api-modules/