Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): remove the floating spreadsheet export buttons

Elian Doran03fb204078ab
diff --git a/apps/client/src/widgets/FloatingButtons.tsx b/apps/client/src/widgets/FloatingButtons.tsx
index 4267088b54..2b8e12223d 100644
--- a/apps/client/src/widgets/FloatingButtons.tsx
+++ b/apps/client/src/widgets/FloatingButtons.tsx
@@ -1,9 +1,7 @@
import { t } from "i18next";
import "./FloatingButtons.css";
import { useNoteContext } from "./react/hooks";
-import { useContext, useEffect, useMemo, useState } from "preact/hooks";
-import { ParentComponent } from "./react/react_utils";
-import { EventData, EventNames } from "../components/app_context";
+import { useEffect, useMemo, useState } from "preact/hooks";
import { type FloatingButtonsList, type FloatingButtonContext } from "./FloatingButtonsDefinitions";
import ActionButton from "./react/ActionButton";
@@ -20,22 +18,14 @@ interface FloatingButtonsProps {
*/
export default function FloatingButtons({ items }: FloatingButtonsProps) {
const { note, noteContext } = useNoteContext();
- const parentComponent = useContext(ParentComponent);
const context = useMemo<FloatingButtonContext | null>(() => {
- if (!note || !noteContext || !parentComponent) return null;
+ if (!note || !noteContext) return null;
return {
note,
- noteContext,
- isDefaultViewMode: noteContext.viewScope?.viewMode === "default",
- triggerEvent<T extends EventNames>(name: T, data?: Omit<EventData<T>, "ntxId">) {
- parentComponent.triggerEvent(name, {
- ntxId: noteContext.ntxId,
- ...data
- } as EventData<T>);
- }
+ isDefaultViewMode: noteContext.viewScope?.viewMode === "default"
};
- }, [ note, noteContext, parentComponent ]);
+ }, [ note, noteContext ]);
// Manage the user-adjustable visibility of the floating buttons.
const [ visible, setVisible ] = useState(true);
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
index fedcf3038e..7dc8152d23 100644
--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
@@ -4,8 +4,6 @@ import { BacklinkCountResponse, BacklinksResponse } from "@triliumnext/commons";
import { VNode } from "preact";
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
-import { EventData, EventNames } from "../components/app_context";
-import NoteContext from "../components/note_context";
import FNote from "../entities/fnote";
import attributes from "../services/attributes";
import froca from "../services/froca";
@@ -23,10 +21,7 @@ import RawHtml from "./react/RawHtml";
export interface FloatingButtonContext {
note: FNote;
- noteContext: NoteContext;
isDefaultViewMode: boolean;
- /** Shorthand for triggering an event from the parent component. The `ntxId` is automatically handled for convenience. */
- triggerEvent<T extends EventNames>(name: T, data?: Omit<EventData<T>, "ntxId">): void;
}
function FloatingButton({ className, ...props }: ActionButtonProps) {
@@ -40,7 +35,6 @@ function FloatingButton({ className, ...props }: ActionButtonProps) {
export type FloatingButtonsList = ((context: FloatingButtonContext) => false | VNode)[];
export const DESKTOP_FLOATING_BUTTONS: FloatingButtonsList = [
- ExportSpreadsheetButton,
InAppHelpButton,
Backlinks
];
@@ -52,24 +46,6 @@ export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [
InAppHelpButton
];
-function ExportSpreadsheetButton({ note, triggerEvent, isDefaultViewMode }: FloatingButtonContext) {
- const isEnabled = note?.type === "spreadsheet" && note?.isContentAvailable() && isDefaultViewMode;
- return isEnabled && (
- <>
- <FloatingButton
- icon="bx bxs-spreadsheet"
- text={t("spreadsheet.export-xlsx")}
- onClick={() => triggerEvent("exportXlsx")}
- />
- <FloatingButton
- icon="bx bxs-spreadsheet"
- text={t("spreadsheet.export-csv")}
- onClick={() => triggerEvent("exportCsv")}
- />
- </>
- );
-}
-
function InAppHelpButton({ note }: FloatingButtonContext) {
const helpUrl = getHelpUrlForNote(note);
const isEnabled = note.type !== "book" && !!helpUrl;