This commit is contained in:
Tanya Fomina 2022-07-13 16:19:37 +08:00
commit aece45df28
2 changed files with 31 additions and 5 deletions

View file

@ -656,15 +656,22 @@ export default class Block extends EventsDispatcher<BlockEvents> {
}
/**
* Returns list of tunes available for block as popover items
* Returns list of tunes available for block in popover format
*/
public getTunesList(): PopoverItem[] {
const tunes = Array.from(this.tunesInstances.values());
const defaultTunes = Array.from(this.defaultTunesInstances.values());
const customTunesInstances = Array.from(this.tunesInstances.values());
const defaultTunesInstances = Array.from(this.defaultTunesInstances.values());
const tunesDefinedInTool =
Array.isArray(this.toolInstance.blockSettings)
? this.toolInstance.blockSettings
: [ this.toolInstance.blockSettings ];
return tunes.concat(defaultTunes)
const otherTunes = customTunesInstances.concat(defaultTunesInstances)
.map(tune => tune.blockSettings)
.filter(item => !!item);
// @ts-ignore
return tunesDefinedInTool.concat(otherTunes).filter(item => !item.isActive);
}
/**
@ -742,6 +749,19 @@ export default class Block extends EventsDispatcher<BlockEvents> {
}
}
/**
*
*/
// public get blockSettings(): PopoverItem | PopoverItem[] {
// if (_.isFunction(this.toolInstance.blockSettings)) {
// return this.toolInstance.blockSettings();
// }
// }
// public async getActiveTunesEntry() {
// }
/**
* Tool could specify several entries to be displayed at the Toolbox (for example, "Heading 1", "Heading 2", "Heading 3")
* This method returns the entry that is related to the Block (depended on the Block data)

View file

@ -5,6 +5,7 @@ import { ToolConfig } from './tool-config';
import { API, BlockAPI, ToolboxConfig } from '../index';
import { PasteEvent } from './paste-events';
import { MoveEvent } from './hook-events';
import { PopoverItem } from '../../src/components/utils/popover';
/**
* Describe Block Tool object
@ -29,6 +30,11 @@ export interface BlockTool extends BaseTool {
*/
renderSettings?(): HTMLElement;
/**
*
*/
blockSettings?: PopoverItem | PopoverItem[];
/**
* Validate Block's data
* @param {BlockToolData} blockData