Issue #1739Opened January 22, 2019by Soharab-Shaikh2 reactions

How to load dynamic CSS style(Not Link) into the Canvas head

Question

Code SnippetTEXT
Hi,
First of all thanks for your great Work !!!!!

I am trying to load a dynamic style into the canvas head. Is there any way to load dynamic object or string into the canvas head.

var **customeCss** = "h1 { color:#000000; font-family:Courier; font-style:italic;; }"
var editor = grapesjs.init({
............................................................
 canvas: {
            scripts: [ "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"],
            styles: [**customeCss**]       **//Is there any way to do so.**
        }
............................................................
}); 
I need your help.
Thanks,

Answers (2)

artfJanuary 22, 20192 reactions

Do this

const head = editor.Canvas.getDocument().head;
head.insertAdjacentHTML('beforeend', `<style>YOUR CSS</style>`)
lock[bot]January 24, 20200 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.