@khanacademy/perseus-editor 14.7.1 → 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/package.json +2 -2
|
@@ -22,7 +22,7 @@ declare class WidgetEditor extends React.Component<WidgetEditorProps, WidgetEdit
|
|
|
22
22
|
_handleAlignmentChange: (e: React.SyntheticEvent<HTMLSelectElement>) => void;
|
|
23
23
|
getSaveWarnings: () => any;
|
|
24
24
|
serialize: () => {
|
|
25
|
-
type: "definition" | "group" | "radio" | "table" | "categorizer" | "
|
|
25
|
+
type: "definition" | "group" | "radio" | "table" | "categorizer" | "cs-program" | "dropdown" | "explanation" | "expression" | "grapher" | "graded-group" | "graded-group-set" | "iframe" | "image" | "input-number" | "interaction" | "interactive-graph" | "label-image" | "matcher" | "matrix" | "measurer" | "molecule-renderer" | "number-line" | "numeric-input" | "orderer" | "passage" | "passage-ref" | "phet-simulation" | "plotter" | "python-program" | "sorter" | "video" | "passage-ref-target" | "deprecated-standin";
|
|
26
26
|
alignment: string | undefined;
|
|
27
27
|
static: boolean | undefined;
|
|
28
28
|
graded: boolean | undefined;
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import "./katex-mhchem";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import type { ChangeHandler, ImageUploader, PerseusWidget } from "@khanacademy/perseus";
|
|
3
|
+
import type { ChangeHandler, ImageUploader, PerseusWidget, PerseusWidgetsMap } from "@khanacademy/perseus";
|
|
4
4
|
type Props = Readonly<{
|
|
5
5
|
apiOptions: any;
|
|
6
6
|
className?: string;
|
|
7
7
|
content: string;
|
|
8
8
|
replace?: any;
|
|
9
9
|
placeholder: string;
|
|
10
|
-
widgets:
|
|
11
|
-
[name: string]: PerseusWidget;
|
|
12
|
-
};
|
|
10
|
+
widgets: PerseusWidgetsMap;
|
|
13
11
|
images: any;
|
|
14
12
|
disabled: boolean;
|
|
15
13
|
widgetEnabled: boolean;
|
package/dist/es/index.js
CHANGED
|
@@ -46,7 +46,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
|
|
|
46
46
|
|
|
47
47
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
48
48
|
const libName = "@khanacademy/perseus-editor";
|
|
49
|
-
const libVersion = "14.
|
|
49
|
+
const libVersion = "14.8.0";
|
|
50
50
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
51
51
|
|
|
52
52
|
function _extends() {
|
|
@@ -21215,7 +21215,7 @@ class Editor extends React.Component {
|
|
|
21215
21215
|
if (matches != null) {
|
|
21216
21216
|
const text = matches[1];
|
|
21217
21217
|
const widgets = Widgets.getAllWidgetTypes();
|
|
21218
|
-
const matchingWidgets =
|
|
21218
|
+
const matchingWidgets = widgets.filter(name => {
|
|
21219
21219
|
return name.substring(0, text.length) === text;
|
|
21220
21220
|
});
|
|
21221
21221
|
if (matchingWidgets.length === 1) {
|
|
@@ -21375,8 +21375,7 @@ class Editor extends React.Component {
|
|
|
21375
21375
|
const newPrelude = isBlock ? makeEndWithAParagraphIfNecessary(prelude) : prelude;
|
|
21376
21376
|
const newPostlude = isBlock ? makeStartWithAParagraphAlways(postlude) : postlude;
|
|
21377
21377
|
const newContent = newPrelude + widgetContent + newPostlude;
|
|
21378
|
-
const newWidgets =
|
|
21379
|
-
// @ts-expect-error TS(2345) Type '"categorizer" | undefined' is not assignable to type '"deprecated-standin"'.
|
|
21378
|
+
const newWidgets = _extends({}, this.props.widgets);
|
|
21380
21379
|
newWidgets[id] = {
|
|
21381
21380
|
options: (_Widgets$getEditor = Widgets.getEditor(widgetType)) == null ? void 0 : _Widgets$getEditor.defaultProps,
|
|
21382
21381
|
type: widgetType,
|
|
@@ -30993,28 +30992,21 @@ const LockedEllipseSettings = props => {
|
|
|
30993
30992
|
onRemove
|
|
30994
30993
|
} = props;
|
|
30995
30994
|
function getPrepopulatedAriaLabel() {
|
|
30995
|
+
let visiblelabel = "";
|
|
30996
|
+
if (labels && labels.length > 0) {
|
|
30997
|
+
visiblelabel += ` ${labels.map(l => l.text).join(" ")}`;
|
|
30998
|
+
}
|
|
30996
30999
|
const isCircle = radius[0] === radius[1];
|
|
30997
31000
|
let str = "";
|
|
30998
31001
|
if (isCircle) {
|
|
30999
|
-
str += `Circle with radius ${radius[0]}`;
|
|
31002
|
+
str += `Circle${visiblelabel} with radius ${radius[0]}`;
|
|
31000
31003
|
} else {
|
|
31001
|
-
str += `Ellipse with x radius ${radius[0]} and y radius ${radius[1]}`;
|
|
31004
|
+
str += `Ellipse${visiblelabel} with x radius ${radius[0]} and y radius ${radius[1]}`;
|
|
31002
31005
|
}
|
|
31003
31006
|
str += `, centered at (${center[0]}, ${center[1]})`;
|
|
31004
31007
|
if (!isCircle && angle !== 0) {
|
|
31005
31008
|
str += `, rotated by ${radianToDegree(angle)} degrees`;
|
|
31006
31009
|
}
|
|
31007
|
-
if (labels && labels.length > 0) {
|
|
31008
|
-
str += ", with label";
|
|
31009
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31010
|
-
// multiple labels.
|
|
31011
|
-
if (labels.length > 1) {
|
|
31012
|
-
str += "s";
|
|
31013
|
-
}
|
|
31014
|
-
|
|
31015
|
-
// Separate additional labels with commas.
|
|
31016
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31017
|
-
}
|
|
31018
31010
|
return str;
|
|
31019
31011
|
}
|
|
31020
31012
|
function handleCenterChange(newCoord) {
|
|
@@ -31260,24 +31252,17 @@ const LockedFunctionSettings = props => {
|
|
|
31260
31252
|
setDomainEntries([domain && domain[0] !== -Infinity ? domain[0].toString() : "", domain && domain[1] !== Infinity ? domain[1].toString() : ""]);
|
|
31261
31253
|
}, [domain]);
|
|
31262
31254
|
function getPrepopulatedAriaLabel() {
|
|
31263
|
-
let
|
|
31255
|
+
let visiblelabel = "";
|
|
31256
|
+
if (labels && labels.length > 0) {
|
|
31257
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31258
|
+
}
|
|
31259
|
+
let str = `Function${visiblelabel} with equation ${equationPrefix}${equation}`;
|
|
31264
31260
|
|
|
31265
31261
|
// Add the domain/range constraints to the aria label
|
|
31266
31262
|
// if they are not the default values.
|
|
31267
31263
|
if (domain && !(domain[0] === -Infinity && domain[1] === Infinity)) {
|
|
31268
31264
|
str += `, domain from ${domain[0]} to ${domain[1]}`;
|
|
31269
31265
|
}
|
|
31270
|
-
if (labels && labels.length > 0) {
|
|
31271
|
-
str += ", with label";
|
|
31272
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31273
|
-
// multiple labels.
|
|
31274
|
-
if (labels.length > 1) {
|
|
31275
|
-
str += "s";
|
|
31276
|
-
}
|
|
31277
|
-
|
|
31278
|
-
// Separate additional labels with commas.
|
|
31279
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31280
|
-
}
|
|
31281
31266
|
return str;
|
|
31282
31267
|
}
|
|
31283
31268
|
|
|
@@ -31700,18 +31685,11 @@ const LockedPointSettings = props => {
|
|
|
31700
31685
|
* "Point at (x, y) with label1, label2, label3".
|
|
31701
31686
|
*/
|
|
31702
31687
|
function getPrepopulatedAriaLabel() {
|
|
31703
|
-
let
|
|
31688
|
+
let visiblelabel = "";
|
|
31704
31689
|
if (labels && labels.length > 0) {
|
|
31705
|
-
|
|
31706
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31707
|
-
// multiple labels.
|
|
31708
|
-
if (labels.length > 1) {
|
|
31709
|
-
str += "s";
|
|
31710
|
-
}
|
|
31711
|
-
|
|
31712
|
-
// Separate additional labels with commas.
|
|
31713
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31690
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31714
31691
|
}
|
|
31692
|
+
const str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
|
|
31715
31693
|
return str;
|
|
31716
31694
|
}
|
|
31717
31695
|
function handleColorChange(newValue) {
|
|
@@ -31908,18 +31886,11 @@ const LockedLineSettings = props => {
|
|
|
31908
31886
|
// Check if the line has length 0.
|
|
31909
31887
|
const isInvalid = vector.equal(point1.coord, point2.coord);
|
|
31910
31888
|
function getPrepopulatedAriaLabel() {
|
|
31911
|
-
let
|
|
31889
|
+
let visiblelabel = "";
|
|
31912
31890
|
if (labels && labels.length > 0) {
|
|
31913
|
-
|
|
31914
|
-
// Make it "with labels" instead of "with label" if there are
|
|
31915
|
-
// multiple labels.
|
|
31916
|
-
if (labels.length > 1) {
|
|
31917
|
-
str += "s";
|
|
31918
|
-
}
|
|
31919
|
-
|
|
31920
|
-
// Separate additional labels with commas.
|
|
31921
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31891
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
31922
31892
|
}
|
|
31893
|
+
const str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
|
|
31923
31894
|
return str;
|
|
31924
31895
|
}
|
|
31925
31896
|
function handleChangePoint(newPointProps, index) {
|
|
@@ -32177,21 +32148,14 @@ const LockedPolygonSettings = props => {
|
|
|
32177
32148
|
onRemove
|
|
32178
32149
|
} = props;
|
|
32179
32150
|
function getPrepopulatedAriaLabel() {
|
|
32180
|
-
let
|
|
32151
|
+
let visiblelabel = "";
|
|
32152
|
+
if (labels && labels.length > 0) {
|
|
32153
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32154
|
+
}
|
|
32155
|
+
let str = `Polygon${visiblelabel} with ${points.length} sides, vertices at `;
|
|
32181
32156
|
|
|
32182
32157
|
// Add the coordinates of each point to the aria label
|
|
32183
32158
|
str += points.map(([x, y]) => `(${x}, ${y})`).join(", ");
|
|
32184
|
-
if (labels && labels.length > 0) {
|
|
32185
|
-
str += ", with label";
|
|
32186
|
-
// Make it "with labels" instead of "with label" if there are
|
|
32187
|
-
// multiple labels.
|
|
32188
|
-
if (labels.length > 1) {
|
|
32189
|
-
str += "s";
|
|
32190
|
-
}
|
|
32191
|
-
|
|
32192
|
-
// Separate additional labels with commas.
|
|
32193
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32194
|
-
}
|
|
32195
32159
|
return str;
|
|
32196
32160
|
}
|
|
32197
32161
|
function handleColorChange(newValue) {
|
|
@@ -32503,18 +32467,11 @@ const LockedVectorSettings = props => {
|
|
|
32503
32467
|
// Check if the line has length 0.
|
|
32504
32468
|
const isInvalid = vector.equal(tail, tip);
|
|
32505
32469
|
function getPrepopulatedAriaLabel() {
|
|
32506
|
-
let
|
|
32470
|
+
let visiblelabel = "";
|
|
32507
32471
|
if (labels && labels.length > 0) {
|
|
32508
|
-
|
|
32509
|
-
// Make it "with labels" instead of "with label" if there are
|
|
32510
|
-
// multiple labels.
|
|
32511
|
-
if (labels.length > 1) {
|
|
32512
|
-
str += "s";
|
|
32513
|
-
}
|
|
32514
|
-
|
|
32515
|
-
// Separate additional labels with commas.
|
|
32516
|
-
str += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32472
|
+
visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
|
|
32517
32473
|
}
|
|
32474
|
+
const str = `Vector${visiblelabel} from (${tail[0]}, ${tail[1]}) to (${tip[0]}, ${tip[1]})`;
|
|
32518
32475
|
return str;
|
|
32519
32476
|
}
|
|
32520
32477
|
function handleChangePoint(newCoord, index) {
|