[Question]Adding Google Font doesn't work
Question
Bonjour,
I try to add Google Font :
var editor = grapesjs.init({
canvas: {
styles: ['https://fonts.googleapis.com/css?family=Archivo+Narrow:400,400i,700,700i|Roboto:300,300i,400,400i,500,500i,700,700i&subset=latin,latin-ext'],
},
});
editor.on('load', function () {
styleManager = editor.StyleManager;
typographySector = styleManager.getSector('Typography');
fontProperty = styleManager.getProperty('Typography', 'font-family');
list = fontProperty.get('list');
list.push({ value: 'Roboto, Arial, sans-serif', name: 'Roboto' });
fontProperty.set('list', list);
styleManager.render();
});
When i click on Typography, script stop in Grapes.jp show: function show() { this.$el.addClass(this.pfx + 'open'); this.getPropertiesEl().style.display = ''; <=== style is null ? this.$caret.removeClass(this.caretR).addClass(this.caretD); },
Where it's wrong ?
Merci.
Answers (3)
I think the real issue here is a need to have methods like
fontProperty.addOption({ value: 'Roboto, Arial, sans-serif', name: 'Roboto' })
// or
fontProperty.setOptions([...])
which then update the view accordingly to the change. So I'll add them for the next release. For now, declare your Style Manager in init configuration object or try with something like this
...
fontProperty.set('list', list);
fontProperty.view.input = null;
fontProperty.view.onRender();
// styleManager.render();
Super merci. !!!!!!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1807
GrapeJs framework breaks on adding external stylesheet
When i add my external stylesheet using the grapesjs framework no more works. How can I have the style sheet as well as the grapesjs framew...
Issue #1722
[QUESTION] how to make my custom tag as selectable and editable inside of canvas ?
Hi, I try to change my custom tag of ion-item has div in view properties but It doesn't work for me as I expected. my custom Blocks is my c...
Issue #859
[QUESTIONS] Change canvas style
Hi there, I have some question about canvas style, in this case i have config like this. By default i use css with name builder-desktop.css...
Issue #2008
[Question]The canvas turns dark and unmodifiable on adding a large piece of custom html.
I used to add custom html with editor.addComponent(). It works well at most of the time, but when I try to insert a large piece of HTML whi...
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.