Merge remote-tracking branch 'origin/main' into react/type_widgets

This commit is contained in:
Elian Doran
2025-09-25 11:12:28 +03:00
98 changed files with 3564 additions and 2104 deletions

View File

@@ -86,6 +86,7 @@ interface FormListItemOpts {
disabledTooltip?: string;
checked?: boolean | null;
selected?: boolean;
container?: boolean;
onClick?: (e: MouseEvent) => void;
triggerCommand?: CommandNames;
description?: string;
@@ -98,7 +99,7 @@ const TOOLTIP_CONFIG: Partial<Tooltip.Options> = {
fallbackPlacements: [ "right" ]
}
export function FormListItem({ className, icon, value, title, active, disabled, checked, onClick, selected, rtl, triggerCommand, description, ...contentProps }: FormListItemOpts) {
export function FormListItem({ className, icon, value, title, active, disabled, checked, container, onClick, selected, rtl, triggerCommand, description, ...contentProps }: FormListItemOpts) {
const itemRef = useRef<HTMLLIElement>(null);
if (checked) {
@@ -110,9 +111,9 @@ export function FormListItem({ className, icon, value, title, active, disabled,
return (
<li
ref={itemRef}
class={`dropdown-item ${active ? "active" : ""} ${disabled ? "disabled" : ""} ${selected ? "selected" : ""} ${className ?? ""}`}
class={`dropdown-item ${active ? "active" : ""} ${disabled ? "disabled" : ""} ${selected ? "selected" : ""} ${container ? "dropdown-container-item": ""} ${className ?? ""}`}
data-value={value} title={title}
tabIndex={0}
tabIndex={container ? -1 : 0}
onClick={onClick}
data-trigger-command={triggerCommand}
dir={rtl ? "rtl" : undefined}

View File

@@ -35,7 +35,7 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIc
if (!ref.current || !jqueryEl) return;
ref.current.replaceChildren(jqueryEl[0]);
highlightSearch(ref.current);
}, [ jqueryEl ]);
}, [ jqueryEl, highlightedTokens ]);
if (style) {
jqueryEl?.css(style);

View File

@@ -332,7 +332,9 @@ export function useNoteRelation(note: FNote | undefined | null, relationName: Re
*
* @param note the note whose label to read/write.
* @param labelName the name of the label to read/write.
* @returns an array where the first element is the getter and the second element is the setter. The setter has a special behaviour for convenience: if the value is undefined, the label is created without a value (e.g. a tag), if the value is null then the label is removed.
* @returns an array where the first element is the getter and the second element is the setter. The setter has a special behaviour for convenience:
* - if the value is undefined, the label is created without a value (e.g. a tag)
* - if the value is null then the label is removed.
*/
export function useNoteLabel(note: FNote | undefined | null, labelName: FilterLabelsByType<string>): [string | null | undefined, (newValue: string | null | undefined) => void] {
const [ , setLabelValue ] = useState<string | null | undefined>();
@@ -352,9 +354,9 @@ export function useNoteLabel(note: FNote | undefined | null, labelName: FilterLa
const setter = useCallback((value: string | null | undefined) => {
if (note) {
if (value || value === undefined) {
if (value !== null) {
attributes.setLabel(note.noteId, labelName, value)
} else if (value === null) {
} else {
attributes.removeOwnedLabelByName(note, labelName);
}
}
@@ -592,10 +594,11 @@ export function useStaticTooltip(elRef: RefObject<Element>, config?: Partial<Too
}, [ elRef, config ]);
}
export function useStaticTooltipWithKeyboardShortcut(elRef: RefObject<Element>, title: string, actionName: KeyboardActionNames | undefined) {
export function useStaticTooltipWithKeyboardShortcut(elRef: RefObject<Element>, title: string, actionName: KeyboardActionNames | undefined, opts?: Omit<Partial<Tooltip.Options>, "title">) {
const [ keyboardShortcut, setKeyboardShortcut ] = useState<string[]>();
useStaticTooltip(elRef, {
title: keyboardShortcut?.length ? `${title} (${keyboardShortcut?.join(",")})` : title
title: keyboardShortcut?.length ? `${title} (${keyboardShortcut?.join(",")})` : title,
...opts
});
useEffect(() => {