@khanacademy/perseus-editor 2.9.1 → 2.11.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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus editors",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "2.9.1",
6
+ "version": "2.11.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -24,38 +24,40 @@
24
24
  "dependencies": {
25
25
  "@khanacademy/kas": "^0.3.5",
26
26
  "@khanacademy/kmath": "^0.1.6",
27
- "@khanacademy/perseus": "^13.1.0",
27
+ "@khanacademy/perseus": "^14.0.0",
28
28
  "@khanacademy/perseus-core": "1.3.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@khanacademy/wonder-blocks-button": "^4.1.3",
32
- "@khanacademy/wonder-blocks-clickable": "^4.0.0",
33
- "@khanacademy/wonder-blocks-color": "^2.0.1",
34
- "@khanacademy/wonder-blocks-core": "^6.0.0",
31
+ "@khanacademy/wonder-blocks-button": "^6.2.2",
32
+ "@khanacademy/wonder-blocks-clickable": "^4.0.11",
33
+ "@khanacademy/wonder-blocks-color": "^3.0.0",
34
+ "@khanacademy/wonder-blocks-core": "^6.3.0",
35
35
  "@khanacademy/wonder-blocks-i18n": "^2.0.2",
36
36
  "@khanacademy/wonder-blocks-spacing": "^4.0.1",
37
- "@khanacademy/wonder-blocks-typography": "^2.1.3",
37
+ "@khanacademy/wonder-blocks-typography": "^2.1.9",
38
38
  "@khanacademy/wonder-stuff-core": "^1.5.1",
39
+ "@phosphor-icons/core": "^2.0.2",
39
40
  "aphrodite": "^1.2.5",
40
41
  "classnames": "^1.1.4",
41
42
  "create-react-class": "^15.6.3",
42
43
  "jquery": "^2.1.1",
43
44
  "katex": "^0.11.1",
44
- "perseus-build-settings": "^0.2.1",
45
+ "perseus-build-settings": "^0.3.0",
45
46
  "prop-types": "^15.6.1",
46
47
  "react": "16.14.0",
47
48
  "react-dom": "16.14.0",
48
49
  "underscore": "^1.4.4"
49
50
  },
50
51
  "peerDependencies": {
51
- "@khanacademy/wonder-blocks-button": "^4.1.3",
52
- "@khanacademy/wonder-blocks-clickable": "^4.0.0",
53
- "@khanacademy/wonder-blocks-color": "^2.0.1",
54
- "@khanacademy/wonder-blocks-core": "^6.0.0",
52
+ "@khanacademy/wonder-blocks-button": "^6.2.2",
53
+ "@khanacademy/wonder-blocks-clickable": "^4.0.11",
54
+ "@khanacademy/wonder-blocks-color": "^3.0.0",
55
+ "@khanacademy/wonder-blocks-core": "^6.3.0",
55
56
  "@khanacademy/wonder-blocks-i18n": "^2.0.2",
56
57
  "@khanacademy/wonder-blocks-spacing": "^4.0.1",
57
- "@khanacademy/wonder-blocks-typography": "^2.1.3",
58
+ "@khanacademy/wonder-blocks-typography": "^2.1.9",
58
59
  "@khanacademy/wonder-stuff-core": "^1.5.1",
60
+ "@phosphor-icons/core": "^2.0.2",
59
61
  "aphrodite": "^1.2.5",
60
62
  "classnames": "^1.1.4",
61
63
  "create-react-class": "^15.6.3",
@@ -11,6 +11,8 @@ import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widge
11
11
 
12
12
  import type {PerseusRenderer} from "@khanacademy/perseus";
13
13
 
14
+ import "../styles/perseus-editor.less";
15
+
14
16
  registerAllWidgetsAndEditorsForTesting(); // SIDE_EFFECTY!!!! :cry:
15
17
 
16
18
  export default {
@@ -279,15 +279,6 @@
279
279
 
280
280
  // Question area styles
281
281
  #problemarea {
282
- /* Override the min-height property used for displaying the problem.
283
- While editing, the size of the editor itself is a better constraint on
284
- the size of the problemarea, and having a smaller problemarea is nicer
285
- if it means it aligns better with the editor. */
286
- min-height: 0;
287
-
288
- // Force the hint width to take up the width of its containing viewport.
289
- width: 100%;
290
-
291
282
  #workarea {
292
283
  margin: 0; // override ke
293
284
 
@@ -0,0 +1,56 @@
1
+ import {Dependencies} from "@khanacademy/perseus";
2
+ import {render, screen} from "@testing-library/react";
3
+ import * as React from "react";
4
+
5
+ import "@testing-library/jest-dom";
6
+
7
+ import {testDependencies} from "../../../../../testing/test-dependencies";
8
+ import ExpressionEditor from "../expression-editor";
9
+
10
+ import type {PropsFor} from "@khanacademy/wonder-blocks-core";
11
+
12
+ describe("expression-editor", () => {
13
+ beforeEach(() => {
14
+ jest.spyOn(Dependencies, "getDependencies").mockReturnValue(
15
+ testDependencies,
16
+ );
17
+ });
18
+
19
+ it("should render", async () => {
20
+ render(<ExpressionEditor onChange={() => undefined} />);
21
+
22
+ expect(await screen.findByText(/Add new answer/)).toBeInTheDocument();
23
+ });
24
+
25
+ it("should render answerForms missing a key", async () => {
26
+ const answerForms: PropsFor<typeof ExpressionEditor>["answerForms"] = [
27
+ {
28
+ value: "x\\cdot3=y",
29
+ form: true,
30
+ simplify: true,
31
+ considered: "correct",
32
+ },
33
+ {
34
+ value: "x^2=y",
35
+ form: true,
36
+ simplify: true,
37
+ considered: "wrong",
38
+ },
39
+ {
40
+ value: "x=y\\cdotπ",
41
+ form: true,
42
+ simplify: true,
43
+ considered: "wrong",
44
+ },
45
+ ];
46
+
47
+ render(
48
+ <ExpressionEditor
49
+ onChange={() => undefined}
50
+ answerForms={answerForms}
51
+ />,
52
+ );
53
+
54
+ expect(await screen.findByText(/π/)).toBeInTheDocument();
55
+ });
56
+ });
@@ -18,7 +18,6 @@ import SortableArea from "../components/sortable";
18
18
  import type {PerseusExpressionWidgetOptions} from "@khanacademy/perseus";
19
19
 
20
20
  const {InfoTip, PropCheckBox, TexButtons} = components;
21
- const {getDependencies} = Dependencies;
22
21
 
23
22
  type Props = {
24
23
  widgetId?: any;
@@ -38,11 +37,12 @@ type DefaultProps = {
38
37
  };
39
38
 
40
39
  const parseAnswerKey = ({key}: AnswerForm): number => {
41
- const parsedKey = Number.parseInt(key ?? "");
42
- if (Number.isNaN(parsedKey)) {
43
- throw new Error(`Invalid answer key: ${key}`);
44
- }
45
- return parsedKey;
40
+ // We don't throw here because there is data stored in some
41
+ // exercises/articles where the answer forms don't have a key. If we throw,
42
+ // it blocks content editors from loading the page at all.
43
+ // TODO(Jeremy): find a way to handle these answer forms that are missing
44
+ // keys more gracefully.
45
+ return Number.parseInt(key ?? "");
46
46
  };
47
47
 
48
48
  // Pick a key that isn't currently used by an answer in answerForms
@@ -182,7 +182,7 @@ class ExpressionEditor extends React.Component<Props, State> {
182
182
  },
183
183
  );
184
184
 
185
- const {TeX} = getDependencies(); // OldExpression only
185
+ const {TeX} = Dependencies.getDependencies(); // OldExpression only
186
186
 
187
187
  buttonSetChoices.splice(
188
188
  1,