Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/note color picker menu item: refactor
Adorian Dorand441bccf8b99
diff --git a/apps/client/src/menus/custom-items/ColorPickerMenuItem.css b/apps/client/src/menus/custom-items/NoteColorPickerMenuItem.csssimilarity index 100%rename from apps/client/src/menus/custom-items/ColorPickerMenuItem.cssrename to apps/client/src/menus/custom-items/NoteColorPickerMenuItem.cssdiff --git a/apps/client/src/menus/custom-items/ColorPickerMenuItem.tsx b/apps/client/src/menus/custom-items/NoteColorPickerMenuItem.tsxsimilarity index 91%rename from apps/client/src/menus/custom-items/ColorPickerMenuItem.tsxrename to apps/client/src/menus/custom-items/NoteColorPickerMenuItem.tsxindex 030a853e4c..3d0b5e7fde 100644--- a/apps/client/src/menus/custom-items/ColorPickerMenuItem.tsx+++ b/apps/client/src/menus/custom-items/NoteColorPickerMenuItem.tsx@@ -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);diff --git a/apps/client/src/menus/tree_context_menu.ts b/apps/client/src/menus/tree_context_menu.tsindex 972f21c117..b02eaf970a 100644--- a/apps/client/src/menus/tree_context_menu.ts+++ b/apps/client/src/menus/tree_context_menu.ts@@ -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<Treekind: "custom",componentFn: () => {if (notOptionsOrHelp && selectedNotes.length === 1) {- return ColorPickerMenuItem({note});+ return NoteColorPickerMenuItem({note});} else {return null;}diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.tsindex ba071cf647..551e96a495 100644--- a/apps/client/src/widgets/collections/board/context_menu.ts+++ b/apps/client/src/widgets/collections/board/context_menu.ts@@ -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),diff --git a/apps/client/src/widgets/collections/calendar/context_menu.ts b/apps/client/src/widgets/collections/calendar/context_menu.tsindex 31de26de57..5120fcc973 100644--- a/apps/client/src/widgets/collections/calendar/context_menu.ts+++ b/apps/client/src/widgets/collections/calendar/context_menu.ts@@ -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),diff --git a/apps/client/src/widgets/collections/geomap/context_menu.ts b/apps/client/src/widgets/collections/geomap/context_menu.tsindex a0a6c8fc6a..c4cf6ebf4d 100644--- a/apps/client/src/widgets/collections/geomap/context_menu.ts+++ b/apps/client/src/widgets/collections/geomap/context_menu.ts@@ -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})}];}diff --git a/apps/client/src/widgets/collections/table/context_menu.ts b/apps/client/src/widgets/collections/table/context_menu.tsindex 11d4477caa..1218dbf6cc 100644--- a/apps/client/src/widgets/collections/table/context_menu.ts+++ b/apps/client/src/widgets/collections/table/context_menu.ts@@ -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),