Issue #2972Opened August 25, 2020by kuhelbeher0 reactions

FEAT: Disable scripts on canvas

Question

Hello, first of all thanks for a great tool.

On my project i hit the problem where I need to disable scripts inside the editor. I found 2 similar issues with this problem - https://github.com/artf/grapesjs/issues/2046 https://github.com/artf/grapesjs/issues/2814. So the problem is quite common and maybe it's better to add such feature to the next version?

In https://github.com/artf/grapesjs/issues/2046 issue @sdrebel mentioned that he's removing scripts in canvas and running them only in preview mode. Can someone prompt how to do it, I didn't find a way how to remove and set js for the template.

Answers (3)

RJCAMAugust 25, 20200 reactions

Hi @kuhelbeher I'm still trying to achieve that too, but here's a tip that can help us to achieve it. I'll post here if I figure out a way. See this issue #2772

kuhelbeherAugust 26, 20200 reactions

@RJCAM thanks for tip, I tried that, but problem with this approach is that it disables script for component, not the whole template.

artfAugust 28, 20200 reactions

Once the editor and its components are loaded it's hard to think about disabling JS, think about a component with custom scripts that binds events all around the DOM (maybe even using some external plugin). The only way it could be possibly done is to reload the entire Frame (with the current components state), once some configuration flag (eg. via Canvas.enableScripts(false)) is updated, and prevent their append here. PRs are welcome :)

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.