Issue #1118Opened May 17, 2018by cgatian0 reactions

[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)

artfMay 18, 20180 reactions

You can make use of this event

editor.on('canvas:drop', (dataTransfer, component) => {
	if (component.getEl().tagName === 'GG-LIST'){
		...
	}
});
cgatianMay 18, 20180 reactions

@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?

artfMay 18, 20180 reactions

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.

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.