You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.5 KiB

4 months ago
import type { RuntimeContext } from '../../runtime/types';
import type { CornerPlacement } from '../../types';
import type { BasePluginOptions } from '../base-plugin';
import { BasePlugin } from '../base-plugin';
import type { ToolbarItem } from './util';
/**
* <zh/> Toolbar
*
* <en/> The options of the Toolbar toolbar
*/
export interface ToolbarOptions extends BasePluginOptions {
/**
* <zh/> DOM classname便 `g6-toolbar`
*
* <en/> The classname appended to the menu DOM for custom styles. The default is `g6-toolbar`
*/
className?: string;
/**
* <zh/> Toolbar DOM style
*
* <en/> The position of the Toolbar relative to the canvas, which will affect the style of the DOM
* @defaultValue 'top-left'
*/
position?: CornerPlacement;
/**
* <zh/> style
*
* <en/> The style style of the Toolbar, which can be used to set its position relative to the canvas
*/
style?: Partial<CSSStyleDeclaration>;
/**
* <zh/>
*
* <en/> The callback method triggered when the toolbar item is clicked
*/
onClick?: (value: string, target: Element) => void;
/**
* <zh/> `Promise`
*
* <en/> Return the list of toolbar items, support return a `Promise` as items
*/
getItems: () => ToolbarItem[] | Promise<ToolbarItem[]>;
}
/**
* <zh/>
*
* <en/> Toolbar, support configuration of toolbar items, and callback methods after clicking
*/
export declare class Toolbar extends BasePlugin<ToolbarOptions> {
static defaultOptions: Partial<ToolbarOptions>;
private $element;
constructor(context: RuntimeContext, options: ToolbarOptions);
/**
* <zh/>
*
* <en/> Update the configuration of the toolbar
* @param options - <zh/> | <en/> The options of the toolbar
* @internal
*/
update(options: Partial<ToolbarOptions>): Promise<void>;
/**
* <zh/>
*
* <en/> Destroy the toolbar
* @internal
*/
destroy(): void;
private getDOMContent;
private onToolbarItemClick;
}