mirror of
https://github.com/zadam/trilium.git
synced 2025-10-12 16:37:52 +08:00
feat(react/floating_buttons): port execute note button
This commit is contained in:
parent
401260d3ca
commit
04b7e0cde9
2 changed files with 12 additions and 7 deletions
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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="));
|
||||
|
|
Loading…
Add table
Reference in a new issue