File tree Expand file tree Collapse file tree 3 files changed +14
-13
lines changed
src/packages/frontend/frame-editors Expand file tree Collapse file tree 3 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 2
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
3
* License: MS-RSL – see LICENSE.md for details
4
4
*/
5
- import { React , redux } from "../../app-framework" ;
5
+ import { redux } from "../../app-framework" ;
6
6
import { DEFAULT_FONT_SIZE } from "@cocalc/util/db-schema/defaults" ;
7
7
8
8
// this doesn't react to font size changes. maybe at some point we want to...
@@ -25,17 +25,10 @@ export function baseFontSize() {
25
25
// transformOrigin: "center 0", // or "0 0"
26
26
// }
27
27
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
+ }
37
30
31
+ export function getScale ( fontSize : number ) : number {
38
32
const base = baseFontSize ( ) ;
39
- set_scaling ( ( font_size != null ? font_size : base ) / base ) ;
40
- return scaling ;
33
+ return ( fontSize != null ? fontSize : base ) / base ;
41
34
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ const EDITOR_SPEC = {
31
31
//"print",
32
32
"decrease_font_size" ,
33
33
"increase_font_size" ,
34
+ "set_zoom" ,
34
35
"save" ,
35
36
"time_travel" ,
36
37
"show_table_of_contents" ,
@@ -51,6 +52,7 @@ const EDITOR_SPEC = {
51
52
"readonly_view" ,
52
53
"decrease_font_size" ,
53
54
"increase_font_size" ,
55
+ "set_zoom" ,
54
56
"sync" ,
55
57
"show_table_of_contents" ,
56
58
] ) ,
@@ -105,6 +107,7 @@ const EDITOR_SPEC = {
105
107
"print" ,
106
108
"decrease_font_size" ,
107
109
"increase_font_size" ,
110
+ "set_zoom" ,
108
111
"show_table_of_contents" ,
109
112
"time_travel" ,
110
113
"undo" , // need these because button bars at top let you do something even in rendered only view.
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { HistoryViewer as JupyterHistoryViewer } from "../../jupyter/history-vie
10
10
import { SagewsCodemirror } from "./sagews-codemirror" ;
11
11
import Whiteboard from "@cocalc/frontend/frame-editors/whiteboard-editor/time-travel" ;
12
12
import { isObjectDoc } from "./view-document" ;
13
+ import { getScale } from "@cocalc/frontend/frame-editors/frame-tree/hooks" ;
13
14
14
15
export function Viewer ( {
15
16
ext,
@@ -58,9 +59,13 @@ export function Viewer({
58
59
case "sagews" :
59
60
return < SagewsCodemirror { ...opts } /> ;
60
61
case "md" :
62
+ const scale = getScale ( font_size ) ;
61
63
return (
62
64
< 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
+ />
64
69
</ div >
65
70
) ;
66
71
case "board" :
You can’t perform that action at this time.
0 commit comments