@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/CHANGELOG.md +29 -0
- package/dist/es/index.js +40 -48
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +38 -50
- package/dist/index.js.map +1 -1
- package/dist/item-extras-editor.d.ts +12 -12
- package/dist/widgets/expression-editor.d.ts +1 -5
- package/dist/widgets/label-image/behavior.d.ts +4 -1
- package/package.json +9 -9
- package/src/__tests__/items-extras-editors.test.tsx +68 -0
- package/src/item-extras-editor.tsx +17 -13
- package/src/widgets/__tests__/expression-editor.test.tsx +347 -0
- package/src/widgets/expression-editor.tsx +34 -70
- package/src/widgets/label-image/__stories__/behavior.stories.tsx +1 -1
- package/src/widgets/label-image/behavior.tsx +32 -0
- package/src/widgets/label-image-editor.tsx +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @khanacademy/perseus-editor
|
|
2
2
|
|
|
3
|
+
## 2.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#804](https://github.com/Khan/perseus/pull/804) [`954dbb96`](https://github.com/Khan/perseus/commit/954dbb96eda47946a15ed819fde73aa931f318bc) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Add a preferred popover direction option to label image
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#856](https://github.com/Khan/perseus/pull/856) [`6c323dc3`](https://github.com/Khan/perseus/commit/6c323dc37e7cc972fe5a1ab7cbf90a23bf4dd3a0) Thanks [@nedredmond](https://github.com/nedredmond)! - Upgrade WB
|
|
12
|
+
|
|
13
|
+
* [#804](https://github.com/Khan/perseus/pull/804) [`07537aae`](https://github.com/Khan/perseus/commit/07537aae870866f4418055b5956e9387f85f72c4) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Unchecking periodic table option unchecks key as well
|
|
14
|
+
|
|
15
|
+
* Updated dependencies [[`2c295e2c`](https://github.com/Khan/perseus/commit/2c295e2c26ff2bf15e1e8e82bcc34e04e4b9bab0), [`ce343147`](https://github.com/Khan/perseus/commit/ce343147f558c2f2a1dcbabae20bdba22c0de86d), [`1c8f2753`](https://github.com/Khan/perseus/commit/1c8f275391b02bef8e14d1daccef8fadea9066cd), [`6c323dc3`](https://github.com/Khan/perseus/commit/6c323dc37e7cc972fe5a1ab7cbf90a23bf4dd3a0), [`7433c91b`](https://github.com/Khan/perseus/commit/7433c91bb05ad0441475f40bcd05a3076e7e19f1), [`dd41dd0e`](https://github.com/Khan/perseus/commit/dd41dd0e8bc76a414bb5906bba4648f57547f188), [`53612027`](https://github.com/Khan/perseus/commit/536120272b8cae3b01cdbe09a59488cc4704329d), [`bb9cd667`](https://github.com/Khan/perseus/commit/bb9cd667dbb4a38724ae174063021fdf18040f9b), [`4553af79`](https://github.com/Khan/perseus/commit/4553af79a26fc0e635d7dc03be74f39cb00a05f6), [`07537aae`](https://github.com/Khan/perseus/commit/07537aae870866f4418055b5956e9387f85f72c4), [`bb81559e`](https://github.com/Khan/perseus/commit/bb81559e02359092ba4d48107010c476b5ae09d5), [`fd09014c`](https://github.com/Khan/perseus/commit/fd09014c26e33d2c83a1e6ae3672027ac9583d41), [`1f4e17ba`](https://github.com/Khan/perseus/commit/1f4e17ba77e1491523813655af18a70285a25989), [`f6be48a9`](https://github.com/Khan/perseus/commit/f6be48a96795858e009bea18cc1092d150f98b71), [`34f7696b`](https://github.com/Khan/perseus/commit/34f7696b537d28c4b2054a3995f567a9a6834f73), [`8857950b`](https://github.com/Khan/perseus/commit/8857950bdeeb6e13bc3766b1c6545289b21cbe2a), [`ded7af48`](https://github.com/Khan/perseus/commit/ded7af488d57e6309f7244ca4b897ac680754d74), [`6f530d58`](https://github.com/Khan/perseus/commit/6f530d58b4368fb3c38d62d4dcf1f63cecf67d90), [`1906ec5a`](https://github.com/Khan/perseus/commit/1906ec5afb7fd7332a6cabc6afc79ee1f779f8ec), [`5e4c21bd`](https://github.com/Khan/perseus/commit/5e4c21bda5717fb793386a810be3144d7b9a9011), [`30ce593a`](https://github.com/Khan/perseus/commit/30ce593a2f1d552338ce0818cf754c13c22af281), [`cccf1897`](https://github.com/Khan/perseus/commit/cccf1897da294e4b1fec804f2639c1c56bd68201)]:
|
|
16
|
+
- @khanacademy/perseus@17.1.0
|
|
17
|
+
- @khanacademy/perseus-core@1.4.1
|
|
18
|
+
- @khanacademy/kas@0.3.7
|
|
19
|
+
- @khanacademy/kmath@0.1.8
|
|
20
|
+
|
|
21
|
+
## 2.13.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [#838](https://github.com/Khan/perseus/pull/838) [`233fc9fc`](https://github.com/Khan/perseus/commit/233fc9fcd4c65d2ff0c8f1ebd1cb1b17b76cbe0c) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove TexButtons and update ExpressionEditor
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`2e2f2cc1`](https://github.com/Khan/perseus/commit/2e2f2cc1afe99613eb688ab1e4e1fccad0c8df57), [`204788f8`](https://github.com/Khan/perseus/commit/204788f8f583bda5ff94d74fd70ec542fedd3d6e), [`233fc9fc`](https://github.com/Khan/perseus/commit/233fc9fcd4c65d2ff0c8f1ebd1cb1b17b76cbe0c)]:
|
|
30
|
+
- @khanacademy/perseus@17.0.0
|
|
31
|
+
|
|
3
32
|
## 2.12.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import * as i18n$1 from '@khanacademy/wonder-blocks-i18n';
|
|
|
24
24
|
|
|
25
25
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
26
26
|
const libName = "@khanacademy/perseus-editor";
|
|
27
|
-
const libVersion = "2.
|
|
27
|
+
const libVersion = "2.14.0";
|
|
28
28
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
29
29
|
|
|
30
30
|
function _extends() {
|
|
@@ -23868,7 +23868,11 @@ class ItemExtrasEditor extends React.Component {
|
|
|
23868
23868
|
checked: this.props.periodicTable,
|
|
23869
23869
|
onChange: e => {
|
|
23870
23870
|
this.props.onChange({
|
|
23871
|
-
periodicTable: e.target.checked
|
|
23871
|
+
periodicTable: e.target.checked,
|
|
23872
|
+
// If the periodic table is unchecked,
|
|
23873
|
+
// this needs to be reset. If table is
|
|
23874
|
+
// checked, it should already be false.
|
|
23875
|
+
periodicTableWithKey: false
|
|
23872
23876
|
});
|
|
23873
23877
|
}
|
|
23874
23878
|
})), /*#__PURE__*/React.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.createElement("div", null, /*#__PURE__*/React.createElement("label", null, "Include key/legend with periodic table:", " ", /*#__PURE__*/React.createElement("input", {
|
|
@@ -23906,15 +23910,6 @@ class ItemExtrasEditor extends React.Component {
|
|
|
23906
23910
|
})), /*#__PURE__*/React.createElement(InfoTip$m, null, "This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions."))));
|
|
23907
23911
|
}
|
|
23908
23912
|
}
|
|
23909
|
-
ItemExtrasEditor.propTypes = {
|
|
23910
|
-
calculator: PropTypes.bool,
|
|
23911
|
-
chi2Table: PropTypes.bool,
|
|
23912
|
-
onChange: PropTypes.func.isRequired,
|
|
23913
|
-
periodicTable: PropTypes.bool,
|
|
23914
|
-
periodicTableWithKey: PropTypes.bool,
|
|
23915
|
-
tTable: PropTypes.bool,
|
|
23916
|
-
zTable: PropTypes.bool
|
|
23917
|
-
};
|
|
23918
23913
|
ItemExtrasEditor.defaultProps = {
|
|
23919
23914
|
calculator: false,
|
|
23920
23915
|
chi2Table: false,
|
|
@@ -26757,12 +26752,12 @@ const SortableItem = createReactClass({
|
|
|
26757
26752
|
|
|
26758
26753
|
const {
|
|
26759
26754
|
InfoTip: InfoTip$j,
|
|
26760
|
-
PropCheckBox: PropCheckBox$b
|
|
26761
|
-
TexButtons
|
|
26755
|
+
PropCheckBox: PropCheckBox$b
|
|
26762
26756
|
} = components;
|
|
26763
26757
|
|
|
26764
26758
|
// types for iterables
|
|
26765
26759
|
|
|
26760
|
+
const buttonSetsList = ["basic", "trig", "prealgebra", "logarithms", "basic relations", "advanced relations"];
|
|
26766
26761
|
const parseAnswerKey = ({
|
|
26767
26762
|
key
|
|
26768
26763
|
}) => {
|
|
@@ -26796,13 +26791,8 @@ const _makeNewKey = answerForms => {
|
|
|
26796
26791
|
return usedKeys.length;
|
|
26797
26792
|
};
|
|
26798
26793
|
class ExpressionEditor extends React.Component {
|
|
26799
|
-
constructor(
|
|
26800
|
-
super(
|
|
26801
|
-
// Is the format of `value` TeX or plain text?
|
|
26802
|
-
// TODO(alex): Remove after backfilling everything to TeX
|
|
26803
|
-
// TODO(joel) - sucks if you edit some expression without
|
|
26804
|
-
// backslashes or curly braces, then come back to the question and
|
|
26805
|
-
// it's surprisingly not TeX anymore.
|
|
26794
|
+
constructor(...args) {
|
|
26795
|
+
super(...args);
|
|
26806
26796
|
this.serialize = () => {
|
|
26807
26797
|
const formSerializables = ["value", "form", "simplify", "considered",
|
|
26808
26798
|
// it's a little weird to serialize the react key, but saves some
|
|
@@ -26896,7 +26886,7 @@ class ExpressionEditor extends React.Component {
|
|
|
26896
26886
|
};
|
|
26897
26887
|
// called when the selected buttonset changes
|
|
26898
26888
|
this.handleButtonSet = changingName => {
|
|
26899
|
-
const buttonSetNames =
|
|
26889
|
+
const buttonSetNames = buttonSetsList;
|
|
26900
26890
|
|
|
26901
26891
|
// Filter to preserve order - using .union and .difference would always
|
|
26902
26892
|
// move the last added button set to the end.
|
|
@@ -26936,22 +26926,6 @@ class ExpressionEditor extends React.Component {
|
|
|
26936
26926
|
newProps.functions = e.target.value.split(/[ ,]+/).filter(isTruthy);
|
|
26937
26927
|
this.props.onChange(newProps);
|
|
26938
26928
|
};
|
|
26939
|
-
let isTex;
|
|
26940
|
-
// default to TeX if new;
|
|
26941
|
-
if (_props.answerForms.length === 0) {
|
|
26942
|
-
isTex = true;
|
|
26943
|
-
} else {
|
|
26944
|
-
isTex = _props.answerForms.some(form => {
|
|
26945
|
-
const {
|
|
26946
|
-
value
|
|
26947
|
-
} = form;
|
|
26948
|
-
// only TeX has backslashes and curly braces
|
|
26949
|
-
return value.indexOf("\\") !== -1 || value.indexOf("{") !== -1;
|
|
26950
|
-
});
|
|
26951
|
-
}
|
|
26952
|
-
this.state = {
|
|
26953
|
-
isTex
|
|
26954
|
-
};
|
|
26955
26929
|
}
|
|
26956
26930
|
change(...args) {
|
|
26957
26931
|
return Changeable.change.apply(this, args);
|
|
@@ -26993,14 +26967,13 @@ class ExpressionEditor extends React.Component {
|
|
|
26993
26967
|
});
|
|
26994
26968
|
|
|
26995
26969
|
// checkboxes to choose which sets of input buttons are shown
|
|
26996
|
-
const buttonSetChoices =
|
|
26970
|
+
const buttonSetChoices = buttonSetsList.map(name => {
|
|
26997
26971
|
// The first one gets special cased to always be checked, disabled,
|
|
26998
26972
|
// and float left.
|
|
26999
26973
|
const isFirst = name === "basic";
|
|
27000
26974
|
const checked = this.props.buttonSets.includes(name) || isFirst;
|
|
27001
|
-
const className = isFirst ? "button-set-label-float" : "button-set-label";
|
|
27002
26975
|
return /*#__PURE__*/React.createElement("label", {
|
|
27003
|
-
className:
|
|
26976
|
+
className: "button-set-label",
|
|
27004
26977
|
key: name
|
|
27005
26978
|
}, /*#__PURE__*/React.createElement("input", {
|
|
27006
26979
|
type: "checkbox",
|
|
@@ -27013,7 +26986,8 @@ class ExpressionEditor extends React.Component {
|
|
|
27013
26986
|
TeX
|
|
27014
26987
|
} = Dependencies.getDependencies(); // OldExpression only
|
|
27015
26988
|
|
|
27016
|
-
buttonSetChoices.
|
|
26989
|
+
buttonSetChoices.unshift( /*#__PURE__*/React.createElement("label", {
|
|
26990
|
+
className: "button-set-label",
|
|
27017
26991
|
key: "show-div"
|
|
27018
26992
|
}, /*#__PURE__*/React.createElement("input", {
|
|
27019
26993
|
type: "checkbox",
|
|
@@ -27034,12 +27008,7 @@ class ExpressionEditor extends React.Component {
|
|
|
27034
27008
|
type: "text",
|
|
27035
27009
|
defaultValue: this.props.functions.join(" "),
|
|
27036
27010
|
onChange: this.handleFunctions
|
|
27037
|
-
})), /*#__PURE__*/React.createElement(InfoTip$j, null, /*#__PURE__*/React.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.createElement("div", null, /*#__PURE__*/React.createElement("div", null, "Button sets:"), buttonSetChoices),
|
|
27038
|
-
className: "math-input-buttons",
|
|
27039
|
-
sets: this.props.buttonSets,
|
|
27040
|
-
convertDotToTimes: this.props.times,
|
|
27041
|
-
onInsert: this.handleTexInsert
|
|
27042
|
-
}), /*#__PURE__*/React.createElement("h3", {
|
|
27011
|
+
})), /*#__PURE__*/React.createElement(InfoTip$j, null, /*#__PURE__*/React.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.createElement("div", null, /*#__PURE__*/React.createElement("div", null, "Button sets:"), buttonSetChoices), /*#__PURE__*/React.createElement("h3", {
|
|
27043
27012
|
className: "expression-editor-h3"
|
|
27044
27013
|
}, "Answers"), /*#__PURE__*/React.createElement("p", {
|
|
27045
27014
|
style: {
|
|
@@ -30806,6 +30775,7 @@ const {
|
|
|
30806
30775
|
const Behavior = ({
|
|
30807
30776
|
multipleAnswers,
|
|
30808
30777
|
hideChoicesFromInstructions,
|
|
30778
|
+
preferredPopoverDirection,
|
|
30809
30779
|
onChange
|
|
30810
30780
|
}) => /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
30811
30781
|
className: css(styles$5.title)
|
|
@@ -30827,7 +30797,28 @@ const Behavior = ({
|
|
|
30827
30797
|
})
|
|
30828
30798
|
}), /*#__PURE__*/React.createElement("span", {
|
|
30829
30799
|
className: css(styles$5.label)
|
|
30830
|
-
}, "Do not display answer choices in instructions"))
|
|
30800
|
+
}, "Do not display answer choices in instructions")), /*#__PURE__*/React.createElement("li", {
|
|
30801
|
+
className: css(styles$5.option)
|
|
30802
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
30803
|
+
className: css(styles$5.label)
|
|
30804
|
+
}, "Preferred pop-over direction"), /*#__PURE__*/React.createElement("select", {
|
|
30805
|
+
value: preferredPopoverDirection,
|
|
30806
|
+
onChange: e => {
|
|
30807
|
+
onChange({
|
|
30808
|
+
preferredPopoverDirection: e.target.value
|
|
30809
|
+
});
|
|
30810
|
+
}
|
|
30811
|
+
}, /*#__PURE__*/React.createElement("option", {
|
|
30812
|
+
value: "NONE"
|
|
30813
|
+
}, " No Preference "), /*#__PURE__*/React.createElement("option", {
|
|
30814
|
+
value: "UP"
|
|
30815
|
+
}, " Up "), /*#__PURE__*/React.createElement("option", {
|
|
30816
|
+
value: "DOWN"
|
|
30817
|
+
}, " Down "), /*#__PURE__*/React.createElement("option", {
|
|
30818
|
+
value: "LEFT"
|
|
30819
|
+
}, " Left "), /*#__PURE__*/React.createElement("option", {
|
|
30820
|
+
value: "RIGHT"
|
|
30821
|
+
}, " Right ")))));
|
|
30831
30822
|
const styles$5 = StyleSheet.create({
|
|
30832
30823
|
title: _extends({}, typography$2.bodyXsmallBold, {
|
|
30833
30824
|
marginBottom: 6,
|
|
@@ -31601,6 +31592,7 @@ class LabelImageEditor extends React.Component {
|
|
|
31601
31592
|
}), /*#__PURE__*/React.createElement("div", {
|
|
31602
31593
|
className: css(styles.largeSpacer)
|
|
31603
31594
|
}), /*#__PURE__*/React.createElement(Behavior, {
|
|
31595
|
+
preferredPopoverDirection: "NONE",
|
|
31604
31596
|
multipleAnswers: multipleAnswers,
|
|
31605
31597
|
hideChoicesFromInstructions: hideChoicesFromInstructions,
|
|
31606
31598
|
onChange: this.handleBehaviorChange
|