From 999315d3c605c60508d46a665ba8d1ea979e0bed Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 10 Dec 2025 15:12:37 +0200 Subject: [PATCH] feat(breadcrumb): basic rename note support --- apps/client/src/widgets/Breadcrumb.css | 14 ++++++- apps/client/src/widgets/Breadcrumb.tsx | 54 ++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/apps/client/src/widgets/Breadcrumb.css b/apps/client/src/widgets/Breadcrumb.css index 24cb22009..2bb58281f 100644 --- a/apps/client/src/widgets/Breadcrumb.css +++ b/apps/client/src/widgets/Breadcrumb.css @@ -96,11 +96,23 @@ body.experimental-feature-new-layout .breadcrumb-row { } .dropdown-item span, - .dropdown-item strong { + .dropdown-item strong, + .breadcrumb-last-item { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; display: block; max-width: 300px; } + + .breadcrumb-last-item { + text-decoration: none; + color: unset; + cursor: text; + } + + input { + padding: 0 10px; + width: 200px; + } } diff --git a/apps/client/src/widgets/Breadcrumb.tsx b/apps/client/src/widgets/Breadcrumb.tsx index 38efb1364..651aafcfd 100644 --- a/apps/client/src/widgets/Breadcrumb.tsx +++ b/apps/client/src/widgets/Breadcrumb.tsx @@ -1,6 +1,6 @@ import "./Breadcrumb.css"; -import { useMemo } from "preact/hooks"; +import { useMemo, useState } from "preact/hooks"; import { Fragment } from "preact/jsx-runtime"; import NoteContext from "../components/note_context"; @@ -12,6 +12,8 @@ import { useChildNotes, useNoteContext, useNoteLabel, useNoteProperty } from "./ import Icon from "./react/Icon"; import NoteLink from "./react/NoteLink"; import link_context_menu from "../menus/link_context_menu"; +import { TitleEditor } from "./collections/board"; +import server from "../services/server"; const COLLAPSE_THRESHOLD = 5; const INITIAL_ITEMS = 2; @@ -27,10 +29,7 @@ export default function Breadcrumb() { <> {notePath.slice(0, INITIAL_ITEMS).map((item, index) => ( - {index === 0 - ? - : - } + ))} @@ -38,7 +37,7 @@ export default function Breadcrumb() { {notePath.slice(-FINAL_ITEMS).map((item, index) => ( - + ))} @@ -47,7 +46,7 @@ export default function Breadcrumb() { {index === 0 ? - : + : } {(index < notePath.length - 1 || note?.hasChildren()) && } @@ -76,7 +75,7 @@ function BreadcrumbRoot({ noteContext }: { noteContext: NoteContext | undefined ); } -function BreadcrumbItem({ notePath }: { notePath: string }) { +function BreadcrumbLink({ notePath }: { notePath: string }) { return ( froca.getNoteFromCache(noteId!)); + const [ isEditing, setIsEditing ] = useState(false); + const title = useNoteProperty(note, "title"); + + if (!note) return null; + + if (!isEditing) { + return ( + setIsEditing(true)} + >{title} + ); + } + + return ( + { return server.put(`notes/${noteId}/title`, { title: newTitle.trim() }); }} + dismiss={() => setIsEditing(false)} + /> + ); +} + +function BreadcrumbItem({ index, notePath, noteContext, notePathLength }: { index: number, notePathLength: number, notePath: string, noteContext: NoteContext | undefined }) { + if (index === 0) { + return ; + } + + if (index === notePathLength - 1) { + return ; + } + + return ; +} + function BreadcrumbSeparator({ notePath, noteContext, activeNotePath }: { notePath: string, activeNotePath: string, noteContext: NoteContext | undefined }) { return (