GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

Script property using function don't work with blocks #792

Closed alvim closed 6 years ago

alvim commented 6 years ago

In Components & JS docs there's this example:

editor.BlockManager.add('test-block', {
  label: 'Test block',
  attributes: {class: 'fa fa-text'},
  content: {
    script: "alert('Hi'); console.log('the element', this)",
    // Add some style just to make the component visible
    style: {
      width: '100px',
      height: '100px',
      'background-color': 'red',
    }
  }
});

This works perfectly. But I couldn't use a function instead of a string in script, as is said it's supported like this example:

editor.BlockManager.add('test-block', {
  ...
  content: {
    script: function () {
      alert('Hi');
      console.log('the element', this);
    },
    ...
  }
});

It won't happen anything. The documentation isn't very clear about using scripts in blocks or components.

artf commented 6 years ago

Find where is the issue, it will be fixed in the next release

chiqui3d commented 6 years ago

@artf These changes when they will be published?

artf commented 6 years ago

@chiqui3d should be fixed

selcukcura commented 5 years ago

Hi @artf, I'm still having this issue even though I'm using the latest build (0.14.61).

I know you mentioned it should be fixed, but Is this still a known issue?

artf commented 5 years ago

I know you mentioned it should be fixed, but Is this still a known issue?

@selcukcura not really Selcuk, it should be fixed so probably you're facing some kind of new regression. It'd be great if you could create a new issue with a reproducible demo. Thanks

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.