I have previously worked with rich text editors such as tiny MCE, all of these have had some ability to allow adding custom CSS to the config. For example I would like to provide headings styles available that are in colours of the brand.
I would also like to be able to target the container which the default rich text module uses: I can see that the class widget-type-rich_text is there. Is this a safe class to target in my css?
Hi @NPeters, if you inspect the code, you will notice that Hubspot wraps every rich text editor (even the "default" one in Blog posts) with some unique IDs and classes, something like:
With that information, you can easily do a CSS file and add it to your page, so when you are editing something in a rich text editor you will already see the new styles.
But the same will happen if you just have a CSS file for all your styles in your page, you should be able to see the styles also when editing the rich text editor.
Also, remember you can see the Source Code in a rich text editor, so you can easily add classes to your elements.
But in general, all styles you have in your page should also apply to the editor, so just make sure you are targetting properly the elements in your page using CSS.
Did my answer help you? Mark it as a solution ✅
Do you need help with your site? Book time with me:
Jun 8, 202110:23 AM - edited Jun 8, 202110:23 AM
Contributor
Adding css classes to the rich text editor
Thank you for both your inputs! Both valid solutions.
I should have clarified, the purpose of the custom dropdown classes is not for me the Developer who can do this manually, but for the non-technical content editors who cannot.
Typically when I setup custom class dropdowns I liken it to the preset text styles that they are accusomted to in MS Word.
As a Developer these are features that I use in WYSIWYG editors to make the end user experience more palatable.
Jun 2, 202110:03 AM - edited Jun 2, 202110:04 AM
Top Contributor | Platinum Partner
Adding css classes to the rich text editor
With the levels of customization that you are wanting, it sounds like you'll want to make your own Rich Text module and/or Heading module. You can limit the functionality of the RT field in custom modules, and you could even separate out headings into their own headings custom module. From there you can provide custom options and styles that match brand guidelines as well as custom classes.
I like kudos almost as much as cake – a close second.
Unfortunately you're not gonna be able to replicate that TinyMCE feature. But you can get somewhat close to that with custom modules and you can make your module part of your theme so it will show above all other "common modules" in a drag and drop editor – minimizing confusion to content editors.
I like kudos almost as much as cake – a close second.
I am using the native HubSpot rich text editor. There is no option to wrap a div around it. That forces me to make a duplicate module for rich text editing! How can I hide the native rich text editior from the list of module options?
Having duplicate modules will confuse our content editors.