@khanacademy/perseus-editor 2.12.1 → 2.14.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
@@ -64,7 +64,7 @@ var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n$1);
64
64
 
65
65
  // This file is processed by a Rollup plugin (replace) to inject the production
66
66
  const libName = "@khanacademy/perseus-editor";
67
- const libVersion = "2.12.1";
67
+ const libVersion = "2.14.0";
68
68
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
69
69
 
70
70
  function _extends() {
@@ -23834,15 +23834,6 @@ const {
23834
23834
  InfoTip: InfoTip$m
23835
23835
  } = perseus.components;
23836
23836
  class ItemExtrasEditor extends React__namespace.Component {
23837
- static propTypes = {
23838
- calculator: PropTypes__default["default"].bool,
23839
- chi2Table: PropTypes__default["default"].bool,
23840
- onChange: PropTypes__default["default"].func.isRequired,
23841
- periodicTable: PropTypes__default["default"].bool,
23842
- periodicTableWithKey: PropTypes__default["default"].bool,
23843
- tTable: PropTypes__default["default"].bool,
23844
- zTable: PropTypes__default["default"].bool
23845
- };
23846
23837
  static defaultProps = {
23847
23838
  calculator: false,
23848
23839
  chi2Table: false,
@@ -23879,7 +23870,11 @@ class ItemExtrasEditor extends React__namespace.Component {
23879
23870
  checked: this.props.periodicTable,
23880
23871
  onChange: e => {
23881
23872
  this.props.onChange({
23882
- periodicTable: e.target.checked
23873
+ periodicTable: e.target.checked,
23874
+ // If the periodic table is unchecked,
23875
+ // this needs to be reset. If table is
23876
+ // checked, it should already be false.
23877
+ periodicTableWithKey: false
23883
23878
  });
23884
23879
  }
23885
23880
  })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions.")), this.props.periodicTable && /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Include key/legend with periodic table:", " ", /*#__PURE__*/React__namespace.createElement("input", {
@@ -26772,12 +26767,12 @@ const SortableItem = createReactClass__default["default"]({
26772
26767
 
26773
26768
  const {
26774
26769
  InfoTip: InfoTip$j,
26775
- PropCheckBox: PropCheckBox$b,
26776
- TexButtons
26770
+ PropCheckBox: PropCheckBox$b
26777
26771
  } = perseus.components;
26778
26772
 
26779
26773
  // types for iterables
26780
26774
 
26775
+ const buttonSetsList = ["basic", "trig", "prealgebra", "logarithms", "basic relations", "advanced relations"];
26781
26776
  const parseAnswerKey = _ref => {
26782
26777
  let {
26783
26778
  key
@@ -26819,31 +26814,6 @@ class ExpressionEditor extends React__namespace.Component {
26819
26814
  buttonSets: ["basic"],
26820
26815
  functions: ["f", "g", "h"]
26821
26816
  };
26822
- constructor(props) {
26823
- super(props);
26824
- // Is the format of `value` TeX or plain text?
26825
- // TODO(alex): Remove after backfilling everything to TeX
26826
- // TODO(joel) - sucks if you edit some expression without
26827
- // backslashes or curly braces, then come back to the question and
26828
- // it's surprisingly not TeX anymore.
26829
-
26830
- let isTex;
26831
- // default to TeX if new;
26832
- if (props.answerForms.length === 0) {
26833
- isTex = true;
26834
- } else {
26835
- isTex = props.answerForms.some(form => {
26836
- const {
26837
- value
26838
- } = form;
26839
- // only TeX has backslashes and curly braces
26840
- return value.indexOf("\\") !== -1 || value.indexOf("{") !== -1;
26841
- });
26842
- }
26843
- this.state = {
26844
- isTex
26845
- };
26846
- }
26847
26817
  change() {
26848
26818
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26849
26819
  args[_key] = arguments[_key];
@@ -26884,14 +26854,13 @@ class ExpressionEditor extends React__namespace.Component {
26884
26854
  });
26885
26855
 
26886
26856
  // checkboxes to choose which sets of input buttons are shown
26887
- const buttonSetChoices = Object.keys(TexButtons.buttonSets).map(name => {
26857
+ const buttonSetChoices = buttonSetsList.map(name => {
26888
26858
  // The first one gets special cased to always be checked, disabled,
26889
26859
  // and float left.
26890
26860
  const isFirst = name === "basic";
26891
26861
  const checked = this.props.buttonSets.includes(name) || isFirst;
26892
- const className = isFirst ? "button-set-label-float" : "button-set-label";
26893
26862
  return /*#__PURE__*/React__namespace.createElement("label", {
26894
- className: className,
26863
+ className: "button-set-label",
26895
26864
  key: name
26896
26865
  }, /*#__PURE__*/React__namespace.createElement("input", {
26897
26866
  type: "checkbox",
@@ -26904,7 +26873,8 @@ class ExpressionEditor extends React__namespace.Component {
26904
26873
  TeX
26905
26874
  } = perseus.Dependencies.getDependencies(); // OldExpression only
26906
26875
 
26907
- buttonSetChoices.splice(1, 1, /*#__PURE__*/React__namespace.createElement("label", {
26876
+ buttonSetChoices.unshift( /*#__PURE__*/React__namespace.createElement("label", {
26877
+ className: "button-set-label",
26908
26878
  key: "show-div"
26909
26879
  }, /*#__PURE__*/React__namespace.createElement("input", {
26910
26880
  type: "checkbox",
@@ -26925,12 +26895,7 @@ class ExpressionEditor extends React__namespace.Component {
26925
26895
  type: "text",
26926
26896
  defaultValue: this.props.functions.join(" "),
26927
26897
  onChange: this.handleFunctions
26928
- })), /*#__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, {
26929
- className: "math-input-buttons",
26930
- sets: this.props.buttonSets,
26931
- convertDotToTimes: this.props.times,
26932
- onInsert: this.handleTexInsert
26933
- }), /*#__PURE__*/React__namespace.createElement("h3", {
26898
+ })), /*#__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), /*#__PURE__*/React__namespace.createElement("h3", {
26934
26899
  className: "expression-editor-h3"
26935
26900
  }, "Answers"), /*#__PURE__*/React__namespace.createElement("p", {
26936
26901
  style: {
@@ -27040,7 +27005,7 @@ class ExpressionEditor extends React__namespace.Component {
27040
27005
 
27041
27006
  // called when the selected buttonset changes
27042
27007
  handleButtonSet = changingName => {
27043
- const buttonSetNames = Object.keys(TexButtons.buttonSets);
27008
+ const buttonSetNames = buttonSetsList;
27044
27009
 
27045
27010
  // Filter to preserve order - using .union and .difference would always
27046
27011
  // move the last added button set to the end.
@@ -30941,6 +30906,7 @@ const Behavior = _ref => {
30941
30906
  let {
30942
30907
  multipleAnswers,
30943
30908
  hideChoicesFromInstructions,
30909
+ preferredPopoverDirection,
30944
30910
  onChange
30945
30911
  } = _ref;
30946
30912
  return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
@@ -30963,7 +30929,28 @@ const Behavior = _ref => {
30963
30929
  })
30964
30930
  }), /*#__PURE__*/React__namespace.createElement("span", {
30965
30931
  className: aphrodite.css(styles$5.label)
30966
- }, "Do not display answer choices in instructions"))));
30932
+ }, "Do not display answer choices in instructions")), /*#__PURE__*/React__namespace.createElement("li", {
30933
+ className: aphrodite.css(styles$5.option)
30934
+ }, /*#__PURE__*/React__namespace.createElement("span", {
30935
+ className: aphrodite.css(styles$5.label)
30936
+ }, "Preferred pop-over direction"), /*#__PURE__*/React__namespace.createElement("select", {
30937
+ value: preferredPopoverDirection,
30938
+ onChange: e => {
30939
+ onChange({
30940
+ preferredPopoverDirection: e.target.value
30941
+ });
30942
+ }
30943
+ }, /*#__PURE__*/React__namespace.createElement("option", {
30944
+ value: "NONE"
30945
+ }, " No Preference "), /*#__PURE__*/React__namespace.createElement("option", {
30946
+ value: "UP"
30947
+ }, " Up "), /*#__PURE__*/React__namespace.createElement("option", {
30948
+ value: "DOWN"
30949
+ }, " Down "), /*#__PURE__*/React__namespace.createElement("option", {
30950
+ value: "LEFT"
30951
+ }, " Left "), /*#__PURE__*/React__namespace.createElement("option", {
30952
+ value: "RIGHT"
30953
+ }, " Right ")))));
30967
30954
  };
30968
30955
  const styles$5 = aphrodite.StyleSheet.create({
30969
30956
  title: {
@@ -31752,6 +31739,7 @@ class LabelImageEditor extends React__namespace.Component {
31752
31739
  }), /*#__PURE__*/React__namespace.createElement("div", {
31753
31740
  className: aphrodite.css(styles.largeSpacer)
31754
31741
  }), /*#__PURE__*/React__namespace.createElement(Behavior, {
31742
+ preferredPopoverDirection: "NONE",
31755
31743
  multipleAnswers: multipleAnswers,
31756
31744
  hideChoicesFromInstructions: hideChoicesFromInstructions,
31757
31745
  onChange: this.handleBehaviorChange