@khanacademy/perseus-editor 7.0.2 → 8.0.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/dist/index.js CHANGED
@@ -81,7 +81,7 @@ var Banner__default = /*#__PURE__*/_interopDefaultLegacy(Banner);
81
81
 
82
82
  // This file is processed by a Rollup plugin (replace) to inject the production
83
83
  const libName = "@khanacademy/perseus-editor";
84
- const libVersion = "7.0.2";
84
+ const libVersion = "8.0.0";
85
85
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
86
86
 
87
87
  function _extends() {
@@ -21430,7 +21430,7 @@ class Editor extends React__namespace.Component {
21430
21430
  } else if (templateType === "allWidgets") {
21431
21431
  template = perseus.Widgets.getAllWidgetTypes().map(type => `[[${perseus.Util.snowman} ${type} 1]]`).join("\n\n");
21432
21432
  } else {
21433
- throw new perseus.PerseusError("Invalid template type: " + templateType, perseus.Errors.InvalidInput, {
21433
+ throw new perseusCore.PerseusError("Invalid template type: " + templateType, perseusCore.Errors.InvalidInput, {
21434
21434
  metadata: {
21435
21435
  templateType
21436
21436
  }
@@ -22090,7 +22090,7 @@ class ArticleEditor extends React__namespace.Component {
22090
22090
  if (this.props.mode === "preview" || this.props.mode === "json") {
22091
22091
  return this.props.json;
22092
22092
  }
22093
- throw new perseus.PerseusError("Could not serialize; mode " + this.props.mode + " not found", perseus.Errors.Internal);
22093
+ throw new perseusCore.PerseusError("Could not serialize; mode " + this.props.mode + " not found", perseusCore.Errors.Internal);
22094
22094
  }
22095
22095
 
22096
22096
  /**
@@ -22103,7 +22103,7 @@ class ArticleEditor extends React__namespace.Component {
22103
22103
  if (this.props.mode !== "edit") {
22104
22104
  // TODO(joshuan): We should be able to get save warnings in
22105
22105
  // preview mode.
22106
- throw new perseus.PerseusError("Can only get save warnings in edit mode.", perseus.Errors.NotAllowed);
22106
+ throw new perseusCore.PerseusError("Can only get save warnings in edit mode.", perseusCore.Errors.NotAllowed);
22107
22107
  }
22108
22108
  return this._sections().map((section, i) => {
22109
22109
  // eslint-disable-next-line react/no-string-refs
@@ -25888,7 +25888,7 @@ class CSProgramEditor extends React__namespace.Component {
25888
25888
  programType: programType
25889
25889
  });
25890
25890
  }).fail((jqxhr, textStatus, error) => {
25891
- perseus.Log.error("Error retrieving scratchpad info for program ID ", perseus.Errors.TransientService, {
25891
+ perseus.Log.error("Error retrieving scratchpad info for program ID ", perseusCore.Errors.TransientService, {
25892
25892
  // @ts-expect-error - TS2322 - Type 'string' is not assignable to type 'Error | null | undefined'.
25893
25893
  cause: error,
25894
25894
  loggedMetadata: {
@@ -29765,6 +29765,14 @@ function getDefaultFigureForType(type) {
29765
29765
  fillStyle: "none",
29766
29766
  strokeStyle: "solid"
29767
29767
  };
29768
+ case "function":
29769
+ return {
29770
+ type: "function",
29771
+ color: DEFAULT_COLOR,
29772
+ strokeStyle: "solid",
29773
+ equation: "x^2",
29774
+ directionalAxis: "x"
29775
+ };
29768
29776
  default:
29769
29777
  throw new wonderStuffCore.UnreachableCaseError(type);
29770
29778
  }
@@ -31050,6 +31058,12 @@ const LockedFiguresSection = props => {
31050
31058
  const buttonLabel = allCollapsed ? "Expand all" : "Collapse all";
31051
31059
  const showExpandButton = !!figures?.length;
31052
31060
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, null, figures?.map((figure, index) => {
31061
+ if (figure.type === "function") {
31062
+ // TODO(LEMS-1947): Add locked function settings.
31063
+ // Remove this block once function locked figure settings are
31064
+ // implemented.
31065
+ return;
31066
+ }
31053
31067
  return /*#__PURE__*/React__namespace.createElement(LockedFigureSettings, _extends({
31054
31068
  key: `${uniqueId}-locked-${figure}-${index}`,
31055
31069
  showM2Features: props.showM2Features,
@@ -34532,9 +34546,14 @@ class NumericInputEditor extends React__namespace.Component {
34532
34546
  onChange: this.props.onChange
34533
34547
  }), /*#__PURE__*/React__namespace.createElement(InfoTip$7, null, /*#__PURE__*/React__namespace.createElement("p", null, "A coefficient style number allows the student to use - for -1 and an empty string to mean 1."))));
34534
34548
  const addAnswerButton = /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("a", {
34535
- href: "javascript:void(0)",
34549
+ href: "#",
34536
34550
  className: "simple-button orange",
34537
- onClick: () => this.addAnswer(),
34551
+ onClick: e => {
34552
+ // preventDefault ensures that href="#"
34553
+ // doesn't scroll to the top of the page
34554
+ e.preventDefault();
34555
+ this.addAnswer();
34556
+ },
34538
34557
  onKeyDown: e => this.onSpace(e, this.addAnswer)
34539
34558
  }, /*#__PURE__*/React__namespace.createElement("span", null, "Add new answer")));
34540
34559
  const instructions = {
@@ -34616,21 +34635,36 @@ class NumericInputEditor extends React__namespace.Component {
34616
34635
  })) : null, /*#__PURE__*/React__namespace.createElement("div", {
34617
34636
  className: "value-divider"
34618
34637
  }), /*#__PURE__*/React__namespace.createElement("a", {
34619
- href: "javascript:void(0)",
34638
+ href: "#",
34620
34639
  className: "answer-status " + answer.status,
34621
- onClick: () => this.onStatusChange(i),
34640
+ onClick: e => {
34641
+ // preventDefault ensures that href="#"
34642
+ // doesn't scroll to the top of the page
34643
+ e.preventDefault();
34644
+ this.onStatusChange(i);
34645
+ },
34622
34646
  onKeyDown: e => this.onSpace(e, this.onStatusChange)
34623
34647
  }, answer.status), /*#__PURE__*/React__namespace.createElement("a", {
34624
- href: "javascript:void(0)",
34648
+ href: "#",
34625
34649
  className: "answer-trash",
34626
34650
  "aria-label": "Delete answer",
34627
- onClick: () => this.onTrashAnswer(i),
34651
+ onClick: e => {
34652
+ // preventDefault ensures that href="#"
34653
+ // doesn't scroll to the top of the page
34654
+ e.preventDefault();
34655
+ this.onTrashAnswer(i);
34656
+ },
34628
34657
  onKeyDown: e => this.onSpace(e, this.onTrashAnswer)
34629
34658
  }, /*#__PURE__*/React__namespace.createElement(InlineIcon$2, iconTrash$1)), /*#__PURE__*/React__namespace.createElement("a", {
34630
- href: "javascript:void(0)",
34659
+ href: "#",
34631
34660
  className: "options-toggle",
34632
34661
  "aria-label": "Toggle options",
34633
- onClick: () => this.onToggleOptions(i),
34662
+ onClick: e => {
34663
+ // preventDefault ensures that href="#"
34664
+ // doesn't scroll to the top of the page
34665
+ e.preventDefault();
34666
+ this.onToggleOptions(i);
34667
+ },
34634
34668
  onKeyDown: e => this.onSpace(e, this.onToggleOptions)
34635
34669
  }, /*#__PURE__*/React__namespace.createElement(InlineIcon$2, iconGear))), /*#__PURE__*/React__namespace.createElement("div", {
34636
34670
  className: "input-answer-editor-message"