@khanacademy/perseus 0.3.1 → 0.3.4
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 +22 -0
- package/dist/es/index.js +14 -17
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +14 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/highlighting/ui/util.js +2 -2
- package/src/interaction-tracker.js +2 -2
- package/src/item-renderer.jsx +1 -1
- package/src/mixins/provide-keypad.jsx +1 -1
- package/src/renderer.jsx +2 -2
- package/src/server-item-renderer.jsx +1 -1
- package/src/types.js +1 -1
- package/src/util/scroll-utils.js +2 -2
- package/src/widgets/definition.jsx +0 -3
- package/src/widgets/interactive-graph.jsx +4 -4
- package/src/widgets/label-image/answer-choices.jsx +1 -1
- package/src/widgets/label-image.jsx +1 -1
- package/src/widgets/molecule/molecule-drawing.jsx +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core Perseus API (includes renderers and widgets)",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.4",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@khanacademy/kmath": "^0.0.5",
|
|
25
25
|
"@khanacademy/kas": "^0.2.4",
|
|
26
|
-
"@khanacademy/math-input": "^0.5.
|
|
26
|
+
"@khanacademy/math-input": "^0.5.5",
|
|
27
27
|
"@khanacademy/perseus-linter": "^0.2.0",
|
|
28
28
|
"@khanacademy/pure-markdown": "^0.1.0",
|
|
29
29
|
"@khanacademy/simple-markdown": "^0.8.3",
|
|
@@ -73,7 +73,7 @@ export function getClientRectsForTextInRange(
|
|
|
73
73
|
function addClientRectsForTextInNodeAndRange(
|
|
74
74
|
node: Node,
|
|
75
75
|
range: DOMRange,
|
|
76
|
-
// eslint-disable-next-line
|
|
76
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
77
77
|
mutableRects: Array<Rect>,
|
|
78
78
|
): void {
|
|
79
79
|
const nodeContentsRange = new Range();
|
|
@@ -116,7 +116,7 @@ function addClientRectsForTextInNodeAndRange(
|
|
|
116
116
|
function addClientRectsForText(
|
|
117
117
|
textNode: Node,
|
|
118
118
|
textRange: DOMRange,
|
|
119
|
-
// eslint-disable-next-line
|
|
119
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
120
120
|
mutableRects: Array<Rect>,
|
|
121
121
|
): void {
|
|
122
122
|
const parentElement = textNode.parentElement;
|
|
@@ -12,13 +12,13 @@ class InteractionTracker {
|
|
|
12
12
|
_tracked: boolean;
|
|
13
13
|
setting: string;
|
|
14
14
|
track: (extraData?: any) => void;
|
|
15
|
-
// eslint-disable-next-line
|
|
15
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
16
16
|
trackApi: Function;
|
|
17
17
|
widgetID: string;
|
|
18
18
|
widgetType: string;
|
|
19
19
|
|
|
20
20
|
constructor(
|
|
21
|
-
// eslint-disable-next-line
|
|
21
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
22
22
|
trackApi: Function, // original apiOptions.trackInteraction
|
|
23
23
|
widgetType: string,
|
|
24
24
|
widgetID: string,
|
package/src/item-renderer.jsx
CHANGED
|
@@ -339,7 +339,7 @@ class ItemRenderer extends React.Component<Props, State> {
|
|
|
339
339
|
* the form "answer-input-number 1", or the string "answer-area"
|
|
340
340
|
* for the whole answer area (if the answer area is a single widget).
|
|
341
341
|
*/
|
|
342
|
-
// eslint-disable-next-line
|
|
342
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
343
343
|
_setWidgetProps(widgetId: string, newProps: any, callback: Function) {
|
|
344
344
|
this.questionRenderer._setWidgetProps(widgetId, newProps, callback);
|
|
345
345
|
}
|
package/src/renderer.jsx
CHANGED
|
@@ -143,7 +143,7 @@ export type Widget = {|
|
|
|
143
143
|
type Props = {|
|
|
144
144
|
apiOptions?: APIOptions,
|
|
145
145
|
alwaysUpdate?: boolean,
|
|
146
|
-
// eslint-disable-next-line
|
|
146
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
147
147
|
findExternalWidgets: Function,
|
|
148
148
|
highlightedWidgets?: $ReadOnlyArray<any>,
|
|
149
149
|
images: PerseusRenderer["images"],
|
|
@@ -214,7 +214,7 @@ class Renderer extends React.Component<Props, State> {
|
|
|
214
214
|
lastRenderedMarkdown: React.Element<PerseusDependencies["KatexProvider"]>;
|
|
215
215
|
reuseMarkdown: boolean;
|
|
216
216
|
translationIndex: number;
|
|
217
|
-
// eslint-disable-next-line
|
|
217
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
218
218
|
widgetIds: Array<string>;
|
|
219
219
|
|
|
220
220
|
static defaultProps: DefaultProps = {
|
|
@@ -222,7 +222,7 @@ export class ServerItemRenderer
|
|
|
222
222
|
* the form "answer-input-number 1", or the string "answer-area"
|
|
223
223
|
* for the whole answer area (if the answer area is a single widget).
|
|
224
224
|
*/
|
|
225
|
-
// eslint-disable-next-line
|
|
225
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
226
226
|
_setWidgetProps(widgetId: string, newProps: Props, callback: Function) {
|
|
227
227
|
this.questionRenderer._setWidgetProps(widgetId, newProps, callback);
|
|
228
228
|
}
|
package/src/types.js
CHANGED
|
@@ -316,7 +316,7 @@ export type DomInsertCheckFn = (
|
|
|
316
316
|
|
|
317
317
|
export type JIPT = {|
|
|
318
318
|
useJIPT: boolean,
|
|
319
|
-
// eslint-disable-next-line
|
|
319
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
320
320
|
domInsertChecks: Array<DomInsertCheckFn>,
|
|
321
321
|
|};
|
|
322
322
|
|
package/src/util/scroll-utils.js
CHANGED
|
@@ -42,7 +42,7 @@ const scrollElementToOffset = (
|
|
|
42
42
|
elementOrWindow: HTMLElement | WindowProxy,
|
|
43
43
|
offset: number,
|
|
44
44
|
duration: number = 0,
|
|
45
|
-
// eslint-disable-next-line
|
|
45
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
46
46
|
callback?: Function,
|
|
47
47
|
) => {
|
|
48
48
|
const startPosition =
|
|
@@ -110,7 +110,7 @@ const SCROLL_ANIMATION_DURATION = 750; // ms
|
|
|
110
110
|
*/
|
|
111
111
|
export const scrollElementIntoView = (
|
|
112
112
|
element: Element,
|
|
113
|
-
// eslint-disable-next-line
|
|
113
|
+
// eslint-disable-next-line ft-flow/no-weak-types
|
|
114
114
|
callback?: Function,
|
|
115
115
|
) => {
|
|
116
116
|
// Often times we scroll an element into with in reaction to some change in
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import Button from "@khanacademy/wonder-blocks-button";
|
|
4
4
|
import Color from "@khanacademy/wonder-blocks-color";
|
|
5
5
|
import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
|
|
6
|
-
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
7
6
|
import * as React from "react";
|
|
8
7
|
|
|
9
8
|
import Renderer from "../renderer.jsx";
|
|
@@ -88,11 +87,9 @@ class Definition extends React.Component<DefinitionProps> {
|
|
|
88
87
|
const styles = {
|
|
89
88
|
tooltipBody: {
|
|
90
89
|
color: Color.offBlack,
|
|
91
|
-
display: "block",
|
|
92
90
|
fontSize: 20,
|
|
93
91
|
fontWeight: 500,
|
|
94
92
|
lineHeight: "30px",
|
|
95
|
-
margin: Spacing.xSmall_8,
|
|
96
93
|
},
|
|
97
94
|
};
|
|
98
95
|
|
|
@@ -392,7 +392,7 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
392
392
|
pointA: ?$FlowFixMe;
|
|
393
393
|
pointB: ?$FlowFixMe;
|
|
394
394
|
pointC: ?$FlowFixMe;
|
|
395
|
-
// eslint-disable-next-line
|
|
395
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
396
396
|
points: Array<$FlowFixMe>;
|
|
397
397
|
polygon: ?$FlowFixMe;
|
|
398
398
|
shouldResetGraphie: boolean;
|
|
@@ -1356,7 +1356,7 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1356
1356
|
return true;
|
|
1357
1357
|
}
|
|
1358
1358
|
|
|
1359
|
-
// eslint-disable-next-line
|
|
1359
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
1360
1360
|
const coords: Array<Coord> = _.invoke(this.points, "coord");
|
|
1361
1361
|
coords[i] = coord;
|
|
1362
1362
|
|
|
@@ -2686,10 +2686,10 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2686
2686
|
rubric.correct.type === "polygon" &&
|
|
2687
2687
|
state.coords != null
|
|
2688
2688
|
) {
|
|
2689
|
-
const guess: Array<Coord> = state.coords?.slice(); // eslint-disable-line
|
|
2689
|
+
const guess: Array<Coord> = state.coords?.slice(); // eslint-disable-line ft-flow/no-mutable-array
|
|
2690
2690
|
// $FlowFixMe[incompatible-type]
|
|
2691
2691
|
// $FlowFixMe[prop-missing]
|
|
2692
|
-
const correct: Array<Coord> = rubric.correct.coords?.slice(); // eslint-disable-line
|
|
2692
|
+
const correct: Array<Coord> = rubric.correct.coords?.slice(); // eslint-disable-line ft-flow/no-mutable-array
|
|
2693
2693
|
|
|
2694
2694
|
let match;
|
|
2695
2695
|
if (rubric.correct.match === "similar") {
|
|
@@ -185,7 +185,7 @@ export default class AnswerChoices extends React.Component<
|
|
|
185
185
|
AnswerChoicesState,
|
|
186
186
|
> {
|
|
187
187
|
// The rendered answers elements.
|
|
188
|
-
// eslint-disable-next-line
|
|
188
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
189
189
|
_choices: Array<?AnswerChoice>;
|
|
190
190
|
|
|
191
191
|
constructor(props: AnswerChoicesProps) {
|
|
@@ -85,7 +85,7 @@ type LabelImageState = {|
|
|
|
85
85
|
|
|
86
86
|
class LabelImage extends React.Component<LabelImageProps, LabelImageState> {
|
|
87
87
|
// The rendered markers on the question image for labeling.
|
|
88
|
-
// eslint-disable-next-line
|
|
88
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
89
89
|
_markers: Array<?Marker>;
|
|
90
90
|
|
|
91
91
|
// The popup component containing the answer choices.
|
|
@@ -159,7 +159,7 @@ function compareElements(item0, item1) {
|
|
|
159
159
|
/**
|
|
160
160
|
* Draw an array of rendering instructions into a 2D canvas drawing context.
|
|
161
161
|
*/
|
|
162
|
-
// eslint-disable-next-line
|
|
162
|
+
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
163
163
|
function draw(ctx: $FlowFixMe, items: Array<$FlowFixMe>) {
|
|
164
164
|
items.sort(compareElements).forEach(drawItem(ctx));
|
|
165
165
|
}
|