Issue #792Opened January 24, 2018by alvim0 reactions

Script property using function don't work with blocks

Question

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.

Answers (3)

artfJanuary 25, 20180 reactions

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

chiqui3dFebruary 9, 20180 reactions

@artf These changes when they will be published?

artfFebruary 13, 20180 reactions

@chiqui3d should be fixed

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.