Skip to content

Commit 8a45dbb

Browse files
authored
Merge pull request #8612 from sagemathinc/latex-output-fixes2
latex output fixes round 2
2 parents acd1b07 + 820fe0b commit 8a45dbb

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

src/packages/frontend/account/editor-settings/font-size.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { InputNumber } from "antd";
77
import { LabeledRow } from "@cocalc/frontend/components";
8+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
89
import { useIntl } from "react-intl";
910

1011
interface Props {
@@ -24,7 +25,7 @@ export function EditorSettingsFontSize(props: Props) {
2425
className="cc-account-prefs-font-size"
2526
>
2627
<InputNumber
27-
onChange={(n) => props.on_change("font_size", n ?? 14)}
28+
onChange={(n) => props.on_change("font_size", n ?? DEFAULT_FONT_SIZE)}
2829
min={5}
2930
max={32}
3031
value={props.font_size}

src/packages/frontend/editors/slate/editable-markdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { EditorFunctions } from "@cocalc/frontend/editors/markdown-input/multimo
2828
import { SAVE_DEBOUNCE_MS } from "@cocalc/frontend/frame-editors/code-editor/const";
2929
import { useFrameContext } from "@cocalc/frontend/frame-editors/frame-tree/frame-context";
3030
import { Path } from "@cocalc/frontend/frame-editors/frame-tree/path";
31+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
3132
import { EditorState } from "@cocalc/frontend/frame-editors/frame-tree/types";
3233
import { markdown_to_html } from "@cocalc/frontend/markdown";
3334
import Fragment, { FragmentId } from "@cocalc/frontend/misc/fragment-id";
@@ -171,7 +172,7 @@ export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
171172
const isMountedRef = useIsMountedRef();
172173
const id = id0 ?? "";
173174
const actions = actions0 ?? {};
174-
const font_size = font_size0 ?? desc?.get("font_size") ?? 14; // so possible to use without specifying this. TODO: should be from account settings
175+
const font_size = font_size0 ?? desc?.get("font_size") ?? DEFAULT_FONT_SIZE; // so possible to use without specifying this. TODO: should be from account settings
175176
const [change, setChange] = useState<number>(0);
176177

177178
const editor = useMemo(() => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function OutputFiles({
6363
path: filePath,
6464
displayPath,
6565
isMain: false,
66-
summary: fileSummaries[filePath] ?? "Loading...",
66+
summary: fileSummaries[filePath] ?? "Summary not available...",
6767
};
6868
});
6969

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
import { EditorState } from "@cocalc/frontend/frame-editors/frame-tree/types";
4141
import { project_api } from "@cocalc/frontend/frame-editors/generic/client";
4242
import { editor, labels } from "@cocalc/frontend/i18n";
43+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
4344

4445
import { TITLE_BAR_BORDER } from "../frame-tree/style";
4546
import { Actions } from "./actions";
@@ -253,8 +254,8 @@ export function Output(props: OutputProps) {
253254
// Handle zoom changes from pinch-to-zoom or wheel gestures
254255
const handleZoomChange = useCallback(
255256
(data: Data) => {
256-
// Convert fontSize to zoom scale (fontSize 14 = 1.0 zoom)
257-
const newZoom = data.fontSize / 14;
257+
// Convert fontSize to zoom scale (DEFAULT_FONT_SIZE = 1.0 zoom)
258+
const newZoom = data.fontSize / DEFAULT_FONT_SIZE;
258259
const local_view_state = actions.store.get("local_view_state");
259260
actions.setState({
260261
local_view_state: local_view_state.setIn([id, "pdf_zoom"], newZoom),
@@ -369,11 +370,8 @@ export function Output(props: OutputProps) {
369370
const autoSyncInProgress =
370371
actions.store.get("autoSyncInProgress");
371372
if (autoSyncInProgress) {
372-
// Debounce the flag clearing to avoid clearing too early during scrolling
373-
clearTimeout((window as any).__autoSyncClearTimeout);
374-
(window as any).__autoSyncClearTimeout = setTimeout(() => {
375-
actions.setState({ autoSyncInProgress: false });
376-
}, 500); // Wait longer to ensure scrolling has stabilized
373+
// Clear immediately to allow next forward sync without delay
374+
actions.setState({ autoSyncInProgress: false });
377375
}
378376
}}
379377
onPageDimensions={setPageDimensions}

src/packages/frontend/frame-editors/latex-editor/pdfjs.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import usePinchToZoom, {
3535
} from "@cocalc/frontend/frame-editors/frame-tree/pinch-to-zoom";
3636
import { EditorState } from "@cocalc/frontend/frame-editors/frame-tree/types";
3737
import { list_alternatives, seconds_ago } from "@cocalc/util/misc";
38+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
3839
import { COLORS } from "@cocalc/util/theme";
3940
import { Actions, Actions as LatexEditorActions } from "./actions";
4041
import { dblclick } from "./mouse-click";
@@ -248,7 +249,7 @@ export function PDFJS({
248249
if (evt.key == "0" && (evt.metaKey || evt.ctrlKey)) {
249250
actions.set_font_size(
250251
id,
251-
redux.getStore("account").get("font_size") ?? 14,
252+
redux.getStore("account").get("font_size") ?? DEFAULT_FONT_SIZE,
252253
);
253254
return;
254255
}
@@ -440,7 +441,8 @@ export function PDFJS({
440441

441442
// Use onZoom callback if available (new zoom system), otherwise fall back to font_size
442443
if (onZoom) {
443-
const fontSize = getFontSize(scale);
444+
// For zoom-to-fit, always use DEFAULT_FONT_SIZE as base to avoid account font size dependency
445+
const fontSize = scale * DEFAULT_FONT_SIZE;
444446
onZoom({ fontSize });
445447
} else {
446448
actions.set_font_size(id, getFontSize(scale));
@@ -464,7 +466,8 @@ export function PDFJS({
464466

465467
// Use onZoom callback if available (new zoom system), otherwise fall back to font_size
466468
if (onZoom) {
467-
const fontSize = getFontSize(scale);
469+
// For zoom-to-fit, always use DEFAULT_FONT_SIZE as base to avoid account font size dependency
470+
const fontSize = scale * DEFAULT_FONT_SIZE;
468471
onZoom({ fontSize });
469472
} else {
470473
actions.set_font_size(id, getFontSize(scale));
@@ -840,11 +843,16 @@ export function PDFJS({
840843
if (zoom !== undefined) {
841844
return zoom;
842845
}
843-
return font_size / (redux.getStore("account").get("font_size") ?? 14);
846+
return (
847+
font_size /
848+
(redux.getStore("account").get("font_size") ?? DEFAULT_FONT_SIZE)
849+
);
844850
}, [zoom, font_size]);
845851

846852
function getFontSize(scale: number): number {
847-
return (redux.getStore("account").get("font_size") ?? 14) * scale;
853+
return (
854+
(redux.getStore("account").get("font_size") ?? DEFAULT_FONT_SIZE) * scale
855+
);
848856
}
849857

850858
function renderOtherViewers() {

src/packages/frontend/frame-editors/whiteboard-editor/overview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { VirtuosoGrid } from "react-virtuoso";
1212

1313
import { useEditorRedux } from "@cocalc/frontend/app-framework";
1414
import { Loading } from "@cocalc/frontend/components";
15+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
1516
import { State, elementsList } from "./actions";
1617
import DeletePage from "./delete-page";
1718
import { useFrameContext } from "./hooks";
@@ -21,7 +22,7 @@ import { Overview as OnePage } from "./tools/navigation";
2122
export default function Overview() {
2223
const { actions, id: frameId, project_id, path, desc } = useFrameContext();
2324
const useEditor = useEditorRedux<State>({ project_id, path });
24-
const size = 15 * (desc?.get("font_size") ?? 14);
25+
const size = 15 * (desc?.get("font_size") ?? DEFAULT_FONT_SIZE);
2526
const isLoaded = useEditor("is_loaded");
2627
const pagesMap = useEditor("pages");
2728
const elementsMap = useEditor("elements");

src/packages/frontend/frame-editors/x11-editor/x11.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from "@cocalc/frontend/app-framework";
2424
import { Loading } from "@cocalc/frontend/components";
2525
import { retry_until_success } from "@cocalc/util/async-utils";
26+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
2627
import { cmp } from "@cocalc/util/misc";
2728
import { Actions } from "./actions";
2829
import { TAB_BAR_GREY } from "./theme";
@@ -56,7 +57,8 @@ export function X11({
5657
const windowRef = useRef<HTMLDivElement>(null as any);
5758
const focusRef = useRef<HTMLTextAreaElement>(null as any);
5859

59-
const default_font_size = useTypedRedux("account", "font_size") ?? 14;
60+
const default_font_size =
61+
useTypedRedux("account", "font_size") ?? DEFAULT_FONT_SIZE;
6062
const windows: Map<string, any> = useRedux(name, "windows");
6163
const x11_is_idle: boolean = useRedux(name, "x11_is_idle");
6264
const disabled: boolean = useRedux(name, "disabled");

src/packages/frontend/jupyter/history-viewer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { fromJS, List, Map } from "immutable";
1111
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
1212
import { ErrorDisplay } from "@cocalc/frontend/components";
1313
import * as cell_utils from "@cocalc/jupyter/util/cell-utils";
14+
import { DEFAULT_FONT_SIZE } from "@cocalc/util/consts/ui";
1415
import { path_split } from "@cocalc/util/misc";
1516
import { CellList } from "./cell-list";
1617
import { cm_options } from "./cm_options";
@@ -30,7 +31,7 @@ function get_cells(doc): { cells: Map<string, any>; cell_list: List<string> } {
3031

3132
export function HistoryViewer({ project_id, path, doc, font_size }) {
3233
const default_font_size =
33-
font_size ?? useTypedRedux("account", "font_size") ?? 14;
34+
font_size ?? useTypedRedux("account", "font_size") ?? DEFAULT_FONT_SIZE;
3435
const { head: directory } = path_split(path);
3536
const { cells, cell_list } = get_cells(doc);
3637

src/packages/util/consts/ui.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ export const DOC_AI = "https://doc.cocalc.com/ai.html";
2929
// anywhere in our frontend.
3030
export const R_IDE = "R IDE";
3131

32+
// Default font size for account settings and UI elements
33+
export const DEFAULT_FONT_SIZE = 14;
3234
// Icon unicode character for dark mode toggle (◑ - circle with right half black)
3335
export const DARK_MODE_ICON = 0x25d1;

0 commit comments

Comments
 (0)