-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Absolute/Designer mode #1936
Comments
First of great job! that take grapes to the next level. dragger = editor.runCommand('core:component-drag', {..}) Solved: dragger = ed.runCommand('core:component-drag', {..}) Managed to bypass it by defining window.editor as the my editor |
@Amir2828 |
In regards to responsive pages, my integrator told me this. When clicking on device modes, if using absolute positioning, would create the styles only for that mode, it would make it easier to build responsive pages, as you could toggle between the device modes and position your elements. It's not a complete idea, but it was just a thought he spewed out, thought i'd share. |
Hi @artf , |
@sunhillbd ... did you read the Preface part of this issue??? |
GrapesJS works already in this way, but this doesn't solve the issue of redoing a big part of the work for each breakpoint |
Yes. Did I miss anything? @artf |
@sunhillbd yes, but probably it's my fault for not being totally clear about the point. Basically, what you see in the demo is an example of mixing static position with absolute one, when you click on the drag icon you detach the component from the static flow so the effect you see it's like removing the node from the parent. This is why I suggest the |
Can I move blocks by measuring the properties of left, top in percent and not in px? |
@WejusT1k not really, but maybe we can find a way to let the user intercept/change the value in px before the update |
Hi, Did you get a chance to work on the Ruler idea? @artf |
@sunhillbd nope, the issues I've mentioned should be fixed in the next release but for the Ruler, I didn't even start |
Hello there and tnx for this awesome feature! |
Quick update, from the https://github.com/artf/grapesjs/releases/tag/v0.15.3 you can start using these new Drag Mode API
|
Hi, sorry to reopen this thread, but currently it's the best information available on the Drag Mode API. Some context: I'm evaluating the use of grapesjs within a narrowcasting application. The plan is to create fixed-aspect slides with grapesjs within the web-based admin interface. Absolute mode is essential here as these slides are currently made in a separate bitmap editor, which obviously has this flexibility. I'm defining blocks within the blockManager to drag onto the slides and I want some blocks (but not all) to use the dragMode 'absolute' setting. But I can't figure out how to make that work. There doesn't seem to be a way to set dragMode declaratively within the blockManager configuration object and I can't figure out how to get to the block's component API after creating it with the blockManager. Can you perhaps share an example of a "partially dragmode" configuration? |
You can add a block with a different Drag Mode in this way: BlockManager.add('my-block', {
...
content: {
type: 'my-component',
dmode: 'absolute'
}
}); |
@artf Can you tell me how to achieve this ? I need to set the positioning in vh/vw instead of px. I can easily translate the value in px to a vw/vh but I don't know how to change the value before the update |
Would be possible in % instead of px, because px your page will not be responsive |
https://jsfiddle.net/9zf4kd6e/ Kindly Check Your Example The Drag Mode is Not working properly in version 0.20.2 |
Hi everyone, Just wanted to know what's the status of this feature in grapesjs. I think examples are not working in recent version. There is no proper documentation about this features in official docs. Does anyone have worked on this, we are planning to use this feature in our upcoming SaaS product, if anyone has any knowledge how to use this in production, please let me know. |
@otlichnyy there is a bug in the latest version which prevents the absolute to work properly but it will be fixed with the new release. |
@artf I'm considering funding this issue but issuehunt.io doesn't appear to allow it because the issue is closed. Ideas? |
Thanks @contentfree you can refer to this open issue related to absolute mode problems |
can i just implement this dragable mode in image block? |
It would be cool if you could define a custom dragMode for percentages or via |
Is there a plan to add a GUI toggle for Absolute/Designer mode? Being able to change it in source is okay, but still leaves an out-of-the-box experience that makes GrapesJS look less excellent than it is. When I refer people to the site to check it out they often comment on the dragging as a source of confusion. |
Hi guys,
this issue is an overview of what is it, what is done, what to do and nice-to-have to complete the Designer Mode feature.
Preface
So let's start by describing what is it and what is the goal of this feature. The Designer mode should allow the user to drag components freely around the canvas, without HTML fixed positioning constraints, more like you'd do in tools like Photoshop/Sketch. This way moving components is much more intuitive especially for who has nothing to do with HTML positioning.
This approach might be extremely useful if you're building documents where the final result is visually static, like, for instance, PDFs or presentation slides. So what I'm trying to say, is that the absolute positioning it's not easy to deal when you have to do with something like websites, mainly because it's kind of a pain to work with responsive templates. A component in absolute position, from a less-technical point of view, is put out of the "HTML fixed flow", so neither its siblings or parent nodes are able to see its dimensions.
Let's see below an example of absolute positioning applied to a simple HTML page
So from this example, you can clearly see how components are removed from the flow (you can notice it by looking at their parent node) and how weird they behave in changing the width of the canvas, where all other components adapt to the new width but the one in absolute stay still. The example shows only a few components in absolute mode, imagine to deal with an entire page.
So for web page designing, I thought about an alternative solution, instead of relying on
position: absolute
it seems to be much more reliabletransform: transition(...)
as it moves the component related to its original fixed position without putting it out from the flow.Obviously, it's not perfect and each template would require its specific adjustments for different device sizes but at least the component it's not moved totally away from its original position.
So, the goal of this feature would be:
This obviously this is not something you can enable with juts "one option". How to mix drag modes should be delegated to who implements the editor
Implementation
From the https://github.com/artf/grapesjs/releases/tag/v0.14.57 you're already able to change the drag mode option, globally or per component.
To init the editor, globally, in one of the drag modes you should change the editor model option. We didn't yet specify any stable API, so any suggestion is welcome, but for the initialization, most likely the option will be something like:
For now you can enable it in this way:
It's not that different changing the drag mode on a single component, we just added a new propriety to the Component instance:
component.set('dmode', 'absolute');
So you could, for example, add a new toolbar icon to switch between different modes
Here an example of a global
absolute
drag modehttps://jsfiddle.net/9zf4kd6e/
You can notice that the editor adds automatically absolute positioning to components.
Let's see more in details about how it's implemented.
When you click on the move icon you activate the default
tlb-move
command where it decides if to move the component using the standard way or to delegate the requested drag operation to another, new,core:component-drag
command.The new command makes use of the Dragger utility and updates the position of the component when the dragger tells to do so.
This command creates also guides for the Dragger, which is able to snap to them (kind of Smart Guides).
Issues/Bugs
Dropping from block [Fixed in v0.15.3]
Currently dropping from blocks is not handled, so all dropped components are placed fixedly.
Not sure if we need to rely on the green placeholder (seems not that bad as idea btw) or just drop it based on the mouse position
Autoscroll [Fixed in v0.15.3]
Autoscroll on component drag is not working
Actually, it's disabled by this CSS rule otherwise the result is even worst
We need to place a
scroll
listener on the start of the dragger (and remove it on the end) and update the positioning of the component on the trigger.Toolbar positioning [Fixed in v0.14.62]
When the component is placed outside of the canvas (on the left side) its toolbar is wrongly positioned
There is definitely something to fix in the
SelectComponent command
Nice to have
Rulers
Its quite common in absolute positioning tools to have rulers, with the possibility to toggle them and adding horizontal/vertical guides.
Here an example of the Sketch interface
This is a quick recap of what is came to my mind and I wanted to share, so any other suggestion, bug reports, API or architectural improvements, are highly welcome. From my point of view the goal
Be able to mix different drag modes
is already at the good point, but for theBe able to create a whole project in absolute mode
the Dropping from block is mandatory.The text was updated successfully, but these errors were encountered: