[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)
@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)
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 #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 #2378
[QUESTION] Modifying global CSS in style manager
We want to achieve the following:Mark our block HTML elements with some classes like:Add some styles that define CSS classes like:Using Gra...
Issue #2076
[QUESTION] How make a new component to allow laravel blade directives?
Hi, thanks for the nice work. I'll like to know if there is a way to use blade directives inside the code. I already add a new functionalit...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.