Issue #2595Opened February 24, 2020by Davidvlv1 reactions

[Question] Having trouble dragging external html with draggable="true"

Question

I want to make an external html element able to be dragged into GrapesJS, like how you can drag in a block and it will add something.

I have a sample, with a div with draggable="true", a regular div and an image. The image drags in fine and if you select the regular div's text and drag that in it works, but the div with draggable="true" doesn't drag in properly. I want the div to behave just as the other two elements, and add itself to the editor. https://jsfiddle.net/091wftym/1/

How can i make the div element with draggable="true" drop itself properly?

Thanks

Answers (3)

artfMarch 3, 20201 reactions

@Davidvlv HTML5 D&D doesn't work like that, adding draggable="true" is not enough. This just tells the browser "Hey you can drag me!", but you have also to specify WHAT do you want to drag (using dataTransfer.setData API).

Here is your example extended with the correct setup and the usage of canvas:dragdata (just as an example, not necessary in this case)

https://jsfiddle.net/artur_arseniev/87rcb24n/

sdrebelFebruary 25, 20200 reactions

Have u tried this?

     editor = grapesjs.init({
         .......
        dragMode: 'absolute', // 'absolute' | 'translate'
         ......
         })

And also you can set drag mode for each component. https://grapesjs.com/docs/api/component.html#index

DavidvlvFebruary 26, 20200 reactions

Hi @sdrebel

This doesn't solve my problem. I have attached a video showcasing the jsfiddle - note the div with draggable="true" doesn't drag into the editor. grapesjs import draggable.zip

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.