@khanacademy/perseus-editor 17.2.0 → 17.3.1
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/components/graph-settings.d.ts +1 -2
- package/dist/es/index.js +17 -66
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +16 -65
- package/dist/index.js.map +1 -1
- package/dist/widgets/interaction-editor/interaction-editor.d.ts +1 -2
- package/dist/widgets/interactive-graph-editor/interactive-graph-editor.d.ts +68 -68
- package/dist/widgets/label-image/marker.d.ts +1 -1
- package/dist/widgets/label-image/question-markers.d.ts +1 -1
- package/dist/widgets/label-image-editor.d.ts +1 -1
- package/package.json +11 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import type { Coords } from "@khanacademy/perseus";
|
|
4
|
-
import type { MarkingsType } from "@khanacademy/perseus-core";
|
|
3
|
+
import type { Coords, MarkingsType } from "@khanacademy/perseus-core";
|
|
5
4
|
type Props = {
|
|
6
5
|
editableSettings: ReadonlyArray<"canvas" | "graph" | "snap" | "image" | "measure">;
|
|
7
6
|
box: readonly number[];
|
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addLibraryVersionToPerseusDebug, PerseusError, Errors, ItemExtras, PerseusExpressionAnswerFormConsidered, lockedFigureColors, lockedFigureFillStyles, plotterPlotTypes } 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,
|
|
1
|
+
import { addLibraryVersionToPerseusDebug, PerseusError, Errors, ItemExtras, PerseusExpressionAnswerFormConsidered, GrapherUtil as GrapherUtil$1, lockedFigureColors, lockedFigureFillStyles, getMatrixSize, plotterPlotTypes } 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';
|
|
3
3
|
export { widgets } from '@khanacademy/perseus';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useId, useRef, useEffect, useState } from 'react';
|
|
@@ -20,7 +20,8 @@ import ReactDOM from 'react-dom';
|
|
|
20
20
|
import * as KAS from '@khanacademy/kas';
|
|
21
21
|
import Button from '@khanacademy/wonder-blocks-button';
|
|
22
22
|
import { isTruthy, UnreachableCaseError } from '@khanacademy/wonder-stuff-core';
|
|
23
|
-
import { KhanMath, vector, number } from '@khanacademy/kmath';
|
|
23
|
+
import { KhanMath, vector, angles, number } from '@khanacademy/kmath';
|
|
24
|
+
import { inputNumberAnswerTypes } from '@khanacademy/perseus-score';
|
|
24
25
|
import { useMathInputI18n, createMathField } from '@khanacademy/math-input';
|
|
25
26
|
import { SingleSelect, OptionItem, ActionMenu, ActionItem } from '@khanacademy/wonder-blocks-dropdown';
|
|
26
27
|
import Banner from '@khanacademy/wonder-blocks-banner';
|
|
@@ -46,7 +47,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
|
|
|
46
47
|
|
|
47
48
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
48
49
|
const libName = "@khanacademy/perseus-editor";
|
|
49
|
-
const libVersion = "17.
|
|
50
|
+
const libVersion = "17.3.1";
|
|
50
51
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
51
52
|
|
|
52
53
|
function _extends() {
|
|
@@ -21619,7 +21620,12 @@ class Editor extends React.Component {
|
|
|
21619
21620
|
if (!Widgets.getEditor(type)) {
|
|
21620
21621
|
return;
|
|
21621
21622
|
}
|
|
21622
|
-
return /*#__PURE__*/React.createElement(WidgetEditor
|
|
21623
|
+
return /*#__PURE__*/React.createElement(WidgetEditor
|
|
21624
|
+
// The order of props matters here. We need to spread the
|
|
21625
|
+
// widget data before specifying the `key` prop, to ensure the
|
|
21626
|
+
// key overrides any `key` field on the widget (which might not
|
|
21627
|
+
// be unique.
|
|
21628
|
+
, _extends({}, this.props.widgets[id], {
|
|
21623
21629
|
ref: id,
|
|
21624
21630
|
id: id,
|
|
21625
21631
|
key: id
|
|
@@ -21631,7 +21637,7 @@ class Editor extends React.Component {
|
|
|
21631
21637
|
onRemove: this._handleWidgetEditorRemove.bind(this, id),
|
|
21632
21638
|
apiOptions: this.props.apiOptions,
|
|
21633
21639
|
widgetIsOpen: this.props.widgetIsOpen
|
|
21634
|
-
}
|
|
21640
|
+
}));
|
|
21635
21641
|
}
|
|
21636
21642
|
render() {
|
|
21637
21643
|
let pieces;
|
|
@@ -26337,7 +26343,6 @@ const {
|
|
|
26337
26343
|
const Grapher = GrapherWidget.widget;
|
|
26338
26344
|
const {
|
|
26339
26345
|
DEFAULT_GRAPHER_PROPS,
|
|
26340
|
-
allTypes,
|
|
26341
26346
|
chooseType,
|
|
26342
26347
|
defaultPlotProps,
|
|
26343
26348
|
getEquationString,
|
|
@@ -26432,7 +26437,7 @@ class GrapherEditor extends React.Component {
|
|
|
26432
26437
|
}, /*#__PURE__*/React.createElement("label", null, "Available functions: "), /*#__PURE__*/React.createElement(MultiButtonGroup$1, {
|
|
26433
26438
|
allowEmpty: false,
|
|
26434
26439
|
values: this.props.availableTypes,
|
|
26435
|
-
buttons: _.map(allTypes, typeToButton),
|
|
26440
|
+
buttons: _.map(GrapherUtil$1.allTypes, typeToButton),
|
|
26436
26441
|
onChange: this.handleAvailableTypesChange
|
|
26437
26442
|
})), graph);
|
|
26438
26443
|
}
|
|
@@ -26898,40 +26903,6 @@ ImageEditor.defaultProps = {
|
|
|
26898
26903
|
const {
|
|
26899
26904
|
InfoTip: InfoTip$g
|
|
26900
26905
|
} = components;
|
|
26901
|
-
const answerTypes = {
|
|
26902
|
-
number: {
|
|
26903
|
-
name: "Numbers",
|
|
26904
|
-
forms: "integer, decimal, proper, improper, mixed"
|
|
26905
|
-
},
|
|
26906
|
-
decimal: {
|
|
26907
|
-
name: "Decimals",
|
|
26908
|
-
forms: "decimal"
|
|
26909
|
-
},
|
|
26910
|
-
integer: {
|
|
26911
|
-
name: "Integers",
|
|
26912
|
-
forms: "integer"
|
|
26913
|
-
},
|
|
26914
|
-
rational: {
|
|
26915
|
-
name: "Fractions and mixed numbers",
|
|
26916
|
-
forms: "integer, proper, improper, mixed"
|
|
26917
|
-
},
|
|
26918
|
-
improper: {
|
|
26919
|
-
name: "Improper numbers (no mixed)",
|
|
26920
|
-
forms: "integer, proper, improper"
|
|
26921
|
-
},
|
|
26922
|
-
mixed: {
|
|
26923
|
-
name: "Mixed numbers (no improper)",
|
|
26924
|
-
forms: "integer, proper, mixed"
|
|
26925
|
-
},
|
|
26926
|
-
percent: {
|
|
26927
|
-
name: "Numbers or percents",
|
|
26928
|
-
forms: "integer, decimal, proper, improper, mixed, percent"
|
|
26929
|
-
},
|
|
26930
|
-
pi: {
|
|
26931
|
-
name: "Numbers with pi",
|
|
26932
|
-
forms: "pi"
|
|
26933
|
-
}
|
|
26934
|
-
};
|
|
26935
26906
|
class InputNumberEditor extends React.Component {
|
|
26936
26907
|
constructor(...args) {
|
|
26937
26908
|
super(...args);
|
|
@@ -26958,7 +26929,7 @@ class InputNumberEditor extends React.Component {
|
|
|
26958
26929
|
});
|
|
26959
26930
|
}
|
|
26960
26931
|
render() {
|
|
26961
|
-
const answerTypeOptions = _.map(
|
|
26932
|
+
const answerTypeOptions = _.map(inputNumberAnswerTypes, function (v, k) {
|
|
26962
26933
|
return /*#__PURE__*/React.createElement("option", {
|
|
26963
26934
|
value: k,
|
|
26964
26935
|
key: k
|
|
@@ -96307,6 +96278,9 @@ const styles$i = StyleSheet.create({
|
|
|
96307
96278
|
}
|
|
96308
96279
|
});
|
|
96309
96280
|
|
|
96281
|
+
const {
|
|
96282
|
+
getClockwiseAngle
|
|
96283
|
+
} = angles;
|
|
96310
96284
|
function getStartCoords(graph) {
|
|
96311
96285
|
if ("startCoords" in graph) {
|
|
96312
96286
|
return graph.startCoords;
|
|
@@ -98977,29 +98951,6 @@ const Matrix = MatrixWidget.widget;
|
|
|
98977
98951
|
// Really large matrices will cause issues with question formatting, so we
|
|
98978
98952
|
// have to cap it at some point.
|
|
98979
98953
|
const MAX_BOARD_SIZE = 6;
|
|
98980
|
-
const getMatrixSize = function getMatrixSize(matrix) {
|
|
98981
|
-
const matrixSize = [1, 1];
|
|
98982
|
-
|
|
98983
|
-
// We need to find the widest row and tallest column to get the correct
|
|
98984
|
-
// matrix size.
|
|
98985
|
-
_(matrix).each((matrixRow, row) => {
|
|
98986
|
-
let rowWidth = 0;
|
|
98987
|
-
_(matrixRow).each((matrixCol, col) => {
|
|
98988
|
-
if (matrixCol != null && matrixCol.toString().length) {
|
|
98989
|
-
rowWidth = col + 1;
|
|
98990
|
-
}
|
|
98991
|
-
});
|
|
98992
|
-
|
|
98993
|
-
// Matrix width:
|
|
98994
|
-
matrixSize[1] = Math.max(matrixSize[1], rowWidth);
|
|
98995
|
-
|
|
98996
|
-
// Matrix height:
|
|
98997
|
-
if (rowWidth > 0) {
|
|
98998
|
-
matrixSize[0] = Math.max(matrixSize[0], row + 1);
|
|
98999
|
-
}
|
|
99000
|
-
});
|
|
99001
|
-
return matrixSize;
|
|
99002
|
-
};
|
|
99003
98954
|
class MatrixEditor extends React.Component {
|
|
99004
98955
|
constructor(..._args) {
|
|
99005
98956
|
super(..._args);
|