diff --git a/src/components/modules/renderer.ts b/src/components/modules/renderer.ts index 402acd78a5..357084feab 100644 --- a/src/components/modules/renderer.ts +++ b/src/components/modules/renderer.ts @@ -91,7 +91,7 @@ export default class Renderer extends Module { const toolToolboxSettings = (Tools.unavailable[tool] as BlockToolConstructable).toolbox; const userToolboxSettings = Tools.getToolSettings(tool).toolbox; - stubData.title = toolToolboxSettings.title || userToolboxSettings.title || stubData.title; + stubData.title = toolToolboxSettings.title || (userToolboxSettings && userToolboxSettings.title) || stubData.title; } const stub = BlockManager.insert({ diff --git a/src/components/modules/toolbar/conversion.ts b/src/components/modules/toolbar/conversion.ts index 5939427950..a420c228f0 100644 --- a/src/components/modules/toolbar/conversion.ts +++ b/src/components/modules/toolbar/conversion.ts @@ -264,10 +264,15 @@ export default class ConversionToolbar extends Module { const toolToolboxSettings = toolClass[internalSettings.TOOLBOX]; const conversionConfig = toolClass[internalSettings.CONVERSION_CONFIG]; + const userSettings = this.Editor.Tools.USER_SETTINGS; + const userToolboxSettings = this.Editor.Tools.getToolSettings(toolName)[userSettings.TOOLBOX]; + + const toolboxSettings = userToolboxSettings ?? toolToolboxSettings; + /** * Skip tools that don't pass 'toolbox' property */ - if (_.isEmpty(toolToolboxSettings) || !toolToolboxSettings.icon) { + if (_.isEmpty(toolboxSettings) || !toolboxSettings.icon) { continue; } @@ -278,7 +283,7 @@ export default class ConversionToolbar extends Module { continue; } - this.addTool(toolName, toolToolboxSettings.icon, toolToolboxSettings.title); + this.addTool(toolName, toolboxSettings.icon, toolboxSettings.title); } } diff --git a/src/components/modules/toolbar/toolbox.ts b/src/components/modules/toolbar/toolbox.ts index 8df8b99fd8..431ae95030 100644 --- a/src/components/modules/toolbar/toolbox.ts +++ b/src/components/modules/toolbar/toolbox.ts @@ -183,16 +183,16 @@ export default class Toolbox extends Module { // return; // } - const userToolboxSettings = this.Editor.Tools.getToolSettings(toolName)[userSettings.TOOLBOX] || {}; + const userToolboxSettings = this.Editor.Tools.getToolSettings(toolName)[userSettings.TOOLBOX]; - if (userToolboxSettings.hidden === undefined ? toolToolboxSettings.hidden : userToolboxSettings.hidden === true) { + if ((userToolboxSettings ?? toolToolboxSettings) === false) { return; } const button = $.make('li', [ this.CSS.toolboxButton ]); button.dataset.tool = toolName; - button.innerHTML = userToolboxSettings.icon || toolToolboxSettings.icon; + button.innerHTML = (userToolboxSettings && userToolboxSettings.icon) || toolToolboxSettings.icon; $.append(this.nodes.toolbox, button); diff --git a/types/tools/tool-settings.d.ts b/types/tools/tool-settings.d.ts index 3b08d4ae93..53731eb4eb 100644 --- a/types/tools/tool-settings.d.ts +++ b/types/tools/tool-settings.d.ts @@ -14,11 +14,6 @@ export interface ToolboxConfig { * HTML string with an icon for Toolbox */ icon?: string; - - /** - * Hide from tool box, but load the tool - */ - hidden?: boolean; } /** @@ -50,5 +45,5 @@ export interface ToolSettings { /** * Tool's Toolbox settings */ - toolbox?: ToolboxConfig; + toolbox?: ToolboxConfig | false; }