@khanacademy/perseus-editor 35.2.1 → 35.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.
- package/dist/components/a11y-context.d.ts +24 -0
- package/dist/components/info-tip/index.d.ts +19 -0
- package/dist/components/info-tip/info-tip-base.d.ts +6 -0
- package/dist/components/issues-panel.d.ts +38 -6
- package/dist/components/show-me-issue.d.ts +8 -3
- package/dist/components/text-list-editor.d.ts +15 -0
- package/dist/components/widget-editor.d.ts +1 -1
- package/dist/editor-page.d.ts +12 -7
- package/dist/es/index.js +87 -73
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +86 -71
- package/dist/index.js.map +1 -1
- package/dist/item-editor.d.ts +9 -5
- package/dist/item-extras-editor.d.ts +1 -0
- package/dist/preview/a11y/map-axe-results.d.ts +13 -0
- package/dist/preview/a11y/overlays.d.ts +22 -0
- package/dist/preview/message-types.d.ts +75 -4
- package/dist/preview/use-preview-controller.d.ts +21 -0
- package/dist/preview/use-preview-presenter.d.ts +19 -1
- package/dist/preview-with-iframe.d.ts +15 -0
- package/dist/util/derive-device-api-options.d.ts +14 -0
- package/dist/util/derive-question-preview-content.d.ts +23 -0
- package/dist/widgets/interaction-editor/arrow-picker.d.ts +2 -2
- package/dist/widgets/interaction-editor/color-picker.d.ts +2 -2
- package/dist/widgets/interaction-editor/dash-picker.d.ts +2 -2
- package/dist/widgets/interaction-editor/element-container.d.ts +3 -3
- package/dist/widgets/interaction-editor/function-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/label-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/line-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/movable-line-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/movable-point-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/parametric-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/point-editor.d.ts +0 -1
- package/dist/widgets/interaction-editor/rectangle-editor.d.ts +0 -1
- package/dist/widgets/interactive-graph-editor/interactive-graph-editor.d.ts +30 -43
- package/dist/widgets/interactive-graph-editor/locked-figures/locked-label-settings.d.ts +7 -0
- package/package.json +44 -44
- package/dist/util/a11y-checker.d.ts +0 -1
- /package/dist/{util → preview/a11y}/a11y-issues-list.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { A11yIssue } from "./issues-panel";
|
|
3
|
+
import type { A11yReport } from "../preview/use-preview-controller";
|
|
4
|
+
export type A11yContextValue = {
|
|
5
|
+
/** Turns one issue's highlight on or off. */
|
|
6
|
+
setIssueHighlight: (instanceId: string, highlighted: boolean) => void;
|
|
7
|
+
/** Whether the preview iframe's axe-core scan is enabled. */
|
|
8
|
+
a11yScanningEnabled: boolean;
|
|
9
|
+
/** Enables/disables the preview iframe's axe-core scan. */
|
|
10
|
+
setA11yScanningEnabled: (enabled: boolean) => void;
|
|
11
|
+
/** instanceIds to highlight in the preview iframe, unioned across every
|
|
12
|
+
* active "Show Me" toggle. */
|
|
13
|
+
highlightInstanceIds: string[];
|
|
14
|
+
/** Forwards the preview iframe's latest scan report to the owner. */
|
|
15
|
+
onA11yReport: (report: A11yReport | null) => void;
|
|
16
|
+
/** The latest scan's issues, for display in `IssuesPanel`. */
|
|
17
|
+
axeCoreIssues: A11yIssue[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Builds an A11yContextValue, defaulting any field a caller doesn't
|
|
21
|
+
* override to a production-safe no-op/empty value.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createA11yContextValue(overrides?: Partial<A11yContextValue>): A11yContextValue;
|
|
24
|
+
export declare const A11yContext: React.Context<A11yContextValue | null>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A wrapper around info-tip/info-tip.jsx that can be rendered on the
|
|
3
|
+
* server without causing a checksum mismatch on the client.
|
|
4
|
+
* (RCSS generates classnames with a randomSuffix, which ensures that any
|
|
5
|
+
* two sets of generated classnames will not match.)
|
|
6
|
+
*/
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import InfoTipBase from "./info-tip-base";
|
|
9
|
+
import type { PropsFor } from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
type Props = PropsFor<typeof InfoTipBase>;
|
|
11
|
+
type State = {
|
|
12
|
+
didMount: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare class InfoTip extends React.Component<Props, State> {
|
|
15
|
+
state: State;
|
|
16
|
+
componentDidMount(): void;
|
|
17
|
+
render(): React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export default InfoTip;
|
|
@@ -1,20 +1,52 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export type IssueImpact = "low" | "medium" | "high";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A problem to show the author, from the editor-side linter or the preview's
|
|
5
|
+
* axe-core scanner.
|
|
6
|
+
*/
|
|
7
|
+
export interface Issue {
|
|
8
|
+
/**
|
|
9
|
+
* The problem identifier (name). This `id` is _not_ guaranteed to be
|
|
10
|
+
* unique and is often the name of the rule that generated this issue (for
|
|
11
|
+
* example, this may be the axe-core rule id or a linter rule name). Shown
|
|
12
|
+
* to the author and used when a fix is offered, so several issues can
|
|
13
|
+
* share one — nine images missing alt text are nine `image-alt`s.
|
|
14
|
+
*/
|
|
4
15
|
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* The unique issue identifier. Distinguishes this issue from every other
|
|
18
|
+
* issue in the same list. Optional because some issue sources may not have
|
|
19
|
+
* one naturally; prefer `getIssueKey` over reading it directly.
|
|
20
|
+
*/
|
|
21
|
+
instanceId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Where this issue came from. Usually unset — used only when the origin
|
|
24
|
+
* (source) tells you the issue can do something the others can't. See
|
|
25
|
+
* {@link A11yIssue}.
|
|
26
|
+
*/
|
|
27
|
+
source?: "a11y";
|
|
5
28
|
description: string;
|
|
6
|
-
elements?: Element[];
|
|
7
29
|
helpUrl: string;
|
|
8
30
|
help: string;
|
|
9
31
|
impact: IssueImpact;
|
|
10
32
|
message: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* An issue the preview's axe-core scanner found, and can therefore highlight —
|
|
36
|
+
* it always has the `instanceId` the element map is keyed by.
|
|
37
|
+
*/
|
|
38
|
+
export type A11yIssue = Issue & {
|
|
39
|
+
source: "a11y";
|
|
40
|
+
instanceId: string;
|
|
11
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* A unique identifier for an issue, suitable for use as a React key or a
|
|
44
|
+
* Record key. Falls back to `id`, which names the rule rather than the
|
|
45
|
+
* occurrence, for issues that arrive without an `instanceId`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getIssueKey(issue: Issue): string;
|
|
12
48
|
type IssuesPanelProps = {
|
|
13
49
|
issues?: Issue[];
|
|
14
|
-
a11yCheck?: {
|
|
15
|
-
callback: () => void;
|
|
16
|
-
isChecked: boolean;
|
|
17
|
-
};
|
|
18
50
|
};
|
|
19
51
|
declare const IssuesPanel: (props: IssuesPanelProps) => React.JSX.Element;
|
|
20
52
|
export default IssuesPanel;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* The issue's highlight handle. Absent when the issue has nothing in the
|
|
5
|
+
* preview to point at, which is what makes the toggle unavailable.
|
|
6
|
+
*/
|
|
7
|
+
instanceId?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const ShowMe: ({ instanceId }: Props) => React.JSX.Element;
|
|
5
10
|
export default ShowMe;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare class TextListEditor extends React.Component<any, any> {
|
|
3
|
+
static propTypes: {
|
|
4
|
+
options: any;
|
|
5
|
+
layout: any;
|
|
6
|
+
onChange: any;
|
|
7
|
+
};
|
|
8
|
+
static defaultProps: any;
|
|
9
|
+
state: any;
|
|
10
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
11
|
+
onChange: (arg1: number, arg2: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
onKeyDown: (arg1: number, arg2: React.KeyboardEvent) => void;
|
|
13
|
+
render(): React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export default TextListEditor;
|
|
@@ -25,7 +25,7 @@ declare class WidgetEditor extends React.Component<WidgetEditorProps, WidgetEdit
|
|
|
25
25
|
_handleAlignmentChange: (newAlignment: Alignment) => void;
|
|
26
26
|
getSaveWarnings: () => any;
|
|
27
27
|
serialize: () => {
|
|
28
|
-
type: "
|
|
28
|
+
type: "image" | "radio" | "categorizer" | "iframe" | "table" | "video" | "definition" | "group" | "cs-program" | "dropdown" | "explanation" | "expression" | "free-response" | "grapher" | "graded-group-set" | "graded-group" | "input-number" | "interaction" | "interactive-graph" | "label-image" | "matcher" | "matrix" | "measurer" | "number-line" | "numeric-input" | "orderer" | "phet-simulation" | "python-program" | "plotter" | "sorter" | "mock-widget" | "deprecated-standin";
|
|
29
29
|
alignment: string | undefined;
|
|
30
30
|
static: boolean | undefined;
|
|
31
31
|
graded: boolean | undefined;
|
package/dist/editor-page.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import CombinedHintsEditor from "./hint-editor";
|
|
3
3
|
import ItemEditor from "./item-editor";
|
|
4
|
-
import type { Issue } from "./components/issues-panel";
|
|
5
|
-
import type {
|
|
4
|
+
import type { A11yIssue, Issue } from "./components/issues-panel";
|
|
5
|
+
import type { A11yReport } from "./preview/use-preview-controller";
|
|
6
|
+
import type { APIOptions, DeviceType, ImageUploader, PerseusDependenciesV2 } from "@khanacademy/perseus";
|
|
6
7
|
import type { Hint, PerseusAnswerArea, PerseusItem, PerseusRenderer } from "@khanacademy/perseus-core";
|
|
7
8
|
type OnChangeParams = {
|
|
8
9
|
jsonMode?: boolean;
|
|
@@ -66,13 +67,15 @@ type State = {
|
|
|
66
67
|
highlightLint: boolean;
|
|
67
68
|
widgetsAreOpen: boolean;
|
|
68
69
|
issues: Issue[];
|
|
69
|
-
axeCoreIssues:
|
|
70
|
-
|
|
70
|
+
axeCoreIssues: A11yIssue[];
|
|
71
|
+
a11yScanningEnabled: boolean;
|
|
72
|
+
/** instanceIds of the issues with an active "Show Me" highlight. */
|
|
73
|
+
highlightInstanceIds: string[];
|
|
71
74
|
};
|
|
72
75
|
declare class EditorPage extends React.Component<Props, State> {
|
|
73
|
-
a11yCheckerTimeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
74
76
|
itemEditor: React.RefObject<ItemEditor>;
|
|
75
77
|
hintsEditor: React.RefObject<CombinedHintsEditor>;
|
|
78
|
+
deriveDeviceApiOptions: (inputs: import("./util/derive-device-api-options").DeviceApiOptionsInputs) => import("@khanacademy/perseus").APIOptionsWithDefaults;
|
|
76
79
|
static defaultProps: DefaultProps;
|
|
77
80
|
constructor(props: Props);
|
|
78
81
|
componentDidMount(): void;
|
|
@@ -82,7 +85,9 @@ declare class EditorPage extends React.Component<Props, State> {
|
|
|
82
85
|
question?: PerseusRenderer | undefined;
|
|
83
86
|
} | null;
|
|
84
87
|
componentDidUpdate(previousProps: Props, prevState: State, snapshot: any): void;
|
|
85
|
-
|
|
88
|
+
setIssueHighlight: (instanceId: string, highlighted: boolean) => void;
|
|
89
|
+
handleA11yReport: (report: A11yReport | null) => void;
|
|
90
|
+
setA11yScanningEnabled: (enabled: boolean) => void;
|
|
86
91
|
/**
|
|
87
92
|
* Updates JSON state when props change from the parent.
|
|
88
93
|
*
|
|
@@ -92,7 +97,6 @@ declare class EditorPage extends React.Component<Props, State> {
|
|
|
92
97
|
*/
|
|
93
98
|
syncJsonStateFromProps(): void;
|
|
94
99
|
toggleJsonMode: () => void;
|
|
95
|
-
getApiOptions(): APIOptionsWithDefaults;
|
|
96
100
|
getSaveWarnings(): any;
|
|
97
101
|
/**
|
|
98
102
|
* Returns the current version of the edited {@link PerseusItem}.
|
|
@@ -101,6 +105,7 @@ declare class EditorPage extends React.Component<Props, State> {
|
|
|
101
105
|
*/
|
|
102
106
|
serialize(): PerseusItem;
|
|
103
107
|
handleChange: (toChange: OnChangeParams) => void;
|
|
108
|
+
handleEditorChange: (newProps: Partial<PerseusRenderer>) => void;
|
|
104
109
|
changeJSON: (newJson: PerseusItem) => void;
|
|
105
110
|
render(): React.ReactNode;
|
|
106
111
|
}
|