editor.js/types/tools/tool-settings.d.ts
Tatiana Fomina e1c70b4fb8
feat(popover): separator (#2690)
* Support delimiter

* Rename types, move types to popover-item folder

* Fix ts errors

* Add tests

* Review fixes

* Review fixes 2

* Fix delimiter while search

* Fix flipper issue

* Fix block tunes types

* Fix types

* Fixes

* Make search input emit event

* Fix types

* Rename delimiter to separator

* Update chengelog
2024-04-22 22:38:20 +03:00

121 lines
2.9 KiB
TypeScript

import { ToolConfig } from './tool-config';
import { ToolConstructable, BlockToolData } from './index';
import { PopoverItemDefaultParams, PopoverItemSeparatorParams, PopoverItemParams } from '../configs';
/**
* Tool may specify its toolbox configuration
* It may include several entries as well
*/
export type ToolboxConfig = ToolboxConfigEntry | ToolboxConfigEntry[];
/**
* Tool's Toolbox settings
*/
export interface ToolboxConfigEntry {
/**
* Tool title for Toolbox
*/
title?: string;
/**
* HTML string with an icon for Toolbox
*/
icon?: string;
/**
* May contain overrides for tool default config
*/
data?: BlockToolData
}
/**
* Represents single interactive (non-separator) Tunes Menu item
*/
export type TunesMenuConfigDefaultItem = PopoverItemDefaultParams & {
/**
* Tune displayed text.
*/
title?: string;
/**
* Tune displayed text.
* Alias for title property
*
* @deprecated - use title property instead
*/
label?: string
/**
* Menu item parameters that should be applied on item activation.
* May be used to ask user for confirmation before executing menu item activation handler.
*/
confirmation?: TunesMenuConfigDefaultItem;
}
/**
* Represents single separator Tunes Menu item
*/
export type TunesMenuConfigSeparatorItem = PopoverItemSeparatorParams;
/**
* Union of all Tunes Menu item types
*/
export type TunesMenuConfigItem = TunesMenuConfigDefaultItem | TunesMenuConfigSeparatorItem;
/**
* Tool may specify its tunes configuration
* that can contain either one or multiple entries
*/
export type TunesMenuConfig = TunesMenuConfigItem | TunesMenuConfigItem[];
/**
* Object passed to the Tool's constructor by {@link EditorConfig#tools}
*
* @template Config - the structure describing a config object supported by the tool
*/
export interface ExternalToolSettings<Config extends object = any> {
/**
* Tool's class
*/
class: ToolConstructable;
/**
* User configuration object that will be passed to the Tool's constructor
*/
config?: ToolConfig<Config>;
/**
* Is need to show Inline Toolbar.
* Can accept array of Tools for InlineToolbar or boolean.
*/
inlineToolbar?: boolean | string[];
/**
* BlockTunes for Tool
* Can accept array of tune names or boolean.
*/
tunes?: boolean | string[];
/**
* Define shortcut that will render Tool
*/
shortcut?: string;
/**
* Tool's Toolbox settings
* It will be hidden from Toolbox when false is specified.
*/
toolbox?: ToolboxConfig | false;
}
/**
* For internal Tools 'class' property is optional
*/
export type InternalToolSettings<Config extends object = any> = Omit<ExternalToolSettings<Config>, 'class'> & Partial<Pick<ExternalToolSettings<Config>, 'class'>>;
/**
* Union of external and internal Tools settings
*/
export type ToolSettings<Config extends object = any> = InternalToolSettings<Config> | ExternalToolSettings<Config>;