@khanacademy/perseus 5.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/components/fixed-to-responsive.d.ts +27 -1
- package/dist/components/fixed-to-responsive.js.flow +27 -1
- package/dist/components/graph.d.ts +42 -26
- package/dist/components/graph.js.flow +42 -28
- package/dist/components/graphie.d.ts +34 -22
- package/dist/components/graphie.js.flow +37 -24
- package/dist/components/hud.d.ts +8 -14
- package/dist/components/hud.js.flow +7 -14
- package/dist/components/inline-icon.d.ts +9 -19
- package/dist/components/inline-icon.js.flow +26 -13
- package/dist/components/lint.d.ts +41 -13
- package/dist/components/lint.js.flow +42 -13
- package/dist/components/math-output.d.ts +15 -11
- package/dist/components/math-output.js.flow +15 -11
- package/dist/components/sortable.d.ts +17 -9
- package/dist/components/sortable.js.flow +22 -9
- package/dist/components/svg-image.d.ts +5 -3
- package/dist/components/svg-image.js.flow +5 -3
- package/dist/components/tooltip.d.ts +45 -4
- package/dist/components/tooltip.js.flow +44 -31
- package/dist/es/index.css +0 -3
- package/dist/es/index.js +478 -649
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +0 -3
- package/dist/index.js +482 -646
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +11 -9
- package/dist/perseus-types.js.flow +11 -9
- package/dist/renderer.d.ts +2 -2
- package/dist/renderer.js.flow +1 -3
- package/dist/styles/shared.d.ts +0 -1
- package/dist/styles/shared.js.flow +0 -1
- package/dist/types.d.ts +0 -10
- package/dist/types.js.flow +0 -13
- package/dist/util/a11y.d.ts +0 -1
- package/dist/util/a11y.js.flow +0 -1
- package/dist/util/interactive.d.ts +2 -0
- package/dist/util/interactive.js.flow +2 -0
- package/dist/util.d.ts +3 -3
- package/dist/util.js.flow +4 -3
- package/dist/widgets/grapher.d.ts +1 -1
- package/dist/widgets/grapher.js.flow +12 -3
- package/dist/widgets/matcher.d.ts +7 -3
- package/dist/widgets/matcher.js.flow +7 -3
- package/dist/widgets/number-line.d.ts +1 -1
- package/dist/widgets/number-line.js.flow +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/item-renderer.test.tsx.snap +151 -159
- package/src/__tests__/__snapshots__/renderer.test.tsx.snap +358 -394
- package/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap +169 -189
- package/src/components/__stories__/lint.stories.tsx +56 -21
- package/src/components/__stories__/sortable.stories.tsx +5 -5
- package/src/components/__stories__/tooltip.stories.tsx +52 -0
- package/src/components/__tests__/__snapshots__/sortable.test.tsx.snap +114 -30
- package/src/components/__tests__/__snapshots__/sorter.test.tsx.snap +172 -204
- package/src/components/__tests__/sortable.test.tsx +54 -16
- package/src/components/__tests__/sorter.test.tsx +12 -9
- package/src/components/fixed-to-responsive.tsx +43 -38
- package/src/components/graph.tsx +95 -81
- package/src/components/graphie.tsx +62 -32
- package/src/components/hud.tsx +104 -115
- package/src/components/inline-icon.tsx +15 -32
- package/src/components/input-with-examples.tsx +4 -4
- package/src/components/lint.tsx +47 -41
- package/src/components/math-output.tsx +17 -11
- package/src/components/simple-keypad-input.tsx +2 -2
- package/src/components/sortable.tsx +134 -94
- package/src/components/svg-image.tsx +10 -11
- package/src/components/tooltip.tsx +189 -171
- package/src/interactive2/types.ts +2 -2
- package/src/mixins/provide-keypad.tsx +2 -2
- package/src/multi-items/__tests__/__snapshots__/multi-renderer.test.tsx.snap +708 -764
- package/src/perseus-types.ts +13 -9
- package/src/renderer.tsx +11 -22
- package/src/types.ts +0 -18
- package/src/util/interactive.ts +18 -5
- package/src/util/tex.ts +13 -77
- package/src/util.ts +3 -4
- package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +2 -2
- package/src/widgets/__tests__/__snapshots__/categorizer.test.ts.snap +717 -773
- package/src/widgets/__tests__/__snapshots__/cs-program.test.ts.snap +28 -36
- package/src/widgets/__tests__/__snapshots__/definition.test.ts.snap +52 -60
- package/src/widgets/__tests__/__snapshots__/dropdown.test.ts.snap +100 -108
- package/src/widgets/__tests__/__snapshots__/explanation.test.ts.snap +212 -260
- package/src/widgets/__tests__/__snapshots__/graded-group-set-jipt.test.ts.snap +613 -641
- package/src/widgets/__tests__/__snapshots__/graded-group-set.test.ts.snap +249 -261
- package/src/widgets/__tests__/__snapshots__/graded-group.test.ts.snap +671 -735
- package/src/widgets/__tests__/__snapshots__/grapher.test.ts.snap +2676 -2684
- package/src/widgets/__tests__/__snapshots__/group.test.tsx.snap +938 -1002
- package/src/widgets/__tests__/__snapshots__/iframe.test.ts.snap +28 -36
- package/src/widgets/__tests__/__snapshots__/image.test.ts.snap +227 -255
- package/src/widgets/__tests__/__snapshots__/input-number.test.ts.snap +353 -357
- package/src/widgets/__tests__/__snapshots__/interaction.test.ts.snap +255 -259
- package/src/widgets/__tests__/__snapshots__/interactive-graph.test.ts.snap +2401 -2433
- package/src/widgets/__tests__/__snapshots__/matcher.test.tsx.snap +600 -756
- package/src/widgets/__tests__/__snapshots__/matrix.test.ts.snap +420 -428
- package/src/widgets/__tests__/__snapshots__/number-line.test.ts.snap +762 -770
- package/src/widgets/__tests__/__snapshots__/numeric-input.test.ts.snap +373 -393
- package/src/widgets/__tests__/__snapshots__/orderer.test.ts.snap +116 -148
- package/src/widgets/__tests__/__snapshots__/passage-ref.test.ts.snap +289 -301
- package/src/widgets/__tests__/__snapshots__/passage.test.tsx.snap +1679 -1711
- package/src/widgets/__tests__/__snapshots__/radio.test.ts.snap +2692 -2960
- package/src/widgets/__tests__/__snapshots__/video.test.ts.snap +90 -98
- package/src/widgets/__tests__/matcher.test.tsx +33 -9
- package/src/widgets/expression.tsx +9 -6
- package/src/widgets/grapher.tsx +3 -3
- package/src/widgets/image.tsx +2 -2
- package/src/widgets/interactive-graph.tsx +5 -5
- package/src/widgets/matcher.tsx +43 -24
- package/src/widgets/number-line.tsx +1 -1
- package/src/widgets/simulator.tsx +4 -6
- package/{tsconfig.json → tsconfig-build.json} +6 -6
- package/tsconfig-build.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +0 -1
package/src/components/hud.tsx
CHANGED
|
@@ -1,127 +1,116 @@
|
|
|
1
1
|
import {StyleSheet, css} from "aphrodite";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
4
|
import * as constants from "../styles/constants";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// Displays a stylized open eye: lint warnings are visible
|
|
7
|
+
const VisibleIcon = () => (
|
|
8
|
+
<svg
|
|
9
|
+
width="24"
|
|
10
|
+
height="24"
|
|
11
|
+
viewBox="0 0 24 24"
|
|
12
|
+
className={css(styles.icon)}
|
|
13
|
+
>
|
|
14
|
+
<defs>
|
|
15
|
+
<path
|
|
16
|
+
id="a"
|
|
17
|
+
d={
|
|
18
|
+
"M7.401 10.035c-1.424.748-2.599 1.905-3.544 " +
|
|
19
|
+
"3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 " +
|
|
20
|
+
"12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 " +
|
|
21
|
+
"1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-" +
|
|
22
|
+
"3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 " +
|
|
23
|
+
"0 0 0 0 6z"
|
|
24
|
+
}
|
|
25
|
+
/>
|
|
26
|
+
</defs>
|
|
27
|
+
<g fill="none" fillRule="evenodd">
|
|
28
|
+
<path fill="none" d="M0 0h24v24H0z" />
|
|
29
|
+
<mask id="b" fill="#fff">
|
|
30
|
+
<use href="#a" />
|
|
31
|
+
</mask>
|
|
32
|
+
<use fill="#fff" fillRule="nonzero" href="#a" />
|
|
33
|
+
<g fill="#fff" mask="url(#b)">
|
|
34
|
+
<path d="M0 0h24v24H0z" />
|
|
35
|
+
</g>
|
|
36
|
+
</g>
|
|
37
|
+
</svg>
|
|
38
|
+
);
|
|
14
39
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
40
|
+
// Displays a stylized eye with a line through it: I don't want to see lint
|
|
41
|
+
const HiddenIcon = () => (
|
|
42
|
+
<svg
|
|
43
|
+
width="24"
|
|
44
|
+
height="24"
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
className={css(styles.icon)}
|
|
47
|
+
>
|
|
48
|
+
<defs>
|
|
49
|
+
<path
|
|
50
|
+
id="a"
|
|
51
|
+
d={
|
|
52
|
+
"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 " +
|
|
53
|
+
"7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 " +
|
|
54
|
+
"1.028c-.945-1.574-2.12-2.73-3.544-3.48.258." +
|
|
55
|
+
"604.401 1.268.401 1.966 0 1.02-.305 " +
|
|
56
|
+
"1.967-.828 2.757l2.535 2.536a1 1 0 0 " +
|
|
57
|
+
"1-1.414 1.414l-12-12a1 1 0 0 1 " +
|
|
58
|
+
"1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 " +
|
|
59
|
+
"0-4.001-4.001l4 4.001zM6.072 8.486l2.976 " +
|
|
60
|
+
"2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 " +
|
|
61
|
+
"0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 " +
|
|
62
|
+
"3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 " +
|
|
63
|
+
"2.363-3.085 3.929-4z"
|
|
64
|
+
}
|
|
65
|
+
/>
|
|
66
|
+
</defs>
|
|
67
|
+
<g fill="none" fillRule="evenodd">
|
|
68
|
+
<path fill="none" d="M0 0h24v24H0z" />
|
|
69
|
+
<mask id="b" fill="#fff">
|
|
70
|
+
<use href="#a" />
|
|
71
|
+
</mask>
|
|
72
|
+
<use fill="#fff" fillRule="nonzero" href="#a" />
|
|
73
|
+
<g fill="#fff" mask="url(#b)">
|
|
74
|
+
<path d="M0 0h24v24H0z" />
|
|
75
|
+
</g>
|
|
76
|
+
</g>
|
|
77
|
+
</svg>
|
|
78
|
+
);
|
|
18
79
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
viewBox="0 0 24 24"
|
|
26
|
-
className={css(styles.icon)}
|
|
27
|
-
>
|
|
28
|
-
<defs>
|
|
29
|
-
<path
|
|
30
|
-
id="a"
|
|
31
|
-
d={
|
|
32
|
-
"M7.401 10.035c-1.424.748-2.599 1.905-3.544 " +
|
|
33
|
-
"3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 " +
|
|
34
|
-
"12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 " +
|
|
35
|
-
"1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-" +
|
|
36
|
-
"3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 " +
|
|
37
|
-
"0 0 0 0 6z"
|
|
38
|
-
}
|
|
39
|
-
/>
|
|
40
|
-
</defs>
|
|
41
|
-
<g fill="none" fillRule="evenodd">
|
|
42
|
-
<path fill="none" d="M0 0h24v24H0z" />
|
|
43
|
-
<mask id="b" fill="#fff">
|
|
44
|
-
<use href="#a" />
|
|
45
|
-
</mask>
|
|
46
|
-
<use fill="#fff" fillRule="nonzero" href="#a" />
|
|
47
|
-
<g fill="#fff" mask="url(#b)">
|
|
48
|
-
<path d="M0 0h24v24H0z" />
|
|
49
|
-
</g>
|
|
50
|
-
</g>
|
|
51
|
-
</svg>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
80
|
+
type Props = {
|
|
81
|
+
message: string;
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
onClick: () => void;
|
|
84
|
+
fixedPosition?: boolean;
|
|
85
|
+
};
|
|
54
86
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<defs>
|
|
65
|
-
<path
|
|
66
|
-
id="a"
|
|
67
|
-
d={
|
|
68
|
-
"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 " +
|
|
69
|
-
"7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 " +
|
|
70
|
-
"1.028c-.945-1.574-2.12-2.73-3.544-3.48.258." +
|
|
71
|
-
"604.401 1.268.401 1.966 0 1.02-.305 " +
|
|
72
|
-
"1.967-.828 2.757l2.535 2.536a1 1 0 0 " +
|
|
73
|
-
"1-1.414 1.414l-12-12a1 1 0 0 1 " +
|
|
74
|
-
"1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 " +
|
|
75
|
-
"0-4.001-4.001l4 4.001zM6.072 8.486l2.976 " +
|
|
76
|
-
"2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 " +
|
|
77
|
-
"0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 " +
|
|
78
|
-
"3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 " +
|
|
79
|
-
"2.363-3.085 3.929-4z"
|
|
80
|
-
}
|
|
81
|
-
/>
|
|
82
|
-
</defs>
|
|
83
|
-
<g fill="none" fillRule="evenodd">
|
|
84
|
-
<path fill="none" d="M0 0h24v24H0z" />
|
|
85
|
-
<mask id="b" fill="#fff">
|
|
86
|
-
<use href="#a" />
|
|
87
|
-
</mask>
|
|
88
|
-
<use fill="#fff" fillRule="nonzero" href="#a" />
|
|
89
|
-
<g fill="#fff" mask="url(#b)">
|
|
90
|
-
<path d="M0 0h24v24H0z" />
|
|
91
|
-
</g>
|
|
92
|
-
</g>
|
|
93
|
-
</svg>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
render(): React.ReactNode {
|
|
98
|
-
let state;
|
|
99
|
-
let icon;
|
|
100
|
-
if (this.props.enabled) {
|
|
101
|
-
state = styles.enabled;
|
|
102
|
-
icon = this.renderVisibleIcon();
|
|
103
|
-
} else {
|
|
104
|
-
state = styles.disabled;
|
|
105
|
-
icon = this.renderHiddenIcon();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<button
|
|
110
|
-
className={css(
|
|
111
|
-
styles.hud,
|
|
112
|
-
this.props.fixedPosition && styles.hudFixedPosition,
|
|
113
|
-
state,
|
|
114
|
-
)}
|
|
115
|
-
onClick={(e) => {
|
|
116
|
-
this.props.onClick();
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
{icon}
|
|
120
|
-
{this.props.message}
|
|
121
|
-
</button>
|
|
122
|
-
);
|
|
87
|
+
const HUD = ({message, enabled, onClick, fixedPosition = true}: Props) => {
|
|
88
|
+
let state;
|
|
89
|
+
let icon;
|
|
90
|
+
if (enabled) {
|
|
91
|
+
state = styles.enabled;
|
|
92
|
+
icon = <VisibleIcon />;
|
|
93
|
+
} else {
|
|
94
|
+
state = styles.disabled;
|
|
95
|
+
icon = <HiddenIcon />;
|
|
123
96
|
}
|
|
124
|
-
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<button
|
|
100
|
+
className={css(
|
|
101
|
+
styles.hud,
|
|
102
|
+
fixedPosition && styles.hudFixedPosition,
|
|
103
|
+
state,
|
|
104
|
+
)}
|
|
105
|
+
onClick={(e) => {
|
|
106
|
+
onClick();
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{icon}
|
|
110
|
+
{message}
|
|
111
|
+
</button>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
125
114
|
|
|
126
115
|
const styles = StyleSheet.create({
|
|
127
116
|
hud: {
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
type InlineIconProps = {
|
|
4
|
+
// An SVG path to render.
|
|
5
|
+
path: string;
|
|
6
|
+
// The path's viewBox dimensions.
|
|
7
|
+
// We set the viewport height to 1em and scale the width accordingly.
|
|
8
|
+
height: number;
|
|
9
|
+
width: number;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
// A11y description for this icon. If absent, icon is marked
|
|
12
|
+
// aria-hidden=true
|
|
13
|
+
title?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
2
16
|
/**
|
|
3
17
|
* A stripped version of Icon.jsx from webapp. Takes an SVG icon and renders it
|
|
4
18
|
* inline like Font Awesome did.
|
|
@@ -23,9 +37,6 @@
|
|
|
23
37
|
* <InlineIcon {...editIcon} />
|
|
24
38
|
*
|
|
25
39
|
*/
|
|
26
|
-
import PropTypes from "prop-types";
|
|
27
|
-
import * as React from "react";
|
|
28
|
-
|
|
29
40
|
const InlineIcon = ({
|
|
30
41
|
path,
|
|
31
42
|
width,
|
|
@@ -46,32 +57,4 @@ const InlineIcon = ({
|
|
|
46
57
|
</svg>
|
|
47
58
|
);
|
|
48
59
|
|
|
49
|
-
InlineIcon.propTypes = {
|
|
50
|
-
// An SVG path to render.
|
|
51
|
-
path: PropTypes.string.isRequired,
|
|
52
|
-
|
|
53
|
-
// The path's viewBox dimensions.
|
|
54
|
-
// We set the viewport height to 1em and scale the width accordingly.
|
|
55
|
-
height: PropTypes.number.isRequired,
|
|
56
|
-
width: PropTypes.number.isRequired,
|
|
57
|
-
|
|
58
|
-
style: PropTypes.object,
|
|
59
|
-
|
|
60
|
-
// A11y description for this icon. If absent, icon is marked
|
|
61
|
-
// aria-hidden=true
|
|
62
|
-
title: PropTypes.string,
|
|
63
|
-
};
|
|
64
|
-
export type InlineIconProps = {
|
|
65
|
-
// An SVG path to render.
|
|
66
|
-
path: string;
|
|
67
|
-
// The path's viewBox dimensions.
|
|
68
|
-
// We set the viewport height to 1em and scale the width accordingly.
|
|
69
|
-
height: number;
|
|
70
|
-
width: number;
|
|
71
|
-
style?: any;
|
|
72
|
-
// A11y description for this icon. If absent, icon is marked
|
|
73
|
-
// aria-hidden=true
|
|
74
|
-
title?: string;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
60
|
export default InlineIcon;
|
|
@@ -10,7 +10,7 @@ import Util from "../util";
|
|
|
10
10
|
import MathInput from "./math-input";
|
|
11
11
|
import MathOutput from "./math-output";
|
|
12
12
|
import TextInput from "./text-input";
|
|
13
|
-
import Tooltip from "./tooltip";
|
|
13
|
+
import Tooltip, {HorizontalDirection, VerticalDirection} from "./tooltip";
|
|
14
14
|
|
|
15
15
|
import type {LinterContextProps} from "../types";
|
|
16
16
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
@@ -184,9 +184,9 @@ class InputWithExamples extends React.Component<Props, State> {
|
|
|
184
184
|
// eslint-disable-next-line react/no-string-refs
|
|
185
185
|
ref="tooltip"
|
|
186
186
|
className="perseus-formats-tooltip preview-measure"
|
|
187
|
-
horizontalPosition=
|
|
188
|
-
horizontalAlign=
|
|
189
|
-
verticalPosition=
|
|
187
|
+
horizontalPosition={HorizontalDirection.Left}
|
|
188
|
+
horizontalAlign={HorizontalDirection.Left}
|
|
189
|
+
verticalPosition={VerticalDirection.Bottom}
|
|
190
190
|
arrowSize={10}
|
|
191
191
|
borderColor="#ccc"
|
|
192
192
|
show={showExamples}
|
package/src/components/lint.tsx
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
import {StyleSheet, css} from "aphrodite";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
|
|
5
|
+
import * as constants from "../styles/constants";
|
|
6
|
+
|
|
7
|
+
import InlineIcon from "./inline-icon";
|
|
8
|
+
|
|
9
|
+
const exclamationIcon = {
|
|
10
|
+
path: "M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",
|
|
11
|
+
height: 12,
|
|
12
|
+
width: 12,
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
enum Severity {
|
|
16
|
+
Error = 1,
|
|
17
|
+
Warning = 2,
|
|
18
|
+
Recommendation = 3,
|
|
19
|
+
OfflineReportingOnly = 4,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Props = {
|
|
23
|
+
// The children are the linty content we're highlighting
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
// Inline lint is highlighted differently than block lint.
|
|
26
|
+
inline?: boolean;
|
|
27
|
+
// This is the text that appears in the tooltip
|
|
28
|
+
message: string;
|
|
29
|
+
// This is used as the fragment id (hash) in the URL of the link
|
|
30
|
+
ruleName: string;
|
|
31
|
+
// Lint warnings inside tables are handled specially
|
|
32
|
+
insideTable: boolean;
|
|
33
|
+
// Should lint highlighting be rendered as a block to the left of
|
|
34
|
+
// the lint instead of on the right gutter?
|
|
35
|
+
blockHighlight?: boolean;
|
|
36
|
+
// How important this lint message is for the editor. Severity goes
|
|
37
|
+
// from 1 (indicating an error) to 4 (offline reporting only)
|
|
38
|
+
severity?: Severity;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type State = {
|
|
42
|
+
tooltipAbove: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
1
45
|
/**
|
|
2
46
|
* This component renders "lint" nodes in a markdown parse tree. Lint nodes
|
|
3
47
|
* are inserted into the tree by the Perseus linter (see
|
|
@@ -20,45 +64,8 @@
|
|
|
20
64
|
* that has a right margin (like anything blockquoted) the circle will appear
|
|
21
65
|
* to the left of where it belongs. And if there is more
|
|
22
66
|
**/
|
|
23
|
-
import {StyleSheet, css} from "aphrodite";
|
|
24
|
-
import PropTypes from "prop-types";
|
|
25
|
-
import * as React from "react";
|
|
26
|
-
import ReactDOM from "react-dom";
|
|
27
|
-
|
|
28
|
-
import * as constants from "../styles/constants";
|
|
29
|
-
|
|
30
|
-
import InlineIcon from "./inline-icon";
|
|
31
|
-
|
|
32
|
-
const exclamationIcon = {
|
|
33
|
-
path: "M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",
|
|
34
|
-
height: 12,
|
|
35
|
-
width: 12,
|
|
36
|
-
} as const;
|
|
37
|
-
|
|
38
|
-
type Props = any;
|
|
39
|
-
type State = any;
|
|
40
|
-
|
|
41
67
|
class Lint extends React.Component<Props, State> {
|
|
42
|
-
_positionTimeout: number |
|
|
43
|
-
|
|
44
|
-
static propTypes = {
|
|
45
|
-
// The children are the linty content we're highlighting
|
|
46
|
-
children: PropTypes.node,
|
|
47
|
-
// Inline lint is highlighted differently than block lint.
|
|
48
|
-
inline: PropTypes.bool,
|
|
49
|
-
// This is the text that appears in the tooltip
|
|
50
|
-
message: PropTypes.string.isRequired,
|
|
51
|
-
// This is used as the fragment id (hash) in the URL of the link
|
|
52
|
-
ruleName: PropTypes.string.isRequired,
|
|
53
|
-
// Lint warnings inside tables are handled specially
|
|
54
|
-
insideTable: PropTypes.bool.isRequired,
|
|
55
|
-
// Should lint highlighting be rendered as a block to the left of
|
|
56
|
-
// the lint instead of on the right gutter?
|
|
57
|
-
blockHighlight: PropTypes.bool,
|
|
58
|
-
// How important this lint message is for the editor. Severity goes
|
|
59
|
-
// from 1 (indicating an error) to 4 (offline reporting only)
|
|
60
|
-
severity: PropTypes.number,
|
|
61
|
-
};
|
|
68
|
+
_positionTimeout: number | undefined;
|
|
62
69
|
|
|
63
70
|
state: State = {
|
|
64
71
|
tooltipAbove: true,
|
|
@@ -73,7 +80,6 @@ class Lint extends React.Component<Props, State> {
|
|
|
73
80
|
componentWillUnmount() {
|
|
74
81
|
// TODO(somewhatabstract): Use WB timing
|
|
75
82
|
// eslint-disable-next-line no-restricted-syntax
|
|
76
|
-
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
77
83
|
window.clearTimeout(this._positionTimeout);
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -98,11 +104,11 @@ class Lint extends React.Component<Props, State> {
|
|
|
98
104
|
let severityStyle;
|
|
99
105
|
let warningText;
|
|
100
106
|
let warningTextStyle;
|
|
101
|
-
if (this.props.severity ===
|
|
107
|
+
if (this.props.severity === Severity.Error) {
|
|
102
108
|
severityStyle = styles.indicatorError;
|
|
103
109
|
warningText = "Error";
|
|
104
110
|
warningTextStyle = styles.publishBlockingError;
|
|
105
|
-
} else if (this.props.severity ===
|
|
111
|
+
} else if (this.props.severity === Severity.Warning) {
|
|
106
112
|
severityStyle = styles.indicatorWarning;
|
|
107
113
|
warningText = "Warning";
|
|
108
114
|
warningTextStyle = styles.warning;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
2
|
import $ from "jquery";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import ReactDOM from "react-dom";
|
|
6
5
|
import _ from "underscore";
|
|
@@ -11,22 +10,29 @@ import TexWrangler from "../tex-wrangler";
|
|
|
11
10
|
|
|
12
11
|
const ModifyTex = TexWrangler.modifyTex;
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
type Props = {
|
|
14
|
+
value: string | number;
|
|
15
|
+
className?: string;
|
|
16
|
+
labelText?: string;
|
|
17
|
+
onFocus: () => void;
|
|
18
|
+
onBlur: () => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type DefaultProps = Pick<Props, "value" | "onFocus" | "onBlur">;
|
|
22
|
+
|
|
23
|
+
type State = {
|
|
24
|
+
focused: boolean;
|
|
25
|
+
selectorNamespace: string;
|
|
26
|
+
};
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
class MathOutput extends React.Component<Props, State> {
|
|
29
|
+
static defaultProps: DefaultProps = {
|
|
24
30
|
value: "",
|
|
25
31
|
onFocus: function () {},
|
|
26
32
|
onBlur: function () {},
|
|
27
33
|
};
|
|
28
34
|
|
|
29
|
-
state:
|
|
35
|
+
state: State = {
|
|
30
36
|
focused: false,
|
|
31
37
|
selectorNamespace: _.uniqueId("math-output"),
|
|
32
38
|
};
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
KeypadInput,
|
|
13
|
-
|
|
13
|
+
KeypadType,
|
|
14
14
|
keypadElementPropType,
|
|
15
15
|
} from "@khanacademy/math-input";
|
|
16
16
|
import PropTypes from "prop-types";
|
|
@@ -61,7 +61,7 @@ export default class SimpleKeypadInput extends React.Component<any> {
|
|
|
61
61
|
if (keypadElement) {
|
|
62
62
|
keypadElement.configure(
|
|
63
63
|
{
|
|
64
|
-
keypadType:
|
|
64
|
+
keypadType: KeypadType.FRACTION,
|
|
65
65
|
},
|
|
66
66
|
() => {
|
|
67
67
|
if (_this._isMounted) {
|