mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 18:34:24 +01:00
feat(note_bars/collection): support dropdown menu click action
This commit is contained in:
parent
a1513a3567
commit
1a9fb34a6e
@ -106,9 +106,17 @@ function ButtonPropertyView({ note, property }: { note: FNote, property: ButtonP
|
|||||||
function SplitButtonPropertyView({ note, property }: { note: FNote, property: SplitButtonProperty }) {
|
function SplitButtonPropertyView({ note, property }: { note: FNote, property: SplitButtonProperty }) {
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
const ItemsComponent = property.items;
|
const ItemsComponent = property.items;
|
||||||
|
const clickContext = parentComponent && {
|
||||||
|
note,
|
||||||
|
triggerCommand: parentComponent.triggerCommand.bind(parentComponent)
|
||||||
|
};
|
||||||
|
|
||||||
return (parentComponent &&
|
return (parentComponent &&
|
||||||
<FormDropdownSubmenu icon={property.icon ?? "bx bx-empty"} title={property.label}>
|
<FormDropdownSubmenu
|
||||||
|
icon={property.icon ?? "bx bx-empty"}
|
||||||
|
title={property.label}
|
||||||
|
onDropdownToggleClicked={() => clickContext && property.onClick(clickContext)}
|
||||||
|
>
|
||||||
<ItemsComponent note={note} parentComponent={parentComponent} />
|
<ItemsComponent note={note} parentComponent={parentComponent} />
|
||||||
</FormDropdownSubmenu>
|
</FormDropdownSubmenu>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -206,10 +206,11 @@ export function FormDropdownDivider() {
|
|||||||
return <div className="dropdown-divider" />;
|
return <div className="dropdown-divider" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FormDropdownSubmenu({ icon, title, children, dropStart }: {
|
export function FormDropdownSubmenu({ icon, title, children, dropStart, onDropdownToggleClicked }: {
|
||||||
icon: string,
|
icon: string,
|
||||||
title: ComponentChildren,
|
title: ComponentChildren,
|
||||||
children: ComponentChildren,
|
children: ComponentChildren,
|
||||||
|
onDropdownToggleClicked?: () => void,
|
||||||
dropStart?: boolean
|
dropStart?: boolean
|
||||||
}) {
|
}) {
|
||||||
const [ openOnMobile, setOpenOnMobile ] = useState(false);
|
const [ openOnMobile, setOpenOnMobile ] = useState(false);
|
||||||
@ -224,6 +225,10 @@ export function FormDropdownSubmenu({ icon, title, children, dropStart }: {
|
|||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
setOpenOnMobile(!openOnMobile);
|
setOpenOnMobile(!openOnMobile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onDropdownToggleClicked) {
|
||||||
|
onDropdownToggleClicked();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon icon={icon} />{" "}
|
<Icon icon={icon} />{" "}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user