mirror of
https://github.com/codex-team/editor.js
synced 2024-05-07 00:46:45 +02:00
63eeec0f3b
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com> Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com> Co-authored-by: tasuku-s <tasuku@freemind.co.jp> Co-authored-by: Athul Anil Kumar <athul7744@outlook.com> Co-authored-by: Taly <vitalik7tv@yandex.ru> Co-authored-by: flaming-cl <51183663+flaming-cl@users.noreply.github.com> Co-authored-by: Nguyen Ngoc Son <sonnn.se@gmail.com> Co-authored-by: Sisir Das K <37764463+sis-dk@users.noreply.github.com> Co-authored-by: Sisir <sisir@hellosivi.com>
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
/* eslint-disable jsdoc/no-undefined-types */
|
|
import Module from '../__module';
|
|
|
|
/**
|
|
* Use external module CodeX Tooltip
|
|
*/
|
|
import CodeXTooltips, { TooltipContent, TooltipOptions } from 'codex-tooltip';
|
|
import { ModuleConfig } from '../../types-internal/module-config';
|
|
|
|
/**
|
|
* Tooltip
|
|
*
|
|
* Decorates any tooltip module like adapter
|
|
*/
|
|
export default class Tooltip extends Module {
|
|
/**
|
|
* Tooltips lib: CodeX Tooltips
|
|
*
|
|
* @see https://github.com/codex-team/codex.tooltips
|
|
*/
|
|
private lib: CodeXTooltips = new CodeXTooltips();
|
|
|
|
/**
|
|
* @class
|
|
* @param {EditorConfig} - Editor's config
|
|
*/
|
|
constructor({ config }: ModuleConfig) {
|
|
super({ config });
|
|
}
|
|
|
|
/**
|
|
* Shows tooltip on element with passed HTML content
|
|
*
|
|
* @param {HTMLElement} element - any HTML element in DOM
|
|
* @param {TooltipContent} content - tooltip's content
|
|
* @param {TooltipOptions} options - showing settings
|
|
*/
|
|
public show(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
|
this.lib.show(element, content, options);
|
|
}
|
|
|
|
/**
|
|
* Hides tooltip
|
|
*/
|
|
public hide(): void {
|
|
this.lib.hide();
|
|
}
|
|
|
|
/**
|
|
* Binds 'mouseenter' and 'mouseleave' events that shows/hides the Tooltip
|
|
*
|
|
* @param {HTMLElement} element - any HTML element in DOM
|
|
* @param {TooltipContent} content - tooltip's content
|
|
* @param {TooltipOptions} options - showing settings
|
|
*/
|
|
public onHover(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
|
this.lib.onHover(element, content, options);
|
|
}
|
|
}
|