Comments (7)
Since grapesjs 0.14.50 drag and drop of mjml components have stopped working. I've debugged it and found the issue with the function updateAttributes
inside ComponentView.js
, specifically with the following lines:
attrs.forEach(function (attr) {
return $el.removeAttr(attr);
});
I tried to trace back what the attributes deleted from the element are that cause the sorter not to know what the target element in onMove
is, but after three days, I am still not sure.
At the moment I commented out those lines.
I've tested with the MJML project and other projects as well, and it all seems to still work.
What do these lines do? realizing these lines cause the MJML components to stop working - what can we update with the MJML components so they work again?
from mjml.
Confirmed fixed.
from mjml.
I have a fix for this problem, so maybe we can update it soon?
the problem is solved bij changing in components.js row 370:
draggable: '[data-type=mj-container]'
to
draggable: true,
in the domc.addType('mj-section' --> model --> defaults
from mjml.
it's more like a workaround rather than a fix, but as I don't have time to investigate more on it I'll accept a PR
from mjml.
@artf I've looked into this, this seems to happen because for the mjml plugin the actual HTML gets generated at coreMjmlView::getTemplateFromMjml() (https://github.com/artf/grapesjs-mjml/blob/master/src/components.js#L161) and assigned to the sandboxEl
. But this sandboxEl
is created and then not inserted into the DOM meaning it has no parentNode (https://github.com/artf/grapesjs-mjml/blob/master/src/components.js#L20). This breaks the draggable/droppable filtering in use by this plugin because the Sorter expects a parentNode or falls back to the body of the document that created the element (https://github.com/artf/grapesjs/blob/dev/src/utils/Sorter.js#L178) . Where it won't find it since it's not inserted in the DOM.
So seems to me either the sandboxEl needs to be inserted into the DOM so it can be found by the querySelectorAll()
calls done by Sorter::matches()
or that same method needs to create a parentNode for the element it's looking for instead of falling back to the body. A sample implementation in Grapesjs' Sorter.js::matches() would be:
matches(el, selector, useBody, debug=false) {
var startEl;
// if we don't have a parentNode, create a node so the
// querySelectorAll() call below can find something.
if (!el.parentNode) {
startEl = document.createElement('div');
startEl.appendChild(el);
} else {
startEl = el.parentNode;
}
//startEl = useBody ? startEl.ownerDocument.body : startEl;
var els = startEl.querySelectorAll(selector);
var i = 0;
while (els[i] && els[i] !== el)
++i;
return !!els[i];
}
Would you take that as a PR too ?
from mjml.
Thanks @mathieuk, it was actually an issue with matches
in Sorter. It was affecting also other stuff inside the core. Now should be fixed, can you confirm?
from mjml.
Seems like this issue is back.
from mjml.
Related Issues (20)
- BUG : edit text on mj-text after set background-color doesn't work HOT 2
- mj-navbar and CKEditor HOT 3
- Default width is not working properly in current version HOT 4
- BUG : Navbar link render twice when paste text into in the demo link
- Image size does not respect specified units HOT 1
- mjml in react encountered a problem,it can not draggle
- Mjml in react,Component cant't draggable HOT 9
- Does the MJML plug-in have an api for converting html to mjml? HOT 2
- Conditional template?
- BUG: The text link pop-up window does not pop up when it is full screen HOT 1
- Question: How to add the custom action(variable) HOT 3
- BUG: Borders missing after dropping components over it
- BUG: Found a Bug in MJML Image Block HOT 5
- Question: Does mjml support body component to configure background image?
- MJML plugin no longer working
- adding mj-styles or mj-head if they don't exist
- Selector Manager (Classes) disappeared in Style Manager HOT 2
- Table creation drag and drop issue
- Set HTML with style in component
- Get the rendered html from the editor? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mjml.