Issue #2177✓ SolvedOpened July 31, 2019by alikabeer323 reactions

How to create a block with HTML and CSS and javascript content.

Quick answerby pouyamiralayi2

Hello there! what you are looking for is here editor.DomComponents.addType('custom-type',{ model:{ defaults:{ script: function () { console.log('hello world'); } }, isComponent(){ return true } }, }) you must define the custom type before your block definition. then in your block content modify this line to inject you...

Read full answer below ↓

Question

Can somebody please show me a code example of how to create a block with javascript and css styles. The main problem is that the js code is added right after the html rather than at the end of the file

Answers (3)

👍 Most helpfulpouyamiralayiAugust 2, 2019

Hello there! what you are looking for is here editor.DomComponents.addType('custom-type',{ model:{ defaults:{ script: function () { console.log('hello world'); } }, isComponent(){ return true } }, }) you must define the custom type before your block definition. then in your block content modify thi...

alikabeer32August 2, 2019

Thank you.

alikabeer32August 2, 2019

Thank you.

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.