Unable to use Font Awesome Icons inside of the Canvas
Question
First off, great work on an amazing project. Can't believe this exists.
OK, I've spent the last few days going through the docs and now am starting to build my own components. However; for template design, I want my components to render differently. I can see that I can intercept the rendering and change that.
But I'm trying to render this:
<div class="templateComponent"> <i class="fa fa-utensils-alt"></i></i> Advanced Menu</div>
And for some some reason, this Font Awesome icon will NOT render. This same icon works fine when rendering blocks like this:
attributes: {class: 'fas fa-utensils-alt fa-2x'},
I then discovered that no Font Awesome icons render inside of the canvas. Why?
Answers (1)
I actually discovered the problem halfway through writing the post but decided to finish it and leave it here in case anyone ran into this.
The styles used for panels, blocks, etc don't apply to the styles inside of the canvas, since the canvas is in an iframe. The problem was that I hadn't installed Font Awesome's CSS inside of the canvas (but had in my outer application, which is why it was working for blocks).
You can do this in the init:
grapesjs.init({
.. // other stuf
canvas: {
// any style sheets here are imported and used for the canvas ONLY
styles: [
"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
]
},
// and anything inside the baseCSS is included in a <styles> tag inside the canvas,
// allowing you to specify inline styles
baseCss: ` random CSS styles`
}
Also - if you want to change the appearance of items inside of the canvas, you can include inline styles using the baseCSS property.
Thanks, Andrew
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1162
[Question]: Editable components in Handlebars rendered template
Hi, I've been using grapes for about a couple of days now. Thanks for the awesome work on this project. I've read through the API docs (hop...
Issue #2065
Few Questions
First of all, Amazing project thumbs up to everybody involved. I have a couple of questions:How can I iterate over all of the components an...
Issue #2972
FEAT: Disable scripts on canvas
Hello, first of all thanks for a great tool. On my project i hit the problem where I need to disable scripts inside the editor. I found 2 s...
Issue #3287
QUESTION: Wrapper styling
First of all, congrats @artf for this amazing project 💯 I am currently working on a project and I wanted to ask if I can edit the wrapper...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.