fix(mobile/note_actions): reintroduce insert child note

This commit is contained in:
Elian Doran 2026-02-01 21:42:48 +02:00
parent 92991cc03c
commit 35ac5fc514
No known key found for this signature in database
2 changed files with 17 additions and 6 deletions

View File

@ -1,12 +1,22 @@
import { t } from "../../services/i18n";
import { FormDropdownDivider } from "../react/FormList";
import { useNoteContext } from "../react/hooks"; import { useNoteContext } from "../react/hooks";
import { NoteContextMenu } from "../ribbon/NoteActions"; import { CommandItem, NoteContextMenu } from "../ribbon/NoteActions";
export default function MobileDetailMenu() { export default function MobileDetailMenu() {
const { note, noteContext } = useNoteContext(); const { note, noteContext } = useNoteContext();
return ( return (
<div style={{ contain: "none" }}> <div style={{ contain: "none" }}>
{note && <NoteContextMenu note={note} noteContext={noteContext} />} {note && (
<NoteContextMenu
note={note} noteContext={noteContext}
extraItems={<>
<CommandItem command="insertChildNote" icon="bx bx-plus" disabled={note.type === "search"} text={t("mobile_detail_menu.insert_child_note")} />
<FormDropdownDivider />
</>}
/>
)}
</div> </div>
); );
} }

View File

@ -1,6 +1,6 @@
import { ConvertToAttachmentResponse } from "@triliumnext/commons"; import { ConvertToAttachmentResponse } from "@triliumnext/commons";
import { Dropdown as BootstrapDropdown } from "bootstrap"; import { Dropdown as BootstrapDropdown } from "bootstrap";
import { RefObject } from "preact"; import { ComponentChildren, RefObject } from "preact";
import { useContext, useEffect, useRef } from "preact/hooks"; import { useContext, useEffect, useRef } from "preact/hooks";
import appContext, { CommandNames } from "../../components/app_context"; import appContext, { CommandNames } from "../../components/app_context";
@ -14,7 +14,7 @@ import { t } from "../../services/i18n";
import protected_session from "../../services/protected_session"; import protected_session from "../../services/protected_session";
import server from "../../services/server"; import server from "../../services/server";
import toast from "../../services/toast"; import toast from "../../services/toast";
import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/utils"; import { isElectron as getIsElectron, isMac as getIsMac, isMobile } from "../../services/utils";
import ws from "../../services/ws"; import ws from "../../services/ws";
import ClosePaneButton from "../buttons/close_pane_button"; import ClosePaneButton from "../buttons/close_pane_button";
import CreatePaneButton from "../buttons/create_pane_button"; import CreatePaneButton from "../buttons/create_pane_button";
@ -63,7 +63,7 @@ function RevisionsButton({ note }: { note: FNote }) {
type ItemToFocus = "basic-properties"; type ItemToFocus = "basic-properties";
export function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: NoteContext }) { export function NoteContextMenu({ note, noteContext, extraItems }: { note: FNote, noteContext?: NoteContext, extraItems?: ComponentChildren; }) {
const dropdownRef = useRef<BootstrapDropdown>(null); const dropdownRef = useRef<BootstrapDropdown>(null);
const parentComponent = useContext(ParentComponent); const parentComponent = useContext(ParentComponent);
const noteType = useNoteProperty(note, "type") ?? ""; const noteType = useNoteProperty(note, "type") ?? "";
@ -107,6 +107,7 @@ export function NoteContextMenu({ note, noteContext }: { note: FNote, noteContex
onHidden={() => itemToFocusRef.current = null } onHidden={() => itemToFocusRef.current = null }
mobileBackdrop mobileBackdrop
> >
{extraItems}
{isReadOnly && <> {isReadOnly && <>
<CommandItem icon="bx bx-pencil" text={t("read-only-info.edit-note")} <CommandItem icon="bx bx-pencil" text={t("read-only-info.edit-note")}
@ -279,7 +280,7 @@ function DevelopmentActions({ note, noteContext }: { note: FNote, noteContext?:
); );
} }
function CommandItem({ icon, text, title, command, disabled }: { icon: string, text: string, title?: string, command: CommandNames | (() => void), disabled?: boolean, destructive?: boolean }) { export function CommandItem({ icon, text, title, command, disabled }: { icon: string, text: string, title?: string, command: CommandNames | (() => void), disabled?: boolean, destructive?: boolean }) {
return <FormListItem return <FormListItem
icon={icon} icon={icon}
title={title} title={title}