@khanacademy/perseus-editor 17.4.0 → 17.5.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
@@ -99,7 +99,7 @@ var arrowCounterClockwise__default = /*#__PURE__*/_interopDefaultLegacy(arrowCou
99
99
 
100
100
  // This file is processed by a Rollup plugin (replace) to inject the production
101
101
  const libName = "@khanacademy/perseus-editor";
102
- const libVersion = "17.4.0";
102
+ const libVersion = "17.5.0";
103
103
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
104
104
 
105
105
  function _extends() {
@@ -20779,8 +20779,7 @@ const _upgradeWidgetInfo = props => {
20779
20779
  // We can't call serialize here because this.refs.widget
20780
20780
  // doesn't exist before this component is mounted.
20781
20781
  const filteredProps = ___default["default"].omit(props, perseus.WIDGET_PROP_DENYLIST);
20782
- // @ts-expect-error TS(2345) Type '"categorizer" | undefined' is not assignable to type '"deprecated-standin"'.
20783
- return perseus.Widgets.upgradeWidgetInfoToLatestVersion(filteredProps);
20782
+ return perseusCore.upgradeWidgetInfoToLatestVersion(filteredProps);
20784
20783
  };
20785
20784
 
20786
20785
  // This component handles upgading widget editor props via prop
@@ -20870,7 +20869,7 @@ class WidgetEditor extends React__namespace.Component {
20870
20869
  const Ed = perseus.Widgets.getEditor(widgetInfo.type);
20871
20870
  let supportedAlignments;
20872
20871
  if (this.props.apiOptions.showAlignmentOptions) {
20873
- supportedAlignments = perseus.Widgets.getSupportedAlignments(widgetInfo.type);
20872
+ supportedAlignments = perseusCore.CoreWidgetRegistry.getSupportedAlignments(widgetInfo.type);
20874
20873
  } else {
20875
20874
  // NOTE(kevinb): "default" is not one in `validAlignments` in widgets.js.
20876
20875
  supportedAlignments = ["default"];
@@ -21554,7 +21553,7 @@ class Editor extends React__namespace.Component {
21554
21553
  const widgetContent = widgetPlaceholder.replace("{id}", id);
21555
21554
 
21556
21555
  // Add newlines before block-display widgets like graphs
21557
- const isBlock = perseus.Widgets.getDefaultAlignment(widgetType) === "block";
21556
+ const isBlock = perseusCore.CoreWidgetRegistry.getDefaultAlignment(widgetType) === "block";
21558
21557
  const prelude = oldContent.slice(0, cursorRange[0]);
21559
21558
  const postlude = oldContent.slice(cursorRange[1]);
21560
21559
  const newPrelude = isBlock ? makeEndWithAParagraphIfNecessary(prelude) : prelude;
@@ -23254,6 +23253,9 @@ class WidgetDiff extends React__namespace.Component {
23254
23253
  }
23255
23254
  }
23256
23255
 
23256
+ /**
23257
+ * A side by side diff view for Perseus renderers.
23258
+ */
23257
23259
  // In diffs, only show the widgetInfo props that can change
23258
23260
  const filterWidgetInfo = function (widgetInfo, showAlignmentOptions) {
23259
23261
  const {
@@ -23267,7 +23269,7 @@ const filterWidgetInfo = function (widgetInfo, showAlignmentOptions) {
23267
23269
  };
23268
23270
 
23269
23271
  // Show alignment options iff multiple valid ones exist for this widget
23270
- if (showAlignmentOptions && perseus.Widgets.getSupportedAlignments(type).length > 1) {
23272
+ if (showAlignmentOptions && perseusCore.CoreWidgetRegistry.getSupportedAlignments(type).length > 1) {
23271
23273
  // @ts-expect-error - TS2339 - Property 'alignment' does not exist on type '{ readonly options: any; }'.
23272
23274
  filteredWidgetInfo.alignment = alignment;
23273
23275
  }
@@ -26360,7 +26362,6 @@ const {
26360
26362
  } = perseus.components;
26361
26363
  const Grapher = perseus.GrapherWidget.widget;
26362
26364
  const {
26363
- DEFAULT_GRAPHER_PROPS,
26364
26365
  chooseType,
26365
26366
  defaultPlotProps,
26366
26367
  getEquationString,
@@ -26371,11 +26372,7 @@ class GrapherEditor extends React__namespace.Component {
26371
26372
  ...perseus.Changeable.propTypes
26372
26373
  };
26373
26374
  static widgetName = "grapher";
26374
- static defaultProps = {
26375
- correct: DEFAULT_GRAPHER_PROPS.plot,
26376
- graph: DEFAULT_GRAPHER_PROPS.graph,
26377
- availableTypes: DEFAULT_GRAPHER_PROPS.availableTypes
26378
- };
26375
+ static defaultProps = perseusCore.grapherLogic.defaultWidgetOptions;
26379
26376
  change = (() => {
26380
26377
  var _this = this;
26381
26378
  return function () {
@@ -28863,14 +28860,16 @@ class InteractiveGraphSettings extends React__namespace.Component {
28863
28860
  label: "x Range"
28864
28861
  }, /*#__PURE__*/React__namespace.createElement(RangeInput$4, {
28865
28862
  value: this.state.rangeTextbox[0],
28866
- onChange: vals => this.changeRange(0, vals)
28863
+ onChange: vals => this.changeRange(0, vals),
28864
+ allowPiTruncation: true
28867
28865
  }))), /*#__PURE__*/React__namespace.createElement("div", {
28868
28866
  className: "perseus-widget-right-col"
28869
28867
  }, /*#__PURE__*/React__namespace.createElement(LabeledRow, {
28870
28868
  label: "y Range"
28871
28869
  }, /*#__PURE__*/React__namespace.createElement(RangeInput$4, {
28872
28870
  value: this.state.rangeTextbox[1],
28873
- onChange: vals => this.changeRange(1, vals)
28871
+ onChange: vals => this.changeRange(1, vals),
28872
+ allowPiTruncation: true
28874
28873
  })))), /*#__PURE__*/React__namespace.createElement("div", {
28875
28874
  className: "perseus-widget-row"
28876
28875
  }, /*#__PURE__*/React__namespace.createElement("div", {
@@ -28879,14 +28878,16 @@ class InteractiveGraphSettings extends React__namespace.Component {
28879
28878
  label: "Tick Step"
28880
28879
  }, /*#__PURE__*/React__namespace.createElement(RangeInput$4, {
28881
28880
  value: this.state.stepTextbox,
28882
- onChange: this.changeStep
28881
+ onChange: this.changeStep,
28882
+ allowPiTruncation: true
28883
28883
  }))), /*#__PURE__*/React__namespace.createElement("div", {
28884
28884
  className: "perseus-widget-right-col"
28885
28885
  }, /*#__PURE__*/React__namespace.createElement(LabeledRow, {
28886
28886
  label: "Grid Step"
28887
28887
  }, /*#__PURE__*/React__namespace.createElement(RangeInput$4, {
28888
28888
  value: this.state.gridStepTextbox,
28889
- onChange: this.changeGridStep
28889
+ onChange: this.changeGridStep,
28890
+ allowPiTruncation: true
28890
28891
  })))), /*#__PURE__*/React__namespace.createElement("div", {
28891
28892
  className: "perseus-widget-row"
28892
28893
  }, /*#__PURE__*/React__namespace.createElement("div", {
@@ -28895,7 +28896,8 @@ class InteractiveGraphSettings extends React__namespace.Component {
28895
28896
  label: "Snap Step"
28896
28897
  }, /*#__PURE__*/React__namespace.createElement(RangeInput$4, {
28897
28898
  value: this.state.snapStepTextbox,
28898
- onChange: this.changeSnapStep
28899
+ onChange: this.changeSnapStep,
28900
+ allowPiTruncation: true
28899
28901
  })))), /*#__PURE__*/React__namespace.createElement("div", {
28900
28902
  className: "perseus-widget-row"
28901
28903
  }, /*#__PURE__*/React__namespace.createElement(LabeledRow, {