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
refactor(client): move the ribbon's leftovers next to what uses them
Elian Doran8923369edf04
diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsxindex b61de77fb2..3eed1971dc 100644--- a/apps/client/src/layouts/desktop_layout.tsx+++ b/apps/client/src/layouts/desktop_layout.tsx@@ -21,7 +21,9 @@ import FloatingButtons from "../widgets/FloatingButtons.jsx";import { DESKTOP_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.jsx";import LauncherContainer from "../widgets/launch_bar/LauncherContainer.jsx";import SpacerWidget from "../widgets/launch_bar/SpacerWidget.jsx";+import { FixedFormattingToolbar } from "../widgets/layout/FormattingToolbar.jsx";import InlineTitle from "../widgets/layout/InlineTitle.jsx";+import NoteActions from "../widgets/layout/NoteActions.jsx";import NoteBadges from "../widgets/layout/NoteBadges.jsx";import NoteTitleActions from "../widgets/layout/NoteTitleActions.jsx";import StatusBar from "../widgets/layout/StatusBar.jsx";@@ -31,8 +33,6 @@ import NoteTreeWidget from "../widgets/note_tree.js";import NoteWrapperWidget from "../widgets/note_wrapper.js";import NoteDetail from "../widgets/NoteDetail.jsx";import QuickSearch from "../widgets/quick_search.jsx";-import { FixedFormattingToolbar } from "../widgets/ribbon/FormattingToolbar.jsx";-import NoteActions from "../widgets/ribbon/NoteActions.jsx";import ScrollPadding from "../widgets/scroll_padding.js";import SearchResult from "../widgets/search_result.jsx";import RightPanelContainer from "../widgets/sidebar/RightPanelContainer.jsx";diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex 3a250a3fc0..12ec8e97e8 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -2409,7 +2409,7 @@ body.zen .tab-row-container,body.zen .tab-row-widget,body.zen .title-row .icon-action,body.zen .note-badges > *:not(.read-only-badge),-body.zen .ribbon-button-container,+body.zen .note-actions-bar,body.zen .inline-title,body.zen .promoted-attributes-widget,body.zen .floating-buttons-children > *:not(.bx-edit-alt),diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.cssindex 3de58f2cbf..31479cc559 100644--- a/apps/client/src/stylesheets/theme-next/base.css+++ b/apps/client/src/stylesheets/theme-next/base.css@@ -2,7 +2,7 @@@import url(./shell.css);@import url(./dialogs.css);@import url(./pages.css);-@import url(./ribbon.css);+@import url(./note-panels.css);@import url(./notes/text.css);@import url(./notes/canvas.css);@import url(./notes/collections/table.css);diff --git a/apps/client/src/stylesheets/theme-next/ribbon.css b/apps/client/src/stylesheets/theme-next/note-panels.csssimilarity index 97%rename from apps/client/src/stylesheets/theme-next/ribbon.cssrename to apps/client/src/stylesheets/theme-next/note-panels.cssindex be594d2e80..8ed1db7002 100644--- a/apps/client/src/stylesheets/theme-next/ribbon.css+++ b/apps/client/src/stylesheets/theme-next/note-panels.css@@ -9,7 +9,7 @@ div.promoted-attributes-container {}/*- * Owned attributes+ * Attribute list*/.attribute-list .add-new-attribute-button,diff --git a/apps/client/src/utils/formatters.ts b/apps/client/src/utils/formatters.tsindex 717d397799..eb06f930e3 100644--- a/apps/client/src/utils/formatters.ts+++ b/apps/client/src/utils/formatters.ts@@ -189,7 +189,7 @@ function parseDate(date: string | Date | number): Date {/*** The language a note is written in.*- * A note carries its own language as a `#language` label, set from the Basic Properties ribbon, but+ * A note carries its own language as a `#language` label, set from the status bar's language switcher, but* the label is opt-in and the picker that sets it stays empty until content languages are enabled —* so in practice almost no note has one. The `defaultContentLanguage` option answers for all of* them, and an empty value there means "follow the application's language" rather than "none".diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsxindex a988cf4375..7612c39391 100644--- a/apps/client/src/widgets/NoteDetail.tsx+++ b/apps/client/src/widgets/NoteDetail.tsx@@ -90,7 +90,7 @@ export default function NoteDetail() {if (!note) return;// we're detecting note type change on the note_detail level, but triggering the noteTypeMimeChanged- // globally, so it gets also to e.g. ribbon components. But this means that the event can be generated multiple+ // globally, so it also reaches widgets outside the note detail. But this means that the event can be generated multiple// times if the same note is open in several tabs.if (note.noteIddiff --git a/apps/client/src/widgets/attribute_widgets/attribute_kind.css b/apps/client/src/widgets/attribute_widgets/attribute_kind.cssindex 8a5540a9c7..5ec3b77988 100644--- a/apps/client/src/widgets/attribute_widgets/attribute_kind.css+++ b/apps/client/src/widgets/attribute_widgets/attribute_kind.css@@ -15,7 +15,7 @@/** A badge on the corner of the icon: a cog for the names Trilium reads for itself (settings of the note* rather than a word for it), a chevron for a definition of a promoted field (one lifted out of the- * attributes and into the note's own ribbon). A second glyph rather than an icon of its own, so+ * attributes and into the note's promoted attributes section). A second glyph rather than an icon of its own, so* `cssClass` still reads as the label it is, and a promoted date field as the date field it defines.*/:is(.attribute-list-panel, .attr-name-suggestion) .attribute-kind.marker-system::after,diff --git a/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx b/apps/client/src/widgets/dialogs/PopupEditor.spec.tsxindex 958f544810..189e63e0d5 100644--- a/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx+++ b/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx@@ -110,7 +110,7 @@ vi.mock("../layout/NoteBadges", () => ({ default: () => null }));vi.mock("../layout/NoteTypeSwitcher", () => ({default: () => <div className="note-type-switcher-stub" />}));-vi.mock("../ribbon/FormattingToolbar", () => ({ default: () => null }));+vi.mock("../layout/FormattingToolbar", () => ({ default: () => null }));vi.mock("../type_widgets/text/mobile_editor_toolbar", () => ({ default: () => <div className="mobile-toolbar-stub" /> }));vi.mock("../note_icon", () => ({ default: () => <div className="note-icon-stub" /> }));vi.mock("../note_title", () => ({ default: () => <div className="note-title-stub" /> }));diff --git a/apps/client/src/widgets/dialogs/PopupEditor.tsx b/apps/client/src/widgets/dialogs/PopupEditor.tsxindex 4f35d5ad0c..5d7c1a088f 100644--- a/apps/client/src/widgets/dialogs/PopupEditor.tsx+++ b/apps/client/src/widgets/dialogs/PopupEditor.tsx@@ -12,6 +12,7 @@ import utils from "../../services/utils";import NoteList from "../collections/NoteList";import FloatingButtons from "../FloatingButtons";import { DESKTOP_FLOATING_BUTTONS, POPUP_HIDDEN_FLOATING_BUTTONS } from "../FloatingButtonsDefinitions";+import FormattingToolbar from "../layout/FormattingToolbar";import NoteTypeSwitcher from "../layout/NoteTypeSwitcher";import TitleRow from "../layout/TitleRow";import NoteDetail from "../NoteDetail";@@ -19,7 +20,6 @@ import PromotedAttributes from "../PromotedAttributes";import { useContainedLinkNavigation, useNoteContext, useNoteLabel, useTriliumEvent } from "../react/hooks";import Modal from "../react/Modal";import { NoteContextContext, ParentComponent } from "../react/react_utils";-import FormattingToolbar from "../ribbon/FormattingToolbar";import MobileEditorToolbar from "../type_widgets/text/mobile_editor_toolbar";/** The layer the stylesheet gives this popup while it stands over another modal. */diff --git a/apps/client/src/widgets/ribbon/FormattingToolbar.css b/apps/client/src/widgets/layout/FormattingToolbar.csssimilarity index 100%rename from apps/client/src/widgets/ribbon/FormattingToolbar.cssrename to apps/client/src/widgets/layout/FormattingToolbar.cssdiff --git a/apps/client/src/widgets/ribbon/FormattingToolbar.spec.ts b/apps/client/src/widgets/layout/FormattingToolbar.spec.tssimilarity index 100%rename from apps/client/src/widgets/ribbon/FormattingToolbar.spec.tsrename to apps/client/src/widgets/layout/FormattingToolbar.spec.tsdiff --git a/apps/client/src/widgets/ribbon/FormattingToolbar.tsx b/apps/client/src/widgets/layout/FormattingToolbar.tsxsimilarity index 100%rename from apps/client/src/widgets/ribbon/FormattingToolbar.tsxrename to apps/client/src/widgets/layout/FormattingToolbar.tsxdiff --git a/apps/client/src/widgets/ribbon/NoteActions.css b/apps/client/src/widgets/layout/NoteActions.csssimilarity index 95%rename from apps/client/src/widgets/ribbon/NoteActions.cssrename to apps/client/src/widgets/layout/NoteActions.cssindex ab5aa43cf0..e3330f3b87 100644--- a/apps/client/src/widgets/ribbon/NoteActions.css+++ b/apps/client/src/widgets/layout/NoteActions.css@@ -1,4 +1,4 @@-.title-row > .ribbon-button-container {+.title-row > .note-actions-bar {--button-gap: 5px;display: flex;diff --git a/apps/client/src/widgets/ribbon/NoteActions.spec.tsx b/apps/client/src/widgets/layout/NoteActions.spec.tsxsimilarity index 100%rename from apps/client/src/widgets/ribbon/NoteActions.spec.tsxrename to apps/client/src/widgets/layout/NoteActions.spec.tsxdiff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/layout/NoteActions.tsxsimilarity index 99%rename from apps/client/src/widgets/ribbon/NoteActions.tsxrename to apps/client/src/widgets/layout/NoteActions.tsxindex e211a927cd..9fe79eef38 100644--- a/apps/client/src/widgets/ribbon/NoteActions.tsx+++ b/apps/client/src/widgets/layout/NoteActions.tsx@@ -21,8 +21,6 @@ import ClosePaneButton from "../buttons/close_pane_button";import CreatePaneButton from "../buttons/create_pane_button";import MovePaneButton from "../buttons/move_pane_button";import { showImageCompressionDialog } from "../dialogs/image_compression/image_compression_dialog";-import { useShareState } from "../layout/NoteBadges";-import { NoteTypeDropdownContent } from "../layout/NoteTypeSwitcher";import { isAlwaysFullWidthByType } from "../note_wrapper";import ActionButton from "../react/ActionButton";import Dropdown, { type DropdownHandle } from "../react/Dropdown";@@ -30,13 +28,15 @@ import { FormDropdownDivider, FormDropdownSubmenu, FormListHeader, FormListItem,import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteLabelOptionalBool, useNoteProperty, useSyncedRef, useTriliumEvent, useTriliumOption } from "../react/hooks";import { ParentComponent } from "../react/react_utils";import NoteActionsCustom from "./NoteActionsCustom";+import { useShareState } from "./NoteBadges";+import { NoteTypeDropdownContent } from "./NoteTypeSwitcher";const isNewLayout = isExperimentalFeatureEnabled("new-layout");export default function NoteActions() {const { note, ntxId, noteContext } = useNoteContext();return (- <div className="ribbon-button-container" style={{ contain: "none" }}>+ <div className="note-actions-bar" style={{ contain: "none" }}>{note && ntxId && noteContext && <NoteActionsCustom note={note} ntxId={ntxId} noteContext={noteContext} typeActionsOnly={!isNewLayout} />}{note && !isNewLayout && <RevisionsButton note={note} />}<MovePaneButton direction="left" />diff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.css b/apps/client/src/widgets/layout/NoteActionsCustom.csssimilarity index 100%rename from apps/client/src/widgets/ribbon/NoteActionsCustom.cssrename to apps/client/src/widgets/layout/NoteActionsCustom.cssdiff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx b/apps/client/src/widgets/layout/NoteActionsCustom.tsxsimilarity index 100%rename from apps/client/src/widgets/ribbon/NoteActionsCustom.tsxrename to apps/client/src/widgets/layout/NoteActionsCustom.tsxdiff --git a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsxindex 3239c0cac5..5b8c012f20 100644--- a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx+++ b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx@@ -9,6 +9,8 @@ import note_create from "../../services/note_create";import server from "../../services/server";import { useLanguageSwitcher } from "../dialogs/content_languages";import { BacklinksWidget, useBacklinkCount } from "../FloatingButtonsDefinitions";+import { NoteContextMenu } from "../layout/NoteActions";+import NoteActionsCustom from "../layout/NoteActionsCustom";import { codeLanguageItems, useMimeTypes } from "../layout/NoteTypeSwitcher";import { getLocaleName, NoteInfoContent, SimilarNotesList } from "../layout/StatusBar";import ActionButton from "../react/ActionButton";@@ -17,8 +19,6 @@ import { FormDropdownDivider, FormDropdownSubmenu, FormListItem } from "../reactimport { useNoteContext, useNoteProperty } from "../react/hooks";import { MenuItemRows } from "../react/Menu";import Modal from "../react/Modal";-import { NoteContextMenu } from "../ribbon/NoteActions";-import NoteActionsCustom from "../ribbon/NoteActionsCustom";import { NotePathsWidget, useSortedNotePaths } from "../sidebar/NotePaths";import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsxindex 441a026c0b..68ba8a0481 100644--- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx+++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx@@ -15,7 +15,7 @@ import { FormDropdownDivider, FormListItem } from "../react/FormList";import { useNoteLabel, useNoteProperty, useTriliumEvent } from "../react/hooks";import Icon from "../react/Icon";import { CheckBoxProperty, ViewProperty } from "../react/NotePropertyMenu";-import { bookPropertiesConfig } from "../ribbon/collection-properties-config";+import { bookPropertiesConfig } from "./collection-properties-config";export const ICON_MAPPINGS: Record<ViewTypeOptions, string> = {grid: "bx bxs-grid",diff --git a/apps/client/src/widgets/ribbon/collection-properties-config.tsx b/apps/client/src/widgets/note_bars/collection-properties-config.tsxsimilarity index 100%rename from apps/client/src/widgets/ribbon/collection-properties-config.tsxrename to apps/client/src/widgets/note_bars/collection-properties-config.tsxdiff --git a/apps/client/src/widgets/react/NoItems.tsx b/apps/client/src/widgets/react/NoItems.tsxindex 46be9df6d9..8735744890 100644--- a/apps/client/src/widgets/react/NoItems.tsx+++ b/apps/client/src/widgets/react/NoItems.tsx@@ -12,7 +12,7 @@ interface NoItemsProps {className?: string;/*** How much room the placeholder takes. `small` shrinks the icon and the spacing around it, for- * the places that only have a few lines to spare — a sidebar card or a ribbon tab — where the+ * the places that only have a few lines to spare — a sidebar card or a status bar pane — where the* full-size one would tower over the content it stands in for.*/size?: "normal" | "small";diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 0e3b8e6a45..e542792114 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -465,7 +465,7 @@ export function useNoteContext() {setNotePath(noteContext.notePath);setViewScope(noteContext.viewScope);// Navigating resets the view scope, so the temporary "enable editing" toggle must be reset too.- // Otherwise the stale value prevents consumers (e.g. the ribbon) from refreshing when the user+ // Otherwise the stale value prevents consumers from refreshing when the user// re-enables editing on a note that was previously made temporarily editable.setIsReadOnlyTemporarilyDisabled(noteContext?.viewScope?.readOnlyTemporarilyDisabled);});diff --git a/apps/client/src/widgets/search_field_editor.tsx b/apps/client/src/widgets/search_field_editor.tsxindex ae440f7b7e..1bce9ce575 100644--- a/apps/client/src/widgets/search_field_editor.tsx+++ b/apps/client/src/widgets/search_field_editor.tsx@@ -23,7 +23,7 @@ export type SearchFieldEditorConfig = Omit<FieldEditorConfig, "extensions">;/*** Builds the editor a search string is written in: the query highlighter, the linter and the- * completions over {@link createFieldEditor}. The quick search and the saved search's ribbon both+ * completions over {@link createFieldEditor}. The quick search and the saved search's parameters both* use it, so a query reads and reports the same way in either field.** The completions are the app's own lists: a note picked with `@` from the note autocomplete's, adiff --git a/apps/client/src/widgets/sidebar/AttributeList.tsx b/apps/client/src/widgets/sidebar/AttributeList.tsxindex ab0ae3cc46..87225a6b8a 100644--- a/apps/client/src/widgets/sidebar/AttributeList.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.tsx@@ -731,7 +731,7 @@ const IS_MOBILE = isMobile();/*** The badge the kind icon carries on its corner, where there is one to carry: a cog for the names* Trilium reads for itself, and a chevron for a definition whose field is promoted — lifted, that is,- * out of the attributes and into the note's own ribbon. At most one of the two, which no attribute is+ * out of the attributes and into the note's promoted attributes section. At most one of the two, which no attribute is* ever both of: no built-in name is a definition. The class alone: what either badge means is a line* of the icon's own tooltip (see {@link getKindTooltip}), the two being read as one mark.*/diff --git a/apps/client/src/widgets/sidebar/NoteMap.css b/apps/client/src/widgets/sidebar/NoteMap.cssindex 1b26af8ead..19e3401feb 100644--- a/apps/client/src/widgets/sidebar/NoteMap.css+++ b/apps/client/src/widgets/sidebar/NoteMap.css@@ -26,7 +26,7 @@}.sidebar-note-map {- /* Anchors the map's floating buttons (map type, fix nodes), same as the ribbon wrapper. */+ /* Anchors the map's floating buttons (map type, fix nodes). */position: relative;/* Fills the card, which is what takes a height (see NoteMap.tsx): the canvas is drawn to whateverthis box is measured at, so the map follows the card without being told a size of its own. */diff --git a/apps/client/src/widgets/type_widgets/Image.tsx b/apps/client/src/widgets/type_widgets/Image.tsxindex d0be9310e9..5d0278f1e7 100644--- a/apps/client/src/widgets/type_widgets/Image.tsx+++ b/apps/client/src/widgets/type_widgets/Image.tsx@@ -3,7 +3,6 @@ import "./Image.css";import { useEffect, useRef, useState } from "preact/hooks";import image_context_menu from "../../menus/image_context_menu";-import { copyImageReferenceToClipboard } from "../../services/image";import { createImageSrcUrl } from "../../services/utils";import { useTriliumEvent } from "../react/hooks";import ImageViewer from "../react/ImageViewer";@@ -15,20 +14,12 @@ import { TypeWidgetProps } from "./type_widget";const IMAGE_PREVIOUS_KEYS = [ "Backspace" ];const IMAGE_NEXT_KEYS = [ "Space" ];-export default function Image({ note, ntxId, noteContext }: TypeWidgetProps) {+export default function Image({ note, noteContext }: TypeWidgetProps) {const containerRef = useRef<HTMLDivElement>(null);const [ refreshCounter, setRefreshCounter ] = useState(0);useEffect(() => image_context_menu.setupContextMenu(refToJQuerySelector(containerRef)), []);- // The ribbon's "copy reference" button triggers this. Select the rendered image's wrapper so- // the clipboard gets clean <img> markup without the surrounding zoom/transform containers.- useTriliumEvent("copyImageReferenceToClipboard", ({ ntxId: eventNtxId }) => {- if (eventNtxId !== ntxId) return;- const $img = refToJQuerySelector(containerRef).find("img");- if ($img.length) copyImageReferenceToClipboard($img.parent());- });-// A new revision swaps the image content; remount so it re-fits to the viewport.useTriliumEvent("entitiesReloaded", ({ loadResults }) => {if (loadResults.isNoteReloaded(note.noteId)) {diff --git a/apps/client/src/widgets/type_widgets/space_usage/context_menu.ts b/apps/client/src/widgets/type_widgets/space_usage/context_menu.tsindex d07ef0dd3c..9fce723c5b 100644--- a/apps/client/src/widgets/type_widgets/space_usage/context_menu.ts+++ b/apps/client/src/widgets/type_widgets/space_usage/context_menu.ts@@ -263,7 +263,7 @@ export function openNoteInNewTab(noteId: string) {});}-/** Note types whose content is a saveable file — the same ones the ribbon offers Download for. */+/** Note types whose content is a saveable file — the same ones the note actions offer Download for. */function isDownloadable(note: FNote) {return note.type === "file" || note.type === "image";}diff --git a/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts b/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.tsindex 0a17015e83..1490209d7a 100644--- a/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts+++ b/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts@@ -184,8 +184,8 @@ export function buildAiAssistantQuickActions(): AiQuickActionGroup[] {submenu: true,actions: buildTranslateActions(),// The one group whose contents are the user's to choose, so the way to choose them- // closes it — as it closes the note's own language picker in the status bar and the- // ribbon, and for the same reason: nobody looking at the list would think to go+ // closes it — as it closes the note's own language picker in the status bar, and for+ // the same reason: nobody looking at the list would think to go// hunting through the settings for what fills it.footer: {label: t("note_language.configure-languages"),