@khanacademy/perseus-editor 14.7.0 → 14.8.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/components/widget-editor.d.ts +1 -1
- package/dist/editor.d.ts +2 -4
- package/dist/es/index.js +28 -71
- package/dist/es/index.js.map +1 -1
- package/dist/hint-editor.d.ts +2 -2
- package/dist/index.js +30 -71
- package/dist/index.js.map +1 -1
- package/dist/widgets/interactive-graph-editor/interactive-graph-editor.d.ts +61 -0
- package/package.json +2 -2
package/dist/hint-editor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import Editor from "./editor";
|
|
3
|
-
import type { APIOptions,
|
|
3
|
+
import type { APIOptions, ImageDict, Hint, ChangeHandler, DeviceType, ImageUploader, PerseusWidgetsMap } from "@khanacademy/perseus";
|
|
4
4
|
type HintEditorProps = {
|
|
5
5
|
itemId?: string;
|
|
6
6
|
apiOptions?: APIOptions;
|
|
@@ -11,7 +11,7 @@ type HintEditorProps = {
|
|
|
11
11
|
showTitle?: boolean;
|
|
12
12
|
content?: string | null | undefined;
|
|
13
13
|
replace?: boolean | null | undefined;
|
|
14
|
-
widgets?:
|
|
14
|
+
widgets?: PerseusWidgetsMap | null | undefined;
|
|
15
15
|
images?: ImageDict | null | undefined;
|
|
16
16
|
isLast: boolean;
|
|
17
17
|
isFirst: boolean;
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ var arrowCounterClockwise__default = /*#__PURE__*/_interopDefaultLegacy(arrowCou
|
|
|
98
98
|
|
|
99
99
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
100
100
|
const libName = "@khanacademy/perseus-editor";
|
|
101
|
-
const libVersion = "14.
|
|
101
|
+
const libVersion = "14.8.0";
|
|
102
102
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
103
103
|
|
|
104
104
|
function _extends() {
|
|
@@ -21354,7 +21354,7 @@ class Editor extends React__namespace.Component {
|
|
|
21354
21354
|
if (matches != null) {
|
|
21355
21355
|
const text = matches[1];
|
|
21356
21356
|
const widgets = perseus.Widgets.getAllWidgetTypes();
|
|
21357
|
-
const matchingWidgets =
|
|
21357
|
+
const matchingWidgets = widgets.filter(name => {
|
|
21358
21358
|
return name.substring(0, text.length) === text;
|
|
21359
21359
|
});
|
|
21360
21360
|
if (matchingWidgets.length === 1) {
|
|
@@ -21513,8 +21513,9 @@ class Editor extends React__namespace.Component {
|
|
|
21513
21513
|
const newPrelude = isBlock ? makeEndWithAParagraphIfNecessary(prelude) : prelude;
|
|
21514
21514
|
const newPostlude = isBlock ? makeStartWithAParagraphAlways(postlude) : postlude;
|
|
21515
21515
|
const newContent = newPrelude + widgetContent + newPostlude;
|
|
21516
|
-
const newWidgets =
|
|
21517
|
-
|
|
21516
|
+
const newWidgets = {
|
|
21517
|
+
...this.props.widgets
|
|
21518
|
+
};
|
|
21518
21519
|
newWidgets[id] = {
|
|
21519
21520
|
options: perseus.Widgets.getEditor(widgetType)?.defaultProps,
|
|
21520
21521
|
type: widgetType,
|
|
@@ -31100,28 +31101,21 @@ const LockedEllipseSettings = props => {
|
|
|
31100
31101
|
onRemove
|
|
31101
31102
|
} = props;
|
|
31102
31103
|
function getPrepopulatedAriaLabel() {
|
|
31104
|
+
let visiblelabel = "";
|
|
31105
|
+
if (labels && labels.length > 0) {
|
|
31106
|
+
visiblelabel += ` ${labels.map(l => l.text).join(" ")}`;
|
|
31107
|
+
}
|
|
31103
31108
|
const isCircle = radius[0] === radius[1];
|
|
31104
31109
|
let str = "";
|
|
31105
31110
|
if (isCircle) {
|
|
31106
|
-
str += `Circle with radius ${radius[0]}`;
|
|
31111
|
+
str += `Circle${visiblelabel} with radius ${radius[0]}`;
|
|
31107
31112
|
} else {
|
|
31108
|
-
str += `Ellipse with x radius ${radius[0]} and y radius ${radius[1]}`;
|
|
31113
|
+
str += `Ellipse${visiblelabel} with x radius ${radius[0]} and y radius ${radius[1]}`;
|
|
31109
31114
|
}
|
|
31110
31115
|
str += `, centered at (${center[0]}, ${center[1]})`;
|
|
31111
31116
|
if (!isCircle && angle !== 0) {
|
|
31112
31117
|
str += `, rotated by ${radianToDegree(angle)} degrees`;
|
|
31113
31118
|
}
|
|
31114
|
-
if (labels && labels.length > 0) {
|
|
31115
|
-
str += ", with label";
|
|
31116
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31117
|
-
// multiple labels.
|
|
31118
|
-
if (labels.length > 1) {
|
|
31119
|
-
str += "s";
|
|
31120
|
-
}
|
|
31121
|
-
|
|
31122
|
-
// Separate additional labels with commas.
|
|
31123
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31124
|
-
}
|
|
31125
31119
|
return str;
|
|
31126
31120
|
}
|
|
31127
31121
|
function handleCenterChange(newCoord) {
|
|
@@ -31371,24 +31365,17 @@ const LockedFunctionSettings = props => {
|
|
|
31371
31365
|
setDomainEntries([domain && domain[0] !== -Infinity ? domain[0].toString() : "", domain && domain[1] !== Infinity ? domain[1].toString() : ""]);
|
|
31372
31366
|
}, [domain]);
|
|
31373
31367
|
function getPrepopulatedAriaLabel() {
|
|
31374
|
-
let
|
|
31368
|
+
let visiblelabel = "";
|
|
31369
|
+
if (labels && labels.length > 0) {
|
|
31370
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31371
|
+
}
|
|
31372
|
+
let str = `Function${visiblelabel} with equation ${equationPrefix}${equation}`;
|
|
31375
31373
|
|
|
31376
31374
|
// Add the domain/range constraints to the aria label
|
|
31377
31375
|
// if they are not the default values.
|
|
31378
31376
|
if (domain && !(domain[0] === -Infinity && domain[1] === Infinity)) {
|
|
31379
31377
|
str += `, domain from ${domain[0]} to ${domain[1]}`;
|
|
31380
31378
|
}
|
|
31381
|
-
if (labels && labels.length > 0) {
|
|
31382
|
-
str += ", with label";
|
|
31383
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31384
|
-
// multiple labels.
|
|
31385
|
-
if (labels.length > 1) {
|
|
31386
|
-
str += "s";
|
|
31387
|
-
}
|
|
31388
|
-
|
|
31389
|
-
// Separate additional labels with commas.
|
|
31390
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31391
|
-
}
|
|
31392
31379
|
return str;
|
|
31393
31380
|
}
|
|
31394
31381
|
|
|
@@ -31814,18 +31801,11 @@ const LockedPointSettings = props => {
|
|
|
31814
31801
|
* "Point at (x, y) with label1, label2, label3".
|
|
31815
31802
|
*/
|
|
31816
31803
|
function getPrepopulatedAriaLabel() {
|
|
31817
|
-
let
|
|
31804
|
+
let visiblelabel = "";
|
|
31818
31805
|
if (labels && labels.length > 0) {
|
|
31819
|
-
|
|
31820
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31821
|
-
// multiple labels.
|
|
31822
|
-
if (labels.length > 1) {
|
|
31823
|
-
str += "s";
|
|
31824
|
-
}
|
|
31825
|
-
|
|
31826
|
-
// Separate additional labels with commas.
|
|
31827
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31806
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31828
31807
|
}
|
|
31808
|
+
const str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
|
|
31829
31809
|
return str;
|
|
31830
31810
|
}
|
|
31831
31811
|
function handleColorChange(newValue) {
|
|
@@ -32026,18 +32006,11 @@ const LockedLineSettings = props => {
|
|
|
32026
32006
|
// Check if the line has length 0.
|
|
32027
32007
|
const isInvalid = kmath.vector.equal(point1.coord, point2.coord);
|
|
32028
32008
|
function getPrepopulatedAriaLabel() {
|
|
32029
|
-
let
|
|
32009
|
+
let visiblelabel = "";
|
|
32030
32010
|
if (labels && labels.length > 0) {
|
|
32031
|
-
|
|
32032
|
-
// Make it "with labels" instead of "with label" if there are
|
|
32033
|
-
// multiple labels.
|
|
32034
|
-
if (labels.length > 1) {
|
|
32035
|
-
str += "s";
|
|
32036
|
-
}
|
|
32037
|
-
|
|
32038
|
-
// Separate additional labels with commas.
|
|
32039
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32011
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32040
32012
|
}
|
|
32013
|
+
const str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
|
|
32041
32014
|
return str;
|
|
32042
32015
|
}
|
|
32043
32016
|
function handleChangePoint(newPointProps, index) {
|
|
@@ -32305,24 +32278,17 @@ const LockedPolygonSettings = props => {
|
|
|
32305
32278
|
onRemove
|
|
32306
32279
|
} = props;
|
|
32307
32280
|
function getPrepopulatedAriaLabel() {
|
|
32308
|
-
let
|
|
32281
|
+
let visiblelabel = "";
|
|
32282
|
+
if (labels && labels.length > 0) {
|
|
32283
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32284
|
+
}
|
|
32285
|
+
let str = `Polygon${visiblelabel} with ${points.length} sides, vertices at `;
|
|
32309
32286
|
|
|
32310
32287
|
// Add the coordinates of each point to the aria label
|
|
32311
32288
|
str += points.map(_ref => {
|
|
32312
32289
|
let [x, y] = _ref;
|
|
32313
32290
|
return `(${x}, ${y})`;
|
|
32314
32291
|
}).join(", ");
|
|
32315
|
-
if (labels && labels.length > 0) {
|
|
32316
|
-
str += ", with label";
|
|
32317
|
-
// Make it "with labels" instead of "with label" if there are
|
|
32318
|
-
// multiple labels.
|
|
32319
|
-
if (labels.length > 1) {
|
|
32320
|
-
str += "s";
|
|
32321
|
-
}
|
|
32322
|
-
|
|
32323
|
-
// Separate additional labels with commas.
|
|
32324
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32325
|
-
}
|
|
32326
32292
|
return str;
|
|
32327
32293
|
}
|
|
32328
32294
|
function handleColorChange(newValue) {
|
|
@@ -32653,18 +32619,11 @@ const LockedVectorSettings = props => {
|
|
|
32653
32619
|
// Check if the line has length 0.
|
|
32654
32620
|
const isInvalid = kmath.vector.equal(tail, tip);
|
|
32655
32621
|
function getPrepopulatedAriaLabel() {
|
|
32656
|
-
let
|
|
32622
|
+
let visiblelabel = "";
|
|
32657
32623
|
if (labels && labels.length > 0) {
|
|
32658
|
-
|
|
32659
|
-
// Make it "with labels" instead of "with label" if there are
|
|
32660
|
-
// multiple labels.
|
|
32661
|
-
if (labels.length > 1) {
|
|
32662
|
-
str += "s";
|
|
32663
|
-
}
|
|
32664
|
-
|
|
32665
|
-
// Separate additional labels with commas.
|
|
32666
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32624
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32667
32625
|
}
|
|
32626
|
+
const str = `Vector${visiblelabel} from (${tail[0]}, ${tail[1]}) to (${tip[0]}, ${tip[1]})`;
|
|
32668
32627
|
return str;
|
|
32669
32628
|
}
|
|
32670
32629
|
function handleChangePoint(newCoord, index) {
|