feat(react/floating_buttons): port open Trilium API docs

This commit is contained in:
Elian Doran
2025-08-27 22:59:07 +03:00
parent 04b7e0cde9
commit 08db03800e
2 changed files with 13 additions and 16 deletions

View File

@@ -14,6 +14,7 @@ import appContext from "../components/app_context";
import protected_session_holder from "../services/protected_session_holder";
import options from "../services/options";
import { AttributeRow } from "../services/load_results";
import { openInAppHelpFromUrl } from "../services/utils";
interface FloatingButtonContext {
parentComponent: Component;
@@ -65,6 +66,10 @@ const FLOATING_BUTTON_DEFINITIONS: FloatingButtonDefinition[] = [
{
component: RunActiveNoteButton,
isEnabled: ({ note }) => note.mime.startsWith("application/javascript") || note.mime === "text/x-sqlite;schema=trilium"
},
{
component: OpenTriliumApiDocsButton,
isEnabled: ({ note }) => note.mime.startsWith("application/javascript;env=")
}
];
@@ -225,6 +230,14 @@ function RunActiveNoteButton() {
/>
}
function OpenTriliumApiDocsButton({ note }: FloatingButtonContext) {
return <ActionButton
icon="bx bx-help-circle"
text={t("code_buttons.trilium_api_docs_button_title")}
onClick={() => openInAppHelpFromUrl(note.mime.endsWith("frontend") ? "Q2z6av6JZVWm" : "MEtfsqa5VwNi")}
/>
}
/**
* Show button that displays floating button after click on close button
*/