@khanacademy/perseus-editor 11.1.0 → 11.3.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.
@@ -3,7 +3,7 @@
3
3
  * multiple (Renderer) sections concatenated together.
4
4
  */
5
5
  import * as React from "react";
6
- import type { APIOptions, Changeable } from "@khanacademy/perseus";
6
+ import type { APIOptions, Changeable, ImageUploader } from "@khanacademy/perseus";
7
7
  type RendererProps = {
8
8
  content?: string;
9
9
  widgets?: any;
@@ -20,7 +20,7 @@ type DefaultProps = {
20
20
  };
21
21
  type Props = DefaultProps & {
22
22
  apiOptions?: APIOptions;
23
- imageUploader?: (arg1: string, arg2: (arg1: string) => unknown) => unknown;
23
+ imageUploader?: ImageUploader;
24
24
  previewURL: string;
25
25
  } & Changeable.ChangeableProps;
26
26
  type State = {
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ export type StyleOptions = "solid" | "dashed";
3
+ type Props = {
4
+ selectedValue: StyleOptions;
5
+ onChange: (newValue: string) => void;
6
+ };
7
+ declare const LineStrokeSelect: (props: Props) => React.JSX.Element;
8
+ export default LineStrokeSelect;
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
2
  type Props = {
3
- showM2Features: boolean;
4
3
  showM2bFeatures: boolean;
5
4
  id: string;
6
5
  onChange: (value: string) => void;
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import type { LockedFigureType } from "@khanacademy/perseus";
3
3
  export type LockedFigureSettingsMovementType = "back" | "backward" | "forward" | "front";
4
4
  type Props = {
5
- showM2Features?: boolean;
6
5
  figureType: LockedFigureType;
7
6
  onMove: (movement: LockedFigureSettingsMovementType) => void;
8
7
  onRemove: () => void;
@@ -7,12 +7,12 @@
7
7
  import * as React from "react";
8
8
  import type { Props as LockedEllipseProps } from "./locked-ellipse-settings";
9
9
  import type { LockedFigureSettingsMovementType } from "./locked-figure-settings-actions";
10
+ import type { Props as LockedFunctionProps } from "./locked-function-settings";
10
11
  import type { Props as LockedLineProps } from "./locked-line-settings";
11
12
  import type { Props as LockedPointProps } from "./locked-point-settings";
12
13
  import type { Props as LockedPolygonProps } from "./locked-polygon-settings";
13
14
  import type { Props as LockedVectorProps } from "./locked-vector-settings";
14
15
  export type LockedFigureSettingsCommonProps = {
15
- showM2Features?: boolean;
16
16
  showM2bFeatures?: boolean;
17
17
  /**
18
18
  * Called when a movement button (top, up, down, bottom) is pressed.
@@ -31,6 +31,6 @@ export type LockedFigureSettingsCommonProps = {
31
31
  */
32
32
  onToggle?: (expanded: boolean) => void;
33
33
  };
34
- type Props = LockedFigureSettingsCommonProps & (LockedPointProps | LockedLineProps | LockedEllipseProps | LockedVectorProps | LockedPolygonProps);
34
+ type Props = LockedFigureSettingsCommonProps & (LockedPointProps | LockedLineProps | LockedEllipseProps | LockedVectorProps | LockedPolygonProps | LockedFunctionProps);
35
35
  declare const LockedFigureSettings: (props: Props) => React.JSX.Element | null;
36
36
  export default LockedFigureSettings;
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import type { Props as InteractiveGraphEditorProps } from "../../widgets/interactive-graph-editor";
3
3
  import type { LockedFigure } from "@khanacademy/perseus";
4
4
  type Props = {
5
- showM2Features: boolean;
6
5
  showM2bFeatures: boolean;
7
6
  figures?: Array<LockedFigure>;
8
7
  onChange: (props: Partial<InteractiveGraphEditorProps>) => void;
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import type { LockedFigureSettingsCommonProps } from "./locked-figure-settings";
3
+ import type { LockedFunctionType } from "@khanacademy/perseus";
4
+ export type Props = LockedFunctionType & LockedFigureSettingsCommonProps & {
5
+ /**
6
+ * Called when the props (points, color, etc.) are updated.
7
+ */
8
+ onChangeProps: (newProps: Partial<LockedFunctionType>) => void;
9
+ };
10
+ declare const LockedFunctionSettings: (props: Props) => React.JSX.Element;
11
+ export default LockedFunctionSettings;
@@ -0,0 +1,21 @@
1
+ import { TextField } from "@khanacademy/wonder-blocks-form";
2
+ import * as React from "react";
3
+ import type { PropsFor } from "@khanacademy/wonder-blocks-core";
4
+ /**
5
+ * This is a custom text field of type="number" for use in Perseus Editors.
6
+ *
7
+ * This makes it so that the text field's input number updates on scroll
8
+ * without scrolling the page.
9
+ *
10
+ * NOTE 1: Native HTML number inputs do not update the number value on scroll,
11
+ * they only scroll the page. Inputs in React do NOT work this way (explanation
12
+ * here: https://stackoverflow.com/a/68266494). By default, scrolling on a
13
+ * focused number input in React causes BOTH the input value to change AND
14
+ * the page to scroll. The behavior in this component is an improvement on
15
+ * the React behavior, but it's the opposite of the native HTML behavior.
16
+ *
17
+ * NOTE 2: Firefox seems to have a custom override for this. Even with this
18
+ * stopPropogation, Firefox matches the native HTML behavior.
19
+ */
20
+ declare const ScrolllessNumberTextField: (props: PropsFor<typeof TextField>) => React.JSX.Element;
21
+ export default ScrolllessNumberTextField;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import type { Coord, PerseusGraphType } from "@khanacademy/perseus";
3
+ type Props = {
4
+ startCoords: [Coord, Coord, Coord];
5
+ onChange: (startCoords: PerseusGraphType["startCoords"]) => void;
6
+ };
7
+ declare const StartCoordsAngle: (props: Props) => React.JSX.Element;
8
+ export default StartCoordsAngle;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import type { Coord, PerseusGraphType } from "@khanacademy/perseus";
3
+ type Props = {
4
+ startCoords: ReadonlyArray<Coord>;
5
+ onChange: (startCoords: PerseusGraphType["startCoords"]) => void;
6
+ };
7
+ declare const StartCoordsPoint: (props: Props) => React.JSX.Element;
8
+ export default StartCoordsPoint;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import type { Coord, PerseusGraphType } from "@khanacademy/perseus";
3
+ type Props = {
4
+ startCoords: [Coord, Coord, Coord];
5
+ onChange: (startCoords: PerseusGraphType["startCoords"]) => void;
6
+ };
7
+ declare const StartCoordsQuadratic: (props: Props) => React.JSX.Element;
8
+ export default StartCoordsQuadratic;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import type { Coord, PerseusGraphType } from "@khanacademy/perseus";
3
+ type Props = {
4
+ startCoords: [Coord, Coord];
5
+ onChange: (startCoords: PerseusGraphType["startCoords"]) => void;
6
+ };
7
+ declare const StartCoordsSinusoid: (props: Props) => React.JSX.Element;
8
+ export default StartCoordsSinusoid;
@@ -1,4 +1,4 @@
1
- import type { Range, LockedFigure, LockedFigureType, LockedPointType, LockedLineType, LockedEllipseType, LockedVectorType, LockedPolygonType, LockedFunctionType, PerseusGraphType } from "@khanacademy/perseus";
1
+ import type { Range, LockedFigure, LockedFigureType, LockedPointType, LockedLineType, LockedEllipseType, LockedVectorType, LockedPolygonType, LockedFunctionType, PerseusGraphType, Coord } from "@khanacademy/perseus";
2
2
  export declare function focusWithChromeStickyFocusBugWorkaround(element: Element): void;
3
3
  export declare function getDefaultFigureForType(type: "point"): LockedPointType;
4
4
  export declare function getDefaultFigureForType(type: "line"): LockedLineType;
@@ -10,3 +10,6 @@ export declare function getDefaultFigureForType(type: LockedFigureType): LockedF
10
10
  export declare function degreeToRadian(degrees: number): number;
11
11
  export declare function radianToDegree(radians: number): number;
12
12
  export declare function getDefaultGraphStartCoords(graph: PerseusGraphType, range: [x: Range, y: Range], step: [x: number, y: number]): PerseusGraphType["startCoords"];
13
+ export declare const getSinusoidEquation: (startCoords: [Coord, Coord]) => string;
14
+ export declare const getQuadraticEquation: (startCoords: [Coord, Coord, Coord]) => string;
15
+ export declare const shouldShowStartCoordsUI: (flags: any, graph: any) => boolean;
@@ -21,7 +21,7 @@ declare class WidgetEditor extends React.Component<WidgetEditorProps, WidgetEdit
21
21
  _handleAlignmentChange: (e: React.SyntheticEvent<HTMLSelectElement>) => void;
22
22
  getSaveWarnings: () => any;
23
23
  serialize: () => {
24
- type: "categorizer" | "image" | "radio" | "table" | "cs-program" | "iframe" | "video" | "definition" | "group" | "dropdown" | "example-graphie-widget" | "example-widget" | "explanation" | "expression" | "graded-group-set" | "graded-group" | "grapher" | "input-number" | "interaction" | "interactive-graph" | "label-image" | "matcher" | "matrix" | "measurer" | "molecule-renderer" | "number-line" | "numeric-input" | "orderer" | "passage-ref" | "passage" | "plotter" | "python-program" | "passage-ref-target" | "simple-markdown-tester" | "sorter" | "deprecated-standin";
24
+ type: "definition" | "group" | "radio" | "table" | "categorizer" | "iframe" | "video" | "image" | "cs-program" | "dropdown" | "example-graphie-widget" | "example-widget" | "explanation" | "expression" | "graded-group-set" | "graded-group" | "grapher" | "input-number" | "interaction" | "interactive-graph" | "label-image" | "matcher" | "matrix" | "measurer" | "molecule-renderer" | "number-line" | "numeric-input" | "orderer" | "passage-ref" | "passage" | "plotter" | "python-program" | "passage-ref-target" | "simple-markdown-tester" | "sorter" | "deprecated-standin";
25
25
  alignment: string | undefined;
26
26
  static: boolean | undefined;
27
27
  graded: boolean | undefined;
package/dist/editor.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./katex-mhchem";
2
2
  import * as React from "react";
3
- import type { ChangeHandler, PerseusWidget } from "@khanacademy/perseus";
3
+ import type { ChangeHandler, ImageUploader, PerseusWidget } from "@khanacademy/perseus";
4
4
  type Props = Readonly<{
5
5
  apiOptions: any;
6
6
  className?: string;
@@ -17,7 +17,7 @@ type Props = Readonly<{
17
17
  showWordCount: boolean;
18
18
  warnNoPrompt: boolean;
19
19
  warnNoWidgets: boolean;
20
- imageUploader?: (file: string, callback: (url: string) => unknown) => unknown;
20
+ imageUploader?: ImageUploader;
21
21
  onChange: ChangeHandler;
22
22
  }>;
23
23
  type DefaultProps = {
package/dist/es/index.css CHANGED
@@ -84,6 +84,9 @@
84
84
  border: 1px solid #ddd;
85
85
  padding: 10px;
86
86
  }
87
+ .perseus-answer-options * {
88
+ margin-bottom: 4px;
89
+ }
87
90
  .perseus-answer-widget {
88
91
  border: 1px solid #ddd;
89
92
  border-radius: 0 0 3px 3px;