How can I pass content with script?
Question
I made custom component like this way and used script as well
bm.add('test-block', {
label: 'Test block',
attributes: {
class: 'fa fa-text'
},
content: {
script: "console.log('the element', this)",
content: "<h1>hello 123</h1>",
// Add some style just to make the component visible
style: {
width: '100px',
height: '100px',
'background-color': 'red',
}
}
});
then script is working fine but I am not able to select component. Is there any other way to write content with script?
Answers (3)
change this
components: "<h1>hello 123</h1>",
I didn't get traits if I use script while creating a custom component. Is there any problem with traits?
well, there are no traits inside your block...
If you're trying instead to use a custom component you have to set the type
content: {
type: 'your-component-type',
script: "console.log('the element', this)",
content: "<h1>hello 123</h1>",
Related Questions and Answers
Continue research with similar issue discussions.
Issue #555
Add external script in script while creating new component
Hello @artf How can I pass external script link while creating a component? like this way, bm.add('test-block2', { label: 'Test block2', at...
Issue #1545
[Question] How I Get ID From Block?
Hi, i have my block and I get print in Div id results from my javascript class component... How i get ID from my block ??? editor.BlockMana...
Issue #792
Script property using function don't work with blocks
In Components & JS docs there's this example: This works perfectly. But I couldn't use a function instead of a string in script, as is said...
Issue #1034
insert element or block inside parent element
Good day, i have component, have block i have Trait on listen changes, how can I add "h1 " inside that block "'<div class="container" style...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.