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
feat(react/floating_buttons): port execute note button
Elian Doran04b7e0cde9d2
diff --git a/apps/client/src/widgets/FloatingButtons.tsx b/apps/client/src/widgets/FloatingButtons.tsxindex 0e1bfc4af0..5ecae1b15b 100644--- a/apps/client/src/widgets/FloatingButtons.tsx+++ b/apps/client/src/widgets/FloatingButtons.tsx@@ -61,6 +61,10 @@ const FLOATING_BUTTON_DEFINITIONS: FloatingButtonDefinition[] = [isEnabled: ({ note, noteContext }) =>note.type === "text" && noteContext?.viewScope?.viewMode === "default"&& !!noteContext.viewScope?.highlightsListTemporarilyHidden+ },+ {+ component: RunActiveNoteButton,+ isEnabled: ({ note }) => note.mime.startsWith("application/javascript") || note.mime === "text/x-sqlite;schema=trilium"}];@@ -213,6 +217,14 @@ function ShowHighlightsListWidgetButton({ noteContext }: FloatingButtonContext)/>}+function RunActiveNoteButton() {+ return <ActionButton+ icon="bx bx-play"+ text={t("code_buttons.execute_button_title")}+ triggerCommand="runActiveNote"+ />+}+/*** Show button that displays floating button after click on close button*/diff --git a/apps/client/src/widgets/floating_buttons/code_buttons.ts b/apps/client/src/widgets/floating_buttons/code_buttons.tsindex 63b0d92bbd..712d1d9eea 100644--- a/apps/client/src/widgets/floating_buttons/code_buttons.ts+++ b/apps/client/src/widgets/floating_buttons/code_buttons.ts@@ -17,10 +17,6 @@ const TPL = /*html*/`}</style>- <button data-trigger-command="runActiveNote" class="execute-button floating-button btn" title="${t("code_buttons.execute_button_title")}">- <span class="bx bx-play"></span>- </button>-<button class="trilium-api-docs-button floating-button btn" title="${t("code_buttons.trilium_api_docs_button_title")}"><span class="bx bx-help-circle"></span></button>@@ -38,7 +34,6 @@ interface SaveSqlConsoleResponse {export default class CodeButtonsWidget extends NoteContextAwareWidget {private $openTriliumApiDocsButton!: JQuery<HTMLElement>;- private $executeButton!: JQuery<HTMLElement>;private $saveToNoteButton!: JQuery<HTMLElement>;isEnabled() {@@ -78,8 +73,6 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget {}async refreshWithNote(note: FNote) {- this.$executeButton.toggle(note.mime.startsWith("application/javascript") || note.mime === "text/x-sqlite;schema=trilium");-this.$saveToNoteButton.toggle(note.mime === "text/x-sqlite;schema=trilium" && note.isHiddenCompletely());this.$openTriliumApiDocsButton.toggle(note.mime.startsWith("application/javascript;env="));