diff --git a/src/components/block/index.ts b/src/components/block/index.ts index 7edea34d..a2df25e7 100644 --- a/src/components/block/index.ts +++ b/src/components/block/index.ts @@ -656,15 +656,22 @@ export default class Block extends EventsDispatcher { } /** - * 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 { } } + /** + * + */ + // 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) diff --git a/types/tools/block-tool.d.ts b/types/tools/block-tool.d.ts index afc2a0ed..58571aa9 100644 --- a/types/tools/block-tool.d.ts +++ b/types/tools/block-tool.d.ts @@ -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