I there a way to apply a default class to an element?
See original GitHub issueHello, first thank you for this amazing library. The question in the title is to solve a problem with bootstrap. I’d like to create a table that has already the class=“table” applyed from the start without having to add it manually from the style or property dialog. `
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Can I set a default css class for an html element - Stack Overflow
Yes, I know, I just wanted to for example assign to all <h1> elements by default and ALSO be able to use on...
Read more >How to Assign a Class to an Element - Pluralsight
The styles or class name can be assigned conditionally by either using state & props, ternary operation, or any other conditional operator, such ......
Read more >HTML class Attribute - W3Schools
The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.
Read more >CSS classes - TeleportHQ Help Center
CSS Classes Reuse style across elements in your project by creating and linking classes. How to create a CSS class. Default classes. How...
Read more >HTML tags | Webflow University
Use HTML element tags to control the default styling for a particular element ... These default styles can then be overridden with classes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Macs75,
Thanks for the kind words 👍 I’d recommend overriding the existing table tool to do this, for example:
Another option would be to listen for the
attach
event and ensure the table has that class:Despite the above options I think supporting for a way to define defaults for elements when added could be very useful, so I’m going to tag this as an enhancement as well.
@itsmelion specifically for the case in question if you wanted to rely on ContentTools to ensure
rel="external,nofollow"
is always in place then the simplest option would be to define your own link tool (based on the existing one but modifying the code here: https://github.com/GetmeUK/ContentTools/blob/master/src/scripts/tools.coffee#L364 to includeelement.a.ref = 'external,nofollow'
).Links are a bit of a special case here because they’re not an ContentEdit element type they only exist as elements within the contents of a ContentEdit.Text element so there’s no simple way to set set a default for them - though I can see the need here and think this might be something to look at as a future feature.