-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
[Feature] Multiple toolbox items for single tool #2050
Conversation
* 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]>
…/editor.js into feat/vertical-toolbox
….com/codex-team/editor.js into feat/vertical-toolbox-multiple-items
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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
src/components/ui/toolbox.ts
Outdated
/** | ||
* Merge real tool's data with data overrides | ||
*/ | ||
const defaultBlockData = await this.api.blocks.composeBlockData(toolName); |
There was a problem hiding this comment.
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.
Co-authored-by: Peter Savchenko <[email protected]>
Co-authored-by: Peter Savchenko <[email protected]>
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