@khanacademy/perseus-editor 11.2.0 → 11.4.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;
@@ -7,6 +7,7 @@
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";
@@ -30,6 +31,6 @@ export type LockedFigureSettingsCommonProps = {
30
31
  */
31
32
  onToggle?: (expanded: boolean) => void;
32
33
  };
33
- type Props = LockedFigureSettingsCommonProps & (LockedPointProps | LockedLineProps | LockedEllipseProps | LockedVectorProps | LockedPolygonProps);
34
+ type Props = LockedFigureSettingsCommonProps & (LockedPointProps | LockedLineProps | LockedEllipseProps | LockedVectorProps | LockedPolygonProps | LockedFunctionProps);
34
35
  declare const LockedFigureSettings: (props: Props) => React.JSX.Element | null;
35
36
  export default LockedFigureSettings;
@@ -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;
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Takes an array of components to sort.
3
+ * As of 08/05/24, there are two sortable components
4
+ * (one in perseus and one in perseus-editor).
5
+ * As far as I can tell, this one is only used in ExpressionEditor.
6
+ */
1
7
  declare const SortableArea: any;
2
8
  export default SortableArea;
@@ -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;
@@ -12,3 +12,4 @@ 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
13
  export declare const getSinusoidEquation: (startCoords: [Coord, Coord]) => string;
14
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;
@@ -326,31 +329,6 @@
326
329
  .perseus-article-editor .perseus-editor-left-cell > .pod-title {
327
330
  padding: 4px 9px;
328
331
  }
329
- .perseus-widget-expression-editor .answer-options-list li {
330
- margin: 5px 0;
331
- }
332
- .perseus-widget-expression-editor .answer-status {
333
- color: inherit;
334
- cursor: pointer;
335
- display: inline-block;
336
- text-align: center;
337
- text-decoration: none;
338
- width: 75%;
339
- -webkit-user-select: none;
340
- user-select: none;
341
- }
342
- .perseus-widget-expression-editor .answer-status.wrong {
343
- background-color: #ffcccc;
344
- }
345
- .perseus-widget-expression-editor .answer-status.correct {
346
- background-color: #aaffaa;
347
- }
348
- .perseus-widget-expression-editor .answer-status.ungraded {
349
- background-color: #d9edf7;
350
- }
351
- .perseus-widget-expression-editor .expression-editor-h3 {
352
- margin: 10px 0 4px;
353
- }
354
332
  .perseus-widget-dropdown input[type="text"] {
355
333
  border: 1px solid #ccc;
356
334
  border-radius: 5px;
@@ -746,48 +724,6 @@
746
724
  .info-tip-content-container p + p {
747
725
  margin-top: 22px;
748
726
  }
749
- .expression-answer-option {
750
- border: 1px solid #ddd;
751
- border-radius: 3px;
752
- }
753
- .expression-answer-option .answer-handle {
754
- background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==) no-repeat 50% 50%;
755
- border-right: 1px solid #ddd;
756
- cursor: move;
757
- display: table-cell;
758
- width: 20px;
759
- }
760
- .expression-answer-option .answer-body {
761
- display: table-cell;
762
- }
763
- .expression-answer-option .answer-considered {
764
- display: table;
765
- }
766
- .expression-answer-option .answer-expression {
767
- display: table-cell;
768
- }
769
- .expression-answer-option .answer-status {
770
- display: table-cell;
771
- width: 100px;
772
- }
773
- .expression-answer-option .answer-option {
774
- padding-left: 5px;
775
- }
776
- .expression-answer-option .remove-container {
777
- padding: 5px;
778
- }
779
- .expression-answer-option .remove-container button {
780
- width: 100%;
781
- }
782
- .expression-answer-option .perseus-math-input {
783
- width: 236px;
784
- }
785
- .expression-answer-option .perseus-math-input .mq-root-block {
786
- border-top: none;
787
- border-right: none;
788
- border-bottom: 1px solid #ddd !important;
789
- border-left: 1px solid #ddd !important;
790
- }
791
727
  .perseus-widget-interaction-editor .perseus-widget-interaction-editor-select-element {
792
728
  background-color: #eee;
793
729
  border: 1px solid #ddd;
@@ -852,21 +788,9 @@
852
788
  .perseus-interaction-element .perseus-interaction-element-content.leave {
853
789
  display: none;
854
790
  }
855
- .button-set-label {
856
- display: block;
857
- }
858
- .button-set-label-float {
859
- display: block;
860
- float: left;
861
- margin-right: 10px;
862
- }
863
791
  .button-set-separator {
864
792
  margin: 10px 0;
865
793
  }
866
- .show-div-button {
867
- -webkit-user-select: none;
868
- user-select: none;
869
- }
870
794
  .perseus-widget-editor .unit-radio {
871
795
  color: black;
872
796
  text-decoration: none;