Fix/hide conversion toolbar (#991)

* Hide conversion toolbar if there is no conversion tool

* update changelog

* update comment

* updates

* improve code

* Update Changelog
This commit is contained in:
Murod Khaydarov 2019-12-07 14:41:36 +03:00 committed by GitHub
parent 83fcf82467
commit aae8ca6a06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 6 deletions

2
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -6,7 +6,8 @@
- `Fix` — Set initial hidden Inline Toolbar position [#979](https://github.com/codex-team/editor.js/issues/979)
- `Fix` — Fix issue with CodeX.Toolips TypeScript definitions [#978](https://github.com/codex-team/editor.js/issues/978)
- `Fix` — Fix some issues with Inline and Tunes toolbars.
- `Fix` - Fix `minHeight` option with zero-value issue [#724](https://github.com/codex-team/editor.js/issues/724)
- `Fix` - Fix `minHeight` option with zero-value issue [#724](https://github.com/codex-team/editor.js/issues/724)
- `Improvements` — Disable Conversion Toolbar if there are no Conversion Tools [#984](https://github.com/codex-team/editor.js/issues/984)
### 2.16

View file

@ -141,6 +141,15 @@ export default class ConversionToolbar extends Module {
}
}
/**
* Returns true if it has more than one tool available for convert in
*/
public hasTools(): boolean {
const tools = Object.keys(this.tools); // available tools in array representation
return !(tools.length === 1 && tools.shift() === this.config.initialBlock);
}
/**
* Replaces one Block with another
* For that Tools must provide import/export methods

View file

@ -144,6 +144,10 @@ export default class InlineToolbar extends Module {
*/
this.addTools();
/**
* Prepare conversion toolbar.
* If it has any conversion tool then it will be enabled in the Inline Toolbar
*/
this.prepareConversionToolbar();
/**
@ -273,10 +277,17 @@ export default class InlineToolbar extends Module {
this.buttonsList = this.nodes.buttons.querySelectorAll(`.${this.CSS.inlineToolButton}`);
this.opened = true;
/**
* Change Conversion Dropdown content for current tool
*/
this.setConversionTogglerContent();
if (this.Editor.ConversionToolbar.hasTools()) {
/**
* Change Conversion Dropdown content for current tool
*/
this.setConversionTogglerContent();
} else {
/**
* hide Conversion Dropdown with there are no tools
*/
this.nodes.conversionToggler.hidden = true;
}
/**
* Get currently visible buttons to pass it to the Flipper