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): replace the ribbon's formatting tab with the fixed toolbar
Elian Doranbfeee9a604ce
diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsxindex 9396ece759..2df4eea4c5 100644--- a/apps/client/src/layouts/desktop_layout.tsx+++ b/apps/client/src/layouts/desktop_layout.tsx@@ -115,7 +115,7 @@ export default class DesktopLayout {.css("height", "40px").css("align-items", "center"))- .optChild(isNewLayout, <FixedFormattingToolbar />)+ .child(<FixedFormattingToolbar />).child(new FlexContainer("row").filling()diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex 48104c99c1..2dd2a918ee 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -2408,9 +2408,7 @@ body.zen #mobile-sidebar-wrapper,body.zen .tab-row-container,body.zen .tab-row-widget,body.zen .shared-info-widget,-body.zen .ribbon-container:not(:has(.classic-toolbar-widget)),-body.zen .ribbon-container:has(.classic-toolbar-widget) .ribbon-top-row,-body.zen .ribbon-container .ribbon-body:not(:has(.classic-toolbar-widget)),+body.zen .ribbon-container,body.zen .title-row .icon-action,body.zen .note-badges > *:not(.read-only-badge),body.zen .ribbon-button-container,@@ -2526,67 +2524,7 @@ body.zen:not(.backdrop-effects-disabled) .note-split.type-text .scrolling-contai/* Fixed formatting toolbar */-body.zen:not(.experimental-feature-new-layout) {- .note-split .ribbon-container {- position: fixed;- left: 0;- bottom: 20px;- width: 100%;- z-index: 1000;- opacity: 0; /* Hidden unless the current note split is focused */- pointer-events: none;- transition: opacity 100ms linear;- }-- /* An open dropdown holds the toolbar up: hovering its submenu takes focus out of the split. */- .note-split:focus-within .ribbon-container,- .ribbon-container:has(.ck-dropdown__panel-visible) {- opacity: 1; /* Show when the note split is focused */- }-- .note-split .ribbon-container .ribbon-body {- border: 0;- }-- .note-split .ribbon-container .classic-toolbar-widget {- margin: auto;- width: fit-content;- box-shadow: 0px 10px 20px rgba(0, 0, 0, .1);- border-radius: 8px;- border: 1px solid var(--main-border-color);- padding: 4px;- background: var(--menu-background-color);- }-- .note-split .ribbon-container .classic-toolbar-widget:not(:has(> .ck-toolbar)) {- /* Hide the toolbar wrapper if the toolbar is missing */- display: none;- }-- .note-split:focus-within .ribbon-container .classic-toolbar-widget,- .ribbon-container:has(.ck-dropdown__panel-visible) .classic-toolbar-widget {- pointer-events: all;- }-- @media (max-width: 1300px) {- .note-split .ribbon-container .classic-toolbar-widget {- /* Set the toolbar to full with */- width: 100%;- }-- .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_se,- .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_sw,- .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_smw,- .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_sme,- .classic-toolbar-widget .ck.ck-dropdown .ck-dropdown__panel.ck-dropdown__panel_s {- /* Force toolbar items overflow dropdowns open upwards */- top: auto;- bottom: 100%;- }- }-}--body.zen.experimental-feature-new-layout {+body.zen {.status-bar {display: none;}diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.cssindex 37fcb52ef1..3de58f2cbf 100644--- a/apps/client/src/stylesheets/theme-next/base.css+++ b/apps/client/src/stylesheets/theme-next/base.css@@ -179,8 +179,7 @@ body.backdrop-effects-disabled {body.desktop .dropdown-menu::before,:root .ck.ck-dropdown__panel::before,-:root .excalidraw .popover::before,-body.zen .note-split .ribbon-container .classic-toolbar-widget::before {+:root .excalidraw .popover::before {content: "";backdrop-filter: var(--dropdown-backdrop-filter);border-radius: var(--dropdown-border-radius);diff --git a/apps/client/src/stylesheets/theme-next/shell.css b/apps/client/src/stylesheets/theme-next/shell.cssindex 86af3e9939..8100c0ad8b 100644--- a/apps/client/src/stylesheets/theme-next/shell.css+++ b/apps/client/src/stylesheets/theme-next/shell.css@@ -137,23 +137,6 @@ body.layout-vertical #horizontal-main-container.left-pane-hidden #launcher-pane.border-inline-end: 2px solid var(--left-pane-collapsed-border-color);}-/*- * Zen mode- */--@keyframes zen-formatting-toolbar-entrance {- from {- transform: translateY(200%);- } to {- transform: translateY(0);- }-}--body.zen .note-split .ribbon-container .classic-toolbar-widget {- position: relative;- animation: zen-formatting-toolbar-entrance 300ms ease-out;-}-/** Gutter*/diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 41753190ee..5d4053c5f1 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2977,9 +2977,6 @@"tab_width": "Tab width","tab_width_unit": "spaces"},- "classic_editor_toolbar": {- "title": "Formatting"- },"editor": {"title": "Editor"},diff --git a/apps/client/src/widgets/ribbon/FormattingToolbar.css b/apps/client/src/widgets/ribbon/FormattingToolbar.cssindex 0b37889448..31ad30444b 100644--- a/apps/client/src/widgets/ribbon/FormattingToolbar.css+++ b/apps/client/src/widgets/ribbon/FormattingToolbar.css@@ -4,6 +4,12 @@--ck-color-button-default-disabled-background: transparent;min-height: 39px;flex-shrink: 0;+ transition: opacity 250ms ease-in;++ &.disabled {+ opacity: 0.3;+ pointer-events: none;+ }}.classic-toolbar-widget .ck.ck-toolbar {@@ -13,12 +19,3 @@.classic-toolbar-widget .ck.ck-button.ck-disabled {opacity: 0.3;}--body.experimental-feature-new-layout .classic-toolbar-widget {- transition: opacity 250ms ease-in;-- &.disabled {- opacity: 0.3;- pointer-events: none;- }-}diff --git a/apps/client/src/widgets/ribbon/FormattingToolbar.tsx b/apps/client/src/widgets/ribbon/FormattingToolbar.tsxindex d687c82d46..ef62476bb1 100644--- a/apps/client/src/widgets/ribbon/FormattingToolbar.tsx+++ b/apps/client/src/widgets/ribbon/FormattingToolbar.tsx@@ -10,14 +10,12 @@ import { useActiveNoteContext, useNoteProperty, useTriliumEvent, useTriliumEventimport { TabConfiguration, TabContext } from "./ribbon-interface";/**- * Handles the editing toolbar when the CKEditor is in decoupled mode.+ * Handles the editing toolbar of a single note context when the CKEditor is in decoupled mode, as+ * used by the quick edit popup. The main window uses `FixedFormattingToolbar` instead.** This toolbar is only enabled if the user has selected the classic CKEditor.*- * The ribbon item is active by default for text notes, as long as they are not in read-only mode.- *- * ! The toolbar is not only used in the ribbon, but also in the quick edit feature.- * * The mobile toolbar is handled separately (see `MobileEditorToolbar`).+ * The mobile toolbar is handled separately (see `MobileEditorToolbar`).*/export default function FormattingToolbar({ hidden, ntxId }: TabContext) {const containerRef = useRef<HTMLDivElement>(null);@@ -43,7 +41,7 @@ export default function FormattingToolbar({ hidden, ntxId }: TabContext) {);};-/** Visibility predicate for the formatting toolbar, shared by the ribbon tab definition and the standalone usages (e.g. the popup editor). */+/** Visibility predicate for the quick edit popup's formatting toolbar. */export const showFormattingToolbar: TabConfiguration["show"] = async ({ note, noteContext }) =>note?.type === "text" && noteContext?.viewScope?.viewMode === "default"&& options.get("textNoteEditorType") === "ckeditor-classic"diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.tsindex f5cf96a9f2..6102738199 100644--- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts+++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts@@ -3,7 +3,6 @@ import options from "../../services/options";import BasicPropertiesTab from "./BasicPropertiesTab";import EditedNotesTab from "./EditedNotesTab";import FilePropertiesTab from "./FilePropertiesTab";-import FormattingToolbar, { showFormattingToolbar } from "./FormattingToolbar";import ImagePropertiesTab from "./ImagePropertiesTab";import InheritedAttributesTab from "./InheritedAttributesTab";import NoteInfoTab from "./NoteInfoTab";@@ -17,15 +16,6 @@ import SearchDefinitionTab from "./SearchDefinitionTab";import SimilarNotesTab from "./SimilarNotesTab";export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [- {- title: t("classic_editor_toolbar.title"),- icon: "bx bx-text",- show: showFormattingToolbar,- toggleCommand: "toggleRibbonTabClassicEditor",- content: FormattingToolbar,- activate: ({ note }) => !options.is("editedNotesOpenInRibbon") || !note?.hasOwnedLabel("dateNote"),- stayInDom: true- },{title: ({ note }) => note?.isTriliumSqlite() ? t("script_executor.query") : t("script_executor.script"),icon: "bx bx-play",