Issue #1472✓ SolvedOpened October 2, 2018by detectedstealth3 reactions

Custom Code block and JS

Quick answerby cjpollard2

Try grapesjs.init({ allowScripts: 1, ... });

Read full answer below ↓

Question

Wondering if there is a limitation or is it actually possible to create a block that allows the user of the editor to write custom javascript code as they are building the template? For example drag and drop a custom code block and write the javascript in it? Example: I created a link and wanted to capture the click event to make an Ajax request etc... I know it is possible to update the editors initialization code to include an external javascript file but ideally we would like this to be handled dynamically in a single place without having to edit settings every time we add a new javascript...

Answers (3)

👍 Most helpfulcjpollardOctober 3, 2018

Try grapesjs.init({ allowScripts: 1, ... });

cjpollardOctober 3, 2018

That just means you won't see the code, but you get something to see and click on to edit it. The JavaScript itself is there and works just fine.

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.