Global functions/variables
Sorry @pouyamiralayi but I believe you didn't get the total meaning of script property in Component (obviously you're not the only one, even if I try to explain this "script paradox" here) What is asked in #1691 it just DOESN'T MAKE SENSE because the context in script property is like ANOTHER WORLD, the only way to co...
Read full answer below βQuestion
Hello there! recently i noticed this issue. I think it would be beneficial to have this feature. in contrast to the suggested approach by @artf that uses canvas scripts as a way to inject globally, i think this is not functional for the main purpose that this feature is intended for. in my opinion the main use case for having global variables and functions is the way script is handled inside the canvas: for each component type, it is executing a function every time that canvas is rendered. so if you are registering some sort of handlers for some events in your script, there is no way for you...
Answers (3)
Sorry @pouyamiralayi but I believe you didn't get the total meaning of script property in Component (obviously you're not the only one, even if I try to explain this "script paradox" here) What is asked in #1691 it just DOESN'T MAKE SENSE because the context in script property is like ANOTHER WORLD...
thanks for your kind answer @artf . after struggling with the idea i am reaching to the point that what you are saying is totally reasonable. that was very naive of me to bringing this matter up again sorry for that. the current workaround is completely correct and it's complement the canvas global...
@pouyamiralayi would you mind providing some more information on how you created a global event bus to send messages between global scripts and local ones? The editor embeds the grapesjs content in an iframe, so you can't use a global window object as an event bus.
Thanks!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3285
[Question]: Doctype in the canvas iframe
Hi. This question has already been asked twice (here and here) but has never got an answer. Is there a way to add <!DOCTYPE html> as the be...
Issue #3130
[Question] Standard approach in slight restructuring the HTML toolbar & badge
Version: 0.15.10 This question is intended to validate if there is a proper way to extend the current https://github.com/artf/grapesjs/blob...
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...
Issue #3367
Modal template
Is there a way for me to modify the template from a compiled state? https://github.com/artf/grapesjs/blob/d3256e621bb43a537213ffcd86b10dc0b...
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 βRelated tutorials
In-depth guides on the same topic.
Tutorial
GJSDocs: Say Goodbye to Manual Document Work
Invoices, contracts, proposals, reports β all generated automatically. GJSDocs turns your template into a live document in seconds.
Tutorial
Super Header & Super Footer for GrapesJS β Now Only $99 for one
Big news for the GrapesJS community π
Tutorial
π Introducing the New GrapesJS Plugin Generator on GJS.Market
Weβre excited to announce a powerful new tool for GrapesJS developers β the GrapesJS Plugin Generator on GJS.Market!
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.