mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 08:09:55 +01:00
feat(layout): keyboard shortcut for collection properties
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import "./CollectionProperties.css";
|
import "./CollectionProperties.css";
|
||||||
|
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { useContext } from "preact/hooks";
|
import { useContext, useRef } from "preact/hooks";
|
||||||
import { Fragment } from "preact/jsx-runtime";
|
import { Fragment } from "preact/jsx-runtime";
|
||||||
|
|
||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
@@ -12,7 +12,7 @@ import ActionButton from "../react/ActionButton";
|
|||||||
import Dropdown from "../react/Dropdown";
|
import Dropdown from "../react/Dropdown";
|
||||||
import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListToggleableItem } from "../react/FormList";
|
import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListToggleableItem } from "../react/FormList";
|
||||||
import FormTextBox from "../react/FormTextBox";
|
import FormTextBox from "../react/FormTextBox";
|
||||||
import { useNoteLabel, useNoteLabelBoolean, useNoteLabelWithDefault } from "../react/hooks";
|
import { useNoteLabel, useNoteLabelBoolean, useNoteLabelWithDefault, useTriliumEvent } from "../react/hooks";
|
||||||
import Icon from "../react/Icon";
|
import Icon from "../react/Icon";
|
||||||
import { ParentComponent } from "../react/react_utils";
|
import { ParentComponent } from "../react/react_utils";
|
||||||
import { bookPropertiesConfig, BookProperty, ButtonProperty, CheckBoxProperty, ComboBoxItem, ComboBoxProperty, NumberProperty, SplitButtonProperty } from "../ribbon/collection-properties-config";
|
import { bookPropertiesConfig, BookProperty, ButtonProperty, CheckBoxProperty, ComboBoxItem, ComboBoxProperty, NumberProperty, SplitButtonProperty } from "../ribbon/collection-properties-config";
|
||||||
@@ -42,8 +42,15 @@ export default function CollectionProperties({ note }: { note: FNote }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ViewTypeSwitcher({ viewType, setViewType }: { viewType: ViewTypeOptions, setViewType: (newValue: ViewTypeOptions) => void }) {
|
function ViewTypeSwitcher({ viewType, setViewType }: { viewType: ViewTypeOptions, setViewType: (newValue: ViewTypeOptions) => void }) {
|
||||||
|
// Keyboard shortcut
|
||||||
|
const dropdownContainerRef = useRef<HTMLDivElement>(null);
|
||||||
|
useTriliumEvent("toggleRibbonTabBookProperties", () => {
|
||||||
|
dropdownContainerRef.current?.querySelector("button")?.focus();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
dropdownContainerRef={dropdownContainerRef}
|
||||||
text={<>
|
text={<>
|
||||||
<Icon icon={ICON_MAPPINGS[viewType]} />
|
<Icon icon={ICON_MAPPINGS[viewType]} />
|
||||||
{VIEW_TYPE_MAPPINGS[viewType]}
|
{VIEW_TYPE_MAPPINGS[viewType]}
|
||||||
|
|||||||
Reference in New Issue
Block a user