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): remove the floating save to note button
Elian Doran858ff60a8444
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsxindex 55384f4752..4ba422d64f 100644--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx@@ -1,10 +1,10 @@import "./Backlinks.css";-import { BacklinkCountResponse, BacklinksResponse, SaveSqlConsoleResponse } from "@triliumnext/commons";+import { BacklinkCountResponse, BacklinksResponse } from "@triliumnext/commons";import { VNode } from "preact";import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";-import appContext, { EventData, EventNames } from "../components/app_context";+import { EventData, EventNames } from "../components/app_context";import NoteContext from "../components/note_context";import FNote from "../entities/fnote";import attributes from "../services/attributes";@@ -15,8 +15,6 @@ 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 toast from "../services/toast";-import tree from "../services/tree";import { createImageSrcUrl, openInAppHelpFromUrl } from "../services/utils";import ActionButton, { ActionButtonProps } from "./react/ActionButton";import { useTriliumEvent, useWindowSize } from "./react/hooks";@@ -43,7 +41,6 @@ function FloatingButton({ className, ...props }: ActionButtonProps) {export type FloatingButtonsList = ((context: FloatingButtonContext) => false | VNode)[];export const DESKTOP_FLOATING_BUTTONS: FloatingButtonsList = [- SaveToNoteButton,CopyImageReferenceButton,ExportImageButtons,ExportSpreadsheetButton,@@ -58,28 +55,6 @@ export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [InAppHelpButton];-function SaveToNoteButton({ note }: FloatingButtonContext) {- const isEnabled = note.mime === "text/x-sqlite;schema=trilium" && note.isHiddenCompletely();- return isEnabled && <FloatingButton- icon="bx bx-save"- text={t("code_buttons.save_to_note_button_title")}- onClick={buildSaveSqlToNoteHandler(note)}- />;-}--export function buildSaveSqlToNoteHandler(note: FNote) {- return async (e: MouseEvent) => {- e.preventDefault();- const { notePath } = await server.post<SaveSqlConsoleResponse>("special-notes/save-sql-console", { sqlConsoleNoteId: note.noteId });- if (notePath) {- toast.showMessage(t("code_buttons.sql_console_saved_message", { "note_path": await tree.getNotePathTitle(notePath) }));- // TODO: This hangs the navigation, for some reason.- //await ws.waitForMaxKnownEntityChangeId();- await appContext.tabManager.getActiveContext()?.setNote(notePath);- }- };-}-function CopyImageReferenceButton({ note, isDefaultViewMode }: FloatingButtonContext) {const hiddenImageCopyRef = useRef<HTMLDivElement>(null);const isEnabled = (diff --git a/apps/client/src/widgets/layout/NoteActionsCustom.tsx b/apps/client/src/widgets/layout/NoteActionsCustom.tsxindex f0ce3d9485..03093b0500 100644--- a/apps/client/src/widgets/layout/NoteActionsCustom.tsx+++ b/apps/client/src/widgets/layout/NoteActionsCustom.tsx@@ -1,8 +1,9 @@import "./NoteActionsCustom.css";-import { NoteType } from "@triliumnext/commons";+import { NoteType, SaveSqlConsoleResponse } from "@triliumnext/commons";import { useContext, useEffect, useRef, useState } from "preact/hooks";+import appContext from "../../components/app_context";import Component from "../../components/component";import NoteContext from "../../components/note_context";import FNote from "../../entities/fnote";@@ -12,9 +13,9 @@ import { getHelpUrlForNote } from "../../services/in_app_help";import { downloadFileNote, openNoteExternally } from "../../services/open";import server from "../../services/server";import toast from "../../services/toast";+import tree from "../../services/tree";import { clearBrowserCache, createImageSrcUrl, isMobile, openInAppHelpFromUrl } from "../../services/utils";import { ViewTypeOptions } from "../collections/interface";-import { buildSaveSqlToNoteHandler } from "../FloatingButtonsDefinitions";import { showImageCompressionDialog } from "../dialogs/image_compression/image_compression_dialog";import ActionButton, { ActionButtonProps } from "../react/ActionButton";import { ButtonGroup } from "../react/Button";@@ -334,6 +335,19 @@ function SaveToNoteButton({ note, noteMime }: NoteActionsCustomInnerProps) {/>;}+function buildSaveSqlToNoteHandler(note: FNote) {+ return async (e: MouseEvent) => {+ e.preventDefault();+ const { notePath } = await server.post<SaveSqlConsoleResponse>("special-notes/save-sql-console", { sqlConsoleNoteId: note.noteId });+ if (notePath) {+ toast.showMessage(t("code_buttons.sql_console_saved_message", { "note_path": await tree.getNotePathTitle(notePath) }));+ // TODO: This hangs the navigation, for some reason.+ //await ws.waitForMaxKnownEntityChangeId();+ await appContext.tabManager.getActiveContext()?.setNote(notePath);+ }+ };+}+function InAppHelpButton({ note }: NoteActionsCustomInnerProps) {const helpUrl = getHelpUrlForNote(note);const isEnabled = !!helpUrl;