@khanacademy/perseus 0.2.5 → 0.2.8

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.
Files changed (87) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +5 -0
  3. package/dist/es/index.js +3094 -5319
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.js +13596 -15827
  6. package/dist/index.js.map +1 -1
  7. package/package.json +16 -12
  8. package/src/__tests__/jipt-paragraphs_test.js +34 -0
  9. package/src/__tests__/perseus-markdown_test.jsx +4 -4
  10. package/src/article-renderer.jsx +3 -4
  11. package/src/components/input-with-examples.jsx +3 -4
  12. package/src/components/sortable.jsx +4 -5
  13. package/src/hint-renderer.jsx +2 -3
  14. package/src/hints-renderer.jsx +2 -3
  15. package/src/item-renderer.jsx +2 -3
  16. package/src/jipt-paragraphs.js +16 -8
  17. package/src/not-gorgon.js +1 -2
  18. package/src/perseus-markdown.jsx +1 -2
  19. package/src/renderer.jsx +2 -3
  20. package/src/widget-container.jsx +1 -1
  21. package/src/widgets/categorizer.jsx +1 -1
  22. package/src/widgets/dropdown.jsx +29 -31
  23. package/src/widgets/explanation.jsx +1 -1
  24. package/src/widgets/expression.jsx +1 -1
  25. package/src/widgets/graded-group-set.jsx +1 -1
  26. package/src/widgets/graded-group.jsx +1 -1
  27. package/src/widgets/group.jsx +1 -1
  28. package/src/widgets/image.jsx +1 -1
  29. package/src/widgets/input-number.jsx +1 -1
  30. package/src/widgets/matcher.jsx +4 -1
  31. package/src/widgets/matrix.jsx +1 -1
  32. package/src/widgets/numeric-input.jsx +1 -1
  33. package/src/widgets/orderer.jsx +4 -1
  34. package/src/widgets/passage-ref-target.jsx +4 -1
  35. package/src/widgets/passage.jsx +1 -1
  36. package/src/widgets/radio/widget.jsx +1 -1
  37. package/src/widgets/sequence.jsx +4 -1
  38. package/src/widgets/sorter.jsx +4 -1
  39. package/src/widgets/table.jsx +4 -1
  40. package/src/README.md +0 -35
  41. package/src/__tests__/__snapshots__/pure-markdown_test.js.snap +0 -113
  42. package/src/__tests__/pure-markdown_test.js +0 -552
  43. package/src/gorgon/README +0 -40
  44. package/src/gorgon/__tests__/matcher_test.js +0 -497
  45. package/src/gorgon/__tests__/rule_test.js +0 -101
  46. package/src/gorgon/__tests__/rules_test.js +0 -487
  47. package/src/gorgon/__tests__/selector-parser_test.js +0 -52
  48. package/src/gorgon/__tests__/tree-transformer_test.js +0 -446
  49. package/src/gorgon/gorgon.js +0 -290
  50. package/src/gorgon/proptypes.js +0 -29
  51. package/src/gorgon/rule.js +0 -413
  52. package/src/gorgon/rules/absolute-url.js +0 -24
  53. package/src/gorgon/rules/all-rules.js +0 -72
  54. package/src/gorgon/rules/blockquoted-math.js +0 -10
  55. package/src/gorgon/rules/blockquoted-widget.js +0 -10
  56. package/src/gorgon/rules/double-spacing-after-terminal.js +0 -12
  57. package/src/gorgon/rules/extra-content-spacing.js +0 -12
  58. package/src/gorgon/rules/heading-level-1.js +0 -14
  59. package/src/gorgon/rules/heading-level-skip.js +0 -20
  60. package/src/gorgon/rules/heading-sentence-case.js +0 -11
  61. package/src/gorgon/rules/heading-title-case.js +0 -63
  62. package/src/gorgon/rules/image-alt-text.js +0 -21
  63. package/src/gorgon/rules/image-in-table.js +0 -10
  64. package/src/gorgon/rules/image-spaces-around-urls.js +0 -35
  65. package/src/gorgon/rules/image-widget.js +0 -50
  66. package/src/gorgon/rules/link-click-here.js +0 -11
  67. package/src/gorgon/rules/lint-utils.js +0 -48
  68. package/src/gorgon/rules/long-paragraph.js +0 -14
  69. package/src/gorgon/rules/math-adjacent.js +0 -10
  70. package/src/gorgon/rules/math-align-extra-break.js +0 -11
  71. package/src/gorgon/rules/math-align-linebreaks.js +0 -43
  72. package/src/gorgon/rules/math-empty.js +0 -10
  73. package/src/gorgon/rules/math-font-size.js +0 -12
  74. package/src/gorgon/rules/math-frac.js +0 -10
  75. package/src/gorgon/rules/math-nested.js +0 -11
  76. package/src/gorgon/rules/math-starts-with-space.js +0 -12
  77. package/src/gorgon/rules/math-text-empty.js +0 -10
  78. package/src/gorgon/rules/math-without-dollars.js +0 -14
  79. package/src/gorgon/rules/nested-lists.js +0 -11
  80. package/src/gorgon/rules/profanity.js +0 -10
  81. package/src/gorgon/rules/table-missing-cells.js +0 -20
  82. package/src/gorgon/rules/unbalanced-code-delimiters.js +0 -14
  83. package/src/gorgon/rules/unescaped-dollar.js +0 -10
  84. package/src/gorgon/rules/widget-in-table.js +0 -10
  85. package/src/gorgon/selector.js +0 -506
  86. package/src/gorgon/tree-transformer.js +0 -588
  87. package/src/pure-markdown.js +0 -347
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.2.5",
6
+ "version": "0.2.8",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -21,26 +21,29 @@
21
21
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
22
22
  },
23
23
  "dependencies": {
24
- "@khanacademy/kmath": "0.0.5",
25
- "@khanacademy/math-input": "^0.5.2",
24
+ "@khanacademy/kmath": "^0.0.5",
26
25
  "@khanacademy/kas": "^0.2.4",
27
- "@khanacademy/simple-markdown": "^0.8.2",
26
+ "@khanacademy/math-input": "^0.5.2",
27
+ "@khanacademy/perseus-linter": "^0.1.0",
28
+ "@khanacademy/pure-markdown": "^0.1.0",
29
+ "@khanacademy/simple-markdown": "^0.8.3",
28
30
  "mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992"
29
31
  },
30
32
  "devDependencies": {
31
- "@khanacademy/wonder-blocks-button": "2.11.5",
33
+ "@khanacademy/wonder-blocks-button": "^2.11.5",
32
34
  "@khanacademy/wonder-blocks-color": "^1.1.20",
33
35
  "@khanacademy/wonder-blocks-core": "^4.3.0",
34
36
  "@khanacademy/wonder-blocks-data": "^7.0.0",
35
37
  "@khanacademy/wonder-blocks-dropdown": "^2.6.7",
36
38
  "@khanacademy/wonder-blocks-i18n": "^1.2.3",
37
- "@khanacademy/wonder-blocks-layout": "1.4.9",
39
+ "@khanacademy/wonder-blocks-layout": "^1.4.9",
38
40
  "@khanacademy/wonder-blocks-link": "^3.8.5",
41
+ "@khanacademy/wonder-blocks-modal": "^2.3.1",
39
42
  "@khanacademy/wonder-blocks-popover": "^1.1.10",
40
- "@khanacademy/wonder-blocks-progress-spinner": "1.1.31",
43
+ "@khanacademy/wonder-blocks-progress-spinner": "^1.1.31",
41
44
  "@khanacademy/wonder-blocks-spacing": "^3.0.5",
42
45
  "@khanacademy/wonder-blocks-tooltip": "^1.3.10",
43
- "@khanacademy/wonder-blocks-typography": "1.1.31",
46
+ "@khanacademy/wonder-blocks-typography": "^1.1.31",
44
47
  "@khanacademy/wonder-stuff-core": "^0.1.2",
45
48
  "aphrodite": "^1.2.5",
46
49
  "classnames": "^1.1.4",
@@ -57,19 +60,20 @@
57
60
  "underscore": "^1.4.4"
58
61
  },
59
62
  "peerDependencies": {
60
- "@khanacademy/wonder-blocks-button": "2.11.5",
63
+ "@khanacademy/wonder-blocks-button": "^2.11.5",
61
64
  "@khanacademy/wonder-blocks-color": "^1.1.20",
62
65
  "@khanacademy/wonder-blocks-core": "^4.3.0",
63
66
  "@khanacademy/wonder-blocks-data": "^7.0.0",
64
67
  "@khanacademy/wonder-blocks-dropdown": "^2.6.7",
65
68
  "@khanacademy/wonder-blocks-i18n": "^1.2.3",
66
- "@khanacademy/wonder-blocks-layout": "1.4.9",
69
+ "@khanacademy/wonder-blocks-layout": "^1.4.9",
67
70
  "@khanacademy/wonder-blocks-link": "^3.8.5",
71
+ "@khanacademy/wonder-blocks-modal": "^2.3.1",
68
72
  "@khanacademy/wonder-blocks-popover": "^1.1.10",
69
- "@khanacademy/wonder-blocks-progress-spinner": "1.1.31",
73
+ "@khanacademy/wonder-blocks-progress-spinner": "^1.1.31",
70
74
  "@khanacademy/wonder-blocks-spacing": "^3.0.5",
71
75
  "@khanacademy/wonder-blocks-tooltip": "^1.3.10",
72
- "@khanacademy/wonder-blocks-typography": "1.1.31",
76
+ "@khanacademy/wonder-blocks-typography": "^1.1.31",
73
77
  "@khanacademy/wonder-stuff-core": "^0.1.2",
74
78
  "aphrodite": "^1.2.5",
75
79
  "classnames": "^1.1.4",
@@ -0,0 +1,34 @@
1
+ // @flow
2
+
3
+ import JiptParagraphs from "../jipt-paragraphs.js";
4
+
5
+ const {parseToArray} = JiptParagraphs;
6
+
7
+ describe("jipt-paragraphs", () => {
8
+ it("should split paragraphs using custom JIPT SimpleMarkdown rules", () => {
9
+ expect(parseToArray(" \n\nhello\n\n")).toMatchInlineSnapshot(`
10
+ Array [
11
+ " ",
12
+ "hello",
13
+ ]
14
+ `);
15
+ });
16
+
17
+ it("should recognize code fences using custom JIPT SimpleMarkdown rules", () => {
18
+ expect(
19
+ parseToArray(
20
+ "Let's write the canonical Hello World in Javascript\n\n" +
21
+ '```js\nconst x = "hello world";\nconsole.log(x);```\n\n' +
22
+ "**Congratulations, you are on your way to becoming a " +
23
+ "computer programmer!",
24
+ ),
25
+ ).toMatchInlineSnapshot(`
26
+ Array [
27
+ "Let's write the canonical Hello World in Javascript",
28
+ "const x = \\"hello world\\";
29
+ console.log(x);",
30
+ "**Congratulations, you are on your way to becoming a computer programmer!",
31
+ ]
32
+ `);
33
+ });
34
+ });
@@ -1,6 +1,6 @@
1
1
  // @flow
2
- import Gorgon from "../gorgon/gorgon.js"; // The linter engine
3
- import {linterContextDefault} from "../gorgon/proptypes.js";
2
+ import * as Gorgon from "@khanacademy/perseus-linter";
3
+
4
4
  import PerseusMarkdown from "../perseus-markdown.jsx";
5
5
 
6
6
  const {parse, basicOutput, characterCount} = PerseusMarkdown;
@@ -565,7 +565,7 @@ describe("perseus markdown", () => {
565
565
  "data 4 | $data 5 | data 6\n" +
566
566
  "data 7 | data 8 | data 9";
567
567
  const context = {
568
- ...linterContextDefault,
568
+ ...Gorgon.linterContextDefault,
569
569
  content,
570
570
  widgets: {},
571
571
  };
@@ -650,7 +650,7 @@ describe("perseus markdown", () => {
650
650
  "data 4 | $data 5 | data 6\n" +
651
651
  "data 7 | data 8 | data 9";
652
652
  const context = {
653
- ...linterContextDefault,
653
+ ...Gorgon.linterContextDefault,
654
654
  content,
655
655
  widgets: {},
656
656
  };
@@ -5,12 +5,11 @@
5
5
  * composed of multiple (Renderer) sections concatenated together.
6
6
  */
7
7
 
8
+ import * as Gorgon from "@khanacademy/perseus-linter";
8
9
  import classNames from "classnames";
9
10
  import PropTypes from "prop-types";
10
11
  import * as React from "react";
11
12
 
12
- import Gorgon from "./gorgon/gorgon.js";
13
- import {linterContextProps, linterContextDefault} from "./gorgon/proptypes.js";
14
13
  import ProvideKeypad from "./mixins/provide-keypad.jsx";
15
14
  import {ClassNames as ApiClassNames, ApiOptions} from "./perseus-api.jsx";
16
15
  import Renderer from "./renderer.jsx";
@@ -38,14 +37,14 @@ class ArticleRenderer extends React.Component<$FlowFixMe, $FlowFixMe> {
38
37
 
39
38
  // Whether to use the new Bibliotron styles for articles
40
39
  useNewStyles: PropTypes.bool,
41
- linterContext: linterContextProps,
40
+ linterContext: Gorgon.linterContextProps,
42
41
  legacyPerseusLint: PropTypes.arrayOf(PropTypes.string),
43
42
  };
44
43
 
45
44
  static defaultProps: $FlowFixMe = {
46
45
  apiOptions: {},
47
46
  useNewStyles: false,
48
- linterContext: linterContextDefault,
47
+ linterContext: Gorgon.linterContextDefault,
49
48
  };
50
49
 
51
50
  constructor(props: $FlowFixMe) {
@@ -1,11 +1,10 @@
1
1
  /* eslint-disable react/sort-comp */
2
2
  // @flow
3
+ import * as Gorgon from "@khanacademy/perseus-linter";
3
4
  import PropTypes from "prop-types";
4
5
  import * as React from "react";
5
6
  import _ from "underscore";
6
7
 
7
- import Gorgon from "../gorgon/gorgon.js";
8
- import {linterContextProps, linterContextDefault} from "../gorgon/proptypes.js";
9
8
  import {ClassNames as ApiClassNames} from "../perseus-api.jsx";
10
9
  import Renderer from "../renderer.jsx";
11
10
  import Util from "../util.js";
@@ -38,7 +37,7 @@ class InputWithExamples extends React.Component<$FlowFixMe, $FlowFixMe> {
38
37
 
39
38
  // A unique string identifying this InputWithExamples
40
39
  id: PropTypes.string.isRequired,
41
- linterContext: linterContextProps,
40
+ linterContext: Gorgon.linterContextProps,
42
41
  };
43
42
 
44
43
  static defaultProps: $FlowFixMe = {
@@ -47,7 +46,7 @@ class InputWithExamples extends React.Component<$FlowFixMe, $FlowFixMe> {
47
46
  onFocus: function () {},
48
47
  onBlur: function () {},
49
48
  disabled: false,
50
- linterContext: linterContextDefault,
49
+ linterContext: Gorgon.linterContextDefault,
51
50
  };
52
51
 
53
52
  state: $FlowFixMe = {
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @babel/no-invalid-this, react/forbid-prop-types, react/no-unsafe, react/sort-comp */
2
2
  // @flow
3
+ import * as Gorgon from "@khanacademy/perseus-linter";
3
4
  import {CircularSpinner} from "@khanacademy/wonder-blocks-progress-spinner";
4
5
  import {StyleSheet, css} from "aphrodite";
5
6
  import $ from "jquery";
@@ -9,8 +10,6 @@ import ReactDOM from "react-dom";
9
10
  import _ from "underscore";
10
11
 
11
12
  import {getDependencies} from "../dependencies.js";
12
- import Gorgon from "../gorgon/gorgon.js";
13
- import {linterContextProps, linterContextDefault} from "../gorgon/proptypes.js";
14
13
  import {ClassNames as ApiClassNames} from "../perseus-api.jsx";
15
14
  import Renderer from "../renderer.jsx";
16
15
  import Util from "../util.js";
@@ -96,13 +95,13 @@ class Draggable extends React.Component<DraggableProps, DraggableState> {
96
95
  onMouseUp: PropTypes.func.isRequired,
97
96
  onRender: PropTypes.func.isRequired,
98
97
  type: PropTypes.oneOf([STATIC, DRAGGING, ANIMATING, DISABLED]),
99
- linterContext: linterContextProps,
98
+ linterContext: Gorgon.linterContextProps,
100
99
  };
101
100
 
102
101
  static defaultProps = {
103
102
  includePadding: true,
104
103
  type: STATIC,
105
- linterContext: linterContextDefault,
104
+ linterContext: Gorgon.linterContextDefault,
106
105
  };
107
106
 
108
107
  state: DraggableState = {
@@ -423,7 +422,7 @@ class Sortable extends React.Component<SortableProps, SortableState> {
423
422
  onMeasure: function () {},
424
423
  margin: 5,
425
424
  onChange: function () {},
426
- linterContext: linterContextDefault,
425
+ linterContext: Gorgon.linterContextDefault,
427
426
  waitForKatexLoad: true,
428
427
  };
429
428
 
@@ -1,11 +1,10 @@
1
1
  // @flow
2
+ import * as Gorgon from "@khanacademy/perseus-linter";
2
3
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
3
4
  import {StyleSheet, css} from "aphrodite";
4
5
  import classnames from "classnames";
5
6
  import * as React from "react";
6
7
 
7
- import Gorgon from "./gorgon/gorgon.js";
8
- import {linterContextDefault} from "./gorgon/proptypes.js";
9
8
  import Renderer from "./renderer.jsx";
10
9
  import {
11
10
  baseUnitPx,
@@ -36,7 +35,7 @@ type DefaultProps = {|
36
35
  /* Renders just a hint preview */
37
36
  class HintRenderer extends React.Component<Props> {
38
37
  static defaultProps: DefaultProps = {
39
- linterContext: linterContextDefault,
38
+ linterContext: Gorgon.linterContextDefault,
40
39
  };
41
40
 
42
41
  getSerializedState: () => void = () => {
@@ -1,4 +1,5 @@
1
1
  // @flow
2
+ import * as Gorgon from "@khanacademy/perseus-linter";
2
3
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
3
4
  import {StyleSheet, css} from "aphrodite";
4
5
  import classnames from "classnames";
@@ -6,8 +7,6 @@ import * as React from "react";
6
7
  import ReactDOM from "react-dom";
7
8
  import _ from "underscore";
8
9
 
9
- import Gorgon from "./gorgon/gorgon.js";
10
- import {linterContextDefault} from "./gorgon/proptypes.js";
11
10
  import HintRenderer from "./hint-renderer.jsx";
12
11
  import {ApiOptions} from "./perseus-api.jsx";
13
12
  import typeof Renderer from "./renderer.jsx";
@@ -43,7 +42,7 @@ type State = {|
43
42
  // eslint-disable-next-line react/no-unsafe
44
43
  class HintsRenderer extends React.Component<Props, State> {
45
44
  static defaultProps: DefaultProps = {
46
- linterContext: linterContextDefault,
45
+ linterContext: Gorgon.linterContextDefault,
47
46
  };
48
47
 
49
48
  // The isFinalHelpPage property determines if the user has requested help
@@ -1,12 +1,11 @@
1
1
  /* eslint-disable react/no-unsafe */
2
2
  // @flow
3
+ import * as Gorgon from "@khanacademy/perseus-linter";
3
4
  import $ from "jquery";
4
5
  import * as React from "react";
5
6
  import * as ReactDOM from "react-dom";
6
7
  import _ from "underscore";
7
8
 
8
- import Gorgon from "./gorgon/gorgon.js";
9
- import {linterContextDefault} from "./gorgon/proptypes.js";
10
9
  import HintsRenderer from "./hints-renderer.jsx";
11
10
  import Objective from "./interactive2/objective_.js";
12
11
  import ProvideKeypad from "./mixins/provide-keypad.jsx";
@@ -88,7 +87,7 @@ class ItemRenderer extends React.Component<Props, State> {
88
87
  initialHintsVisible: 0,
89
88
  workAreaSelector: "#workarea",
90
89
  reviewMode: false,
91
- linterContext: linterContextDefault,
90
+ linterContext: Gorgon.linterContextDefault,
92
91
  };
93
92
 
94
93
  constructor(props: Props) {
@@ -11,28 +11,36 @@ const arrayRules: ParserRules = {
11
11
  fence: {
12
12
  match: SimpleMarkdown.defaultRules.fence.match,
13
13
  order: 1,
14
- // $FlowFixMe[incompatible-type]
15
- parse: (capture, state, parse) => capture[3],
14
+ parse: (capture, state, parse) => ({
15
+ type: "codeBlock",
16
+ lang: capture[2] || undefined,
17
+ content: capture[3],
18
+ }),
16
19
  },
17
20
  paragraph: {
18
21
  match: SimpleMarkdown.defaultRules.paragraph.match,
19
22
  order: 2,
20
- // $FlowFixMe[incompatible-type]
21
- parse: (capture, state, parse) => capture[1],
23
+ parse: (capture, state, parse) => ({
24
+ content: capture[1],
25
+ }),
22
26
  },
23
27
  };
24
28
 
25
- // $FlowFixMe[prop-missing]
26
- const builtArrayParser = SimpleMarkdown.parserFor(arrayRules);
29
+ const builtArrayParser: $Call<
30
+ typeof SimpleMarkdown.parserFor,
31
+ typeof arrayRules,
32
+ > = SimpleMarkdown.parserFor(arrayRules);
27
33
 
28
34
  // This should just return an array of strings! magick!
29
- const parseToArray = (source: string): $FlowFixMe => {
35
+ const parseToArray = (source: string): Array<string> => {
30
36
  // Remove any leading newlines to avoid splitting weirdness
31
37
  // (simple-markdown has the `newline` rule for this, and i have
32
38
  // no idea how this will handle leading newlines without that rule),
33
39
  // and add \n\n to let it parse at a block/paragraph level
34
40
  const paragraphedSource = source.replace(/^\n\s*\n/, "") + "\n\n";
35
- return builtArrayParser(paragraphedSource, {inline: false});
41
+ return builtArrayParser(paragraphedSource, {inline: false}).map((c) => {
42
+ return c["content"];
43
+ });
36
44
  };
37
45
 
38
46
  const joinFromArray = (paragraphs: $ReadOnlyArray<string>): string =>
package/src/not-gorgon.js CHANGED
@@ -1,8 +1,7 @@
1
1
  // @flow
2
+ import {Rule} from "@khanacademy/perseus-linter";
2
3
  import {debounce} from "underscore";
3
4
 
4
- import Rule from "./gorgon/rule.js";
5
-
6
5
  /**
7
6
  * NotGorgon asynchronously calls Khan Academy's poentry linter.
8
7
  *
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-useless-escape, no-prototype-builtins */
2
2
  // @flow
3
- // TODO(FEI-4465): move this into it's own package called perseus-markdown
3
+ import {pureMarkdownRules} from "@khanacademy/pure-markdown";
4
4
  import SimpleMarkdown from "@khanacademy/simple-markdown";
5
5
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
6
6
  import * as React from "react";
@@ -8,7 +8,6 @@ import _ from "underscore";
8
8
 
9
9
  import Lint from "./components/lint.jsx";
10
10
  import {getDependencies} from "./dependencies.js";
11
- import {pureMarkdownRules} from "./pure-markdown.js";
12
11
 
13
12
  const rules = {
14
13
  ...pureMarkdownRules,
package/src/renderer.jsx CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable react/no-unsafe */
2
2
  // @flow
3
+ import * as Gorgon from "@khanacademy/perseus-linter";
3
4
  import classNames from "classnames";
4
5
  import $ from "jquery";
5
6
  import * as React from "react";
@@ -13,8 +14,6 @@ import ZoomableTeX from "./components/zoomable-tex.jsx";
13
14
  import Zoomable from "./components/zoomable.jsx";
14
15
  import {getDependencies} from "./dependencies.js";
15
16
  import ErrorBoundary from "./error-boundary.jsx";
16
- import Gorgon from "./gorgon/gorgon.js"; // The linter engine
17
- import {linterContextDefault} from "./gorgon/proptypes.js";
18
17
  import InteractionTracker from "./interaction-tracker.js";
19
18
  import Objective from "./interactive2/objective_.js";
20
19
  import JiptParagraphs from "./jipt-paragraphs.js";
@@ -234,7 +233,7 @@ class Renderer extends React.Component<Props, State> {
234
233
  reviewMode: false,
235
234
  serializedState: null,
236
235
  onSerializedStateUpdated: () => {},
237
- linterContext: linterContextDefault,
236
+ linterContext: Gorgon.linterContextDefault,
238
237
  };
239
238
 
240
239
  constructor(props: Props, context: Context) {
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable react/no-unsafe, react/sort-comp */
2
2
  // @flow
3
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
3
4
  import classNames from "classnames";
4
5
  import * as React from "react";
5
6
  import ReactDOM from "react-dom";
6
7
 
7
- import {linterContextDefault} from "./gorgon/proptypes.js";
8
8
  import {zIndexInteractiveComponent} from "./styles/constants.js";
9
9
  import {containerSizeClass, getClassFromWidth} from "./util/sizing-utils.js";
10
10
  import * as Widgets from "./widgets.js";
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable react/sort-comp */
2
2
  // @flow
3
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
4
5
  import {StyleSheet, css} from "aphrodite";
5
6
  import classNames from "classnames";
@@ -7,7 +8,6 @@ import * as React from "react";
7
8
  import _ from "underscore";
8
9
 
9
10
  import InlineIcon from "../components/inline-icon.jsx";
10
- import {linterContextDefault} from "../gorgon/proptypes.js";
11
11
  import {iconCircle, iconCircleThin} from "../icon-paths.js";
12
12
  import * as Changeable from "../mixins/changeable.jsx";
13
13
  import WidgetJsonifyDeprecated from "../mixins/widget-jsonify-deprecated.jsx";
@@ -1,9 +1,7 @@
1
- /* eslint-disable react/sort-comp */
2
1
  // @flow
3
2
  import {SingleSelect, OptionItem} from "@khanacademy/wonder-blocks-dropdown";
4
3
  import * as React from "react";
5
4
  import ReactDOM from "react-dom";
6
- import _ from "underscore";
7
5
 
8
6
  import {ApiOptions} from "../perseus-api.jsx";
9
7
 
@@ -51,6 +49,33 @@ class Dropdown extends React.Component<Props> {
51
49
  };
52
50
  }
53
51
 
52
+ focus: () => boolean = () => {
53
+ // TODO(LP-10797): This focus() call doesn't do anything because our
54
+ // root element is a <div> and that cannot be focused without a
55
+ // tabIndex.
56
+ // $FlowFixMe[incompatible-use]
57
+ // $FlowFixMe[prop-missing]
58
+ ReactDOM.findDOMNode(this).focus();
59
+ return true;
60
+ };
61
+
62
+ _handleChangeEvent: (SyntheticInputEvent<>) => void = (e) => {
63
+ this._handleChange(parseInt(e.target.value));
64
+ };
65
+
66
+ _handleChange: (number) => void = (selected) => {
67
+ this.props.trackInteraction();
68
+ this.props.onChange({selected: selected});
69
+ };
70
+
71
+ getUserInput: () => UserInput = () => {
72
+ return {value: this.props.selected};
73
+ };
74
+
75
+ simpleValidate: (Rubric) => PerseusScore = (rubric) => {
76
+ return Dropdown.validate(this.getUserInput(), rubric);
77
+ };
78
+
54
79
  render(): React.Node {
55
80
  const children = [
56
81
  <OptionItem
@@ -79,8 +104,8 @@ class Dropdown extends React.Component<Props> {
79
104
  e.stopPropagation();
80
105
  }}
81
106
  >
82
- {/* $FlowFixMe[prop-missing]: placeholder is missing */}
83
107
  <SingleSelect
108
+ placeholder=""
84
109
  onChange={(value) => this._handleChange(parseInt(value))}
85
110
  selectedValue={String(this.props.selected)}
86
111
  disabled={this.props.apiOptions.readOnly}
@@ -90,33 +115,6 @@ class Dropdown extends React.Component<Props> {
90
115
  </div>
91
116
  );
92
117
  }
93
-
94
- focus: () => boolean = () => {
95
- // TODO(LP-10797): This focus() call doesn't do anything because our
96
- // root element is a <div> and that cannot be focused without a
97
- // tabIndex.
98
- // $FlowFixMe[incompatible-use]
99
- // $FlowFixMe[prop-missing]
100
- ReactDOM.findDOMNode(this).focus();
101
- return true;
102
- };
103
-
104
- _handleChangeEvent: (SyntheticInputEvent<>) => void = (e) => {
105
- this._handleChange(parseInt(e.target.value));
106
- };
107
-
108
- _handleChange: (number) => void = (selected) => {
109
- this.props.trackInteraction();
110
- this.props.onChange({selected: selected});
111
- };
112
-
113
- getUserInput: () => UserInput = () => {
114
- return {value: this.props.selected};
115
- };
116
-
117
- simpleValidate: (Rubric) => PerseusScore = (rubric) => {
118
- return Dropdown.validate(this.getUserInput(), rubric);
119
- };
120
118
  }
121
119
 
122
120
  type RenderProps = {|
@@ -129,7 +127,7 @@ const optionsTransform: (PerseusDropdownWidgetOptions) => RenderProps = (
129
127
  ) => {
130
128
  return {
131
129
  placeholder: widgetOptions.placeholder,
132
- choices: _.map(widgetOptions.choices, (choice) => choice.content),
130
+ choices: widgetOptions.choices.map((choice) => choice.content),
133
131
  };
134
132
  };
135
133
 
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable react/sort-comp */
2
2
  // @flow
3
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
3
4
  import {StyleSheet, css} from "aphrodite";
4
5
  import * as React from "react";
5
6
  import _ from "underscore";
6
7
 
7
- import {linterContextDefault} from "../gorgon/proptypes.js";
8
8
  import * as Changeable from "../mixins/changeable.jsx";
9
9
  import Renderer from "../renderer.jsx";
10
10
  import * as styleConstants from "../styles/constants.js";
@@ -2,6 +2,7 @@
2
2
  // @flow
3
3
  import * as KAS from "@khanacademy/kas";
4
4
  import {KeypadInput, KeypadTypes} from "@khanacademy/math-input";
5
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
5
6
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
6
7
  import classNames from "classnames";
7
8
  import * as React from "react";
@@ -11,7 +12,6 @@ import InlineIcon from "../components/inline-icon.jsx";
11
12
  import InputWithExamples from "../components/input-with-examples.jsx";
12
13
  import MathInput from "../components/math-input.jsx";
13
14
  import Tooltip from "../components/tooltip.jsx";
14
- import {linterContextDefault} from "../gorgon/proptypes.js";
15
15
  import {iconExclamationSign} from "../icon-paths.js";
16
16
  import {Errors as PerseusErrors, Log} from "../logging/log.js";
17
17
  import * as Changeable from "../mixins/changeable.jsx";
@@ -1,10 +1,10 @@
1
1
  // @flow
2
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
2
3
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
3
4
  import {StyleSheet, css} from "aphrodite";
4
5
  import * as React from "react";
5
6
 
6
7
  import {getDependencies} from "../dependencies.js";
7
- import {linterContextDefault} from "../gorgon/proptypes.js";
8
8
  import * as Changeable from "../mixins/changeable.jsx";
9
9
  import {
10
10
  grayLight,
@@ -1,4 +1,5 @@
1
1
  // @flow
2
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
2
3
  import Button from "@khanacademy/wonder-blocks-button";
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
4
5
  import {StyleSheet, css} from "aphrodite";
@@ -7,7 +8,6 @@ import * as React from "react";
7
8
  import _ from "underscore";
8
9
 
9
10
  import InlineIcon from "../components/inline-icon.jsx";
10
- import {linterContextDefault} from "../gorgon/proptypes.js";
11
11
  import {iconOk, iconRemove} from "../icon-paths.js";
12
12
  import * as Changeable from "../mixins/changeable.jsx";
13
13
  import {ApiOptions} from "../perseus-api.jsx";
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable react/sort-comp */
2
2
  // @flow
3
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
3
4
  import classNames from "classnames";
4
5
  import * as React from "react";
5
6
  import _ from "underscore";
6
7
 
7
- import {linterContextDefault} from "../gorgon/proptypes.js";
8
8
  import * as Changeable from "../mixins/changeable.jsx";
9
9
  import {ApiOptions} from "../perseus-api.jsx";
10
10
  import Renderer from "../renderer.jsx";
@@ -1,13 +1,13 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  /* eslint-disable react/sort-comp */
3
3
  // @flow
4
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
4
5
  import {StyleSheet, css} from "aphrodite";
5
6
  import classNames from "classnames";
6
7
  import * as React from "react";
7
8
  import _ from "underscore";
8
9
 
9
10
  import SvgImage from "../components/svg-image.jsx";
10
- import {linterContextDefault} from "../gorgon/proptypes.js";
11
11
  import * as Changeable from "../mixins/changeable.jsx";
12
12
  import Renderer from "../renderer.jsx";
13
13
  import {baseUnitPx} from "../styles/constants.js";
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  /* eslint-disable react/sort-comp */
3
3
  // @flow
4
+ import {linterContextDefault} from "@khanacademy/perseus-linter";
4
5
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
5
6
  import classNames from "classnames";
6
7
  import * as React from "react";
@@ -9,7 +10,6 @@ import _ from "underscore";
9
10
  import InputWithExamples from "../components/input-with-examples.jsx";
10
11
  import PossibleAnswers from "../components/possible-answers.jsx";
11
12
  import SimpleKeypadInput from "../components/simple-keypad-input.jsx";
12
- import {linterContextDefault} from "../gorgon/proptypes.js";
13
13
  import {ClassNames as ApiClassNames, ApiOptions} from "../perseus-api.jsx";
14
14
  import TexWrangler from "../tex-wrangler.js";
15
15
  import KhanAnswerTypes from "../util/answer-types.js";
@@ -1,5 +1,9 @@
1
1
  /* eslint-disable react/forbid-prop-types, react/sort-comp */
2
2
  // @flow
3
+ import {
4
+ linterContextProps,
5
+ linterContextDefault,
6
+ } from "@khanacademy/perseus-linter";
3
7
  import {CircularSpinner} from "@khanacademy/wonder-blocks-progress-spinner";
4
8
  import {StyleSheet, css} from "aphrodite";
5
9
  import PropTypes from "prop-types";
@@ -8,7 +12,6 @@ import _ from "underscore";
8
12
 
9
13
  import Sortable from "../components/sortable.jsx";
10
14
  import {getDependencies} from "../dependencies.js";
11
- import {linterContextProps, linterContextDefault} from "../gorgon/proptypes.js";
12
15
  import {ApiOptions} from "../perseus-api.jsx";
13
16
  import Renderer from "../renderer.jsx";
14
17
  import Util from "../util.js";