feat(layout/note_actions): integrate execute script button

This commit is contained in:
Elian Doran
2025-12-15 08:19:40 +02:00
parent 04a641199b
commit 906fe4f8da
2 changed files with 11 additions and 1 deletions

View File

@@ -173,7 +173,7 @@ function ShowHighlightsListWidgetButton({ note, noteContext, isDefaultViewMode }
} }
function RunActiveNoteButton({ note }: FloatingButtonContext) { function RunActiveNoteButton({ note }: FloatingButtonContext) {
const isEnabled = note.mime.startsWith("application/javascript") || note.mime === "text/x-sqlite;schema=trilium"; const isEnabled = !isNewLayout && (note.mime.startsWith("application/javascript") || note.mime === "text/x-sqlite;schema=trilium");
return isEnabled && <FloatingButton return isEnabled && <FloatingButton
icon="bx bx-play" icon="bx bx-play"
text={t("code_buttons.execute_button_title")} text={t("code_buttons.execute_button_title")}

View File

@@ -49,6 +49,7 @@ export default function NoteActionsCustom(props: NoteActionsCustomProps) {
return (innerProps && return (innerProps &&
<div className="note-actions-custom"> <div className="note-actions-custom">
<RunActiveNoteButton {...innerProps } />
<SwitchSplitOrientationButton {...innerProps} /> <SwitchSplitOrientationButton {...innerProps} />
<ToggleReadOnlyButton {...innerProps} /> <ToggleReadOnlyButton {...innerProps} />
<RefreshButton {...innerProps} /> <RefreshButton {...innerProps} />
@@ -174,3 +175,12 @@ function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: NoteActions
onClick={() => setReadOnly(!isReadOnly)} onClick={() => setReadOnly(!isReadOnly)}
/>; />;
} }
function RunActiveNoteButton({ note }: NoteActionsCustomInnerProps) {
const isEnabled = note.mime.startsWith("application/javascript") || note.mime === "text/x-sqlite;schema=trilium";
return isEnabled && <ActionButton
icon="bx bx-play"
text={t("code_buttons.execute_button_title")}
triggerCommand="runActiveNote"
/>;
}