Skip to content

Commit fbb1bc7

Browse files
committed
fix #7739 -- timetravel with rendered markdown doesn't respect font size selection in menu
1 parent e58b098 commit fbb1bc7

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/packages/frontend/frame-editors/frame-tree/hooks.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
33
* License: MS-RSL – see LICENSE.md for details
44
*/
5-
import { React, redux } from "../../app-framework";
5+
import { redux } from "../../app-framework";
66
import { DEFAULT_FONT_SIZE } from "@cocalc/util/db-schema/defaults";
77

88
// this doesn't react to font size changes. maybe at some point we want to...
@@ -25,17 +25,10 @@ export function baseFontSize() {
2525
// transformOrigin: "center 0", // or "0 0"
2626
// }
2727
export function use_font_size_scaling(font_size: number): number {
28-
const [font_size_prev, set_font_size_prev] =
29-
React.useState<number>(DEFAULT_FONT_SIZE);
30-
const [scaling, set_scaling] = React.useState<number>(1);
31-
32-
if (font_size != font_size_prev) {
33-
set_font_size_prev(font_size);
34-
} else {
35-
return scaling;
36-
}
28+
return getScale(font_size);
29+
}
3730

31+
export function getScale(fontSize: number): number {
3832
const base = baseFontSize();
39-
set_scaling((font_size != null ? font_size : base) / base);
40-
return scaling;
33+
return (fontSize != null ? fontSize : base) / base;
4134
}

src/packages/frontend/frame-editors/markdown-editor/editor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const EDITOR_SPEC = {
3131
//"print",
3232
"decrease_font_size",
3333
"increase_font_size",
34+
"set_zoom",
3435
"save",
3536
"time_travel",
3637
"show_table_of_contents",
@@ -51,6 +52,7 @@ const EDITOR_SPEC = {
5152
"readonly_view",
5253
"decrease_font_size",
5354
"increase_font_size",
55+
"set_zoom",
5456
"sync",
5557
"show_table_of_contents",
5658
]),
@@ -105,6 +107,7 @@ const EDITOR_SPEC = {
105107
"print",
106108
"decrease_font_size",
107109
"increase_font_size",
110+
"set_zoom",
108111
"show_table_of_contents",
109112
"time_travel",
110113
"undo", // need these because button bars at top let you do something even in rendered only view.

src/packages/frontend/frame-editors/time-travel-editor/viewer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { HistoryViewer as JupyterHistoryViewer } from "../../jupyter/history-vie
1010
import { SagewsCodemirror } from "./sagews-codemirror";
1111
import Whiteboard from "@cocalc/frontend/frame-editors/whiteboard-editor/time-travel";
1212
import { isObjectDoc } from "./view-document";
13+
import { getScale } from "@cocalc/frontend/frame-editors/frame-tree/hooks";
1314

1415
export function Viewer({
1516
ext,
@@ -58,9 +59,13 @@ export function Viewer({
5859
case "sagews":
5960
return <SagewsCodemirror {...opts} />;
6061
case "md":
62+
const scale = getScale(font_size);
6163
return (
6264
<div style={{ overflow: "auto", padding: "50px 70px" }}>
63-
<StaticMarkdown value={doc.to_str()} />
65+
<StaticMarkdown
66+
value={doc.to_str()}
67+
style={{ fontSize: `${100 * scale}%` }}
68+
/>
6469
</div>
6570
);
6671
case "board":

0 commit comments

Comments
 (0)