Skip to content

Commit 50a6924

Browse files
Copiloteliandoran
andcommitted
Fix keyboard shortcut support and address code review feedback
- Add editBranchPrefixCommand in note_tree.ts to support F2 keyboard shortcut with multi-selection - Extract CSS to separate branch_prefix.css file - Remove hard-coded color, use CSS class instead - Fix translation key usage to keep t() calls visible in IDE - Remove all inline styles Co-authored-by: eliandoran <[email protected]>
1 parent 82e5de2 commit 50a6924

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.branch-prefix-dialog .branch-prefix-notes-list {
2+
margin-top: 10px;
3+
}
4+
5+
.branch-prefix-dialog .branch-prefix-notes-list ul {
6+
max-height: 200px;
7+
overflow: auto;
8+
margin-top: 5px;
9+
}
10+
11+
.branch-prefix-dialog .branch-prefix-current {
12+
opacity: 0.6;
13+
}

apps/client/src/widgets/dialogs/branch_prefix.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FormGroup from "../react/FormGroup.js";
1111
import { useTriliumEvent } from "../react/hooks.jsx";
1212
import FBranch from "../../entities/fbranch.js";
1313
import type { ContextMenuCommandData } from "../../components/app_context.js";
14+
import "./branch_prefix.css";
1415

1516
// Virtual branches (e.g., from search results) start with this prefix
1617
const VIRTUAL_BRANCH_PREFIX = "virt-";
@@ -84,12 +85,11 @@ export default function BranchPrefixDialog() {
8485
}
8586

8687
const isSingleBranch = branches.length === 1;
87-
const titleKey = isSingleBranch ? "branch_prefix.edit_branch_prefix" : "branch_prefix.edit_branch_prefix_multiple";
8888

8989
return (
9090
<Modal
9191
className="branch-prefix-dialog"
92-
title={t(titleKey, { count: branches.length })}
92+
title={isSingleBranch ? t("branch_prefix.edit_branch_prefix") : t("branch_prefix.edit_branch_prefix_multiple", { count: branches.length })}
9393
size="lg"
9494
onShown={() => branchInput.current?.focus()}
9595
onHidden={() => setShown(false)}
@@ -108,14 +108,14 @@ export default function BranchPrefixDialog() {
108108
</div>
109109
</FormGroup>
110110
{!isSingleBranch && (
111-
<div className="branch-prefix-notes-list" style={{ marginTop: "10px" }}>
111+
<div className="branch-prefix-notes-list">
112112
<strong>{t("branch_prefix.affected_branches", { count: branches.length })}</strong>
113-
<ul style={{ maxHeight: "200px", overflow: "auto", marginTop: "5px" }}>
113+
<ul>
114114
{branches.map((branch) => {
115115
const note = branch.getNoteFromCache();
116116
return (
117117
<li key={branch.branchId}>
118-
{branch.prefix && <span style={{ color: "#888" }}>{branch.prefix} - </span>}
118+
{branch.prefix && <span className="branch-prefix-current">{branch.prefix} - </span>}
119119
{note.title}
120120
</li>
121121
);

apps/client/src/widgets/note_tree.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,20 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
15911591
this.clearSelectedNodes();
15921592
}
15931593

1594+
async editBranchPrefixCommand({ node }: CommandListenerData<"editBranchPrefix">) {
1595+
const branchIds = this.getSelectedOrActiveBranchIds(node).filter((branchId) => !branchId.startsWith("virt-"));
1596+
1597+
if (!branchIds.length) {
1598+
return;
1599+
}
1600+
1601+
// Trigger the event with the selected branch IDs
1602+
appContext.triggerEvent("editBranchPrefix", {
1603+
selectedOrActiveBranchIds: branchIds,
1604+
node: node
1605+
});
1606+
}
1607+
15941608
canBeMovedUpOrDown(node: Fancytree.FancytreeNode) {
15951609
if (node.data.noteId === "root") {
15961610
return false;

0 commit comments

Comments
 (0)