File tree Expand file tree Collapse file tree 5 files changed +34
-1
lines changed
Expand file tree Collapse file tree 5 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -470,7 +470,9 @@ export class MainUI {
470470 ) =>
471471 button . icon &&
472472 ( typeof button . mobile === "undefined" ||
473- button . mobile === viewState . isMobile ) ,
473+ button . mobile === viewState . isMobile ) &&
474+ ( typeof button . standalone === "undefined" ||
475+ button . standalone === viewState . isStandalone ) ,
474476 )
475477 // Then ensure all buttons have a priority set (by default based on array index)
476478 . map ( ( button , index ) => ( {
@@ -619,6 +621,7 @@ type ActionButton = {
619621 icon : string ;
620622 description ?: string ;
621623 mobile ?: boolean ;
624+ standalone ?: boolean ;
622625 dropdown ?: boolean ;
623626 priority ?: number ;
624627 run : ( ) => void ;
Original file line number Diff line number Diff line change @@ -21,10 +21,13 @@ export default function reducer(
2121 } ;
2222 case "page-loaded" : {
2323 const mouseDetected = globalThis . matchMedia ( "(pointer:fine)" ) . matches ;
24+ const isBrowser = globalThis . matchMedia ( "(display-mode: browser)" )
25+ . matches ;
2426 return {
2527 ...state ,
2628 isLoading : false ,
2729 isMobile : ! mouseDetected ,
30+ isStandalone : ! isBrowser ,
2831 current : {
2932 path : action . path ,
3033 meta : action . meta as PageMeta ,
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export type AppViewState = {
2929
3030 isLoading : boolean ;
3131 isMobile : boolean ;
32+ isStandalone : boolean ;
3233 showPageNavigator : boolean ;
3334 showCommandPalette : boolean ;
3435 showCommandPaletteContext ?: string ;
@@ -88,6 +89,7 @@ export const initialViewState: AppViewState = {
8889 forcedROMode : false ,
8990 } ,
9091 isMobile : false ,
92+ isStandalone : false ,
9193 panels : {
9294 lhs : { } ,
9395 rhs : { } ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Keys to define:
1414* ` description ` (optional): description of button (appears on hover)
1515* ` priority ` (optional): determines priority of button (the higher, the earlier in the list)
1616* ` mobile ` : when set to ` true ` this button will only appear on mobile devices
17+ * ` standalone ` : when set to ` true ` this button will only appear in standalone/PWA mode; when ` false ` , only in browser mode
1718* ` dropdown ` (optional): when set to ` false ` , the button stays visible outside the dropdown menu on mobile (default: ` true ` )
1819
1920# Example
Original file line number Diff line number Diff line change @@ -363,6 +363,10 @@ config.define("actionButtons", {
363363 type = "boolean",
364364 description = "Optional boolean indicating if the action button is applicable for mobile"
365365 },
366+ standalone = {
367+ type = "boolean",
368+ description = "Optional: when set to true, button only appears in standalone/PWA mode; when false, only in browser mode"
369+ },
366370 dropdown = {
367371 type = "boolean",
368372 description = "Optional: set to false to keep this button outside the dropdown menu on mobile (default: true)"
@@ -413,6 +417,26 @@ config.set {
413417 run = function()
414418 editor.invokeCommand "Open Command Palette"
415419 end,
420+ },
421+ {
422+ icon = "chevron-left",
423+ description = "Go back",
424+ standalone = true,
425+ dropdown = false,
426+ priority = 0,
427+ run = function()
428+ editor.goHistory(-1)
429+ end,
430+ },
431+ {
432+ icon = "chevron-right",
433+ description = "Go forward",
434+ standalone = true,
435+ dropdown = false,
436+ priority = -1,
437+ run = function()
438+ editor.goHistory(1)
439+ end,
416440 }
417441 },
418442}
You can’t perform that action at this time.
0 commit comments