mirror of
https://github.com/codex-team/editor.js
synced 2026-03-14 22:55:47 +01:00
* fix types export * lint * changelog * tests fixed * fix tests imports * lint tests * upd submodule * Update yarn.lock * rename wrapper to factory * Update package.json * rename to adapters * Update tools.d.ts * BlockTool -> BlockToolAdapter etc * Update nested-list * Update collection.ts
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import type { Tooltip as ITooltip } from '../../../../types/api';
|
|
import type { TooltipOptions, TooltipContent } from 'codex-tooltip/types';
|
|
import Module from '../../__module';
|
|
import type { ModuleConfig } from '../../../types-internal/module-config';
|
|
import * as tooltip from '../../utils/tooltip';
|
|
/**
|
|
* @class TooltipAPI
|
|
* @classdesc Tooltip API
|
|
*/
|
|
export default class TooltipAPI extends Module {
|
|
/**
|
|
* @class
|
|
* @param moduleConfiguration - Module Configuration
|
|
* @param moduleConfiguration.config - Editor's config
|
|
* @param moduleConfiguration.eventsDispatcher - Editor's event dispatcher
|
|
*/
|
|
constructor({ config, eventsDispatcher }: ModuleConfig) {
|
|
super({
|
|
config,
|
|
eventsDispatcher,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Available methods
|
|
*/
|
|
public get methods(): ITooltip {
|
|
return {
|
|
show: (element: HTMLElement,
|
|
content: TooltipContent,
|
|
options?: TooltipOptions
|
|
): void => this.show(element, content, options),
|
|
hide: (): void => this.hide(),
|
|
onHover: (element: HTMLElement,
|
|
content: TooltipContent,
|
|
options?: TooltipOptions
|
|
): void => this.onHover(element, content, options),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Method show tooltip on element with passed HTML content
|
|
*
|
|
* @param {HTMLElement} element - element on which tooltip should be shown
|
|
* @param {TooltipContent} content - tooltip content
|
|
* @param {TooltipOptions} options - tooltip options
|
|
*/
|
|
public show(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
|
tooltip.show(element, content, options);
|
|
}
|
|
|
|
/**
|
|
* Method hides tooltip on HTML page
|
|
*/
|
|
public hide(): void {
|
|
tooltip.hide();
|
|
}
|
|
|
|
/**
|
|
* Decorator for showing Tooltip by mouseenter/mouseleave
|
|
*
|
|
* @param {HTMLElement} element - element on which tooltip should be shown
|
|
* @param {TooltipContent} content - tooltip content
|
|
* @param {TooltipOptions} options - tooltip options
|
|
*/
|
|
public onHover(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
|
tooltip.onHover(element, content, options);
|
|
}
|
|
}
|