Issue #1118💬 AnsweredOpened May 17, 2018by cgatian0 reactions

Generate dynamic identifier in Block

Quick answerby artf

You can make use of this event

Read full answer below ↓

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. 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, 2018

You can make use of this event

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

@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, 2018

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.