Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Cannot add css to editor field in Admin

admin

Solved by Anna View solution

Started by Anna 5 years ago · 1 replies · 724 views
5 years ago

I would like to enhance the Markdown editor field a bit. For a start, I would like to see the red dots marked up differently according to which character they're replacing. Currently I am experimenting with soft hyphens (\uad) and no-break spaces (\ua0). These are rendered by the editor as red dots, and in the markup like this:

HTML
Spectre provides <span class="cm-invalidchar" title="\uad" aria-label="\uad" cm-text="­">•</span> bas<span class="cm-invalidchar" title="\ua0" aria-label="\ua0" cm-text="&nbsp;">•</span>ic styl<span class="cm-invalidchar" title="\uad" aria-label="\uad" cm-text="­">•</span><span class="cm-invalidchar" title="\ua0" aria-label="\ua0" cm-text="&nbsp;">•</span>es for t<span class="cm-invalidchar" title="\ua0" aria-label="\ua0" cm-text="&nbsp;">•</span>ypography, elements, and a respon<span class="cm-invalidchar" title="\uad" aria-label="\uad" cm-text="­">•</span>sive layout system that utilizes best practices and consistent language design.

I can address these different chars via their title or aria-label attributes in css, BUT no matter how I try adding the css file, it doesn't turn up.

I have copied the twig template user/plugins/admin/themes/grav/templates/forms/fields/editor/editor.html.twig into user/plugins/typography-helper/admin/themes/grav/templates/forms/fields/editor/editor.html.twig. This works alright and gets used. If I hardcode a style in there it shows up in the editor. However, this does not seem to do anything:

TWIG
{% do assets.addCss('plugin://typography-helper/css/typography-highlighting.css', {'loading': 'inline', position: 'after'}) %}

But I think it should work? Why not? 🤔

Your input is much appreciated!

5 years ago Solution

Ok I take it back – it does work, and I just couldn't find it in all the javascripting. I'm not sure where exactly it gets added, but it's there, and since I've fixed my selector, the style also shows up as expected. :-)

Suggested topics

Topic Participants Replies Views Activity
Plugins · by renedebaaij, 4 hours ago
0 10 4 hours ago
Plugins · by complanar, 2 weeks ago
6 377 2 weeks ago
Plugins · by BenLaKnet, 2 weeks ago
1 192 2 weeks ago
Plugins · by complanar, 1 month ago
2 471 4 weeks ago
Plugins · by Vladimir Novak, 2 months ago
3 749 2 months ago