[Question] Generate dynamic identifier in Block
Question
Im looking to create a block that when dropped will generate two components and these components would share some unique identifier between each other. If I dropped a second block to the canvas a second identifier would be used.
blockManager.add('combined', {
label: 'combined',
category: 'Workflow',
content: `<gg-list bind-id="SOMEID"></gg-list><gg-label bind-id="SOMEID"></gg-label>`,
});
I believe you could do this by creating your own component, but then you loose the ability resize/edit each individual component within he components content property.
Any help would be appreciated. Thank you.
Answers (3)
You can make use of this event
editor.on('canvas:drop', (dataTransfer, component) => {
if (component.getEl().tagName === 'GG-LIST'){
...
}
});
@artf Thank you for the reply! OK I was second guessing this approach, good to get some feedback on this. Just to follow up I dont believe there's a way to detect which block was actually dropped during the event, correct?
Just to follow up I dont believe there's a way to detect which block was actually dropped during the event, correct?
The component it's just the first one of your list, if you wrap your 2 elements inside another div that one will be the dropped component
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1875
[QUESTION] ID changes when importing html or passing html in components prop in config.
Hi, I built a component and block that I can drag and drop in the canvas. My issue is that some styles rely on the ID. I know this might no...
Issue #580
[Question] Any/Trigger event when any block is dropped inside canvas?
Hey, How can I trigger some event when any new block or content inside canvas is updated? Something like editor.onCanvasUpdate() Thanks!
Issue #1484
[Question]: Textblock subsequent rows do not give cursor/richtext editor when clicked, but are selected instead
I have noticed a strange behaviour in my adaptation of GrapesJS concerning the richtext editor and the gjs-blocks-basic plugin. Whenever I...
Issue #951
[QUESTION] Selection of custom components not possible from canvas.
Hey, I tried to figure this out by myself, but I'm feeling I'm going a little bit in circles. So I hope you will have some time to read thi...
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.