How to add script for all widgets(like protectedCss)
You can initialize custom js in the canvas in this way:
Read full answer below βQuestion
I want to add some functions for all components accessible. when initialize editor, there is a option like protectedCss. Isn't there a way javascript like above?
Answers (3)
You can initialize custom js in the canvas in this way:
const editor = grapesjs.init({
...
canvas: {
scripts: ['https://.../script.js']
}
});
Thank you. Btw what I want to need is inline javascirpt. not external link... regards.
In that case, I suggest you access the document of the iframe and to append manually the inline script (to get the document use editor.Canvas.getDocument())
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2404
Question: how to observe children changes in component
Is there an easy way to subscribe/listen to changes in the components/children of my custom component type? Perhaps an event I can subscrib...
Issue #3231
how to change gjs-ckeditor-format component
hi guys, we all know that gjs-ckeditor-plugin working with [data-gjs-type]="text" components. I wanna know , could we change this option? I...
Issue #3194
How do I repurpose the Spectrum Color Picker?
I would like to repurpose the color picker used in GrapesJS. I have to use a color picker for some project level settings. These settings a...
Issue #2950
Edit panels styles (rookie question)
Hi all, I would like to get some guidance about the code I should add/edit in order to change the way panels look. In general, I will need...
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.