@@ -81,7 +81,7 @@ export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [
8181const isNewLayout = isExperimentalFeatureEnabled ( "new-layout" ) ;
8282
8383function RefreshBackendLogButton ( { note, parentComponent, noteContext, isDefaultViewMode } : FloatingButtonContext ) {
84- const isEnabled = ( note . noteId === "_backendLog" || note . type === "render" ) && isDefaultViewMode ;
84+ const isEnabled = ! isNewLayout && ( note . noteId === "_backendLog" || note . type === "render" ) && isDefaultViewMode ;
8585 return isEnabled && < FloatingButton
8686 text = { t ( "backend_log.refresh" ) }
8787 icon = "bx bx-refresh"
@@ -90,7 +90,7 @@ function RefreshBackendLogButton({ note, parentComponent, noteContext, isDefault
9090}
9191
9292function SwitchSplitOrientationButton ( { note, isReadOnly, isDefaultViewMode } : FloatingButtonContext ) {
93- const isEnabled = note . type === "mermaid" && note . isContentAvailable ( ) && ! isReadOnly && isDefaultViewMode ;
93+ const isEnabled = ! isNewLayout && note . type === "mermaid" && note . isContentAvailable ( ) && ! isReadOnly && isDefaultViewMode ;
9494 const [ splitEditorOrientation , setSplitEditorOrientation ] = useTriliumOption ( "splitEditorOrientation" ) ;
9595 const upcomingOrientation = splitEditorOrientation === "horizontal" ? "vertical" : "horizontal" ;
9696
@@ -103,7 +103,7 @@ function SwitchSplitOrientationButton({ note, isReadOnly, isDefaultViewMode }: F
103103
104104function ToggleReadOnlyButton ( { note, viewType, isDefaultViewMode } : FloatingButtonContext ) {
105105 const [ isReadOnly , setReadOnly ] = useNoteLabelBoolean ( note , "readOnly" ) ;
106- const isEnabled = ( [ "mermaid" , "mindMap" , "canvas" ] . includes ( note . type ) || viewType === "geoMap" )
106+ const isEnabled = ! isNewLayout && ( [ "mermaid" , "mindMap" , "canvas" ] . includes ( note . type ) || viewType === "geoMap" )
107107 && note . isContentAvailable ( ) && isDefaultViewMode ;
108108
109109 return isEnabled && < FloatingButton
@@ -173,7 +173,7 @@ function ShowHighlightsListWidgetButton({ note, noteContext, isDefaultViewMode }
173173}
174174
175175function RunActiveNoteButton ( { note } : FloatingButtonContext ) {
176- const isEnabled = note . mime . startsWith ( "application/javascript" ) || note . mime === "text/x-sqlite;schema=trilium" ;
176+ const isEnabled = ! isNewLayout && ( note . mime . startsWith ( "application/javascript" ) || note . mime === "text/x-sqlite;schema=trilium" ) ;
177177 return isEnabled && < FloatingButton
178178 icon = "bx bx-play"
179179 text = { t ( "code_buttons.execute_button_title" ) }
@@ -182,7 +182,7 @@ function RunActiveNoteButton({ note }: FloatingButtonContext) {
182182}
183183
184184function OpenTriliumApiDocsButton ( { note } : FloatingButtonContext ) {
185- const isEnabled = note . mime . startsWith ( "application/javascript;env=" ) ;
185+ const isEnabled = ! isNewLayout && note . mime . startsWith ( "application/javascript;env=" ) ;
186186 return isEnabled && < FloatingButton
187187 icon = "bx bx-help-circle"
188188 text = { t ( "code_buttons.trilium_api_docs_button_title" ) }
@@ -191,25 +191,29 @@ function OpenTriliumApiDocsButton({ note }: FloatingButtonContext) {
191191}
192192
193193function SaveToNoteButton ( { note } : FloatingButtonContext ) {
194- const isEnabled = note . mime === "text/x-sqlite;schema=trilium" && note . isHiddenCompletely ( ) ;
194+ const isEnabled = ! isNewLayout && note . mime === "text/x-sqlite;schema=trilium" && note . isHiddenCompletely ( ) ;
195195 return isEnabled && < FloatingButton
196196 icon = "bx bx-save"
197197 text = { t ( "code_buttons.save_to_note_button_title" ) }
198- onClick = { async ( e ) => {
199- e . preventDefault ( ) ;
200- const { notePath } = await server . post < SaveSqlConsoleResponse > ( "special-notes/save-sql-console" , { sqlConsoleNoteId : note . noteId } ) ;
201- if ( notePath ) {
202- toast . showMessage ( t ( "code_buttons.sql_console_saved_message" , { "note_path" : await tree . getNotePathTitle ( notePath ) } ) ) ;
203- // TODO: This hangs the navigation, for some reason.
204- //await ws.waitForMaxKnownEntityChangeId();
205- await appContext . tabManager . getActiveContext ( ) ?. setNote ( notePath ) ;
206- }
207- } }
198+ onClick = { buildSaveSqlToNoteHandler ( note ) }
208199 /> ;
209200}
210201
202+ export function buildSaveSqlToNoteHandler ( note : FNote ) {
203+ return async ( e : MouseEvent ) => {
204+ e . preventDefault ( ) ;
205+ const { notePath } = await server . post < SaveSqlConsoleResponse > ( "special-notes/save-sql-console" , { sqlConsoleNoteId : note . noteId } ) ;
206+ if ( notePath ) {
207+ toast . showMessage ( t ( "code_buttons.sql_console_saved_message" , { "note_path" : await tree . getNotePathTitle ( notePath ) } ) ) ;
208+ // TODO: This hangs the navigation, for some reason.
209+ //await ws.waitForMaxKnownEntityChangeId();
210+ await appContext . tabManager . getActiveContext ( ) ?. setNote ( notePath ) ;
211+ }
212+ } ;
213+ }
214+
211215function RelationMapButtons ( { note, isDefaultViewMode, triggerEvent } : FloatingButtonContext ) {
212- const isEnabled = ( note . type === "relationMap" && isDefaultViewMode ) ;
216+ const isEnabled = ( ! isNewLayout && note . type === "relationMap" && isDefaultViewMode ) ;
213217 return isEnabled && (
214218 < >
215219 < FloatingButton
@@ -242,7 +246,7 @@ function RelationMapButtons({ note, isDefaultViewMode, triggerEvent }: FloatingB
242246}
243247
244248function GeoMapButtons ( { triggerEvent, viewType, isReadOnly } : FloatingButtonContext ) {
245- const isEnabled = viewType === "geoMap" && ! isReadOnly ;
249+ const isEnabled = ! isNewLayout && viewType === "geoMap" && ! isReadOnly ;
246250 return isEnabled && (
247251 < FloatingButton
248252 icon = "bx bx-plus-circle"
@@ -283,7 +287,7 @@ function CopyImageReferenceButton({ note, isDefaultViewMode }: FloatingButtonCon
283287}
284288
285289function ExportImageButtons ( { note, triggerEvent, isDefaultViewMode } : FloatingButtonContext ) {
286- const isEnabled = [ "mermaid" , "mindMap" ] . includes ( note ?. type ?? "" )
290+ const isEnabled = ! isNewLayout && [ "mermaid" , "mindMap" ] . includes ( note ?. type ?? "" )
287291 && note ?. isContentAvailable ( ) && isDefaultViewMode ;
288292 return isEnabled && (
289293 < >
@@ -304,7 +308,7 @@ function ExportImageButtons({ note, triggerEvent, isDefaultViewMode }: FloatingB
304308
305309function InAppHelpButton ( { note } : FloatingButtonContext ) {
306310 const helpUrl = getHelpUrlForNote ( note ) ;
307- const isEnabled = ! ! helpUrl && ( ! isNewLayout || ( note ?. type !== "book" ) ) ;
311+ const isEnabled = ! ! helpUrl && ! isNewLayout ;
308312
309313 return isEnabled && (
310314 < FloatingButton
0 commit comments