Rename and cleanup

This commit is contained in:
Tanya Fomina 2022-07-05 00:02:14 +08:00
commit 3e2f6244f7
2 changed files with 6 additions and 22 deletions

View file

@ -643,29 +643,13 @@ export default class Block extends EventsDispatcher<BlockEvents> {
}
/**
* Enumerates initialized tunes and returns fragment that can be appended to the toolbars area
*
* @returns {DocumentFragment[]}
* Returns list of tunes available for block
*/
public renderTunes(): [DocumentFragment, DocumentFragment] {
const tunesElement = document.createDocumentFragment();
const defaultTunesElement = document.createDocumentFragment();
public getTunesList(): PopoverItem[] {
const tunes = Array.from(this.tunesInstances.values());
const defaultTunes = Array.from(this.defaultTunesInstances.values());
this.tunesInstances.forEach((tune) => {
$.append(tunesElement, tune.render());
});
this.defaultTunesInstances.forEach((tune) => {
$.append(defaultTunesElement, tune.render());
});
return [tunesElement, defaultTunesElement];
}
/**
*
*/
public getTunesItems(): PopoverItem[] {
return Array.from(this.defaultTunesInstances.values())
return tunes.concat(defaultTunes)
.map(tune => tune.blockSettings)
.filter(item => !!item);
}

View file

@ -109,7 +109,7 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
searchable: true,
filterLabel: I18n.ui(I18nInternalNS.ui.toolbar.toolbox, 'Filter'),
nothingFoundLabel: I18n.ui(I18nInternalNS.ui.toolbar.toolbox, 'Nothing found'),
items: targetBlock.getTunesItems(),
items: targetBlock.getTunesList(),
customContent: this.nodes.toolSettings,
api: this.Editor.API.methods,
});