-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
added rules.canDrop #35
Conversation
There is one problem with this approach:
I think that is a bug with @prevwong Should I file a separate issue? If you have some pointers I can try to fix that bug, too :) |
It was discussed previously, that the automounting of components is an unexpected behavior and that, for example the Grapejs library also doesn't automount components when they start dragging from the toolbox. I believe @prevwong expressed that he wants to resolve this by preventing the automount, so its safe to work on. |
@ankri I've merged a fix for that in master, can you pull it to your local branch and try again? |
Finally merged with master. Finally ready to review. |
bf04b11
to
60aca5b
Compare
…ri-can-drop # Conflicts: # lerna.json # packages/core/src/editor/query.tsx # packages/core/src/utils/createNode.ts # packages/docs/docs/api/API.js # packages/docs/docs/api/Node.md # packages/docs/docs/api/UserComponent.md
# Conflicts: # packages/core/src/utils/parseNodeFromJSX.tsx # packages/utils/src/constants.ts
Merge changes from main repo
Deploy preview for craftjs ready! Built with commit 51f1946 |
* add test staged * add prepush hook * run prettier * change unit test matcher * ignore Canvas root id test Caused by Subscriber, to be fixed * v0.1.0-beta.4 * Update contributing * fix: allow Subscriber to collect state when created (prevwong#52) * fix: add types for subscriber * docs: update styling * docs: fix typos * docs: add example for drop indicator colours * chore: add open collective * docs: add layers gif * chore: update README * docs: fix Frame props description * chore: migrate staging to Netlify * docs: fix typos * v0.1.0-beta.5 * fix(layers): remove side effect Remove the need for side effects for changing layer name via the .setCustom action * Create CODEOWNERS * Deep clone data nodes (prevwong#67) Otherwise immer will mutate the object as we remove nodes * hotfix: add action errors (prevwong#68) * v0.1.0-beta.6 * fix: indicator width over the line (prevwong#70) * fix: indicator width * fix: width calculation * Merge changes from candulabs/craft.js (prevwong#69) * Add prepush hook, some small nits to the craft project setup (#1) * add test staged * add prepush hook * Add onStateChanged hook (#2) * improve unit tests setup, refactor and move some unit tests. Also add a callback for nodes * add pull request template * add unit tests for frame, improve handling of frame * Editor state get & set (#3) * Adds nodes state get and set methods * Fixes over-shadowing bug * Add private @candulabs scope for release * Switches whole repo to point to @candulabs fork * Updates tests * Bumps up core version * Update README.md Adds warning about using this fork instead of official release * Sync changes from main repo (#4) * add test staged * add prepush hook * run prettier * change unit test matcher * ignore Canvas root id test Caused by Subscriber, to be fixed * v0.1.0-beta.4 * Update contributing * update naming * update version number * package naming Co-authored-by: Prev Wong <prevwong@gmail.com> * Adds github workflow (#5) * Adds test workflow * Fixes shell linter * Refactors flow to use node step * Adds build step * Corrects dep version * Removes bad dependency * Fixes potential case sensitive typo * Configures lerna version * Reset fork versions for lerna * v0.1.5 * Adds optional publish step * Adds better name to workflow * Removes redundant job name * Improves naming further * Actions - second attempt (#6) * Adds test workflow * Fixes shell linter * Refactors flow to use node step * Adds build step * Corrects dep version * Removes bad dependency * Fixes potential case sensitive typo * Configures lerna version * Reset fork versions for lerna * v0.1.5 * Adds optional publish step * Adds better name to workflow * Removes redundant job name * Improves naming further * Introduces split workflow * v0.1.6 * Adds npmrc * Moves env to job level * v0.1.7 * Sync changes from main repo (#8) * add test staged * add prepush hook * run prettier * change unit test matcher * ignore Canvas root id test Caused by Subscriber, to be fixed * v0.1.0-beta.4 * Update contributing * fix: allow Subscriber to collect state when created (prevwong#52) * fix: add types for subscriber * docs: update styling * docs: fix typos * docs: add example for drop indicator colours * chore: add open collective * docs: add layers gif * chore: update README * docs: fix Frame props description Co-authored-by: Michele Riccardo Esposito <mresposito5@gmail.com> Co-authored-by: Prev Wong <prevwong@gmail.com> * v0.1.8 * expose use node context (#9) * v0.1.9 * Rewrite actions.delete and actions.add plus unit tests (#10) * tidy up the style inside actions * add unit tests for action * improve actions.add and actions.delete functions * fix drag selection * v0.1.10 * Refactor event handler to add more unit tests and make it more readable (#11) * couple small style improvements * refactor event handlers * sort the query methods by name * v0.1.11 * Local development with yalc (#12) * Adds setup for local development with yalc * Adds nodemon config file to npmignore * v0.1.12 * Parse entire tree when dropping a node (#13) * change query to create and parse a tree, small code style nits * parse an entire tree from jsx instead of just a single node * implement adding the tree recursively * fix dropping shadow * improve the renderNode function to render nodes among children if there are any * prevent nodes from being stripped from state if they are not in a canvas node * v0.1.13 * Adds check if resolver has isCanvas set (#14) * v0.1.14 * fix: use Subscriber to handle onStateChange (#15) * v0.1.15 * add enzyme deps * pr review * feat: Improvements to PR-69 (prevwong#72) * Add parseNodeFromNodeData method in query, deprecate query.createNode (#18) * rename query.createNode to query.parseNodeFromReactNode * refactor transformJSXToNode and create node * some light refactoring for readibiliyt * try up the code * add a couple unit tests, fix some small bugs * fix fromEntries on node # Conflicts: # packages/core/src/render/Frame.tsx # packages/core/src/render/tests/Frame.test.tsx # packages/utils/src/tests/History.test.ts * fix: remove support for adding child nodes in non-Canvas This will be added when the Element component is introduced * fix: resetting parent nodes, re-added support for childCanvas * chore: move event() to utils * feat: PR improvements * chore: rename SerialisedNodeData * chore * nit Co-authored-by: Michele Riccardo Esposito <mresposito5@gmail.com> Co-authored-by: Mateusz Drulis <mateusz.drulis@gmail.com> Co-authored-by: Prev Wong <prevwong@gmail.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Prev Wong <prevwong@icloud.com> * fix(docs): Fixed the misplaced closing canvas tag in user-components docs (prevwong#76) * feat: refactor API (prevwong#74) * feat: add deprecation util * feat: add normaliser to createNode/transformJSX * feat: refactor actions * feat: refactor rendering * feat: deprecate Canvas with Element * cleanup * fix: render node bug when node deleted * fix tests * fix: remove timeout hack * feat: deprecate adding array of Nodes * fix: simplify RenderNode * nit: cleanup unused vars * nit: remove comments * chore: add yalc * fix: Element rehydration * chore: refactor parseNodeDataFromJSX * fix: api scheme * chore: remove capture/debounce handlers * chore: handle deprecated _childNodes * chore: hidden => isHidden * chore: _childCanvas => linkedNodes * nit: cleanup * feat: add hydrationTimestamp * chore: cleanup * nit: rename Tree => NodeTree * fix: deprecate decendants * feat: move connectors to context * fix: RenderNode * fix: deserialisation * feat: update hooks exposed actions * fix: update action * chore: cleanup * chore: update api in test * feat: refactor NodeHelpers * nit: update element isCanvas => canvas * fix: typo * fix: NodeHelpers * feat: refactor queries * chore: cleanup * fix: remove drag * chore: update docs * fix: remove drag * feat: rename addTree => addNodeTree * chore: rename onStateChange => onNodesChange * feat: update linkednode parent * chore: update docs * feat: change to click event * feat: remove id prefix and rename root node * cleanup * chore * chore: remove isHidden * chore: cleanup API * chore: add test watch command * chore: fix docs * nit * nit: cleanup * nit: pr * feat: deprecate craft name/defaultProps * feat: ensure dragged element is selected * chore: update docs * fix: ensure events exist * nit(layers): use updated API * fix: existing node in element * nit: cleanup * nit: cleanup * fix: dropend remove EventHandlers.events.indicator (prevwong#77) Co-authored-by: jinzhe <jinzhe@hualala.com> * chore: add versioned docs commit bdd5a12 Merge: 0b73cef da714eb Author: Prev Wong <prevwong@gmail.com> Date: Fri Jun 12 13:58:56 2020 +0800 Merge branch 'develop' into version-docs # Conflicts: # yarn.lock commit 0b73cef Author: Prev Wong <prevwong@gmail.com> Date: Thu Jun 11 18:06:55 2020 +0800 feat: update doc styling commit 3efb9e1 Author: Prev Wong <prevwong@gmail.com> Date: Thu Jun 11 14:09:11 2020 +0800 feat: version docs commit c77911e Author: Prev Wong <prevwong@gmail.com> Date: Thu Jun 11 14:08:58 2020 +0800 feat: move support to dedicated page commit 5b77d41 Author: Prev Wong <prevwong@gmail.com> Date: Thu Jun 11 13:18:00 2020 +0800 feat: update styling commit d4e27e6 Author: Prev Wong <prevwong@gmail.com> Date: Thu Jun 11 12:22:45 2020 +0800 chore: update docs * fix: event handlers test * chore: add CI for PRs * fix: docs navbar ssr * hotfix: invalid nodes in ancestors/descendants helpers * fix(landing): labels position * chore: automate NPM release * fix(docs): useNode API * chore: fix action * chore: update examples (prevwong#81) * chore: add publish command * chore: update docs * feat: expose query in onNodesChange * chore: add release * v0.1.0-beta.7 * chore: update stable docs * chore: Add prettier config (prevwong#87) * chore: update stable docs * Adds prettier config * Fix wrong tab width * Brings back semis Co-authored-by: Prev Wong <prevwong@gmail.com> * Adds helper scaffold script * feat: improve NodeHelpers.descendants (prevwong#86) * feat: refactor NodeHelpers.toNodeTree() * chore: update docs * chore: rename variables * feat: Custom event blocking flag (prevwong#85) * chore: update stable docs * Adds prettier config * Adds helper scaffold script * Replaces stopPropgation with custom block flag * Applies new prettier settings to project * Updates tests * Revert "Updates tests" This reverts commit caab87d. * Revert "Applies new prettier settings to project" This reverts commit cdc438e. * Remove prettier config * Revert prettier changes in handler files * Fixes tests once again * Revert back to using mousedown for selection * Updates tests Co-authored-by: Prev Wong <prevwong@gmail.com> * hotfix: isDroppable rules (prevwong#89) * fix: isDroppable rules * nit * fix: Handlers API (prevwong#93) * fix: Handlers API * chore: rename CraftEvent => CraftDOMEvent * chore: add canDrop * feat: added rules.canDrop (#35) Co-authored-by: Prev Wong <prevwong@gmail.com> * fix: handle propagation by matching descendant (prevwong#94) * feat: handle propagation by descendant * chore: cleanup * fix: ignore matching self * chore: update layer handlers * chore: cleanup * chore: update docs * chore: cleanup * v0.1.0-beta.8 * chore: fix typo Co-authored-by: Michele Riccardo Esposito <mresposito5@gmail.com> Co-authored-by: Joel Schneider <jmschneider@users.noreply.github.com> Co-authored-by: Sigit Prabowo <sgt@prbw.net> Co-authored-by: Mateusz Drulis <mateusz.drulis@gmail.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Srinath Janakiraman <me@vjsrinath.com> Co-authored-by: Kim <boqiaok@gmail.com> Co-authored-by: jinzhe <jinzhe@hualala.com> Co-authored-by: Andy Krings-Stern <ankri@users.noreply.github.com>
I also needed a
canDrop
rule like @ackvf and you discussed in #26This PR adds the
canDrop
rule:With this you can prevent the node that is being dragged (
currentNode
) to be dropped into the target node (targetNode
).I also added documentation and a simple example to the Basic example. In there I added two components:
<ColumnLayout />
and<Column />
<Column />
s may only be added to<ColumnLayout />
s and<ColumnLayout />
s only accept<Column />
s.