@khanacademy/perseus-editor 28.4.2 → 28.5.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.
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import Editor from "./editor";
3
3
  import IframeContentRenderer from "./iframe-content-renderer";
4
4
  import ItemExtrasEditor from "./item-extras-editor";
5
- import type { Issue } from "./issues-panel";
5
+ import type { Issue } from "./components/issues-panel";
6
6
  import type { APIOptions, ImageUploader, ChangeHandler, DeviceType } from "@khanacademy/perseus";
7
7
  import type { PerseusAnswerArea, PerseusWidgetsMap, PerseusRenderer } from "@khanacademy/perseus-core";
8
8
  type Props = {
@@ -1,4 +1,4 @@
1
- import type { Issue } from "./issues-panel";
1
+ import type { Issue } from "./components/issues-panel";
2
2
  export declare const WARNINGS: {
3
3
  inaccessibleWidget: (widgetType: string, widgetId: string) => Issue;
4
4
  genericLinterWarning: (rule: string, message: string) => Issue;
@@ -0,0 +1,44 @@
1
+ import { type PerseusRenderer, type PerseusWidgetsMap } from "@khanacademy/perseus-core";
2
+ type IssueCta = {
3
+ label: string;
4
+ onClick: () => void;
5
+ };
6
+ /**
7
+ * Based on the given widgets within a question, return the first available
8
+ * index for a specified widget type.
9
+ *
10
+ * Example: If the question has two image widgets named "image 1" and "image 3",
11
+ * the next available index for an image widget would be 2, for "image 2".
12
+ *
13
+ * @param widgetType - The type of the widget to get the index for. (e.g. "image", "radio", etc.)
14
+ * @param widgets - The question's `widgets` to search through.
15
+ * @returns The first available index for the given widget type, starting from 1.
16
+ */
17
+ export declare function getFirstAvailableWidgetIndex(widgetType: string, widgets: PerseusWidgetsMap): number;
18
+ /**
19
+ * Convert all image markdown in a question to image widgets.
20
+ *
21
+ * This function uses regex to find image markdown, then replaces it with an
22
+ * image widget. It does not use PerseusMarkdown to parse the content for image
23
+ * markdown, because PerseusMarkdown doesn't have a node-to-text converter. We'd
24
+ * have to manually process the tree to convert every single other markdown syntax
25
+ * type back to its text content form.
26
+ *
27
+ * @param question - The question being parsed for image markdown.
28
+ * @param onEditorChange - The function to update the editor's content.
29
+ */
30
+ export declare function convertImageMarkdownToImageWidget(question: PerseusRenderer, onEditorChange: (newProps: any) => void): Promise<void>;
31
+ /**
32
+ * Based on the given issue id, return the appropriate CTA for the issue.
33
+ * Example: If the issue id is "image-markdown", return the CTA to convert all
34
+ * image markdown to image widgets.
35
+ *
36
+ * @param issueId - The id of the issue to get the CTA for.
37
+ * @param question - The question being parsed for the issue.
38
+ * @param onEditorChange - The function to update the editor's content.
39
+ * @returns the `label` for the button text and the `onClick` function to call
40
+ * when the button is clicked. Returns `null` if no CTA is found for
41
+ * the given issue id.
42
+ */
43
+ export declare function getCtaForIssueId(issueId: string, question: PerseusRenderer, onEditorChange: (newProps: any) => void): IssueCta | null;
44
+ export {};
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import type { PerseusRenderer } from "@khanacademy/perseus-core";
3
+ export type ItemEditorContextType = {
4
+ question: PerseusRenderer;
5
+ onEditorChange: (newProps: any) => void;
6
+ };
7
+ export declare const ItemEditorContext: React.Context<ItemEditorContextType>;
8
+ export default function useItemEditorContext(): ItemEditorContextType;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus editors",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "28.4.2",
6
+ "version": "28.5.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -35,35 +35,35 @@
35
35
  "mafs": "^0.19.0",
36
36
  "tiny-invariant": "1.3.1",
37
37
  "@khanacademy/kas": "2.1.2",
38
- "@khanacademy/keypad-context": "3.2.11",
39
- "@khanacademy/kmath": "2.2.11",
40
- "@khanacademy/math-input": "26.2.12",
41
- "@khanacademy/perseus": "71.2.3",
42
- "@khanacademy/perseus-core": "20.0.0",
43
- "@khanacademy/perseus-linter": "4.4.1",
44
- "@khanacademy/perseus-score": "8.0.0",
38
+ "@khanacademy/keypad-context": "3.2.12",
39
+ "@khanacademy/kmath": "2.2.12",
40
+ "@khanacademy/math-input": "26.2.13",
41
+ "@khanacademy/perseus": "71.3.0",
42
+ "@khanacademy/perseus-core": "20.1.0",
43
+ "@khanacademy/perseus-linter": "4.4.2",
44
+ "@khanacademy/perseus-score": "8.0.1",
45
45
  "@khanacademy/perseus-utils": "2.1.0",
46
46
  "@khanacademy/pure-markdown": "2.2.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@khanacademy/mathjax-renderer": "3.0.0",
50
- "@khanacademy/wonder-blocks-accordion": "3.1.41",
51
- "@khanacademy/wonder-blocks-banner": "4.5.1",
52
- "@khanacademy/wonder-blocks-button": "11.2.3",
50
+ "@khanacademy/wonder-blocks-accordion": "3.1.42",
51
+ "@khanacademy/wonder-blocks-banner": "4.5.2",
52
+ "@khanacademy/wonder-blocks-button": "11.2.4",
53
53
  "@khanacademy/wonder-blocks-clickable": "8.0.0",
54
54
  "@khanacademy/wonder-blocks-core": "12.4.0",
55
- "@khanacademy/wonder-blocks-dropdown": "10.4.2",
56
- "@khanacademy/wonder-blocks-form": "7.3.9",
57
- "@khanacademy/wonder-blocks-icon": "5.2.20",
58
- "@khanacademy/wonder-blocks-icon-button": "10.5.2",
55
+ "@khanacademy/wonder-blocks-dropdown": "10.4.5",
56
+ "@khanacademy/wonder-blocks-form": "7.4.1",
57
+ "@khanacademy/wonder-blocks-icon": "5.3.0",
58
+ "@khanacademy/wonder-blocks-icon-button": "10.5.3",
59
59
  "@khanacademy/wonder-blocks-labeled-field": "4.0.6",
60
60
  "@khanacademy/wonder-blocks-layout": "3.1.37",
61
- "@khanacademy/wonder-blocks-link": "10.0.0",
62
- "@khanacademy/wonder-blocks-pill": "3.1.42",
63
- "@khanacademy/wonder-blocks-switch": "3.3.19",
61
+ "@khanacademy/wonder-blocks-link": "10.0.1",
62
+ "@khanacademy/wonder-blocks-pill": "3.1.43",
63
+ "@khanacademy/wonder-blocks-switch": "3.3.20",
64
64
  "@khanacademy/wonder-blocks-timing": "7.0.2",
65
65
  "@khanacademy/wonder-blocks-tokens": "14.0.0",
66
- "@khanacademy/wonder-blocks-tooltip": "4.1.48",
66
+ "@khanacademy/wonder-blocks-tooltip": "4.1.50",
67
67
  "@khanacademy/wonder-blocks-typography": "4.2.22",
68
68
  "@khanacademy/wonder-stuff-core": "1.5.5",
69
69
  "@phosphor-icons/core": "2.0.2",
@@ -79,23 +79,23 @@
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@khanacademy/mathjax-renderer": "^3.0.0",
82
- "@khanacademy/wonder-blocks-accordion": "^3.1.41",
83
- "@khanacademy/wonder-blocks-banner": "^4.5.1",
84
- "@khanacademy/wonder-blocks-button": "^11.2.3",
82
+ "@khanacademy/wonder-blocks-accordion": "^3.1.42",
83
+ "@khanacademy/wonder-blocks-banner": "^4.5.2",
84
+ "@khanacademy/wonder-blocks-button": "^11.2.4",
85
85
  "@khanacademy/wonder-blocks-clickable": "^8.0.0",
86
86
  "@khanacademy/wonder-blocks-core": "^12.4.0",
87
- "@khanacademy/wonder-blocks-dropdown": "^10.4.2",
88
- "@khanacademy/wonder-blocks-form": "^7.3.9",
89
- "@khanacademy/wonder-blocks-icon": "^5.2.20",
90
- "@khanacademy/wonder-blocks-icon-button": "^10.5.2",
87
+ "@khanacademy/wonder-blocks-dropdown": "^10.4.5",
88
+ "@khanacademy/wonder-blocks-form": "^7.4.1",
89
+ "@khanacademy/wonder-blocks-icon": "^5.3.0",
90
+ "@khanacademy/wonder-blocks-icon-button": "^10.5.3",
91
91
  "@khanacademy/wonder-blocks-labeled-field": "^4.0.6",
92
92
  "@khanacademy/wonder-blocks-layout": "^3.1.37",
93
- "@khanacademy/wonder-blocks-link": "^10.0.0",
94
- "@khanacademy/wonder-blocks-pill": "^3.1.42",
95
- "@khanacademy/wonder-blocks-switch": "^3.3.19",
93
+ "@khanacademy/wonder-blocks-link": "^10.0.1",
94
+ "@khanacademy/wonder-blocks-pill": "^3.1.43",
95
+ "@khanacademy/wonder-blocks-switch": "^3.3.20",
96
96
  "@khanacademy/wonder-blocks-timing": "^7.0.2",
97
97
  "@khanacademy/wonder-blocks-tokens": "^14.0.0",
98
- "@khanacademy/wonder-blocks-tooltip": "^4.1.48",
98
+ "@khanacademy/wonder-blocks-tooltip": "^4.1.50",
99
99
  "@khanacademy/wonder-blocks-typography": "^4.2.22",
100
100
  "@khanacademy/wonder-stuff-core": "^1.5.5",
101
101
  "@phosphor-icons/core": "^2.0.2",
@@ -1,10 +0,0 @@
1
- import { type APIOptions } from "@khanacademy/perseus";
2
- import { type Hint, type PerseusRenderer } from "@khanacademy/perseus-core";
3
- import * as React from "react";
4
- type Props = {
5
- apiOptions?: APIOptions;
6
- question?: PerseusRenderer;
7
- hints?: ReadonlyArray<Hint>;
8
- };
9
- declare function EditorPageWithStorybookPreview(props: Props): React.JSX.Element;
10
- export default EditorPageWithStorybookPreview;
@@ -1,32 +0,0 @@
1
- import * as React from "react";
2
- type PreviewPanelProps = {
3
- /**
4
- * The content to display inside the panel
5
- */
6
- children: React.ReactNode;
7
- /**
8
- * Text to display on the "open panel" button
9
- */
10
- openButtonText: string;
11
- /**
12
- * Optional: Control the panel open state externally
13
- */
14
- isOpen?: boolean;
15
- /**
16
- * Optional: Callback when panel open state changes
17
- */
18
- onOpenChange?: (isOpen: boolean) => void;
19
- /**
20
- * Optional: Additional CSS class for the open button
21
- */
22
- openButtonClassName?: string;
23
- };
24
- /**
25
- * A reusable component that provides a toggleable preview panel with:
26
- * - A fixed-position panel on the right side
27
- * - A button to open the panel when closed
28
- * - A close button (X) when the panel is open
29
- * - Accepts any children to render inside the panel
30
- */
31
- declare function PreviewPanel({ children, openButtonText, isOpen: controlledIsOpen, onOpenChange, openButtonClassName, }: PreviewPanelProps): React.JSX.Element;
32
- export default PreviewPanel;
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import type { Issue } from "./issues-panel";
3
- type IssueProps = {
4
- issue: Issue;
5
- };
6
- declare const IssueDetails: ({ issue }: IssueProps) => React.JSX.Element;
7
- export default IssueDetails;