diff --git a/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx b/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx
index 7a5f9b6b1..80627151f 100644
--- a/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx
+++ b/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx
@@ -116,20 +116,13 @@ function SplitButtonPropertyView({ note, property }: { note: FNote, property: Sp
triggerCommand: parentComponent.triggerCommand.bind(parentComponent)
};
+ const ItemsComponent = property.items;
return clickContext && property.onClick(clickContext)}
>
- {clickContext && property.items.map(subproperty => {
- if ("type" in subproperty && subproperty) {
- return
- }
-
- return (
- clickContext && subproperty.onClick(clickContext)}>{subproperty.label}
- );
- })}
+ {parentComponent && }
}
diff --git a/apps/client/src/widgets/ribbon/collection-properties-config.ts b/apps/client/src/widgets/ribbon/collection-properties-config.tsx
similarity index 80%
rename from apps/client/src/widgets/ribbon/collection-properties-config.ts
rename to apps/client/src/widgets/ribbon/collection-properties-config.tsx
index 5161e1496..c0827d8b2 100644
--- a/apps/client/src/widgets/ribbon/collection-properties-config.ts
+++ b/apps/client/src/widgets/ribbon/collection-properties-config.tsx
@@ -6,6 +6,10 @@ import { DEFAULT_MAP_LAYER_NAME, MAP_LAYERS, type MapLayer } from "../collection
import { ViewTypeOptions } from "../collections/interface";
import { FilterLabelsByType } from "@triliumnext/commons";
import { DEFAULT_THEME, getPresentationThemes } from "../collections/presentation/themes";
+import { VNode } from "preact";
+import { useNoteLabel } from "../react/hooks";
+import { FormDropdownDivider, FormListItem } from "../react/FormList";
+import Component from "../../components/component";
interface BookConfig {
properties: BookProperty[];
@@ -27,12 +31,7 @@ export interface ButtonProperty {
export interface SplitButtonProperty extends Omit {
type: "split-button";
- items: ({
- label: string;
- onClick(context: BookContext): void;
- } | {
- type: "separator"
- })[];
+ items({ note, parentComponent }: { note: FNote, parentComponent: Component }): VNode;
}
export interface NumberProperty {
@@ -100,34 +99,7 @@ export const bookPropertiesConfig: Record = {
type: "split-button",
icon: "bx bx-move-vertical",
onClick: buildExpandListHandler(1),
- items: [
- {
- label: "Expand 1 level",
- onClick: buildExpandListHandler(1)
- },
- { type: "separator" },
- {
- label: "Expand 2 levels",
- onClick: buildExpandListHandler(2),
- },
- {
- label: "Expand 3 levels",
- onClick: buildExpandListHandler(3),
- },
- {
- label: "Expand 4 levels",
- onClick: buildExpandListHandler(4),
- },
- {
- label: "Expand 5 levels",
- onClick: buildExpandListHandler(5),
- },
- { type: "separator" },
- {
- label: "Expand all children",
- onClick: buildExpandListHandler("all"),
- }
- ]
+ items: ListExpandDepth
}
]
},
@@ -217,6 +189,33 @@ function buildMapLayer([ id, layer ]: [ string, MapLayer ]): ComboBoxItem {
};
}
+function ListExpandDepth(context: { note: FNote, parentComponent: Component }) {
+ const [ currentDepth ] = useNoteLabel(context.note, "expanded");
+
+ return (
+ <>
+
+
+ {Array.from({ length: 4 }, (_, i) => i + 2).map(depth => [
+
+ ])}
+
+
+ >
+ )
+}
+
+function ListExpandDepthButton({ label, depth, note, parentComponent, checked }: { label: string, depth: number | "all", note: FNote, parentComponent: Component, checked?: boolean }) {
+ const handler = buildExpandListHandler(depth);
+
+ return (
+ handler({ note, triggerCommand: parentComponent.triggerCommand.bind(parentComponent) })}
+ checked={checked}
+ >{label}
+ );
+}
+
function buildExpandListHandler(depth: number | "all") {
return async ({ note, triggerCommand }: BookContext) => {
const { noteId } = note;