Custom panel button that dynamically Enable/Disable user scripts
You can change it in this way editor.getConfig().allowScripts = ...
Read full answer below βQuestion
Hello and thanks for sharing such a good project. I'm trying to customize some things in the editor but I have some questions that I would appreciate if they could be clarified. Recently I create a panel button to switch editor from absolute and default modes and it's working without any problem. But when I try the same method (pratically the same code) to make another panel button that allows users to enable/disable scripts in the editor (allowScripts: 0 or 1). I really see this is changing the value through the editor.getModel().attributes.allowScripts function but in practise it's not work...
Answers (3)
You can change it in this way editor.getConfig().allowScripts = ...
AllowScripts is for enabling parsing of JS, once the script is inserted it's executed, so you can't remove it (one way would be accessing the iframe's context and making changes manually)
Thank you for the response @artf . Here's the problem, the code you give me changes the value but still doesn't work as I described above. In the demo I share (https://codepen.io/RJCAM/pen/xxZbNLw) I have a button that shows an alert when clicked. Expected Behavior: When button AllowScripts is disa...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2852
[QUESTION]: Can't enable 2 panel buttons at the same time
Hi, I'm trying to enable more than one custom panel button at the same time. I think when I create some custom panel button (using code bel...
Issue #3004
QUESTION : custom style properties to change class
Hi, Thanks for this good editor. In my project, I want to adjust classes of components using the style manager. For example, I am using boo...
Issue #2350
[Question] How do I add elements/sectors to views container using a custom button in the Panel
I have added a custom button to the Panel as below: const pm = editor.Panels; pm.addButton('views', { id: 'customButton', className: '', co...
Issue #2972
FEAT: Disable scripts on canvas
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 s...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins βPremium plugins ship with support, regular updates, and production-ready features β save days of integration work.
Browse premium plugins βBrowse Plugin Categories
Jump directly to plugin category pages on the marketplace.