@khanacademy/perseus-editor 2.0.1 → 2.0.3

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 (66) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/article-editor.d.ts +2 -2
  3. package/dist/article-editor.js.flow +2 -2
  4. package/dist/components/dropdown-option.d.ts +2 -2
  5. package/dist/components/dropdown-option.js.flow +2 -2
  6. package/dist/components/link.d.ts +2 -2
  7. package/dist/components/link.js.flow +2 -2
  8. package/dist/diffs/__stories__/perseus-diff-wrapper.d.ts +3 -2
  9. package/dist/diffs/__stories__/perseus-diff-wrapper.js.flow +3 -2
  10. package/dist/editor.d.ts +7 -7
  11. package/dist/editor.js.flow +7 -7
  12. package/dist/es/index.js +9 -70
  13. package/dist/es/index.js.map +1 -1
  14. package/dist/index.js +9 -70
  15. package/dist/index.js.map +1 -1
  16. package/dist/section-control-button.d.ts +10 -1
  17. package/dist/section-control-button.js.flow +13 -1
  18. package/dist/widgets/label-image/answer-choices.d.ts +1 -1
  19. package/dist/widgets/label-image/answer-choices.js.flow +1 -1
  20. package/dist/widgets/label-image/behavior.d.ts +2 -2
  21. package/dist/widgets/label-image/behavior.js.flow +2 -2
  22. package/dist/widgets/label-image/marker.d.ts +5 -5
  23. package/dist/widgets/label-image/marker.js.flow +5 -7
  24. package/dist/widgets/label-image/question-markers.d.ts +2 -2
  25. package/dist/widgets/label-image/question-markers.js.flow +2 -4
  26. package/dist/widgets/label-image/select-image.d.ts +2 -2
  27. package/dist/widgets/label-image/select-image.js.flow +2 -2
  28. package/dist/widgets/label-image-editor.d.ts +3 -3
  29. package/dist/widgets/label-image-editor.js.flow +3 -3
  30. package/package.json +2 -2
  31. package/src/__stories__/section-control-button.stories.tsx +3 -3
  32. package/src/article-editor.tsx +2 -6
  33. package/src/components/dropdown-option.tsx +2 -10
  34. package/src/components/link.ts +2 -2
  35. package/src/diffs/__stories__/perseus-diff-wrapper.tsx +4 -2
  36. package/src/diffs/__stories__/structured-item-diff.stories.tsx +5 -9
  37. package/src/diffs/__stories__/tags-diff.stories.tsx +1 -1
  38. package/src/diffs/__stories__/text-diff.stories.tsx +1 -1
  39. package/src/diffs/text-diff.tsx +0 -1
  40. package/src/diffs/widget-diff.tsx +0 -2
  41. package/src/editor.tsx +8 -11
  42. package/src/multirenderer-editor.tsx +8 -32
  43. package/src/widgets/__stories__/label-image-editor.stories.tsx +1 -4
  44. package/src/widgets/__stories__/radio-editor.stories.tsx +1 -2
  45. package/src/widgets/categorizer-editor.tsx +0 -1
  46. package/src/widgets/cs-program-editor.tsx +0 -2
  47. package/src/widgets/expression-editor.tsx +0 -2
  48. package/src/widgets/grapher-editor.tsx +0 -1
  49. package/src/widgets/iframe-editor.tsx +0 -2
  50. package/src/widgets/input-number-editor.tsx +0 -1
  51. package/src/widgets/interaction-editor.tsx +0 -1
  52. package/src/widgets/interactive-graph-editor.tsx +0 -1
  53. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +3 -7
  54. package/src/widgets/label-image/__stories__/behavior.stories.tsx +1 -1
  55. package/src/widgets/label-image/__stories__/marker.stories.tsx +2 -2
  56. package/src/widgets/label-image/__stories__/question-markers.stories.tsx +3 -3
  57. package/src/widgets/label-image/__stories__/select-image.stories.tsx +3 -3
  58. package/src/widgets/label-image/answer-choices.tsx +5 -5
  59. package/src/widgets/label-image/behavior.tsx +3 -3
  60. package/src/widgets/label-image/marker.tsx +5 -6
  61. package/src/widgets/label-image/question-markers.tsx +2 -2
  62. package/src/widgets/label-image/select-image.tsx +2 -5
  63. package/src/widgets/label-image-editor.tsx +3 -3
  64. package/src/widgets/numeric-input-editor.tsx +0 -20
  65. package/src/widgets/transformer-editor.tsx +0 -1
  66. package/tsconfig.tsbuildinfo +1 -1
package/dist/index.js CHANGED
@@ -1056,7 +1056,6 @@ class Editor extends React__namespace.Component {
1056
1056
  }, function () {
1057
1057
  perseus.Util.textarea.moveCursor(
1058
1058
  // findDOMNode can return Text but we know this is Element
1059
- // $FlowFixMe[incompatible-call]
1060
1059
  // @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'Element | Text | null' is not assignable to parameter of type 'HTMLTextAreaElement'.
1061
1060
  textarea,
1062
1061
  // We want to put the cursor after the widget
@@ -1901,7 +1900,6 @@ class ArticleEditor extends React__namespace.Component {
1901
1900
  }
1902
1901
  _defineProperty(ArticleEditor, "defaultProps", {
1903
1902
  contentPaths: [],
1904
- // $FlowFixMe[incompatible-exact]
1905
1903
  json: [{}],
1906
1904
  mode: "edit",
1907
1905
  screen: "desktop",
@@ -4610,7 +4608,7 @@ class ModeDropdown extends React__namespace.Component {
4610
4608
  _defineProperty(this, "_handleSelectMode", event => {
4611
4609
  if (this.props.onChange) {
4612
4610
  // event.target.value corresponds to the options' values below which
4613
- // are limited to EditorMode, but flow doesn't know that so we have
4611
+ // are limited to EditorMode, but TypeScript doesn't know that so we have
4614
4612
  // to cast through any here.
4615
4613
  const value = event.target.value;
4616
4614
  this.props.onChange(value);
@@ -4682,7 +4680,6 @@ const Header = _ref => {
4682
4680
  } = _ref;
4683
4681
  const headerLevel = Math.min(depth, 5) + 1;
4684
4682
  const HeaderTag = "h".concat(headerLevel);
4685
- // @ts-expect-error [FEI-5003] - TS2559 - Type '{ children?: ReactNode; }' has no properties in common with type 'IntrinsicAttributes'.
4686
4683
  return /*#__PURE__*/React__namespace.createElement(HeaderTag, props);
4687
4684
  };
4688
4685
 
@@ -4846,7 +4843,7 @@ const NodeContent = props => {
4846
4843
 
4847
4844
  // All uses of `data` have been cast through any which isn't safe. This was
4848
4845
  // done to avoid introducing new logic which may have resulted in a change
4849
- // of behavior. Also, there doesn't appear to be a way to tell flow the
4846
+ // of behavior. Also, there doesn't appear to be a way to tell TypeScript the
4850
4847
  // difference between and `TagsNode` and `ItemArrayNode`, see
4851
4848
  // perseus-all-package/multi-items/item-types.js.
4852
4849
  if (shape.type === "content") {
@@ -4925,12 +4922,6 @@ const withStickiness = WrappedComponent => {
4925
4922
  render() {
4926
4923
  return (
4927
4924
  /*#__PURE__*/
4928
- /**
4929
- * $FlowFixMe[incompatible-exact]
4930
- * TODO(somewhatabstract, JIRA-XXXX):
4931
- * Cannot create WrappedComponent element because inexact props
4932
- * [1] is incompatible with exact WithStickiness [2].
4933
- */
4934
4925
  // @ts-expect-error [FEI-5003] - TS2322 - Type 'Readonly<Config> & { sticky: boolean; children?: ReactNode; }' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<Component, PropsWithChildren<WithStickiness<Config>>>'.
4935
4926
  React__namespace.createElement(WrappedComponent, _extends({}, this.props, {
4936
4927
  sticky: this.state.sticky
@@ -4959,9 +4950,6 @@ const ItemNodeContent = withStickiness(props => {
4959
4950
  className: aphrodite.css(sticky && styles$c.sticky)
4960
4951
  },
4961
4952
  /*#__PURE__*/
4962
- // $FlowFixMe[incompatible-exact]: {...data} pass too many props
4963
- // $FlowFixMe[incompatible-type]
4964
- // $FlowFixMe[prop-missing]
4965
4953
  // @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
4966
4954
  React__namespace.createElement(Editor, _extends({}, data, {
4967
4955
  onChange: newVal => actions.mergeValueAtPath(path, newVal),
@@ -5065,10 +5053,7 @@ const ArrayNodeContent = props => {
5065
5053
  onClick: () => actions.moveArrayElementUp(subpath)
5066
5054
  }, /*#__PURE__*/React__namespace.createElement("div", {
5067
5055
  className: aphrodite.css(styles$c.verticalFlip)
5068
- }, /*#__PURE__*/React__namespace.createElement(InlineIcon$7, iconChevronDown)))),
5069
- // $FlowFixMe[unsafe-addition]
5070
- // $FlowFixMe[prop-missing]
5071
- i < data.length - 1 && /*#__PURE__*/React__namespace.createElement("div", {
5056
+ }, /*#__PURE__*/React__namespace.createElement(InlineIcon$7, iconChevronDown)))), i < data.length - 1 && /*#__PURE__*/React__namespace.createElement("div", {
5072
5057
  key: "moveArrayElementDown",
5073
5058
  className: aphrodite.css(styles$c.control)
5074
5059
  }, /*#__PURE__*/React__namespace.createElement(SimpleButton, {
@@ -5705,14 +5690,10 @@ class PairEditor$1 extends React__namespace.Component {
5705
5690
  return /*#__PURE__*/React__namespace.createElement("fieldset", {
5706
5691
  className: "pair-editor"
5707
5692
  }, /*#__PURE__*/React__namespace.createElement("label", null, "Name:", " ", /*#__PURE__*/React__namespace.createElement(BlurInput, {
5708
- value: this.props.name
5709
- // $FlowFixMe[incompatible-type] single-param call returns a callback
5710
- ,
5693
+ value: this.props.name,
5711
5694
  onChange: this.change("name")
5712
5695
  })), /*#__PURE__*/React__namespace.createElement("label", null, " ", "Value:", " ", /*#__PURE__*/React__namespace.createElement(BlurInput, {
5713
- value: this.props.value
5714
- // $FlowFixMe[incompatible-type] single-param call returns a callback
5715
- ,
5696
+ value: this.props.value,
5716
5697
  onChange: this.change("value")
5717
5698
  })));
5718
5699
  }
@@ -6869,10 +6850,7 @@ class ExpressionEditor extends React__namespace.Component {
6869
6850
  })), /*#__PURE__*/React__namespace.createElement(InfoTip$j, null, /*#__PURE__*/React__namespace.createElement("p", null, "Single-letter variables listed here will be interpreted as functions. This let us know that f(x) means \"f of x\" and not \"f times x\"."))), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", null, "Button sets:"), buttonSetChoices), this.state.isTex && /*#__PURE__*/React__namespace.createElement(TexButtons, {
6870
6851
  className: "math-input-buttons",
6871
6852
  sets: this.props.buttonSets,
6872
- convertDotToTimes: this.props.times
6873
- // onInsert is typed as `(string | ((input: $FlowFixMe) => void)) => void`
6874
- // $FlowFixMe[incompatible-type]
6875
- ,
6853
+ convertDotToTimes: this.props.times,
6876
6854
  onInsert: this.handleTexInsert
6877
6855
  }), /*#__PURE__*/React__namespace.createElement("h3", {
6878
6856
  className: "expression-editor-h3"
@@ -7775,7 +7753,6 @@ class GrapherEditor extends React__namespace.Component {
7775
7753
  // NOTE(jeremy): This editor doesn't pass in a bunch of
7776
7754
  // standard props that the Renderer provides normally (eg.
7777
7755
  // alignment, findWidgets, etc).
7778
- // $FlowFixMe[prop-missing]
7779
7756
  // @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
7780
7757
  React__namespace.createElement(Grapher, _extends({}, graphProps, {
7781
7758
  apiOptions: this.props.apiOptions,
@@ -7915,14 +7892,10 @@ class PairEditor extends React__namespace.Component {
7915
7892
  }
7916
7893
  render() {
7917
7894
  return /*#__PURE__*/React__namespace.createElement("fieldset", null, /*#__PURE__*/React__namespace.createElement("label", null, "Name:", /*#__PURE__*/React__namespace.createElement(BlurInput, {
7918
- value: this.props.name
7919
- // $FlowFixMe[incompatible-type] single-param call returns a callback
7920
- ,
7895
+ value: this.props.name,
7921
7896
  onChange: this.change("name")
7922
7897
  })), /*#__PURE__*/React__namespace.createElement("label", null, "Value:", /*#__PURE__*/React__namespace.createElement(BlurInput, {
7923
- value: this.props.value
7924
- // $FlowFixMe[incompatible-type] single-param call returns a callback
7925
- ,
7898
+ value: this.props.value,
7926
7899
  onChange: this.change("value")
7927
7900
  })));
7928
7901
  }
@@ -8409,9 +8382,7 @@ class InputNumberEditor extends React__namespace.Component {
8409
8382
  disabled: !this.props.inexact,
8410
8383
  defaultValue: this.props.maxError,
8411
8384
  onBlur: e => {
8412
- const ans = "" + (
8413
- // $FlowFixMe[incompatible-type]
8414
- perseus.Util.firstNumericalParse(e.target.value) || 0);
8385
+ const ans = "" + (perseus.Util.firstNumericalParse(e.target.value) || 0);
8415
8386
  e.target.value = ans;
8416
8387
  this.props.onChange({
8417
8388
  maxError: ans
@@ -9812,7 +9783,6 @@ const InteractiveGraphEditor = createReactClass__default["default"]({
9812
9783
  // There are a bunch of props that renderer.jsx passes to widgets via
9813
9784
  // getWidgetProps() and widget-container.jsx that the editors don't
9814
9785
  // bother passing.
9815
- // $FlowFixMe[prop-missing]
9816
9786
  // @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
9817
9787
  React__namespace.createElement(InteractiveGraph, _extends({}, graphProps, {
9818
9788
  containerSizeClass: sizeClass,
@@ -10713,9 +10683,6 @@ class Option extends React__namespace.Component {
10713
10683
  ariaLabel
10714
10684
  } = this.props;
10715
10685
  return /*#__PURE__*/React__namespace.createElement("button", {
10716
- // TODO(mdr): We found a new Flow error when upgrading:
10717
- // "node (null) This type is incompatible with this.node (HTMLDivElement)"
10718
- // $FlowFixMe[incompatible-type](0.52.0->0.53.0)
10719
10686
  // @ts-expect-error [FEI-5003] - TS2322 - Type 'HTMLButtonElement | null' is not assignable to type 'HTMLDivElement'.
10720
10687
  ref: node => this.node = node,
10721
10688
  value: value,
@@ -10726,11 +10693,6 @@ class Option extends React__namespace.Component {
10726
10693
  ,
10727
10694
  onClick: value => {
10728
10695
  if (!disabled && onClick) {
10729
- // TODO(mdr): We found a new Flow error here when upgrading
10730
- // from 0.35.0 to 0.52.0: "value (unused function
10731
- // argument)". This comment was automatically added to
10732
- // this file, to suppress the error for now. Please
10733
- // consider fixing!
10734
10696
  // @ts-expect-error [FEI-5003] - TS2554 - Expected 0 arguments, but got 1.
10735
10697
  onClick(value);
10736
10698
  }
@@ -10991,7 +10953,6 @@ class Marker extends React__namespace.Component {
10991
10953
  }), /*#__PURE__*/React__namespace.createElement(OptionGroup, {
10992
10954
  onSelected: this.handleSelectAnswer
10993
10955
  // TODO(WB-1096): make selectedValues immutable in wonder-blocks
10994
- // $FlowFixMe[incompatible-type]
10995
10956
  // @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
10996
10957
  ,
10997
10958
  selectedValues: answers
@@ -12411,7 +12372,6 @@ const NumericInputEditor = createReactClass__default["default"]({
12411
12372
  size: "normal",
12412
12373
  coefficient: false,
12413
12374
  labelText: "",
12414
- multipleNumberInput: false,
12415
12375
  rightAlign: false
12416
12376
  };
12417
12377
  },
@@ -12605,14 +12565,6 @@ const NumericInputEditor = createReactClass__default["default"]({
12605
12565
  return /*#__PURE__*/React__namespace.createElement("div", {
12606
12566
  className: "perseus-input-number-editor"
12607
12567
  }, /*#__PURE__*/React__namespace.createElement("div", {
12608
- ref: e => this.multInputOption = e
12609
- }, /*#__PURE__*/React__namespace.createElement("select", {
12610
- onChange: this.onMultipleInputChange
12611
- }, /*#__PURE__*/React__namespace.createElement("option", {
12612
- value: "simple-numeric-input"
12613
- }, "Ask for one correct solution"), /*#__PURE__*/React__namespace.createElement("option", {
12614
- value: "multiple-numeric-input"
12615
- }, "Ask for all correct solutions"))), /*#__PURE__*/React__namespace.createElement("div", {
12616
12568
  className: "ui-title"
12617
12569
  }, "User input"), /*#__PURE__*/React__namespace.createElement("div", {
12618
12570
  className: "msg-title"
@@ -12658,18 +12610,6 @@ const NumericInputEditor = createReactClass__default["default"]({
12658
12610
  simplify: newStatus === "correct" ? "required" : "accepted"
12659
12611
  });
12660
12612
  },
12661
- onMultipleInputChange: function (event) {
12662
- const newOption = event.target.value;
12663
- if (newOption === "multiple-numeric-input") {
12664
- this.props.onChange({
12665
- multipleNumberInput: true
12666
- });
12667
- } else {
12668
- this.props.onChange({
12669
- multipleNumberInput: false
12670
- });
12671
- }
12672
- },
12673
12613
  updateAnswer: function (choiceIndex, update) {
12674
12614
  if (!___default["default"].isObject(update)) {
12675
12615
  return ___default["default"].partial((choiceIndex, key, value) => {
@@ -14815,7 +14755,6 @@ class TransformationsShapeEditor extends React__namespace.Component {
14815
14755
  });
14816
14756
  _defineProperty(this, "updateCoords", () => {
14817
14757
  this.props.onChange({
14818
- // $FlowFixMe[prop-missing]
14819
14758
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'shape' does not exist on type 'TransformationsShapeEditor'.
14820
14759
  shape: this.shape.toJSON()
14821
14760
  });