mirror of
https://github.com/codex-team/editor.js
synced 2024-05-20 15:26:48 +02:00
Do not show plus button if toolbox is empty (#439)
This commit is contained in:
parent
bd09c150bf
commit
f2f8bc0851
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "codex.editor",
|
||||
"version": "2.0.6",
|
||||
"version": "2.0.7",
|
||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||
"main": "build/codex-editor.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -35,6 +35,12 @@ export default class Toolbox extends Module {
|
|||
* @type {number}
|
||||
*/
|
||||
this.activeButtonIndex = -1;
|
||||
|
||||
/**
|
||||
* How many tools displayed in Toolbox
|
||||
* @type {number}
|
||||
*/
|
||||
this.displayedToolsCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,6 +132,9 @@ export default class Toolbox extends Module {
|
|||
if (toolSettings && toolSettings[this.Editor.Tools.apiSettings.SHORTCUT]) {
|
||||
this.enableShortcut(tool, toolName, toolSettings[this.Editor.Tools.apiSettings.SHORTCUT]);
|
||||
}
|
||||
|
||||
/** Increment Tools count */
|
||||
this.displayedToolsCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,6 +204,10 @@ export default class Toolbox extends Module {
|
|||
* Open Toolbox with Tools
|
||||
*/
|
||||
open() {
|
||||
if (this.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.nodes.toolbox.classList.add(Toolbox.CSS.toolboxOpened);
|
||||
this.opened = true;
|
||||
}
|
||||
|
@ -300,4 +313,12 @@ export default class Toolbox extends Module {
|
|||
|
||||
return childNodes[this.activeButtonIndex].title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns True if Toolbox is Empty and nothing to show
|
||||
* @return {boolean}
|
||||
*/
|
||||
get isEmpty() {
|
||||
return this.displayedToolsCount === 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,7 +227,12 @@ export default class Toolbar extends Module {
|
|||
get plusButton() {
|
||||
return {
|
||||
hide: () => this.nodes.plusButton.classList.add(Toolbar.CSS.plusButtonHidden),
|
||||
show: () => this.nodes.plusButton.classList.remove(Toolbar.CSS.plusButtonHidden)
|
||||
show: () => {
|
||||
if (this.Editor.Toolbox.isEmpty) {
|
||||
return;
|
||||
}
|
||||
this.nodes.plusButton.classList.remove(Toolbar.CSS.plusButtonHidden);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue