@@ -8,6 +8,8 @@ Build Controls Component for LaTeX Editor Output Panel
88Provides build, force build, clean, download, and print controls
99*/
1010
11+ import type { SizeType } from "antd/es/config-provider/SizeContext" ;
12+
1113import type { MenuProps } from "antd" ;
1214import { Dropdown } from "antd" ;
1315import { useIntl } from "react-intl" ;
@@ -30,11 +32,17 @@ import { Actions } from "./actions";
3032
3133interface BuildControlsProps {
3234 actions : Actions ;
33- id : string ;
35+ id ? : string ; // must be set if used for the PDF preview, used by the print command
3436 narrow ?: boolean ;
37+ size ?: SizeType ;
3538}
3639
37- export function BuildControls ( { actions, id, narrow } : BuildControlsProps ) {
40+ export function BuildControls ( {
41+ actions,
42+ id,
43+ narrow,
44+ size = "small" ,
45+ } : BuildControlsProps ) {
3846 const intl = useIntl ( ) ;
3947
4048 // Get build on save setting from account store
@@ -100,36 +108,39 @@ export function BuildControls({ actions, id, narrow }: BuildControlsProps) {
100108 icon : < Icon name = "cloud-download" /> ,
101109 onClick : ( ) => actions . download_pdf ( ) ,
102110 } ,
103- {
111+ ] ;
112+
113+ if ( id != null ) {
114+ buildMenuItems . push ( {
104115 key : "print" ,
105116 label : intl . formatMessage ( COMMANDS . print . label as IntlMessage ) ,
106117 icon : < Icon name = "print" /> ,
107118 onClick : ( ) => actions . print ( id ) ,
108- } ,
109- {
110- type : "divider" ,
111- } ,
112- {
113- key : "auto-build" ,
114- icon : (
115- < Icon
116- name = {
117- buildOnSave
118- ? BUILD_ON_SAVE_ICON_ENABLED
119- : BUILD_ON_SAVE_ICON_DISABLED
120- }
121- />
122- ) ,
123- label : intl . formatMessage ( BUILD_ON_SAVE_LABEL , { enabled : buildOnSave } ) ,
124- onClick : toggleBuildOnSave ,
125- } ,
126- ] ;
119+ } ) ;
120+ }
121+
122+ buildMenuItems . push ( {
123+ type : "divider" ,
124+ } ) ;
125+
126+ buildMenuItems . push ( {
127+ key : "auto-build" ,
128+ icon : (
129+ < Icon
130+ name = {
131+ buildOnSave ? BUILD_ON_SAVE_ICON_ENABLED : BUILD_ON_SAVE_ICON_DISABLED
132+ }
133+ />
134+ ) ,
135+ label : intl . formatMessage ( BUILD_ON_SAVE_LABEL , { enabled : buildOnSave } ) ,
136+ onClick : toggleBuildOnSave ,
137+ } ) ;
127138
128139 return (
129140 < >
130141 < Dropdown . Button
131142 type = "primary"
132- size = "small"
143+ size = { size }
133144 icon = { < Icon name = "caret-down" /> }
134145 menu = { { items : buildMenuItems } }
135146 trigger = { [ "click" ] }
@@ -141,7 +152,7 @@ export function BuildControls({ actions, id, narrow }: BuildControlsProps) {
141152 </ Dropdown . Button >
142153
143154 { /* Dark mode toggle - only shown when global dark mode is enabled */ }
144- { isDarkMode && (
155+ { isDarkMode && id != null && (
145156 < BSButton
146157 bsSize = "xsmall"
147158 active = { pdfDarkModeDisabled }
0 commit comments