@khanacademy/perseus-editor 5.0.1 → 5.0.2
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 = "5.0.
|
|
67
|
+
const libVersion = "5.0.2";
|
|
68
68
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
69
69
|
|
|
70
70
|
function _extends() {
|
|
@@ -27510,7 +27510,6 @@ const GraphSettings = createReactClass__default["default"]({
|
|
|
27510
27510
|
const {
|
|
27511
27511
|
TeX
|
|
27512
27512
|
} = perseus.Dependencies.getDependencies();
|
|
27513
|
-
this.props.box; // ?
|
|
27514
27513
|
return /*#__PURE__*/React__namespace.createElement("div", null, ___default["default"].contains(this.props.editableSettings, "canvas") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
27515
27514
|
className: "graph-settings"
|
|
27516
27515
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -29607,6 +29606,9 @@ function numSteps(range, step) {
|
|
|
29607
29606
|
}
|
|
29608
29607
|
class InteractiveGraphSettings extends React__namespace.Component {
|
|
29609
29608
|
_isMounted = false;
|
|
29609
|
+
bgUrlRef = /*#__PURE__*/React__namespace.createRef();
|
|
29610
|
+
labelXRef = /*#__PURE__*/React__namespace.createRef();
|
|
29611
|
+
labelYRef = /*#__PURE__*/React__namespace.createRef();
|
|
29610
29612
|
static stateFromProps(props) {
|
|
29611
29613
|
return {
|
|
29612
29614
|
labelsTextbox: props.labels,
|
|
@@ -29614,7 +29616,10 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29614
29616
|
snapStepTextbox: props.snapStep,
|
|
29615
29617
|
stepTextbox: props.step,
|
|
29616
29618
|
rangeTextbox: props.range,
|
|
29617
|
-
|
|
29619
|
+
// Shallow-copied clone
|
|
29620
|
+
backgroundImage: {
|
|
29621
|
+
...props.backgroundImage
|
|
29622
|
+
}
|
|
29618
29623
|
};
|
|
29619
29624
|
}
|
|
29620
29625
|
constructor(props) {
|
|
@@ -29622,7 +29627,6 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29622
29627
|
this.state = InteractiveGraphSettings.stateFromProps(props);
|
|
29623
29628
|
}
|
|
29624
29629
|
static defaultProps = {
|
|
29625
|
-
editableSettings: ["graph", "snap", "image", "measure"],
|
|
29626
29630
|
box: [perseus.interactiveSizes.defaultBoxSizeSmall, perseus.interactiveSizes.defaultBoxSizeSmall],
|
|
29627
29631
|
labels: ["x", "y"],
|
|
29628
29632
|
range: [[-10, 10], [-10, 10]],
|
|
@@ -29682,7 +29686,10 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29682
29686
|
return;
|
|
29683
29687
|
}
|
|
29684
29688
|
const setUrl = (url, width, height) => {
|
|
29685
|
-
|
|
29689
|
+
// Shallow-copied clone
|
|
29690
|
+
const image = {
|
|
29691
|
+
...this.props.backgroundImage
|
|
29692
|
+
};
|
|
29686
29693
|
image.url = url;
|
|
29687
29694
|
image.width = width;
|
|
29688
29695
|
image.height = height;
|
|
@@ -29690,9 +29697,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29690
29697
|
backgroundImage: image
|
|
29691
29698
|
}, this.changeGraph);
|
|
29692
29699
|
};
|
|
29693
|
-
|
|
29694
|
-
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
29695
|
-
const url = ReactDOM__default["default"].findDOMNode(this.refs["bg-url"]).value; // eslint-disable-line react/no-string-refs
|
|
29700
|
+
const url = this.bgUrlRef.current?.value;
|
|
29696
29701
|
if (url) {
|
|
29697
29702
|
perseus.Util.getImageSize(url, (width, height) => {
|
|
29698
29703
|
if (this._isMounted) {
|
|
@@ -29704,11 +29709,10 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29704
29709
|
}
|
|
29705
29710
|
};
|
|
29706
29711
|
renderLabelChoices = choices => {
|
|
29707
|
-
return
|
|
29708
|
-
|
|
29709
|
-
|
|
29710
|
-
|
|
29711
|
-
});
|
|
29712
|
+
return choices.map(nameAndValue => /*#__PURE__*/React__namespace.createElement("option", {
|
|
29713
|
+
key: nameAndValue[1],
|
|
29714
|
+
value: nameAndValue[1]
|
|
29715
|
+
}, nameAndValue[0]));
|
|
29712
29716
|
};
|
|
29713
29717
|
validRange = range => {
|
|
29714
29718
|
const numbers = ___default["default"].every(range, function (num) {
|
|
@@ -29730,9 +29734,6 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29730
29734
|
minTicks,
|
|
29731
29735
|
maxTicks
|
|
29732
29736
|
} = settings;
|
|
29733
|
-
if (!___default["default"].isFinite(step)) {
|
|
29734
|
-
return name + " must be a valid number";
|
|
29735
|
-
}
|
|
29736
29737
|
const nSteps = numSteps(range, step);
|
|
29737
29738
|
if (nSteps < minTicks) {
|
|
29738
29739
|
return name + " is too large, there must be at least " + minTicks + " ticks.";
|
|
@@ -29901,27 +29902,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29901
29902
|
};
|
|
29902
29903
|
|
|
29903
29904
|
render() {
|
|
29904
|
-
|
|
29905
|
-
const {
|
|
29906
|
-
TeX
|
|
29907
|
-
} = perseus.Dependencies.getDependencies();
|
|
29908
|
-
return /*#__PURE__*/React__namespace.createElement("div", null, ___default["default"].contains(this.props.editableSettings, "canvas") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
29909
|
-
className: "graph-settings"
|
|
29910
|
-
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
29911
|
-
className: "perseus-widget-row"
|
|
29912
|
-
}, /*#__PURE__*/React__namespace.createElement("label", {
|
|
29913
|
-
htmlFor: "canvas-size"
|
|
29914
|
-
}, "Canvas size (x,y pixels)"), /*#__PURE__*/React__namespace.createElement(RangeInput$4, {
|
|
29915
|
-
id: "canvas-size",
|
|
29916
|
-
value: this.props.box,
|
|
29917
|
-
onChange: box => {
|
|
29918
|
-
this.change({
|
|
29919
|
-
box: box
|
|
29920
|
-
});
|
|
29921
|
-
}
|
|
29922
|
-
})), /*#__PURE__*/React__namespace.createElement("div", {
|
|
29923
|
-
className: "perseus-widget-row"
|
|
29924
|
-
}, "Scale (px per div):", " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(" + scale[0] + ", " + scale[1] + ")"))), ___default["default"].contains(this.props.editableSettings, "graph") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
29905
|
+
return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
29925
29906
|
className: "graph-settings"
|
|
29926
29907
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
29927
29908
|
className: "perseus-widget-row"
|
|
@@ -29932,10 +29913,8 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29932
29913
|
}, "x Label"), /*#__PURE__*/React__namespace.createElement("input", {
|
|
29933
29914
|
id: "labels-x",
|
|
29934
29915
|
type: "text",
|
|
29935
|
-
className: "graph-settings-axis-label"
|
|
29936
|
-
|
|
29937
|
-
,
|
|
29938
|
-
ref: "labels-0",
|
|
29916
|
+
className: "graph-settings-axis-label",
|
|
29917
|
+
ref: this.labelXRef,
|
|
29939
29918
|
onChange: e => this.changeLabel(0, e),
|
|
29940
29919
|
value: this.state.labelsTextbox[0] || ""
|
|
29941
29920
|
})), /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -29945,10 +29924,8 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29945
29924
|
}, "y Label"), /*#__PURE__*/React__namespace.createElement("input", {
|
|
29946
29925
|
id: "labels-y",
|
|
29947
29926
|
type: "text",
|
|
29948
|
-
className: "graph-settings-axis-label"
|
|
29949
|
-
|
|
29950
|
-
,
|
|
29951
|
-
ref: "labels-1",
|
|
29927
|
+
className: "graph-settings-axis-label",
|
|
29928
|
+
ref: this.labelYRef,
|
|
29952
29929
|
onChange: e => this.changeLabel(1, e),
|
|
29953
29930
|
value: this.state.labelsTextbox[1] || ""
|
|
29954
29931
|
}))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -29987,7 +29964,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
29987
29964
|
id: "grid-step",
|
|
29988
29965
|
value: this.state.gridStepTextbox,
|
|
29989
29966
|
onChange: this.changeGridStep
|
|
29990
|
-
}))),
|
|
29967
|
+
}))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
29991
29968
|
className: "perseus-widget-row"
|
|
29992
29969
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
29993
29970
|
className: "perseus-widget-left-col"
|
|
@@ -30019,17 +29996,15 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
30019
29996
|
label: "Show tooltips",
|
|
30020
29997
|
showTooltips: this.props.showTooltips,
|
|
30021
29998
|
onChange: this.change
|
|
30022
|
-
}))),
|
|
29999
|
+
}))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
30023
30000
|
className: "image-settings"
|
|
30024
30001
|
}, /*#__PURE__*/React__namespace.createElement("div", null, "Background image:"), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", {
|
|
30025
30002
|
htmlFor: "bg-url"
|
|
30026
30003
|
}, "Url:"), /*#__PURE__*/React__namespace.createElement("input", {
|
|
30027
30004
|
id: "bg-url",
|
|
30028
30005
|
type: "text",
|
|
30029
|
-
className: "graph-settings-background-url"
|
|
30030
|
-
|
|
30031
|
-
,
|
|
30032
|
-
ref: "bg-url",
|
|
30006
|
+
className: "graph-settings-background-url",
|
|
30007
|
+
ref: this.bgUrlRef,
|
|
30033
30008
|
value: this.state.backgroundImage.url || "",
|
|
30034
30009
|
onChange: e => {
|
|
30035
30010
|
const image = ___default["default"].clone(this.props.backgroundImage);
|
|
@@ -30040,7 +30015,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
30040
30015
|
},
|
|
30041
30016
|
onKeyPress: this.changeBackgroundUrl,
|
|
30042
30017
|
onBlur: this.changeBackgroundUrl
|
|
30043
|
-
}), /*#__PURE__*/React__namespace.createElement(InfoTip$c, null, /*#__PURE__*/React__namespace.createElement("p", null, "Create an image in graphie, or use the \"Add image\" function to create a background.")))),
|
|
30018
|
+
}), /*#__PURE__*/React__namespace.createElement(InfoTip$c, null, /*#__PURE__*/React__namespace.createElement("p", null, "Create an image in graphie, or use the \"Add image\" function to create a background.")))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
30044
30019
|
className: "misc-settings"
|
|
30045
30020
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
30046
30021
|
className: "perseus-widget-row"
|
|
@@ -30070,6 +30045,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
30070
30045
|
value: this.props.rulerTicks
|
|
30071
30046
|
}, ___default["default"].map([1, 2, 4, 8, 10, 16], function (n) {
|
|
30072
30047
|
return /*#__PURE__*/React__namespace.createElement("option", {
|
|
30048
|
+
key: `ruler-tick-${n}`,
|
|
30073
30049
|
value: n
|
|
30074
30050
|
}, n);
|
|
30075
30051
|
})))))));
|
|
@@ -30183,6 +30159,7 @@ class InteractiveGraphEditor extends React__namespace.Component {
|
|
|
30183
30159
|
markings: this.props.markings,
|
|
30184
30160
|
showProtractor: this.props.showProtractor,
|
|
30185
30161
|
showRuler: this.props.showRuler,
|
|
30162
|
+
showTooltips: this.props.showTooltips,
|
|
30186
30163
|
rulerLabel: this.props.rulerLabel,
|
|
30187
30164
|
rulerTicks: this.props.rulerTicks,
|
|
30188
30165
|
trackInteraction: function () {},
|