@khanacademy/perseus-editor 28.8.0 → 28.8.2

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,4 +2,5 @@ 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, severity: number | undefined) => Issue;
5
+ texError: (math: string, errorMessage: string, index: number) => Issue;
5
6
  };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * This file contains the various message types passed between the editor and
3
+ * the preview iframe.
4
+ */
5
+ import type { APIOptions, DeviceType } from "@khanacademy/perseus";
6
+ import type { Hint, PerseusArticle, PerseusItem } from "@khanacademy/perseus-core";
7
+ import type { LinterContextProps } from "@khanacademy/perseus-linter";
8
+ /**
9
+ * Constant identifier for all Perseus preview messages
10
+ */
11
+ export declare const PREVIEW_MESSAGE_SOURCE: "perseus-preview";
12
+ /**
13
+ * Base type for all preview messages
14
+ */
15
+ interface PreviewMessageBase {
16
+ source: typeof PREVIEW_MESSAGE_SOURCE;
17
+ id: string | number;
18
+ }
19
+ /**
20
+ * Data for question preview (full item with question, answer area, and hints)
21
+ */
22
+ export type QuestionPreviewData = {
23
+ item: PerseusItem;
24
+ apiOptions: APIOptions;
25
+ initialHintsVisible: number;
26
+ device: DeviceType;
27
+ linterContext: LinterContextProps;
28
+ reviewMode?: boolean;
29
+ legacyPerseusLint?: ReadonlyArray<string>;
30
+ problemNum?: number;
31
+ };
32
+ /**
33
+ * Data for single hint preview (used in hint editor)
34
+ */
35
+ export type HintPreviewData = {
36
+ hint: Hint;
37
+ bold: boolean;
38
+ pos: number;
39
+ apiOptions: APIOptions;
40
+ linterContext: LinterContextProps;
41
+ };
42
+ /**
43
+ * Data for article section preview
44
+ */
45
+ export type ArticlePreviewData = {
46
+ apiOptions: APIOptions;
47
+ json: PerseusArticle;
48
+ linterContext: LinterContextProps;
49
+ legacyPerseusLint?: ReadonlyArray<string>;
50
+ };
51
+ /**
52
+ * Union of all preview content types
53
+ */
54
+ export type PreviewContent = {
55
+ type: "question";
56
+ data: QuestionPreviewData;
57
+ } | {
58
+ type: "hint";
59
+ data: HintPreviewData;
60
+ } | {
61
+ type: "article";
62
+ data: ArticlePreviewData;
63
+ } | {
64
+ type: "article-all";
65
+ data: ArticlePreviewData[];
66
+ };
67
+ /**
68
+ * Message from iframe requesting data from parent
69
+ * (iframe sends its ID as a string)
70
+ */
71
+ export type PreviewDataRequestMessage = string;
72
+ /**
73
+ * Message from parent sending data to iframe
74
+ * (parent sends iframe ID as a string, iframe looks up data in iframeDataStore)
75
+ */
76
+ export type PreviewDataResponseMessage = string | number;
77
+ /**
78
+ * Message from iframe reporting its content height
79
+ */
80
+ export type PreviewHeightUpdateMessage = PreviewMessageBase & {
81
+ type: "height-update";
82
+ height: number;
83
+ };
84
+ /**
85
+ * Message from iframe reporting lint warnings
86
+ */
87
+ export type PreviewLintReportMessage = PreviewMessageBase & {
88
+ type: "lint-report";
89
+ lintWarnings: ReadonlyArray<any>;
90
+ };
91
+ /**
92
+ * Union of all messages sent from iframe to parent
93
+ */
94
+ export type IframeToParentMessage = PreviewDataRequestMessage | PreviewHeightUpdateMessage | PreviewLintReportMessage;
95
+ /**
96
+ * Union of all messages sent from parent to iframe
97
+ */
98
+ export type ParentToIframeMessage = PreviewDataResponseMessage;
99
+ export {};
@@ -0,0 +1,14 @@
1
+ import "../katex-mhchem";
2
+ type TexError = {
3
+ math: string;
4
+ message: string;
5
+ };
6
+ /**
7
+ * Detects TeX rendering errors in markdown content by parsing the content
8
+ * and attempting to render each math expression with KaTeX.
9
+ *
10
+ * @param content - The markdown content to check for TeX errors
11
+ * @returns An array of TeX errors found in the content
12
+ */
13
+ export declare function detectTexErrors(content: string): TexError[];
14
+ export {};
@@ -2,10 +2,12 @@ import * as React from "react";
2
2
  interface RadioImageEditorProps {
3
3
  initialImageUrl: string;
4
4
  initialImageAltText: string;
5
+ initialImageWidth?: number;
6
+ initialImageHeight?: number;
5
7
  containerClassName?: string;
6
- onSave: (imageUrl: string, imageAltText: string) => void;
8
+ onSave: (imageUrl: string, imageAltText: string, width?: number, height?: number) => void;
7
9
  onClose?: () => void;
8
10
  onDelete?: () => void;
9
11
  }
10
- export default function RadioImageEditor({ initialImageUrl, initialImageAltText, containerClassName, onSave, onClose, onDelete, }: RadioImageEditorProps): React.ReactElement;
12
+ export default function RadioImageEditor({ initialImageUrl, initialImageAltText, initialImageWidth, initialImageHeight, containerClassName, onSave, onClose, onDelete, }: RadioImageEditorProps): React.ReactElement;
11
13
  export {};
@@ -0,0 +1,15 @@
1
+ import { type VideoDefaultWidgetOptions, type PerseusVideoWidgetOptions } from "@khanacademy/perseus-core";
2
+ import * as React from "react";
3
+ export interface VideoEditorProps extends PerseusVideoWidgetOptions {
4
+ onChange: (options: PerseusVideoWidgetOptions) => void;
5
+ }
6
+ /**
7
+ * This is the main editor for this widget, to specify all the options.
8
+ */
9
+ declare class VideoEditor extends React.Component<VideoEditorProps> {
10
+ static widgetName: "video";
11
+ static defaultProps: VideoDefaultWidgetOptions;
12
+ serialize: () => PerseusVideoWidgetOptions;
13
+ render(): React.ReactNode;
14
+ }
15
+ export default VideoEditor;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import type { VideoEditorProps } from "./video-editor";
3
+ /**
4
+ * Specific settings for the Video widget.
5
+ */
6
+ export default function VideoSettings(props: VideoEditorProps): React.JSX.Element;
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.8.0",
6
+ "version": "28.8.2",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -34,37 +34,37 @@
34
34
  "katex": "0.11.1",
35
35
  "mafs": "^0.19.0",
36
36
  "tiny-invariant": "1.3.1",
37
- "@khanacademy/kas": "2.1.5",
38
- "@khanacademy/keypad-context": "3.2.18",
39
- "@khanacademy/kmath": "2.2.18",
40
- "@khanacademy/math-input": "26.2.21",
41
- "@khanacademy/perseus": "72.2.1",
42
- "@khanacademy/perseus-core": "20.2.1",
43
- "@khanacademy/perseus-linter": "4.6.0",
44
- "@khanacademy/perseus-score": "8.0.7",
45
- "@khanacademy/perseus-utils": "2.1.3"
37
+ "@khanacademy/kas": "2.1.6",
38
+ "@khanacademy/keypad-context": "3.2.20",
39
+ "@khanacademy/kmath": "2.2.20",
40
+ "@khanacademy/math-input": "26.2.23",
41
+ "@khanacademy/perseus": "72.4.0",
42
+ "@khanacademy/perseus-core": "20.4.0",
43
+ "@khanacademy/perseus-linter": "4.6.2",
44
+ "@khanacademy/perseus-score": "8.0.9",
45
+ "@khanacademy/perseus-utils": "2.1.4"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@khanacademy/mathjax-renderer": "3.0.0",
49
- "@khanacademy/wonder-blocks-accordion": "3.1.46",
50
- "@khanacademy/wonder-blocks-banner": "5.0.4",
51
- "@khanacademy/wonder-blocks-button": "11.2.8",
52
- "@khanacademy/wonder-blocks-clickable": "8.0.4",
49
+ "@khanacademy/wonder-blocks-accordion": "3.1.47",
50
+ "@khanacademy/wonder-blocks-banner": "5.0.6",
51
+ "@khanacademy/wonder-blocks-button": "11.2.10",
52
+ "@khanacademy/wonder-blocks-clickable": "8.0.5",
53
53
  "@khanacademy/wonder-blocks-core": "12.4.2",
54
- "@khanacademy/wonder-blocks-dropdown": "10.5.4",
55
- "@khanacademy/wonder-blocks-form": "7.4.5",
56
- "@khanacademy/wonder-blocks-icon": "5.3.4",
57
- "@khanacademy/wonder-blocks-icon-button": "10.5.7",
58
- "@khanacademy/wonder-blocks-labeled-field": "4.0.10",
59
- "@khanacademy/wonder-blocks-layout": "3.1.41",
60
- "@khanacademy/wonder-blocks-link": "10.0.5",
61
- "@khanacademy/wonder-blocks-pill": "3.1.47",
62
- "@khanacademy/wonder-blocks-switch": "3.3.24",
54
+ "@khanacademy/wonder-blocks-dropdown": "10.5.6",
55
+ "@khanacademy/wonder-blocks-form": "7.4.6",
56
+ "@khanacademy/wonder-blocks-icon": "5.3.5",
57
+ "@khanacademy/wonder-blocks-icon-button": "11.0.1",
58
+ "@khanacademy/wonder-blocks-labeled-field": "4.0.11",
59
+ "@khanacademy/wonder-blocks-layout": "3.1.42",
60
+ "@khanacademy/wonder-blocks-link": "10.0.6",
61
+ "@khanacademy/wonder-blocks-pill": "3.1.48",
62
+ "@khanacademy/wonder-blocks-switch": "3.3.25",
63
63
  "@khanacademy/wonder-blocks-timing": "7.0.4",
64
- "@khanacademy/wonder-blocks-tokens": "14.1.2",
65
- "@khanacademy/wonder-blocks-tooltip": "4.1.58",
66
- "@khanacademy/wonder-blocks-typography": "4.2.26",
67
- "@khanacademy/wonder-stuff-core": "1.5.5",
64
+ "@khanacademy/wonder-blocks-tokens": "14.1.3",
65
+ "@khanacademy/wonder-blocks-tooltip": "4.1.60",
66
+ "@khanacademy/wonder-blocks-typography": "4.2.27",
67
+ "@khanacademy/wonder-stuff-core": "3.0.0",
68
68
  "@phosphor-icons/core": "2.0.2",
69
69
  "aphrodite": "1.2.5",
70
70
  "classnames": "1.1.4",
@@ -78,25 +78,25 @@
78
78
  },
79
79
  "peerDependencies": {
80
80
  "@khanacademy/mathjax-renderer": "^3.0.0",
81
- "@khanacademy/wonder-blocks-accordion": "^3.1.46",
82
- "@khanacademy/wonder-blocks-banner": "^5.0.4",
83
- "@khanacademy/wonder-blocks-button": "^11.2.8",
84
- "@khanacademy/wonder-blocks-clickable": "^8.0.4",
81
+ "@khanacademy/wonder-blocks-accordion": "^3.1.47",
82
+ "@khanacademy/wonder-blocks-banner": "^5.0.6",
83
+ "@khanacademy/wonder-blocks-button": "^11.2.10",
84
+ "@khanacademy/wonder-blocks-clickable": "^8.0.5",
85
85
  "@khanacademy/wonder-blocks-core": "^12.4.2",
86
- "@khanacademy/wonder-blocks-dropdown": "^10.5.4",
87
- "@khanacademy/wonder-blocks-form": "^7.4.5",
88
- "@khanacademy/wonder-blocks-icon": "^5.3.4",
89
- "@khanacademy/wonder-blocks-icon-button": "^10.5.7",
90
- "@khanacademy/wonder-blocks-labeled-field": "^4.0.10",
91
- "@khanacademy/wonder-blocks-layout": "^3.1.41",
92
- "@khanacademy/wonder-blocks-link": "^10.0.5",
93
- "@khanacademy/wonder-blocks-pill": "^3.1.47",
94
- "@khanacademy/wonder-blocks-switch": "^3.3.24",
86
+ "@khanacademy/wonder-blocks-dropdown": "^10.5.6",
87
+ "@khanacademy/wonder-blocks-form": "^7.4.6",
88
+ "@khanacademy/wonder-blocks-icon": "^5.3.5",
89
+ "@khanacademy/wonder-blocks-icon-button": "^11.0.1",
90
+ "@khanacademy/wonder-blocks-labeled-field": "^4.0.11",
91
+ "@khanacademy/wonder-blocks-layout": "^3.1.42",
92
+ "@khanacademy/wonder-blocks-link": "^10.0.6",
93
+ "@khanacademy/wonder-blocks-pill": "^3.1.48",
94
+ "@khanacademy/wonder-blocks-switch": "^3.3.25",
95
95
  "@khanacademy/wonder-blocks-timing": "^7.0.4",
96
- "@khanacademy/wonder-blocks-tokens": "^14.1.2",
97
- "@khanacademy/wonder-blocks-tooltip": "^4.1.58",
98
- "@khanacademy/wonder-blocks-typography": "^4.2.26",
99
- "@khanacademy/wonder-stuff-core": "^1.5.5",
96
+ "@khanacademy/wonder-blocks-tokens": "^14.1.3",
97
+ "@khanacademy/wonder-blocks-tooltip": "^4.1.60",
98
+ "@khanacademy/wonder-blocks-typography": "^4.2.27",
99
+ "@khanacademy/wonder-stuff-core": "^3.0.0",
100
100
  "@phosphor-icons/core": "^2.0.2",
101
101
  "aphrodite": "^1.2.5",
102
102
  "classnames": "^1.1.4",
@@ -108,7 +108,7 @@
108
108
  },
109
109
  "keywords": [],
110
110
  "khan": {
111
- "catalogHash": "055a0d11e03b8181"
111
+ "catalogHash": "93c3d2d70bbfa1c3"
112
112
  },
113
113
  "scripts": {}
114
114
  }
@@ -1,6 +0,0 @@
1
- import { TextArea } from "@khanacademy/wonder-blocks-form";
2
- import * as React from "react";
3
- import type { PropsFor } from "@khanacademy/wonder-blocks-core";
4
- type TextAreaProps = Omit<PropsFor<typeof TextArea>, "rows">;
5
- export declare const AutoResizingTextArea: (props: TextAreaProps) => React.JSX.Element;
6
- export {};
@@ -1,18 +0,0 @@
1
- import { type VideoDefaultWidgetOptions } from "@khanacademy/perseus-core";
2
- import * as React from "react";
3
- type Props = any;
4
- /**
5
- * This is the main editor for this widget, to specify all the options.
6
- */
7
- declare class VideoEditor extends React.Component<Props> {
8
- static propTypes: {
9
- location: any;
10
- onChange: any;
11
- };
12
- static widgetName: "video";
13
- static defaultProps: VideoDefaultWidgetOptions;
14
- _handleUrlChange: (arg1: string) => void;
15
- serialize: () => any;
16
- render(): React.ReactNode;
17
- }
18
- export default VideoEditor;