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

[Feature] Multiple toolbox items for single tool #2050

Merged
merged 84 commits into from
Jun 17, 2022

Conversation

TatianaFomina
Copy link
Contributor

@TatianaFomina TatianaFomina commented May 4, 2022

Adds support of multiple toolbox entries for single tool.
A tool's toolbox property now can be represented as an array of items. Which item can include tool's default config overrides (such as level for header tool). These config overrides are merged with default tool settings when inserting relevant block.

Example of tool with multiple toolbox items can be found at editor-js/header#79

neSpecc and others added 30 commits January 13, 2022 20:45
* FIx mobile popover fixed positioning

* Add mobile popover overlay

* Hide mobile popover on scroll

* Alter toolbox buttons hover

* Fix closing popover on overlay click

* Tests fix

* Fix onchange test

* restore focus after toolbox closing by ESC

* don't move toolbar by block-hover on mobile

Resolves #1972

* popover mobile styles improved

* Cleanup

* Remove scroll event listener

* Lock scroll on mobile

* don't show shortcuts in mobile popover

* Change data attr name

* Remove unused styles

* Remove unused listeners

* disable hover on mobile popover

* Scroll fix

* Lint

* Revert "Scroll fix"

This reverts commit 82deae5.

* Return back background color for active state of toolbox buttons

Co-authored-by: Peter Savchenko <[email protected]>
* Replace visibility property with display for hiding popover

* Disable arrow right and left keys for popover

* Revert "Replace visibility property with display for hiding popover"

This reverts commit af521cf.

* Hide popover via setting max-height to 0 to fix animation in safari

* Remove redundant condition
* Change popover opening direction based on available space below it

* Update check

* Use cacheable decorator
Co-authored-by: George Berezhnoy <[email protected]>
@TatianaFomina TatianaFomina requested a review from ilyamore88 May 29, 2022 12:55
Copy link
Member

@ilyamore88 ilyamore88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* extend converted data with this item's "data" overrides
*/
if (blockDataOverrides) {
newBlockData = Object.assign(newBlockData, blockDataOverrides);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a problem if override is not on the first level.
Eg.

// data
{
  settings: {
    level: 1, 
    anotherProp: 'value',
  }
}

// override
{
  config: {
    level: 2
  }
}

Maybe just left a todo to use deep merge in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will add a note at the docs describing that data overrides should have the same structure that block data

/**
* Skip tools without «import» rule specified
*/
if (!conversionConfig || !conversionConfig.import) {
return;
}

this.addTool(name, toolboxSettings.icon, toolboxSettings.title);
if (Array.isArray(tool.toolbox)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can unify that to array somewhere at the start, so we don't need to add checks everywhere

/**
* Merge real tool's data with data overrides
*/
const defaultBlockData = await this.api.blocks.composeBlockData(toolName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do that only if we have the blockDataOverrides. In other cases (insertion of a regular tool) we will skip extra block construction/saving/merging.

types/api/blocks.d.ts Outdated Show resolved Hide resolved
src/components/modules/api/blocks.ts Outdated Show resolved Hide resolved
@TatianaFomina TatianaFomina merged commit 6c0555a into next Jun 17, 2022
@TatianaFomina TatianaFomina deleted the feat/vertical-toolbox-multiple-items branch June 17, 2022 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants