mirror of
https://github.com/codex-team/editor.js
synced 2024-06-17 13:15:20 +02:00
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:
parent
83fcf82467
commit
aae8ca6a06
2
dist/editor.js
vendored
2
dist/editor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue