Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Cannot add css to editor field in Admin

admin

Solved by Anna View solution

Started by Anna 5 years ago · 1 replies · 531 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 Rene, 1 week ago
2 49 1 week ago
Plugins · by Xavier, 4 weeks ago
2 57 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1184 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 50 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 75 2 months ago