mirror of
https://github.com/codex-team/editor.js
synced 2024-06-01 21:42:26 +02:00
Merge 7aa97aeab0
into ea2be754e7
This commit is contained in:
commit
5714bb3a20
|
@ -46,14 +46,14 @@ export default class TooltipAPI extends Module {
|
|||
* @param {TooltipOptions} options - tooltip options
|
||||
*/
|
||||
public show(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
||||
tooltip.show(element, content, options);
|
||||
tooltip.show(element, content, options, this.config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method hides tooltip on HTML page
|
||||
*/
|
||||
public hide(): void {
|
||||
tooltip.hide();
|
||||
tooltip.hide(false, this.config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,6 +64,6 @@ export default class TooltipAPI extends Module {
|
|||
* @param {TooltipOptions} options - tooltip options
|
||||
*/
|
||||
public onHover(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
||||
tooltip.onHover(element, content, options);
|
||||
tooltip.onHover(element, content, options, this.config);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,7 +397,7 @@ export default class Toolbar extends Module<ToolbarNodes> {
|
|||
|
||||
tooltip.onHover(this.nodes.plusButton, tooltipContent, {
|
||||
hidingDelay: 400,
|
||||
});
|
||||
}, this.config);
|
||||
|
||||
/**
|
||||
* Fill Actions Zone:
|
||||
|
@ -416,7 +416,8 @@ export default class Toolbar extends Module<ToolbarNodes> {
|
|||
I18n.ui(I18nInternalNS.ui.blockTunes.toggler, 'Click to tune'),
|
||||
{
|
||||
hidingDelay: 400,
|
||||
}
|
||||
},
|
||||
this.config
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -450,7 +450,7 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
|
|||
tooltip.onHover(this.nodes.conversionToggler, I18n.ui(I18nInternalNS.ui.inlineToolbar.converter, 'Convert to'), {
|
||||
placement: 'top',
|
||||
hidingDelay: 100,
|
||||
});
|
||||
}, this.config);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,7 +593,7 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
|
|||
tooltip.onHover(button, tooltipContent, {
|
||||
placement: 'top',
|
||||
hidingDelay: 100,
|
||||
});
|
||||
}, this.config);
|
||||
}
|
||||
|
||||
instance.checkState(SelectionUtils.get());
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
import CodeXTooltips from 'codex-tooltip';
|
||||
import type { TooltipOptions, TooltipContent } from 'codex-tooltip/types';
|
||||
import { EditorConfig } from '../../../types';
|
||||
|
||||
/**
|
||||
* Tooltips lib: CodeX Tooltips
|
||||
|
@ -16,13 +17,15 @@ let lib: null | CodeXTooltips = null;
|
|||
* If library is needed, but it is not initialized yet, this function will initialize it
|
||||
*
|
||||
* For example, if editor was destroyed and then initialized again
|
||||
*
|
||||
* @param {string} nonce - The nonce to apply to the injected styles.
|
||||
*/
|
||||
function prepare(): void {
|
||||
export function prepare(nonce?: string): void {
|
||||
if (lib) {
|
||||
return;
|
||||
}
|
||||
|
||||
lib = new CodeXTooltips();
|
||||
lib = new CodeXTooltips(nonce);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,9 +34,10 @@ function prepare(): void {
|
|||
* @param {HTMLElement} element - any HTML element in DOM
|
||||
* @param content - tooltip's content
|
||||
* @param options - showing settings
|
||||
* @param {EditorConfig} config - The EditorJS config
|
||||
*/
|
||||
export function show(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
||||
prepare();
|
||||
export function show(element: HTMLElement, content: TooltipContent, options?: TooltipOptions, config?: EditorConfig): void {
|
||||
prepare(config?.style.nonce);
|
||||
|
||||
lib?.show(element, content, options);
|
||||
}
|
||||
|
@ -42,9 +46,10 @@ export function show(element: HTMLElement, content: TooltipContent, options?: To
|
|||
* Hides tooltip
|
||||
*
|
||||
* @param skipHidingDelay — pass true to immediately hide the tooltip
|
||||
* @param {EditorConfig} config - The EditorJS config
|
||||
*/
|
||||
export function hide(skipHidingDelay = false): void {
|
||||
prepare();
|
||||
export function hide(skipHidingDelay = false, config?: EditorConfig): void {
|
||||
prepare(config?.style.nonce);
|
||||
|
||||
lib?.hide(skipHidingDelay);
|
||||
}
|
||||
|
@ -55,9 +60,10 @@ export function hide(skipHidingDelay = false): void {
|
|||
* @param {HTMLElement} element - any HTML element in DOM
|
||||
* @param content - tooltip's content
|
||||
* @param options - showing settings
|
||||
* @param {EditorConfig} config - The EditorJS config
|
||||
*/
|
||||
export function onHover(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
||||
prepare();
|
||||
export function onHover(element: HTMLElement, content: TooltipContent, options?: TooltipOptions, config?: EditorConfig): void {
|
||||
prepare(config?.style.nonce);
|
||||
|
||||
lib?.onHover(element, content, options);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue