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

Enables Block Grouping/UnGrouping using core/group #14908

Merged
merged 76 commits into from
Jun 5, 2019

Commits on Jun 3, 2019

  1. Experiment with rudity mentory mechanic to allow Block Grouping

    Tried a few approaches via `insertBlock/removeBlocks` and even `replaceBlocks` but nothing preserved the undo history apart from this rather brute force method.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    ec83e29 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    84cedd1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4499172 View commit details
    Browse the repository at this point in the history
  4. Adds transform and updates Group button implementation to mirror

    Adds a `from` transform to the `core/group` Block. Currently this only works for `core/paragraph` but will need to work for all Block types. Updates the convert button to utilise `switchToBlockType` which invokes the same functionality as used in Block transform thereby unifiying the two methods of grouping.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    ec38f09 View commit details
    Browse the repository at this point in the history
  5. Adds and applies Group icon

    As provided here #14908 (comment)
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    6a340cc View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    9250dfe View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    81bbde6 View commit details
    Browse the repository at this point in the history
  8. Adds wildcard Block transforms

    A major update to the transforms logic to enable wildcard Block transforms.
    
    * Pass Block names into transform callback function - enables dynamic Block creation in wildcard transforms (see `core/group`)
    * Add edge cases to Block transformation logic to account for specifying `*` (all) Block types as valid for a transformation
    * Remove unwanted test that checks all Blocks are of the same type before allowing a transform on a Multi Block selection
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    5417118 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    10cc373 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    0d0d259 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    febf5b0 View commit details
    Browse the repository at this point in the history
  12. Extracts key transform test logic into dedicated methods

    Previously hard coded values and difficult to follow logic were making the `switchToBlockType` overly complex. Extracted to well name methods to improve readability and allow to further refactoring.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    6bcfe33 View commit details
    Browse the repository at this point in the history
  13. Extract method to test for wildcard block transforms

    DRYs up code by extracting a function to test for the presence of a wildcard block transform
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    b7691dc View commit details
    Browse the repository at this point in the history
  14. Moves logic to allow for wildcard transform into central transform ch…

    …ecking method
    
    Previously test to allow wildcard transform to be valid were manually added as edge cases in conditions in predicate functions. This update centralises all logic to test whether a given transform is possible but including the logic that allows wildcard transforms within the main method `isPossibleTransformForSource` which determines whether a given transform is possible.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    be26e72 View commit details
    Browse the repository at this point in the history
  15. Adds UnGrouping mechanic

    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    f05f7bb View commit details
    Browse the repository at this point in the history
  16. Adds UnGroup Icon

    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    322ec73 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    68a16f2 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    824a168 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    1effcde View commit details
    Browse the repository at this point in the history
  20. Adds more e2e test coverage

    Includes testing grouping via transforms, options menu and keyboard shortcuts
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    45b7b80 View commit details
    Browse the repository at this point in the history
  21. Adds check for group block availability before displaying grouping UI

    Also adds e2e tests to cover this.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    1666e97 View commit details
    Browse the repository at this point in the history
  22. Updates misnamned components

    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    0e4a2d3 View commit details
    Browse the repository at this point in the history
  23. Updates to preserve widest width alignment of child block on group co…

    …ntainer
    
    Previously if one of the child blocks being grouped had a width alignment (eg: wide or full) then the group block did not respect this. This meant that layouts weren’t preserved when grouping. Adds functionality and tests to ensure that when a group is created the widest alignment setting of the child blocks is set on the group block.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    d6cb0cc View commit details
    Browse the repository at this point in the history
  24. Updates to DRY out tests

    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    3e76175 View commit details
    Browse the repository at this point in the history
  25. Updates to simplify test setup

    Previously API calls were cleaning up blocks. This can be removed because all posts are auto removed before each test is run.
    
    Addresses #14908 (comment)
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    2627694 View commit details
    Browse the repository at this point in the history
  26. Updates to simplify test assertion

    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    29b5ed4 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    fd257ff View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    4bdce11 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    27143f9 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    77a4268 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    2ef8e03 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    2c8adfd View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    96c11ba View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    607404e View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    2328b54 View commit details
    Browse the repository at this point in the history
  36. Fix Block deletion test failure via keyboard workaround

    Due to the addition of the “Group” item into the Block Options toolbar the “Remove Block” item had been removed outside the viewable portion of the Popover (not the popover has a restricted height and allows scrolling to see the additional items if there is insufficient space to display them all).
    
    Pupeteer isn’t able to click on items that are not visible. The simplest work around is to us the keyboard to select the “Remove Block” menu item rather. Trying to scroll a div within Pupeteer is fraught with problems and inconsistencies.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    a99d98f View commit details
    Browse the repository at this point in the history
  37. Fixes Remove Block button helper to be more resilient to change

    Previously we relied on the number of tab stops to locate the correct button in the menu. This change uses the actual text of the button to identify it and uses an assertion to ensure that the correct button is explicitly required.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    0f51ec5 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    7b95fab View commit details
    Browse the repository at this point in the history
  39. Fixes to catch transforms which are invalid for blocks of different t…

    …ypes
    
    A check was accidentally removed in `b2af0f2611e2a2bc66c62959dbf483abcbe103a9` which allowed multiple blocks of different types to be considered valid even if they were not. Adds conditional to ensure that unless the transform is a wildcard then we test that all the blocks are of the same type as the first block’s type before considering the transform to be valid.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    1ba77c0 View commit details
    Browse the repository at this point in the history
  40. Removes redundant snapshots

    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    6d2d3d7 View commit details
    Browse the repository at this point in the history
  41. Fixes Transforms test to not over-test Group transforms

    Previously we tested every block transforming into the Group Block. This was unwanted overhead.
    
    Fixed to only test 1 single Block transforming into Group. Removed redundant snapshots as a result of removing it.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    7328bbf View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    c950c2e View commit details
    Browse the repository at this point in the history
  43. Fix to make Group transform snapshot tests more resilient to change

    Now explicity selects paragraph and image blocks to test the Group transform rather than simply testing the first block that transform into a Group. This ensures that if the order of transforms changes in the fixtures the test won’t be accidentally invalidated.
    
    Resolves: #14908
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    16c20c6 View commit details
    Browse the repository at this point in the history
  44. Updates to DRY out test and reduce test redundancy and performance

    Through use of smarter filtering we can get away with a single `it.each()` block which improves perf and removes redundant tests.
    
    Addresses #14908 (comment)
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    587ec4b View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    8074131 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    024cdae View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    7453ef2 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    1b3f357 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    dbac411 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    36fda5a View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    358bc1c View commit details
    Browse the repository at this point in the history
  52. Updates to remove unwanted level of context on the translation

    Co-Authored-By: Andrew Duthie <andrew@andrewduthie.com>
    getdave and aduth committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    2b229fc View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    c3bdf0f View commit details
    Browse the repository at this point in the history
  54. Adds tests for isContainerGroupBlock function

    Note these test will need updating when we land #15774
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    b2519fa View commit details
    Browse the repository at this point in the history
  55. Fixes logic around multi blocks of same type and adds tests

    Prevously we had 1 function attempting to test for multiple block selection and checking that the selection was all of the same block type.
    
    This caused bugs within `switchToBlockType` because the logic was confusing. For example, if a selection isn’t a multi block then we don’t need to test that all the blocks are the same.
    
    Separated the two functions and updated conditions in switchToBlockType to reflect this.
    
    Added unit tests to cover two new functions.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    b474df5 View commit details
    Browse the repository at this point in the history
  56. Adds new generator based API signature to Block transforms

    Previously the transforms function was pased two arguments
    
    1. attributes
    2. innerblocks
    
    This wasn’t extensible and more advanced transformations require more information about the block (eg: name).
    
    To avoid bloating the signature, a progressive enhancement approach is applied whereby if a generator function is passed as the transform then we pass the entire block object to the generator.
    
    This is opt-in only and is backwards compatible with all existing transform functions.
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    8c6ccd3 View commit details
    Browse the repository at this point in the history
  57. Adds new apply option method to transform API

    Previously we were modifying the existing transform function to conform to the requirements of a new API (ie: receiving the entire block object rather than the individual arguments).
    
    It was decided that introducing a new `apply` option and soft deprecating the old transform option would be preferable. The apply option if provided now takes precedence over the transform option.
    
    This is fully backwards compatible.
    
    See https://wordpress.slack.com/archives/C02QB2JS7/p1559567845087000
    getdave committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    a30367d View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    1dc6c6d View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    1981661 View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    e8f7506 View commit details
    Browse the repository at this point in the history

Commits on Jun 4, 2019

  1. Fixes test util to avoid infinite loops

    Previously if the button wasn’t found then the loop would continue forever looking for the button. This would have caused timeouts.
    
    Limits the loop to the number of buttons in the document. Also bails out immediately having found the button.
    
    Resolves #14908 (comment)
    getdave committed Jun 4, 2019
    Configuration menu
    Copy the full SHA
    5570049 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8cb7c2f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4254769 View commit details
    Browse the repository at this point in the history
  4. Fix convert API to match established patterns for consistency

    Previously `convert` always passed an array of block objects even if there was only a single block.
    
    This is inconsistent with the implementation of the existing `transform` method which passes only a block’s attributes/innerBlocks pair when it is not a multi block.
    
    To retain consistency with the existing `isMultiBlock` paradiagm this updates the API of `convert` to pass a single block object when not in multiblock mode.
    getdave committed Jun 4, 2019
    Configuration menu
    Copy the full SHA
    60bb8a7 View commit details
    Browse the repository at this point in the history
  5. Fixes error in docs

    Co-Authored-By: Andrew Duthie <andrew@andrewduthie.com>
    getdave and aduth authored Jun 4, 2019
    Configuration menu
    Copy the full SHA
    91f1868 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a579c5f View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    b6f7f55 View commit details
    Browse the repository at this point in the history
  8. Updates to remove keyboard shortcuts

    Following a discussion it was not possible to achieve a consensus on which shortcuts was most suitable (or indeed whether keyboard shortcuts for this were even a good idea).
    
    As a result this has been descoped from this PR and will be addressed elsewhere. Once merged I will push a new placeholder PR with the foundation for shortcuts in place and others can then amend it.
    getdave committed Jun 4, 2019
    Configuration menu
    Copy the full SHA
    4707009 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    afec594 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5dd3452 View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2019

  1. Fixes unwanted check introduced during debugging

    Test for existence of transform is not required and was introduced during debugging. Can be removed.
    getdave committed Jun 5, 2019
    Configuration menu
    Copy the full SHA
    abbcd4e View commit details
    Browse the repository at this point in the history
  2. Updates to collapse spaces in doc blocks

    Co-Authored-By: Andrew Duthie <andrew@andrewduthie.com>
    getdave and aduth authored Jun 5, 2019
    Configuration menu
    Copy the full SHA
    b9350e2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    efa7ac6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c6ee214 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f9fd251 View commit details
    Browse the repository at this point in the history
  6. Reinstate missing Ungroup icon

    Accidentally got lost during renaming of “UnGroup” to “Ungroup”!
    getdave committed Jun 5, 2019
    Configuration menu
    Copy the full SHA
    1a938ad View commit details
    Browse the repository at this point in the history