Skip to content
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

How to create multiple canvases inside a canvas #56

Closed
abdhalees opened this issue Apr 1, 2020 · 5 comments
Closed

How to create multiple canvases inside a canvas #56

abdhalees opened this issue Apr 1, 2020 · 5 comments
Labels
question Further information is requested

Comments

@abdhalees
Copy link

I want to create a component similar to 3 columns component in grapejs https://grapesjs.com/demo.html

Kapture 2020-04-01 at 9 53 00

I want the container and all inside elements to be draggable, droppable and deletable, I've tried different options but none meet all the above requirements.
is this achievable?

@ankri
Copy link
Collaborator

ankri commented Apr 1, 2020

I created a Demo CodeSandbox for you. Is this what you wanted to achieve?

Note: as soon as #35 is merged it is easier to define the rules

@prevwong
Copy link
Owner

prevwong commented Apr 1, 2020

I think the example in Grape.js requires some extra rules ( I will refer to ColumnLayout in @ankri's example as "Row" for simplicity):

  • The example in Grape.js disallows the Columns to be dragged out of the Row. We would need to set the Row's canMoveOut to false. But right now, when a Node is being moved, it checks for the target Canvas' canMoveOut rule. In this case, when a Column is being moved inside the Row to swap places with its sibling Columns, it checks for Row's canMoveOut rule and since it's false, it will not be allowed to be moved. I think this is incorrect since the Column is not being moved out of the Row, so there is no need to check for the canMoveOut rule.

  • The Row should not accept anything in it other than the 3 initial Columns. The canMoveIn rule in Row currently only allows Column, but this would mean that we can still drag more Columns into it. If we set canMoveIn to false then the 3 initial Columns cannot be added into Row at all. This is because when a new Node is being added, it checks for the drag-n-drop rules as well. I'm now considering that we should only check for drag-n-drop rules when the Node is being moved.

What do you guys think, if it makes sense to make these changes?

@ankri
Copy link
Collaborator

ankri commented Apr 1, 2020

The example in Grape.js disallows the Columns to be dragged out of the Row

In my use case (not the CodeSandbox) it should be possible to drag Columns from one ColumnLayout to another ColumnLayout. In my opinion this should still be possible.

I think this is incorrect since the Column is not being moved out of the Row, so there is no need to check for the canMoveOut rule.
Yes, reordering Columns should be possible.

In my use case canMoveIn and canDrop from #35 should do the trick:
ColumnLayout should only accept Column -> canMoveIn
Columns should only be able to be placed into ColumnLayouts -> canDrop

I think adding a restriction on a specific number of Columns per layout should be possible, too.

@abdhalees abdhalees changed the title How to create a multiple canvases inside a canvas How to create multiple canvases inside a canvas Apr 1, 2020
@abdhalees
Copy link
Author

I created a Demo CodeSandbox for you. Is this what you wanted to achieve?

thanks @ankri that worked.
what I was missing is that I needed to nest the components in connectors.create not in ColumnsLayout

ref={ref => {
        connectors.create(
          ref,
          <Canvas is={ColumnLayout}>
            <Canvas is={Column}>1</Canvas>
            <Canvas is={Column}>2</Canvas>
            <Canvas is={Column}>3</Canvas>
          </Canvas>
        );
      }}

@abdhalees
Copy link
Author

What do you guys think, if it makes sense to make these changes?

for my use case it's ok not to have these rules but I could see cases where they're needed

@prevwong prevwong added the question Further information is requested label Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants