@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/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { addLibraryVersionToPerseusDebug, PerseusError, Errors, ItemExtras, categorizerLogic, csProgramLogic, definitionLogic, dropdownLogic, explanationLogic, expressionLogic, PerseusExpressionAnswerFormConsidered, gradedGroupLogic, gradedGroupSetLogic, GrapherUtil as GrapherUtil$1, groupLogic, iframeLogic, imageLogic, inputNumberLogic, interactionLogic, lockedFigureColors, lockedFigureFillStyles, interactiveGraphLogic, labelImageLogic, matcherLogic, matrixLogic, getMatrixSize, measurerLogic, numberLineLogic, numericInputLogic, ordererLogic, passageLogic, passageRefLogic, passageRefTargetLogic, phetSimulationLogic, plotterLogic, plotterPlotTypes, pythonProgramLogic, radioLogic, sorterLogic, tableLogic, videoLogic } from '@khanacademy/perseus-core';
2
- import { components, Widgets, iconChevronDown, iconTrash, WIDGET_PROP_DENYLIST, Util, Log, PerseusMarkdown, preprocessTex, ApiOptions, itemDataVersion, ClassNames, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, Expression, interactiveSizes, GrapherWidget, GrapherUtil, containerSizeClass, getInteractiveBoxFromSizeClass, PerseusI18nContext, KhanColors, mathOnlyParser, getAngleCoords, getPolygonCoords, getPointCoords, getQuadraticCoords, getSinusoidCoords, getCircleCoords, getLinearSystemCoords, getSegmentCoords, getLineCoords, InteractiveGraphWidget, bodyXsmallBold, MatrixWidget, makeSafeUrl, PlotterWidget, BaseRadio, TableWidget, widgets } from '@khanacademy/perseus';
1
+ import { addLibraryVersionToPerseusDebug, upgradeWidgetInfoToLatestVersion, CoreWidgetRegistry, PerseusError, Errors, ItemExtras, categorizerLogic, csProgramLogic, definitionLogic, dropdownLogic, explanationLogic, expressionLogic, PerseusExpressionAnswerFormConsidered, gradedGroupLogic, gradedGroupSetLogic, grapherLogic, GrapherUtil, groupLogic, iframeLogic, imageLogic, inputNumberLogic, interactionLogic, lockedFigureColors, lockedFigureFillStyles, interactiveGraphLogic, labelImageLogic, matcherLogic, matrixLogic, getMatrixSize, measurerLogic, numberLineLogic, numericInputLogic, ordererLogic, passageLogic, passageRefLogic, passageRefTargetLogic, phetSimulationLogic, plotterLogic, plotterPlotTypes, pythonProgramLogic, radioLogic, sorterLogic, tableLogic, videoLogic } from '@khanacademy/perseus-core';
2
+ import { components, Widgets, iconChevronDown, iconTrash, WIDGET_PROP_DENYLIST, Util, Log, PerseusMarkdown, preprocessTex, ApiOptions, itemDataVersion, ClassNames, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, Expression, interactiveSizes, GrapherWidget, containerSizeClass, getInteractiveBoxFromSizeClass, GrapherUtil as GrapherUtil$1, PerseusI18nContext, KhanColors, mathOnlyParser, getAngleCoords, getPolygonCoords, getPointCoords, getQuadraticCoords, getSinusoidCoords, getCircleCoords, getLinearSystemCoords, getSegmentCoords, getLineCoords, InteractiveGraphWidget, bodyXsmallBold, MatrixWidget, makeSafeUrl, PlotterWidget, BaseRadio, TableWidget, widgets } from '@khanacademy/perseus';
3
3
  export { widgets } from '@khanacademy/perseus';
4
4
  import * as React from 'react';
5
5
  import { useId, useRef, useEffect, useState } from 'react';
@@ -47,7 +47,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
47
47
 
48
48
  // This file is processed by a Rollup plugin (replace) to inject the production
49
49
  const libName = "@khanacademy/perseus-editor";
50
- const libVersion = "17.4.0";
50
+ const libVersion = "17.5.0";
51
51
  addLibraryVersionToPerseusDebug(libName, libVersion);
52
52
 
53
53
  function _extends() {
@@ -20731,8 +20731,7 @@ const _upgradeWidgetInfo = props => {
20731
20731
  // We can't call serialize here because this.refs.widget
20732
20732
  // doesn't exist before this component is mounted.
20733
20733
  const filteredProps = _.omit(props, WIDGET_PROP_DENYLIST);
20734
- // @ts-expect-error TS(2345) Type '"categorizer" | undefined' is not assignable to type '"deprecated-standin"'.
20735
- return Widgets.upgradeWidgetInfoToLatestVersion(filteredProps);
20734
+ return upgradeWidgetInfoToLatestVersion(filteredProps);
20736
20735
  };
20737
20736
 
20738
20737
  // This component handles upgading widget editor props via prop
@@ -20819,7 +20818,7 @@ class WidgetEditor extends React.Component {
20819
20818
  const Ed = Widgets.getEditor(widgetInfo.type);
20820
20819
  let supportedAlignments;
20821
20820
  if (this.props.apiOptions.showAlignmentOptions) {
20822
- supportedAlignments = Widgets.getSupportedAlignments(widgetInfo.type);
20821
+ supportedAlignments = CoreWidgetRegistry.getSupportedAlignments(widgetInfo.type);
20823
20822
  } else {
20824
20823
  // NOTE(kevinb): "default" is not one in `validAlignments` in widgets.js.
20825
20824
  supportedAlignments = ["default"];
@@ -21411,7 +21410,7 @@ class Editor extends React.Component {
21411
21410
  const widgetContent = widgetPlaceholder.replace("{id}", id);
21412
21411
 
21413
21412
  // Add newlines before block-display widgets like graphs
21414
- const isBlock = Widgets.getDefaultAlignment(widgetType) === "block";
21413
+ const isBlock = CoreWidgetRegistry.getDefaultAlignment(widgetType) === "block";
21415
21414
  const prelude = oldContent.slice(0, cursorRange[0]);
21416
21415
  const postlude = oldContent.slice(cursorRange[1]);
21417
21416
  const newPrelude = isBlock ? makeEndWithAParagraphIfNecessary(prelude) : prelude;
@@ -23214,6 +23213,9 @@ WidgetDiff.defaultProps = {
23214
23213
  type: ""
23215
23214
  };
23216
23215
 
23216
+ /**
23217
+ * A side by side diff view for Perseus renderers.
23218
+ */
23217
23219
  // In diffs, only show the widgetInfo props that can change
23218
23220
  const filterWidgetInfo = function filterWidgetInfo(widgetInfo, showAlignmentOptions) {
23219
23221
  const {
@@ -23227,7 +23229,7 @@ const filterWidgetInfo = function filterWidgetInfo(widgetInfo, showAlignmentOpti
23227
23229
  };
23228
23230
 
23229
23231
  // Show alignment options iff multiple valid ones exist for this widget
23230
- if (showAlignmentOptions && Widgets.getSupportedAlignments(type).length > 1) {
23232
+ if (showAlignmentOptions && CoreWidgetRegistry.getSupportedAlignments(type).length > 1) {
23231
23233
  // @ts-expect-error - TS2339 - Property 'alignment' does not exist on type '{ readonly options: any; }'.
23232
23234
  filteredWidgetInfo.alignment = alignment;
23233
23235
  }
@@ -26292,12 +26294,11 @@ const {
26292
26294
  } = components;
26293
26295
  const Grapher = GrapherWidget.widget;
26294
26296
  const {
26295
- DEFAULT_GRAPHER_PROPS,
26296
26297
  chooseType,
26297
26298
  defaultPlotProps,
26298
26299
  getEquationString,
26299
26300
  typeToButton
26300
- } = GrapherUtil;
26301
+ } = GrapherUtil$1;
26301
26302
  class GrapherEditor extends React.Component {
26302
26303
  constructor(..._args) {
26303
26304
  super(..._args);
@@ -26387,18 +26388,14 @@ class GrapherEditor extends React.Component {
26387
26388
  }, /*#__PURE__*/React.createElement("label", null, "Available functions: "), /*#__PURE__*/React.createElement(MultiButtonGroup, {
26388
26389
  allowEmpty: false,
26389
26390
  values: this.props.availableTypes,
26390
- buttons: _.map(GrapherUtil$1.allTypes, typeToButton),
26391
+ buttons: _.map(GrapherUtil.allTypes, typeToButton),
26391
26392
  onChange: this.handleAvailableTypesChange
26392
26393
  })), graph);
26393
26394
  }
26394
26395
  }
26395
26396
  GrapherEditor.propTypes = _extends({}, Changeable.propTypes);
26396
26397
  GrapherEditor.widgetName = "grapher";
26397
- GrapherEditor.defaultProps = {
26398
- correct: DEFAULT_GRAPHER_PROPS.plot,
26399
- graph: DEFAULT_GRAPHER_PROPS.graph,
26400
- availableTypes: DEFAULT_GRAPHER_PROPS.availableTypes
26401
- };
26398
+ GrapherEditor.defaultProps = grapherLogic.defaultWidgetOptions;
26402
26399
 
26403
26400
  class GroupEditor extends React.Component {
26404
26401
  constructor(..._args) {
@@ -28723,14 +28720,16 @@ class InteractiveGraphSettings extends React.Component {
28723
28720
  label: "x Range"
28724
28721
  }, /*#__PURE__*/React.createElement(RangeInput$4, {
28725
28722
  value: this.state.rangeTextbox[0],
28726
- onChange: vals => this.changeRange(0, vals)
28723
+ onChange: vals => this.changeRange(0, vals),
28724
+ allowPiTruncation: true
28727
28725
  }))), /*#__PURE__*/React.createElement("div", {
28728
28726
  className: "perseus-widget-right-col"
28729
28727
  }, /*#__PURE__*/React.createElement(LabeledRow, {
28730
28728
  label: "y Range"
28731
28729
  }, /*#__PURE__*/React.createElement(RangeInput$4, {
28732
28730
  value: this.state.rangeTextbox[1],
28733
- onChange: vals => this.changeRange(1, vals)
28731
+ onChange: vals => this.changeRange(1, vals),
28732
+ allowPiTruncation: true
28734
28733
  })))), /*#__PURE__*/React.createElement("div", {
28735
28734
  className: "perseus-widget-row"
28736
28735
  }, /*#__PURE__*/React.createElement("div", {
@@ -28739,14 +28738,16 @@ class InteractiveGraphSettings extends React.Component {
28739
28738
  label: "Tick Step"
28740
28739
  }, /*#__PURE__*/React.createElement(RangeInput$4, {
28741
28740
  value: this.state.stepTextbox,
28742
- onChange: this.changeStep
28741
+ onChange: this.changeStep,
28742
+ allowPiTruncation: true
28743
28743
  }))), /*#__PURE__*/React.createElement("div", {
28744
28744
  className: "perseus-widget-right-col"
28745
28745
  }, /*#__PURE__*/React.createElement(LabeledRow, {
28746
28746
  label: "Grid Step"
28747
28747
  }, /*#__PURE__*/React.createElement(RangeInput$4, {
28748
28748
  value: this.state.gridStepTextbox,
28749
- onChange: this.changeGridStep
28749
+ onChange: this.changeGridStep,
28750
+ allowPiTruncation: true
28750
28751
  })))), /*#__PURE__*/React.createElement("div", {
28751
28752
  className: "perseus-widget-row"
28752
28753
  }, /*#__PURE__*/React.createElement("div", {
@@ -28755,7 +28756,8 @@ class InteractiveGraphSettings extends React.Component {
28755
28756
  label: "Snap Step"
28756
28757
  }, /*#__PURE__*/React.createElement(RangeInput$4, {
28757
28758
  value: this.state.snapStepTextbox,
28758
- onChange: this.changeSnapStep
28759
+ onChange: this.changeSnapStep,
28760
+ allowPiTruncation: true
28759
28761
  })))), /*#__PURE__*/React.createElement("div", {
28760
28762
  className: "perseus-widget-row"
28761
28763
  }, /*#__PURE__*/React.createElement(LabeledRow, {