Issue #2012Opened May 13, 2019by webdeveloper04290 reactions

[question] how to add script for all widgets(like protectedCss)

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)

artfMay 19, 20190 reactions

You can initialize custom js in the canvas in this way:

const editor = grapesjs.init({
  ...
  canvas: {
    scripts: ['https://.../script.js']
  }
});

webdeveloper0429May 20, 20190 reactions

Thank you. Btw what I want to need is inline javascirpt. not external link... regards.

artfMay 27, 20190 reactions

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.

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.