Skip to content

Commit

Permalink
Use false in order to hide toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
hata6502 committed Jul 31, 2020
1 parent 36ccfef commit 9d0d169
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/modules/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions src/components/modules/toolbar/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 1 addition & 6 deletions types/tools/tool-settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -50,5 +45,5 @@ export interface ToolSettings {
/**
* Tool's Toolbox settings
*/
toolbox?: ToolboxConfig;
toolbox?: ToolboxConfig | false;
}

0 comments on commit 9d0d169

Please sign in to comment.