mirror of
https://github.com/zadam/trilium.git
synced 2026-01-06 14:44:25 +01:00
client/note color picker menu item: refactor
Some checks are pending
Checks / main (push) Waiting to run
Some checks are pending
Checks / main (push) Waiting to run
This commit is contained in:
parent
e6847355e7
commit
d441bccf8b
@ -1,4 +1,4 @@
|
||||
import "./ColorPickerMenuItem.css";
|
||||
import "./NoteColorPickerMenuItem.css";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import attributes from "../../services/attributes";
|
||||
import FNote from "../../entities/fnote";
|
||||
@ -6,12 +6,12 @@ import froca from "../../services/froca";
|
||||
|
||||
const COLORS = ["blue", "green", "cyan", "red", "magenta", "brown", "yellow", ""];
|
||||
|
||||
export interface ColorPickerMenuItemProps {
|
||||
export interface NoteColorPickerMenuItemProps {
|
||||
/** The target Note instance or its ID string. */
|
||||
note: FNote | string | null;
|
||||
}
|
||||
|
||||
export default function ColorPickerMenuItem(props: ColorPickerMenuItemProps) {
|
||||
export default function NoteColorPickerMenuItem(props: NoteColorPickerMenuItemProps) {
|
||||
if (!props.note) return null;
|
||||
|
||||
const [note, setNote] = useState<FNote | null>(null);
|
||||
@ -1,4 +1,4 @@
|
||||
import ColorPickerMenuItem from "./custom-items/ColorPickerMenuItem.jsx";
|
||||
import NoteColorPickerMenuItem from "./custom-items/NoteColorPickerMenuItem.jsx";
|
||||
import treeService from "../services/tree.js";
|
||||
import froca from "../services/froca.js";
|
||||
import clipboard from "../services/clipboard.js";
|
||||
@ -264,7 +264,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
|
||||
kind: "custom",
|
||||
componentFn: () => {
|
||||
if (notOptionsOrHelp && selectedNotes.length === 1) {
|
||||
return ColorPickerMenuItem({note});
|
||||
return NoteColorPickerMenuItem({note});
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import ColorPickerMenuItem from "../../../menus/custom-items/ColorPickerMenuItem";
|
||||
import FNote from "../../../entities/fnote";
|
||||
import NoteColorPickerMenuItem from "../../../menus/custom-items/NoteColorPickerMenuItem";
|
||||
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
|
||||
import link_context_menu from "../../../menus/link_context_menu";
|
||||
import attributes from "../../../services/attributes";
|
||||
@ -78,7 +78,7 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo
|
||||
{ kind: "separator" },
|
||||
{
|
||||
kind: "custom",
|
||||
componentFn: () => ColorPickerMenuItem({note})
|
||||
componentFn: () => NoteColorPickerMenuItem({note})
|
||||
}
|
||||
],
|
||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, note.noteId),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import ColorPickerMenuItem from "../../../menus/custom-items/ColorPickerMenuItem";
|
||||
import NoteColorPickerMenuItem from "../../../menus/custom-items/NoteColorPickerMenuItem";
|
||||
import FNote from "../../../entities/fnote";
|
||||
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
|
||||
import link_context_menu from "../../../menus/link_context_menu";
|
||||
@ -40,7 +40,7 @@ export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, par
|
||||
{ kind: "separator" },
|
||||
{
|
||||
kind: "custom",
|
||||
componentFn: () => ColorPickerMenuItem({note: noteId})
|
||||
componentFn: () => NoteColorPickerMenuItem({note: noteId})
|
||||
}
|
||||
],
|
||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, noteId),
|
||||
|
||||
@ -2,7 +2,7 @@ import type { LatLng, LeafletMouseEvent } from "leaflet";
|
||||
import appContext, { type CommandMappings } from "../../../components/app_context.js";
|
||||
import contextMenu, { type MenuItem } from "../../../menus/context_menu.js";
|
||||
import linkContextMenu from "../../../menus/link_context_menu.js";
|
||||
import ColorPickerMenuItem from "../../../menus/custom-items/ColorPickerMenuItem.jsx";
|
||||
import NoteColorPickerMenuItem from "../../../menus/custom-items/NoteColorPickerMenuItem.jsx";
|
||||
import { t } from "../../../services/i18n.js";
|
||||
import { createNewNote } from "./api.js";
|
||||
import { copyTextWithToast } from "../../../services/clipboard_ext.js";
|
||||
@ -23,7 +23,7 @@ export default function openContextMenu(noteId: string, e: LeafletMouseEvent, is
|
||||
{ kind: "separator"},
|
||||
{
|
||||
kind: "custom",
|
||||
componentFn: () => ColorPickerMenuItem({note: noteId})
|
||||
componentFn: () => NoteColorPickerMenuItem({note: noteId})
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ import { TableData } from "./rows.js";
|
||||
import link_context_menu from "../../../menus/link_context_menu.js";
|
||||
import froca from "../../../services/froca.js";
|
||||
import branches from "../../../services/branches.js";
|
||||
import ColorPickerMenuItem from "../../../menus/custom-items/ColorPickerMenuItem.jsx";
|
||||
import Component from "../../../components/component.js";
|
||||
import NoteColorPickerMenuItem from "../../../menus/custom-items/NoteColorPickerMenuItem.jsx";
|
||||
import { RefObject } from "preact";
|
||||
|
||||
export function useContextMenu(parentNote: FNote, parentComponent: Component | null | undefined, tabulator: RefObject<Tabulator>): Partial<EventCallBackMethods> {
|
||||
@ -224,7 +224,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
|
||||
{ kind: "separator"},
|
||||
{
|
||||
kind: "custom",
|
||||
componentFn: () => ColorPickerMenuItem({note: rowData.noteId})
|
||||
componentFn: () => NoteColorPickerMenuItem({note: rowData.noteId})
|
||||
}
|
||||
],
|
||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, rowData.noteId),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user