Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaFomina committed May 15, 2022
1 parent 22259eb commit ebe55e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/components/tools/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ export enum InternalBlockToolSettings {
* Tool Toolbox config
*/
Toolbox = 'toolbox',
/**
* Current active toolbox item
*/
ToolboxItem = 'toolboxItem',
/**
* Tool conversion config
*/
Expand Down
20 changes: 16 additions & 4 deletions src/components/tools/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ export default class BlockTool extends BaseTool<IBlockTool> {
const toolToolboxSettings = this.constructable[InternalBlockToolSettings.Toolbox] as ToolboxConfig;

if (Array.isArray(toolToolboxSettings)) {
return toolToolboxSettings.map(item => this.getActualToolboxSettings(item)).map(item => ({
...item,
id: _.getHash(item.icon + item.title),
}));
return toolToolboxSettings
.map(item => this.getActualToolboxSettings(item))
.map(item => this.addIdToToolboxConfig(item));
} else {
return this.getActualToolboxSettings(toolToolboxSettings);
}
Expand Down Expand Up @@ -183,4 +182,17 @@ export default class BlockTool extends BaseTool<IBlockTool> {

return Object.assign({}, toolboxItemSettings, userToolboxSettings);
}

/**
* Returns toolbox config entry with apended id field which is used later for
* identifying an entry in case the tool has multiple toolbox entries configured.
*
* @param config - toolbox config entry
*/
private addIdToToolboxConfig(config: ToolboxConfig): ToolboxConfig {
return {
...config,
id: _.getHash(config.icon + config.title),
};
}
}

0 comments on commit ebe55e6

Please sign in to comment.