mirror of
https://github.com/codex-team/editor.js
synced 2024-05-06 16:36:47 +02:00
581289c03e
* Default tunes to popover * Add the rest of default tunes * Add popover * Cleanup * Rename custom content * Cleanup * Add ability to open block settings upwards * Fix tests * Cleanup default tunes * Rename and cleanup * Add ability to display rendered custom tunes * cleanup * Rename * Add flag to close tunes popover * Cleanup * i18n * Cleanup * Fix build and tests * Fix for iframe * Add comments * Display active item, move closeOnActivate to popover * Add confirmation support to popover * Handle boolean value in confirmation param * Clarify flippable logic in popover * Comments * Pass editor element as a param of popover constructor * Fix readability * Tests * Fix flipper for confirmation element * Update confirmation config structure * Rename onClick to onActivate * Fix tests and build * Make confirmation props optional * Simplify processing tunes * Renamings * Fix text block tunes * Docs * Update event type * Move enabling confirmation state to separate method * move popover types * Unhardcode color * Support toggling * Add support of disabled items * Fix tab in empty block leading to selecting second item in popover * Remove margins for styles api settings button class * Fix arrow navigation between blocks after opening block tunes * Cleaup in default tunes code * Fix chaining confirmations * Colors * Types * Change the way flippable elements of popover custom area are set * Remove borders around popover icons * Fix untabbable inline toolbar * Fix locked scroll after closing tunes popover on mobile * Cleanup * Set max popover width * Make popover icon's border outside * Fix tab issue * Fix focus/hover issue * Reformat * Cleanup * Fix opening block tunes via keyboard * Add disableSpecialHoverAndFocusBehavior * Add deprecated comment * Cleanup * Fix popover active state * Fix checklist deletion with confirmation * Fix checklist deletion 2 * Fix popover focus * Fix popover items being impossible to flip after searching * Fix popover item highlighting issue * Update flipper.spec.ts * Fixes after review * Add Tunes Api tests * Fix multiple popover entries configured by one tune * Add tool's renderSettings() tests * Add popover confirmation state test * Fix popover width on mobile * Add popover tests * Add changelog and update version * Update changelog * Fix block tunes being unable to open after tune activation Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
87 lines
2 KiB
TypeScript
87 lines
2 KiB
TypeScript
import { ToolConfig } from './tool-config';
|
|
import { ToolConstructable, BlockToolData } from './index';
|
|
import { PopoverItem } 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
|
|
}
|
|
|
|
/**
|
|
* Tool may specify its tunes configuration
|
|
* that can contain either one or multiple entries
|
|
*/
|
|
export type TunesMenuConfig = PopoverItem | PopoverItem[];
|
|
|
|
/**
|
|
* 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>;
|