mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
chore(client): fix type error due to React integration
This commit is contained in:
parent
3e213699e0
commit
ed320e4e24
@ -504,6 +504,24 @@ export function useTooltip(elRef: RefObject<HTMLElement>, config: Partial<Toolti
|
|||||||
return { showTooltip, hideTooltip };
|
return { showTooltip, hideTooltip };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to {@link useTooltip}, but doesn't expose methods to imperatively hide or show the tooltip.
|
||||||
|
*
|
||||||
|
* @param elRef the element to bind the tooltip to.
|
||||||
|
* @param config optionally, the tooltip configuration.
|
||||||
|
*/
|
||||||
|
export function useStaticTooltip(elRef: RefObject<HTMLElement>, config?: Partial<Tooltip.Options>) {
|
||||||
|
useEffect(() => {
|
||||||
|
if (!elRef?.current) return;
|
||||||
|
|
||||||
|
const $el = $(elRef.current);
|
||||||
|
$el.tooltip(config);
|
||||||
|
return () => {
|
||||||
|
$el.tooltip("dispose");
|
||||||
|
}
|
||||||
|
}, [ elRef, config ]);
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||||
export function useLegacyImperativeHandlers(handlers: Record<string, Function>) {
|
export function useLegacyImperativeHandlers(handlers: Record<string, Function>) {
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
||||||
import { t } from "../../services/i18n";
|
import { t } from "../../services/i18n";
|
||||||
import { useNoteContext, useTriliumEvents } from "../react/hooks";
|
import { useNoteContext, useStaticTooltip, useTooltip, useTriliumEvents } from "../react/hooks";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
import { VNode } from "preact";
|
import { VNode } from "preact";
|
||||||
import BasicPropertiesTab from "./BasicPropertiesTab";
|
import BasicPropertiesTab from "./BasicPropertiesTab";
|
||||||
@ -233,6 +233,9 @@ export default function Ribbon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RibbonTab({ icon, title, active, onClick }: { icon: string; title: string; active: boolean, onClick: () => void }) {
|
function RibbonTab({ icon, title, active, onClick }: { icon: string; title: string; active: boolean, onClick: () => void }) {
|
||||||
|
const iconRef = useRef<HTMLDivElement>(null);
|
||||||
|
useStaticTooltip(iconRef, { });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@ -240,6 +243,7 @@ function RibbonTab({ icon, title, active, onClick }: { icon: string; title: stri
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
ref={iconRef}
|
||||||
className={`ribbon-tab-title-icon ${icon}`}
|
className={`ribbon-tab-title-icon ${icon}`}
|
||||||
title={title}
|
title={title}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user