Skip to content

Commit a4afe72

Browse files
committed
frontend/latex/output/build: add compact build button in front of the build command, roughly same location as in the PDF preview
1 parent 19c3748 commit a4afe72

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

src/packages/frontend/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"pythontex",
4747
"rclass",
4848
"rereturn",
49+
"rescan",
4950
"respawns",
5051
"revealjs",
5152
"Rmarkdown",

src/packages/frontend/frame-editors/latex-editor/build-command.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { React } from "@cocalc/frontend/app-framework";
1616
import { Icon, Loading, Paragraph } from "@cocalc/frontend/components";
1717
import { split } from "@cocalc/util/misc";
1818
import { Actions } from "./actions";
19+
import { BuildControls } from "./output-control-build";
1920
import {
2021
Engine,
2122
ENGINES,
@@ -166,6 +167,7 @@ export const BuildCommand: React.FC<Props> = React.memo((props: Props) => {
166167
onBlur={() => {
167168
handle_build_change();
168169
}}
170+
addonBefore={<BuildControls actions={actions} narrow={true} />}
169171
/>
170172
);
171173
}
@@ -272,7 +274,14 @@ export const BuildCommand: React.FC<Props> = React.memo((props: Props) => {
272274
<Icon name="reload" /> Rescan
273275
</a>
274276
</h4>
275-
<pre style={{ whiteSpace: "pre-line" }}>{build_command}</pre>
277+
<div style={{ display: "flex", gap: "10px", alignItems: "center" }}>
278+
<div>
279+
<BuildControls actions={actions} narrow={true} />
280+
</div>
281+
<pre style={{ whiteSpace: "pre-line", flex: 1, margin: 0 }}>
282+
{build_command}
283+
</pre>
284+
</div>
276285
{renderHardcodedInfo()}
277286
</>
278287
);

src/packages/frontend/frame-editors/latex-editor/output-control-build.tsx

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Build Controls Component for LaTeX Editor Output Panel
88
Provides build, force build, clean, download, and print controls
99
*/
1010

11+
import type { SizeType } from "antd/es/config-provider/SizeContext";
12+
1113
import type { MenuProps } from "antd";
1214
import { Dropdown } from "antd";
1315
import { useIntl } from "react-intl";
@@ -30,11 +32,17 @@ import { Actions } from "./actions";
3032

3133
interface 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

Comments
 (0)