Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): remove the floating help button

Elian Doran64ff87a3b3c4
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
index 7dc8152d23..ac6f9ab0ba 100644
--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
@@ -8,12 +8,9 @@ import FNote from "../entities/fnote";
import attributes from "../services/attributes";
import froca from "../services/froca";
import { t } from "../services/i18n";
-import { getHelpUrlForNote } from "../services/in_app_help";
import LoadResults from "../services/load_results";
import { sanitizeNoteContentHtml } from "../services/sanitize_content";
import server from "../services/server";
-import { openInAppHelpFromUrl } from "../services/utils";
-import ActionButton, { ActionButtonProps } from "./react/ActionButton";
import { useTriliumEvent, useWindowSize } from "./react/hooks";
import NoItems from "./react/NoItems";
import NoteLink from "./react/NoteLink";
@@ -24,41 +21,12 @@ export interface FloatingButtonContext {
isDefaultViewMode: boolean;
}
-function FloatingButton({ className, ...props }: ActionButtonProps) {
- return <ActionButton
- className={`floating-button ${className ?? ""}`}
- noIconActionClass
- {...props}
- />;
-}
-
export type FloatingButtonsList = ((context: FloatingButtonContext) => false | VNode)[];
export const DESKTOP_FLOATING_BUTTONS: FloatingButtonsList = [
- InAppHelpButton,
Backlinks
];
-/**
- * Floating buttons that should be hidden in popup editor (Quick edit).
- */
-export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [
- InAppHelpButton
-];
-
-function InAppHelpButton({ note }: FloatingButtonContext) {
- const helpUrl = getHelpUrlForNote(note);
- const isEnabled = note.type !== "book" && !!helpUrl;
-
- return isEnabled && (
- <FloatingButton
- icon="bx bx-help-circle"
- text={t("help-button.title")}
- onClick={() => helpUrl && openInAppHelpFromUrl(helpUrl)}
- />
- );
-}
-
function Backlinks({ note, isDefaultViewMode }: FloatingButtonContext) {
const [ popupOpen, setPopupOpen ] = useState(false);
const backlinksContainerRef = useRef<HTMLDivElement>(null);
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx b/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx
index 189e63e0d5..b00366664f 100644
--- a/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx
+++ b/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx
@@ -102,8 +102,7 @@ vi.mock("../NoteDetail", () => ({ default: () => <div className="note-detail-stu
vi.mock("../collections/NoteList", () => ({ default: () => null }));
vi.mock("../FloatingButtons", () => ({ default: () => null }));
vi.mock("../FloatingButtonsDefinitions", () => ({
- DESKTOP_FLOATING_BUTTONS: [ "kept", "hidden" ],
- POPUP_HIDDEN_FLOATING_BUTTONS: [ "hidden" ]
+ DESKTOP_FLOATING_BUTTONS: []
}));
vi.mock("../PromotedAttributes", () => ({ default: () => null }));
vi.mock("../layout/NoteBadges", () => ({ default: () => null }));
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.tsx b/apps/client/src/widgets/dialogs/PopupEditor.tsx
index 5d7c1a088f..1d69db5b2f 100644
--- a/apps/client/src/widgets/dialogs/PopupEditor.tsx
+++ b/apps/client/src/widgets/dialogs/PopupEditor.tsx
@@ -1,7 +1,7 @@
import "./PopupEditor.css";
import { ComponentChildren } from "preact";
-import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
+import { useCallback, useContext, useEffect, useRef, useState } from "preact/hooks";
import appContext from "../../components/app_context";
import NoteContext from "../../components/note_context";
@@ -11,7 +11,7 @@ import tree from "../../services/tree";
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 { DESKTOP_FLOATING_BUTTONS } from "../FloatingButtonsDefinitions";
import FormattingToolbar from "../layout/FormattingToolbar";
import NoteTypeSwitcher from "../layout/NoteTypeSwitcher";
import TitleRow from "../layout/TitleRow";
@@ -36,10 +36,6 @@ export default function PopupEditor() {
const [ noteContext, setNoteContext ] = useState(() => new NoteContext("_popup-editor"));
const modalRef = useRef<HTMLDivElement>(null);
const isMobile = utils.isMobile();
- const items = useMemo(() => {
- const baseItems = isMobile ? [] : DESKTOP_FLOATING_BUTTONS;
- return baseItems.filter(item => !POPUP_HIDDEN_FLOATING_BUTTONS.includes(item));
- }, [ isMobile ]);
useTriliumEvent("openInPopup", async ({ noteIdOrPath, viewScope, showNoteTypeSwitcher }) => {
const noteId = tree.getNoteIdAndParentIdFromUrl(noteIdOrPath);
@@ -185,7 +181,7 @@ export default function PopupEditor() {
? <MobileEditorToolbar inPopupEditor />
: <FormattingToolbar />}
- <FloatingButtons items={items} />
+ <FloatingButtons items={isMobile ? [] : DESKTOP_FLOATING_BUTTONS} />
<NoteDetail />
<NoteList media="screen" displayOnlyCollections />
{switchable && <NoteTypeSwitcher note={noteContext.note} />}