@khanacademy/perseus 93.0.3 → 94.0.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.
@@ -1,3 +1,4 @@
1
+ import WrappedEllipse from "./wrapped-ellipse";
1
2
  import type { Movable } from "./movable";
2
3
  import type { Constraint, ConstraintCallbacks, Coord } from "./types";
3
4
  import type { Graphie } from "../util/graphie";
@@ -23,7 +24,7 @@ type State = {
23
24
  static: boolean;
24
25
  tooltip: boolean;
25
26
  touchOffset: null | Coord;
26
- mouseTarget: unknown;
27
+ mouseTarget: WrappedEllipse | null;
27
28
  visibleShape: {
28
29
  wrapper: HTMLElement;
29
30
  toBack(): void;
@@ -74,7 +75,7 @@ export declare class MovablePoint {
74
75
  static: boolean;
75
76
  tooltip: boolean;
76
77
  touchOffset: null | Coord;
77
- mouseTarget: unknown;
78
+ mouseTarget: WrappedEllipse | null;
78
79
  visibleShape: {
79
80
  wrapper: HTMLElement;
80
81
  toBack(): void;
@@ -152,7 +153,7 @@ export declare class MovablePoint {
152
153
  toFront(): void;
153
154
  };
154
155
  outOfBounds(): boolean;
155
- mouseTarget(): unknown;
156
+ mouseTarget(): WrappedEllipse | null;
156
157
  touchOffset(): Coord | null;
157
158
  /**
158
159
  * Forwarding methods to this.movable:
@@ -8,8 +8,9 @@ declare class WrappedEllipse extends WrappedDrawing {
8
8
  visibleShape: VisibleShape;
9
9
  constructor(graphie: any, center: Coord, radii: [number, number], options: any);
10
10
  /**
11
- * Turns the ellipse's drop shadow on or off.
11
+ * Turns the ellipse's drop shadow on or off. Static ellipses get a gray
12
+ * shadow to match their disabled color.
12
13
  */
13
- setShadow(shadow: boolean): void;
14
+ setShadow(shadow: boolean, isStatic?: boolean): void;
14
15
  }
15
16
  export default WrappedEllipse;
@@ -4,7 +4,6 @@ export declare const ApiOptions: {
4
4
  };
5
5
  export declare const ClassNames: {
6
6
  readonly RENDERER: "perseus-renderer";
7
- readonly TWO_COLUMN_RENDERER: "perseus-renderer-two-columns";
8
7
  readonly RESPONSIVE_RENDERER: "perseus-renderer-responsive";
9
8
  readonly INPUT: "perseus-input";
10
9
  readonly FOCUSED: "perseus-focused";
@@ -21,6 +21,7 @@ type WidgetState = {
21
21
  paragraphIndex?: number;
22
22
  foundFullWidth?: boolean;
23
23
  baseElements?: any;
24
+ unwrapTitledTableContents?: boolean;
24
25
  };
25
26
  type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
26
27
  content: PerseusRenderer["content"];
@@ -52,7 +53,6 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
52
53
  * the linter and any warnings will be highlighted in the rendered output.
53
54
  */
54
55
  linterContext: LinterContextProps;
55
- legacyPerseusLint?: ReadonlyArray<string>;
56
56
  /**
57
57
  * Skip adding paragraph class
58
58
  */
@@ -85,7 +85,6 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
85
85
  [id: string]: InteractionTracker<any>;
86
86
  };
87
87
  _isMounted: boolean;
88
- _isTwoColumn: boolean;
89
88
  _translationLinter: TranslationLinter;
90
89
  _widgetContainers: Map<string, WidgetContainer>;
91
90
  translationIndex: number;
@@ -164,7 +163,13 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
164
163
  replaceJiptContent(content: string, paragraphIndex?: number): void;
165
164
  outputMarkdown: (ast: ASTNode, state: WidgetState) => React.ReactNode;
166
165
  outputNested: (ast: ASTNode, state: WidgetState) => React.ReactNode;
167
- outputNode: (node: SingleASTNode, nestedOutput: (ast: SingleASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
166
+ outputNode: (node: SingleASTNode, nestedOutput: (ast: ASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
167
+ /**
168
+ * Renders a markdown table nodes.
169
+ */
170
+ outputTableElement: (node: SingleASTNode, nestedOutput: (ast: ASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactElement;
171
+ outputTable: (node: SingleASTNode, nestedOutput: (ast: ASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactElement;
172
+ outputTitledTable: (node: SingleASTNode, nestedOutput: (ast: ASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
168
173
  handleRender: (prevProps: Props) => void;
169
174
  _setCurrentFocus: (path: FocusPath) => void;
170
175
  focus: () => boolean | null | undefined;
@@ -14,8 +14,7 @@ export default class TranslationLinter {
14
14
  runLinter: any;
15
15
  /**
16
16
  * Applies an array of errors generated by linters without position
17
- * information (TranslationLinter and the legacy getSaveWarnings()) to the
18
- * top of a Perseus tree.
17
+ * information (TranslationLinter) to the top of a Perseus tree.
19
18
  */
20
19
  applyLintErrors(parsedMarkdown: any, translationLintErrors: ReadonlyArray<string>): void;
21
20
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Parse a string of text and math into a list of objects with type and content
3
+ *
4
+ * Example: "Pi is about $\frac{22}{7}$" ==>
5
+ * [
6
+ * {type: "text", content: "Pi is about "},
7
+ * {type: "math", content: "\\frac{22}{7}"},
8
+ * ]
9
+ */
10
+ export declare const mathOnlyParser: import("@khanacademy/simple-markdown").Parser;
11
+ /**
12
+ * Replace all text outside of the $ TeX blocks with `\\text{...}`
13
+ * This way, the entire resulting string can be rendered within <TeX>
14
+ * and the text outside of the $ blocks will be non-TeX text.
15
+ */
16
+ export declare function replaceOutsideTeX(mathString: string): string;
package/dist/util.d.ts CHANGED
@@ -36,13 +36,21 @@ type TouchHandlers = {
36
36
  */
37
37
  declare function inputPathsEqual(a?: ReadonlyArray<string> | null, b?: ReadonlyArray<string> | null): boolean;
38
38
  export declare const isContentGraphie: (node: SingleASTNode) => boolean;
39
+ type TableCell = Array<SingleASTNode>;
40
+ export declare function isEmptyTableCell(cell: TableCell): boolean;
41
+ export declare function isBoldTableCell(cell: TableCell): boolean;
39
42
  /**
40
- * Some widgets render as inline content but CANNOT safely live
41
- * inside a paragraph (`<p>`). When this function returns true, the
42
- * QuestionParagraph component will not render the containing <p> element.
43
- * No additional processing is done on the sibling nodes.
43
+ * Markdown has no syntax for row headers, so we infer them from two common
44
+ * authoring patterns:
45
+ *
46
+ * 1. The first column header is empty.
47
+ * Or
48
+ * 2. Every body cell in the first column is bold.
49
+ *
50
+ * Tables with a single column are never treated as having row headers, as
51
+ * there would be no data cells for the headers to describe.
44
52
  */
45
- export declare const noParagraphForInlineWidget: (node: SingleASTNode) => boolean;
53
+ export declare function tableHasRowHeaders(node: SingleASTNode): boolean;
46
54
  /**
47
55
  * Combines adjacent text nodes in an ASTNode array into a single text node.
48
56
  * Does not recurse.
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ type BlankContextValue = {
3
+ /** The tile placed in a blank, or null when it is empty. */
4
+ renderPlacedTile: (blankId: string) => React.ReactNode;
5
+ };
6
+ /**
7
+ * Connects a parent widget to the blank widgets in its content. The
8
+ * Renderer renders those widgets, so the parent cannot pass them props.
9
+ */
10
+ export declare const BlankContext: React.Context<BlankContextValue | null>;
11
+ export {};
@@ -1,12 +1,14 @@
1
1
  import * as React from "react";
2
2
  import type { WidgetProps, Widget } from "../../types";
3
- import type { PerseusFillInTheBlankWidgetOptions } from "@khanacademy/perseus-core";
4
- type FillInTheBlankProps = WidgetProps<PerseusFillInTheBlankWidgetOptions>;
3
+ import type { PerseusFillInTheBlankUserInput, PerseusFillInTheBlankWidgetOptions } from "@khanacademy/perseus-core";
4
+ type FillInTheBlankProps = WidgetProps<PerseusFillInTheBlankWidgetOptions, PerseusFillInTheBlankUserInput>;
5
+ declare function getStartUserInput(): PerseusFillInTheBlankUserInput;
5
6
  declare const _default: {
6
7
  name: string;
7
8
  displayName: string;
8
9
  widget: React.ForwardRefExoticComponent<FillInTheBlankProps & React.RefAttributes<Widget>>;
9
10
  isLintable: false;
10
11
  hidden: true;
12
+ getStartUserInput: typeof getStartUserInput;
11
13
  };
12
14
  export default _default;
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import type { TilePlacements, TileUsage } from "../../components/drag-and-drop/tile-placements";
3
+ import type { useTileMoveActions } from "../../components/drag-and-drop/use-tile-move-actions";
4
+ import type { PerseusFillInTheBlankWidgetOptions } from "@khanacademy/perseus-core";
5
+ type TileMoveActions = ReturnType<typeof useTileMoveActions>;
6
+ type TileBankProps = {
7
+ tiles: PerseusFillInTheBlankWidgetOptions["tiles"];
8
+ placements: TilePlacements;
9
+ tileUsage: TileUsage;
10
+ /** Max placements per tile; undefined means unlimited. */
11
+ maxUses: number | undefined;
12
+ blankIds: ReadonlyArray<string>;
13
+ blankLabels: Record<string, string>;
14
+ onMove: TileMoveActions["handleMove"];
15
+ /** Attached to the first bank tile's menu so focus can return to it. */
16
+ firstMenuRef: TileMoveActions["firstBankMenuRef"];
17
+ };
18
+ /**
19
+ * Renders the choice bank: the tiles that haven't been placed in a blank
20
+ * yet, or can be placed again (multi-use).
21
+ */
22
+ export declare function TileBank({ tiles, placements, tileUsage, maxUses, blankIds, blankLabels, onMove, firstMenuRef, }: TileBankProps): React.ReactElement;
23
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { TilePlacements } from "../../components/drag-and-drop/tile-placements";
2
+ import type { PerseusFillInTheBlankUserInput, PerseusFillInTheBlankWidgetOptions } from "@khanacademy/perseus-core";
3
+ type Tile = PerseusFillInTheBlankWidgetOptions["tiles"][number];
4
+ type Args = {
5
+ content: PerseusFillInTheBlankWidgetOptions["content"];
6
+ widgets: PerseusFillInTheBlankWidgetOptions["widgets"];
7
+ tiles: PerseusFillInTheBlankWidgetOptions["tiles"];
8
+ userInput: PerseusFillInTheBlankUserInput;
9
+ };
10
+ type Result = {
11
+ /** The unique blank widget ids, in the order they appear in content. */
12
+ blankIds: ReadonlyArray<string>;
13
+ /** Accessible label for each blank, keyed by blank id. */
14
+ blankLabels: Record<string, string>;
15
+ tilesById: ReadonlyMap<string, Tile>;
16
+ /** Which tile is in each filled blank, keyed by blank id. */
17
+ placements: TilePlacements;
18
+ };
19
+ /**
20
+ * Derives the blanks, tile lookup and current placements that Fill in the
21
+ * Blank renders from its options and user input.
22
+ */
23
+ export declare function useFITBTiles({ content, widgets, tiles, userInput, }: Args): Result;
24
+ export {};
@@ -20,22 +20,6 @@ export declare function boundToEdgeAndSnapToGrid(point: vec.Vector2, { snapStep,
20
20
  range: [Interval, Interval];
21
21
  }): vec.Vector2;
22
22
  export declare function isUnlimitedGraphState(state: InteractiveGraphState): state is UnlimitedGraphState;
23
- /**
24
- * Parse a string of text and math into a list of objects with type and content
25
- *
26
- * Example: "Pi is about $\frac{22}{7}$" ==>
27
- * [
28
- * {type: "text", content: "Pi is about "},
29
- * {type: "math", content: "\\frac{22}{7}"},
30
- * ]
31
- */
32
- export declare const mathOnlyParser: import("@khanacademy/simple-markdown").Parser;
33
- /**
34
- * Replace all text outside of the $ TeX blocks with `\\text{...}`
35
- * This way, the entire resulting string can be rendered within <TeX>
36
- * and the text outside of the $ blocks will be non-TeX text.
37
- */
38
- export declare function replaceOutsideTeX(mathString: string): string;
39
23
  export declare const calculateNestedSVGCoords: (range: vec.Vector2[], width: number, height: number) => {
40
24
  viewboxX: number;
41
25
  viewboxY: number;
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { SorterLegendCap } from "@khanacademy/perseus-core";
3
+ type LegendBarOrientation = "horizontal" | "vertical";
4
+ export interface LegendBarProps {
5
+ orientation: LegendBarOrientation;
6
+ startCap?: SorterLegendCap;
7
+ endCap?: SorterLegendCap;
8
+ }
9
+ export declare function LegendBar({ orientation, startCap, endCap, }: LegendBarProps): React.ReactElement;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ export interface LegendLabelProps {
3
+ /** Label Content */
4
+ content: string;
5
+ }
6
+ /**
7
+ * One visible label at the start or end of the Sorter legend.
8
+ */
9
+ export declare function LegendLabel({ content }: LegendLabelProps): React.ReactElement;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "93.0.3",
6
+ "version": "94.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -28,14 +28,14 @@
28
28
  "@dnd-kit/dom": "^0.5.0",
29
29
  "@dnd-kit/react": "^0.5.0",
30
30
  "@khanacademy/kas": "3.1.1",
31
- "@khanacademy/keypad-context": "6.0.12",
32
- "@khanacademy/kmath": "3.1.5",
33
- "@khanacademy/math-input": "30.2.2",
34
- "@khanacademy/perseus-core": "42.2.0",
35
- "@khanacademy/perseus-linter": "8.0.0",
36
- "@khanacademy/perseus-score": "9.0.13",
31
+ "@khanacademy/keypad-context": "6.0.14",
32
+ "@khanacademy/kmath": "3.1.7",
33
+ "@khanacademy/math-input": "30.2.4",
34
+ "@khanacademy/perseus-core": "42.4.0",
35
+ "@khanacademy/perseus-linter": "8.1.0",
36
+ "@khanacademy/perseus-score": "9.0.15",
37
37
  "@khanacademy/perseus-utils": "3.0.2",
38
- "@khanacademy/pure-markdown": "3.1.2",
38
+ "@khanacademy/pure-markdown": "4.0.0",
39
39
  "@khanacademy/simple-markdown": "4.0.3",
40
40
  "@use-gesture/react": "^10.2.27",
41
41
  "gifuct-js": "^2.1.2",
@@ -46,26 +46,27 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@internal/build-settings": "0.9.2",
49
+ "@khanacademy/mathjax-renderer": "3.2.0",
49
50
  "@khanacademy/wonder-blocks-announcer": "1.1.2",
50
- "@khanacademy/wonder-blocks-banner": "5.2.0",
51
+ "@khanacademy/wonder-blocks-banner": "5.2.2",
51
52
  "@khanacademy/wonder-blocks-button": "11.7.13",
52
53
  "@khanacademy/wonder-blocks-clickable": "8.3.2",
53
54
  "@khanacademy/wonder-blocks-core": "12.5.0",
54
55
  "@khanacademy/wonder-blocks-data": "15.1.0",
55
- "@khanacademy/wonder-blocks-dropdown": "10.13.7",
56
- "@khanacademy/wonder-blocks-form": "7.7.4",
56
+ "@khanacademy/wonder-blocks-dropdown": "11.0.0",
57
+ "@khanacademy/wonder-blocks-form": "7.7.6",
57
58
  "@khanacademy/wonder-blocks-icon": "6.0.3",
58
59
  "@khanacademy/wonder-blocks-icon-button": "12.0.2",
59
- "@khanacademy/wonder-blocks-labeled-field": "4.3.4",
60
+ "@khanacademy/wonder-blocks-labeled-field": "4.3.6",
60
61
  "@khanacademy/wonder-blocks-layout": "3.2.1",
61
- "@khanacademy/wonder-blocks-link": "10.5.1",
62
- "@khanacademy/wonder-blocks-modal": "8.10.1",
63
- "@khanacademy/wonder-blocks-popover": "7.1.1",
62
+ "@khanacademy/wonder-blocks-link": "10.5.3",
63
+ "@khanacademy/wonder-blocks-modal": "8.10.3",
64
+ "@khanacademy/wonder-blocks-popover": "7.1.3",
64
65
  "@khanacademy/wonder-blocks-progress-spinner": "3.2.0",
65
66
  "@khanacademy/wonder-blocks-switch": "3.4.15",
66
67
  "@khanacademy/wonder-blocks-timing": "7.1.0",
67
68
  "@khanacademy/wonder-blocks-tokens": "18.1.0",
68
- "@khanacademy/wonder-blocks-tooltip": "4.2.12",
69
+ "@khanacademy/wonder-blocks-tooltip": "4.2.14",
69
70
  "@khanacademy/wonder-blocks-typography": "5.0.6",
70
71
  "@khanacademy/wonder-stuff-core": "3.0.0",
71
72
  "@phosphor-icons/core": "2.0.2",
@@ -81,26 +82,27 @@
81
82
  "underscore": "1.4.4"
82
83
  },
83
84
  "peerDependencies": {
85
+ "@khanacademy/mathjax-renderer": "^3.2.0",
84
86
  "@khanacademy/wonder-blocks-announcer": "^1.1.2",
85
- "@khanacademy/wonder-blocks-banner": "^5.2.0",
87
+ "@khanacademy/wonder-blocks-banner": "^5.2.2",
86
88
  "@khanacademy/wonder-blocks-button": "^11.7.13",
87
89
  "@khanacademy/wonder-blocks-clickable": "^8.3.2",
88
90
  "@khanacademy/wonder-blocks-core": "^12.5.0",
89
91
  "@khanacademy/wonder-blocks-data": "^15.1.0",
90
- "@khanacademy/wonder-blocks-dropdown": "^10.13.7",
91
- "@khanacademy/wonder-blocks-form": "^7.7.4",
92
+ "@khanacademy/wonder-blocks-dropdown": "^11.0.0",
93
+ "@khanacademy/wonder-blocks-form": "^7.7.6",
92
94
  "@khanacademy/wonder-blocks-icon": "^6.0.3",
93
95
  "@khanacademy/wonder-blocks-icon-button": "^12.0.2",
94
- "@khanacademy/wonder-blocks-labeled-field": "^4.3.4",
96
+ "@khanacademy/wonder-blocks-labeled-field": "^4.3.6",
95
97
  "@khanacademy/wonder-blocks-layout": "^3.2.1",
96
- "@khanacademy/wonder-blocks-link": "^10.5.1",
97
- "@khanacademy/wonder-blocks-modal": "^8.10.1",
98
- "@khanacademy/wonder-blocks-popover": "^7.1.1",
98
+ "@khanacademy/wonder-blocks-link": "^10.5.3",
99
+ "@khanacademy/wonder-blocks-modal": "^8.10.3",
100
+ "@khanacademy/wonder-blocks-popover": "^7.1.3",
99
101
  "@khanacademy/wonder-blocks-progress-spinner": "^3.2.0",
100
102
  "@khanacademy/wonder-blocks-switch": "^3.4.15",
101
103
  "@khanacademy/wonder-blocks-timing": "^7.1.0",
102
104
  "@khanacademy/wonder-blocks-tokens": "^18.1.0",
103
- "@khanacademy/wonder-blocks-tooltip": "^4.2.12",
105
+ "@khanacademy/wonder-blocks-tooltip": "^4.2.14",
104
106
  "@khanacademy/wonder-blocks-typography": "^5.0.6",
105
107
  "@khanacademy/wonder-stuff-core": "^3.0.0",
106
108
  "@phosphor-icons/core": "^2.0.2",
@@ -115,7 +117,7 @@
115
117
  },
116
118
  "keywords": [],
117
119
  "khan": {
118
- "catalogHash": "c5e0d95da455a764"
120
+ "catalogHash": "7aaf5fd9f24a04a9"
119
121
  },
120
122
  "scripts": {}
121
123
  }