@khanacademy/perseus-editor 6.0.1 → 6.0.3
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 +89 -91
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +36 -29
- package/dist/index.js.map +1 -1
- package/dist/widgets/numeric-input-editor.d.ts +9 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -67,7 +67,7 @@ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
|
67
67
|
|
|
68
68
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
69
69
|
const libName = "@khanacademy/perseus-editor";
|
|
70
|
-
const libVersion = "6.0.
|
|
70
|
+
const libVersion = "6.0.3";
|
|
71
71
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
72
72
|
|
|
73
73
|
function _extends() {
|
|
@@ -33732,20 +33732,23 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
33732
33732
|
className: "msg-title"
|
|
33733
33733
|
}, "Message shown to user on attempt"), generateInputAnswerEditors(), addAnswerButton, inputSize, rightAlign, coefficientCheck, labelText);
|
|
33734
33734
|
}
|
|
33735
|
-
change() {
|
|
33736
|
-
|
|
33737
|
-
|
|
33738
|
-
|
|
33739
|
-
|
|
33740
|
-
|
|
33741
|
-
|
|
33735
|
+
change = (() => {
|
|
33736
|
+
var _this = this;
|
|
33737
|
+
return function () {
|
|
33738
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33739
|
+
args[_key] = arguments[_key];
|
|
33740
|
+
}
|
|
33741
|
+
return perseus.Changeable.change.apply(_this, args);
|
|
33742
|
+
};
|
|
33743
|
+
})();
|
|
33744
|
+
onToggleOptions = choiceIndex => {
|
|
33742
33745
|
const showOptions = this.state.showOptions.slice();
|
|
33743
33746
|
showOptions[choiceIndex] = !showOptions[choiceIndex];
|
|
33744
33747
|
this.setState({
|
|
33745
33748
|
showOptions: showOptions
|
|
33746
33749
|
});
|
|
33747
|
-
}
|
|
33748
|
-
onTrashAnswer
|
|
33750
|
+
};
|
|
33751
|
+
onTrashAnswer = choiceIndex => {
|
|
33749
33752
|
if (choiceIndex >= 0 && choiceIndex < this.props.answers.length) {
|
|
33750
33753
|
const answers = this.props.answers.slice(0);
|
|
33751
33754
|
answers.splice(choiceIndex, 1);
|
|
@@ -33753,16 +33756,20 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
33753
33756
|
answers: answers
|
|
33754
33757
|
});
|
|
33755
33758
|
}
|
|
33756
|
-
}
|
|
33757
|
-
onSpace(
|
|
33758
|
-
|
|
33759
|
-
|
|
33760
|
-
|
|
33761
|
-
|
|
33762
|
-
|
|
33763
|
-
|
|
33764
|
-
|
|
33765
|
-
|
|
33759
|
+
};
|
|
33760
|
+
onSpace = (() => {
|
|
33761
|
+
var _this2 = this;
|
|
33762
|
+
return function (e, callback) {
|
|
33763
|
+
if (e.key === " ") {
|
|
33764
|
+
e.preventDefault(); // prevent page shifting
|
|
33765
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
33766
|
+
args[_key2 - 2] = arguments[_key2];
|
|
33767
|
+
}
|
|
33768
|
+
callback.apply(_this2, args);
|
|
33769
|
+
}
|
|
33770
|
+
};
|
|
33771
|
+
})();
|
|
33772
|
+
onStatusChange = choiceIndex => {
|
|
33766
33773
|
const statuses = ["wrong", "ungraded", "correct"];
|
|
33767
33774
|
const answers = this.props.answers;
|
|
33768
33775
|
const i = ___default["default"].indexOf(statuses, answers[choiceIndex].status);
|
|
@@ -33771,8 +33778,8 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
33771
33778
|
status: newStatus,
|
|
33772
33779
|
simplify: newStatus === "correct" ? "required" : "accepted"
|
|
33773
33780
|
});
|
|
33774
|
-
}
|
|
33775
|
-
updateAnswer(choiceIndex, update) {
|
|
33781
|
+
};
|
|
33782
|
+
updateAnswer = (choiceIndex, update) => {
|
|
33776
33783
|
if (!___default["default"].isObject(update)) {
|
|
33777
33784
|
return ___default["default"].partial((choiceIndex, key, value) => {
|
|
33778
33785
|
const update = {};
|
|
@@ -33795,15 +33802,15 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
33795
33802
|
this.props.onChange({
|
|
33796
33803
|
answers: answers
|
|
33797
33804
|
});
|
|
33798
|
-
}
|
|
33799
|
-
addAnswer() {
|
|
33805
|
+
};
|
|
33806
|
+
addAnswer = () => {
|
|
33800
33807
|
const lastAnswer = initAnswer(this.state.lastStatus);
|
|
33801
33808
|
const answers = this.props.answers.concat(lastAnswer);
|
|
33802
33809
|
this.props.onChange({
|
|
33803
33810
|
answers: answers
|
|
33804
33811
|
});
|
|
33805
|
-
}
|
|
33806
|
-
getSaveWarnings() {
|
|
33812
|
+
};
|
|
33813
|
+
getSaveWarnings = () => {
|
|
33807
33814
|
// Filter out all the empty answers
|
|
33808
33815
|
const warnings = [];
|
|
33809
33816
|
// TODO(emily): This doesn't actually work, because the value is either
|
|
@@ -33821,10 +33828,10 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
33821
33828
|
}
|
|
33822
33829
|
});
|
|
33823
33830
|
return warnings;
|
|
33824
|
-
}
|
|
33825
|
-
serialize() {
|
|
33831
|
+
};
|
|
33832
|
+
serialize = () => {
|
|
33826
33833
|
return perseus.EditorJsonify.serialize.call(this);
|
|
33827
|
-
}
|
|
33834
|
+
};
|
|
33828
33835
|
}
|
|
33829
33836
|
|
|
33830
33837
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|