Having trouble dragging external html with draggable="true"
@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)
@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...
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
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.
Issue #1111
How to add parent class when drag element
Hi @artf, Hope you are doing fine. Please let us know how we can add the parent class of div when new element is dragged inside that div li...
Issue #3251
How can I specify position of dropped element ?
I want to specify the position of dragging element. for example, if I have a header block which no matter where you drag, it should be plac...
Issue #2170
[QUESTION] Custom component - how to set editable to true
Hi, I've created a custom component type, but I am having some trouble making it editable. The component is a "span" with component type "t...
Issue #4249
image src won't change in exported HTML
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? chrome 100 Reproducible demo link https://...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.