question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Add html, css and js to Block Manager

See original GitHub issue

[QUESTION]

Hi! I’m retrieving dynamic html,css and js codes from the database. How can I create Blocks with this? Currently, this is my code,

    editor.BlockManager.add($aBlock['name'], {
        id: $aBlock['name'],
        label: $aBlock['name'],
        category: $aBlock['category'],
        content: $aBlock['html'],
        style: $aBlock['css'],
        script: $aBlock['css'],
      });

But its not working. Please help. Thank you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
pouyamiralayicommented, Feb 26, 2020

@cristianumali22 your code looks fine and it is not executed before grapesjs initialization because you are passing the reference and not actually calling it! i suggest using the grapesjs cli because it is doing all the setups for you and providing you with a nice and clean environment. Cheers!

1reaction
cristianumali22commented, Feb 25, 2020

Hi @pouyamiralayi , thus, doing, content: '<div></div><style></style>' will seperate the HTML from CSS in the download code feature of GrapesJS?

Note that in every blocks of code, there is different HTML, CSS and JS. Is the css of, example block_1, will not affect the style of block_2?

Read more comments on GitHub >

github_iconTop Results From Across the Web

episerver - Insert HTML, CSS and JavaScript in a block
Is it possible to inject a HTML, CSS and JavaScript into a block in EPIServer? I tried to add some HTML and it...
Read more >
Add CSS and JS that is not block-related using BEMHTML
Basically I would like to know how to be able to add custom CSS for a webpage that isn't directly block related. For...
Read more >
Introducing Runnable JavaScript, CSS, and HTML Code ...
So we've created our own way to embed runnable JavaScript, CSS, and HTML code blocks right in the body of a post.
Read more >
Adding custom code to your site - Squarespace Help Center
Ways to add custom code ; Code block (Advanced), Business and Commerce plans. CSS HTML iframes JavaScript. Markdown. Add code to a specific...
Read more >
Organizing your CSS - Learn web development | MDN
A good tip is to add a block of comments between logical sections in your stylesheet too, to help locate different sections quickly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found