Auto wrap every component drag into canvas with another component
@pouyamiralayi I managed to solve the problem by making component as an object. Like so. Anyway thanks for trying to help.
Read full answer below ↓Question
I am trying to make sure every component drag into the canvas to be wrapped with a column component. To achieve that I use canvas event. First I disabled window event to prevent default html 5 drag and drop event to be fired. canvas:drop event Let's say that my column component is so simple, only a single div. canvas:dragdata event Above code return error, saying that dataTransfer not defined What I understand is we can customize what we drop to the canvas with result.content something like or What I don't understand is how to wrap the dragged component with element/component.
Answers (2)
@pouyamiralayi I managed to solve the problem by making component as an object. Like so. Anyway thanks for trying to help.
Hello there! the event you are looking for is this editor.on('block:drag:stop', function (element) { element.replaceWith({ tagName:'div', style:{'border': '1px solid red'}, components: [element] }) }) Notice here I am using a red bordered div as my wrapper; in your case it is the column. cheers.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2129
How to append a button inside default modal and catch it's click event
I want a form inside a modal (using the default modal ), on click of the submit button make an ajax call. I have created a new component wh...
Issue #1895
Drag component over canvas with script, script appended multiple times.
Hi, not sure if this is a bug or not. But I noticed a weird behavior, when I drag a block that has a component that contains a script funct...
Issue #1414
Component "first render" event
Hi. I'm developing a plugin for charts using chart.js. I need to persist the model of the chart inside the generated component to render th...
Issue #3939
Disabled drag and drop in preview
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? v95Reproducible demo link https://codesandbo...
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.