Issue #2595💬 AnsweredOpened February 24, 2020by Davidvlv1 reactions

Having trouble dragging external html with draggable="true"

Quick answerby artf1

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

Read full answer below ↓

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, 2020

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

sdrebelFebruary 25, 2020

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, 2020

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

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 →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.