mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 15:55:52 +01:00
16 lines
433 B
TypeScript
16 lines
433 B
TypeScript
import type { RefObject } from "preact";
|
|
|
|
/**
|
|
* Takes in a React ref and returns a corresponding JQuery selector.
|
|
*
|
|
* @param ref the React ref from which to obtain the jQuery selector.
|
|
* @returns the corresponding jQuery selector.
|
|
*/
|
|
export function refToJQuerySelector<T extends HTMLElement>(ref: RefObject<T> | null): JQuery<T> {
|
|
if (ref?.current) {
|
|
return $(ref.current);
|
|
} else {
|
|
return $();
|
|
}
|
|
}
|