-
Hello. I have a custom component to add videos. The code is below: const block = {
id: 'video-block',
label: 'Video',
media: `tmp`,
content: {
type: 'video-custom',
style: {
'margin-top': 0,
display: 'block'
}
},
activate: true,
category: 'Elements'
}
const videoComponent = editor => {
editor.DomComponents.addType('video-custom', {
model: {
defaults: {
tagName: 'div',
droppable: false,
style: {
display: 'block'
},
components: {
type: 'video',
provider: 'yt',
style: {
display: 'inline-block',
}
},
}
}
});
}; Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Found myself in a similar situation, will publish in the next release the const cmpOutType = 'cmp-out';
const cmpInType = 'cmp-in';
editor.Components.addType(cmpOutType, {
model: {
defaults: {
style: { padding: '20px' },
components: { type: cmpInType },
draggable: (src, trg) => trg.is('wrapper'),
delegate: {
// Select the inner component when trying to select this one
select: (cmp) => cmp.findType(cmpInType)[0],
},
}
},
});
editor.Components.addType(cmpInType, {
model: {
defaults: {
style: { padding: '5px' },
components: 'Inner component',
delegate: {
// Delegate these commands to the parent
remove: (cmp) => cmp.closestType(cmpOutType),
move: (cmp) => cmp.closestType(cmpOutType),
copy: (cmp) => cmp.closestType(cmpOutType),
}
}
},
});
editor.Blocks.add(cmpOutType, {
label: cmpOutType,
content: { type: cmpOutType },
select: true,
}); |
Beta Was this translation helpful? Give feedback.
Found myself in a similar situation, will publish in the next release the
delegate
property.Here is what it would look like: