@khanacademy/perseus 92.0.0 → 92.0.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.
- package/dist/{chunk-register-all-widgets-for-testing-BqbrdgLs.js → chunk-register-all-widgets-for-testing-BicV4HKq.js} +11 -21
- package/dist/chunk-register-all-widgets-for-testing-BicV4HKq.js.map +1 -0
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +3 -3
- package/dist/question-paragraph.d.ts +2 -4
- package/dist/renderer.d.ts +201 -15
- package/dist/strings.js +1 -1
- package/dist/strings.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-register-all-widgets-for-testing-BqbrdgLs.js.map +0 -1
- package/dist/perseus-markdown.new.d.ts +0 -11
- package/dist/question-paragraph.new.d.ts +0 -10
- package/dist/renderer.new.d.ts +0 -199
- package/dist/renderer.old.d.ts +0 -210
- package/dist/widget-container.old.d.ts +0 -24
- /package/dist/{widget-container.new.d.ts → widget-container.d.ts} +0 -0
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
characterCount: (source: string) => number;
|
|
3
|
-
traverseContent: (ast: any, cb: (node: any) => void) => void;
|
|
4
|
-
parse: (source: string, state: any) => any;
|
|
5
|
-
parseInline: (source: string, state: any) => any;
|
|
6
|
-
reactFor: (arg1: import("@khanacademy/simple-markdown").ReactNodeOutput) => import("@khanacademy/simple-markdown").ReactOutput;
|
|
7
|
-
ruleOutput: any;
|
|
8
|
-
basicOutput: any;
|
|
9
|
-
sanitizeUrl: (url?: string | null | undefined) => string | null | undefined;
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
type Props = {
|
|
3
|
-
className?: string | null | undefined;
|
|
4
|
-
translationIndex?: number;
|
|
5
|
-
paragraphIndex?: number;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
inline?: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare const QuestionParagraph: (props: Props) => React.ReactNode;
|
|
10
|
-
export default QuestionParagraph;
|
package/dist/renderer.new.d.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* WARNING!!!! THERE ARE ACTIVE CHANGES HAPPENING IN THE RENDERER! *
|
|
4
|
-
* *
|
|
5
|
-
***********************************************************************/
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
import { PerseusI18nContext } from "./components/i18n-context";
|
|
8
|
-
import InteractionTracker from "./interaction-tracker";
|
|
9
|
-
import TranslationLinter from "./translation-linter";
|
|
10
|
-
import WidgetContainer from "./widget-container.new";
|
|
11
|
-
import type { DependenciesContext } from "./dependencies";
|
|
12
|
-
import type { PerseusStrings } from "./strings";
|
|
13
|
-
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FindWidgetsFunction, FocusPath, Widget, WidgetProps } from "./types";
|
|
14
|
-
import type { HandleUserInputCallback, InitializeUserInputCallback } from "./user-input-manager";
|
|
15
|
-
import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
|
|
16
|
-
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
17
|
-
import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
|
|
18
|
-
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
19
|
-
import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
|
|
20
|
-
import "./styles/perseus-renderer.new.css";
|
|
21
|
-
type WidgetState = {
|
|
22
|
-
isMobile?: boolean;
|
|
23
|
-
inTable?: boolean;
|
|
24
|
-
key?: number;
|
|
25
|
-
paragraphIndex?: number;
|
|
26
|
-
foundFullWidth?: boolean;
|
|
27
|
-
baseElements?: any;
|
|
28
|
-
};
|
|
29
|
-
type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
|
|
30
|
-
content: PerseusRenderer["content"];
|
|
31
|
-
widgets: PerseusRenderer["widgets"];
|
|
32
|
-
images: PerseusRenderer["images"];
|
|
33
|
-
apiOptions?: APIOptions;
|
|
34
|
-
userInput?: UserInputMap;
|
|
35
|
-
handleUserInput?: HandleUserInputCallback;
|
|
36
|
-
initializeUserInput?: InitializeUserInputCallback;
|
|
37
|
-
alwaysUpdate?: boolean;
|
|
38
|
-
findExternalWidgets: FindWidgetsFunction;
|
|
39
|
-
keypadElement?: KeypadAPI | null;
|
|
40
|
-
onRender: (node?: any) => void;
|
|
41
|
-
problemNum?: number;
|
|
42
|
-
reviewMode?: boolean | null | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Meant to differentiate between "scorable" contexts (exercises, GradedGroup)
|
|
45
|
-
* and non-"scorable" contexts (articles, hints)
|
|
46
|
-
*/
|
|
47
|
-
isScorable?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* If set to "all", all rationales or solutions will be shown. If set to
|
|
50
|
-
* "selected", soltions will only be shown for selected choices. If set to
|
|
51
|
-
* "none", solutions will not be shown-- equivalent to `undefined`.
|
|
52
|
-
*/
|
|
53
|
-
showSolutions?: ShowSolutions;
|
|
54
|
-
/**
|
|
55
|
-
* If linterContext.highlightLint is true, then content will be passed to
|
|
56
|
-
* the linter and any warnings will be highlighted in the rendered output.
|
|
57
|
-
*/
|
|
58
|
-
linterContext: LinterContextProps;
|
|
59
|
-
legacyPerseusLint?: ReadonlyArray<string>;
|
|
60
|
-
/**
|
|
61
|
-
* Skip adding paragraph class
|
|
62
|
-
*/
|
|
63
|
-
inline?: boolean;
|
|
64
|
-
strings: PerseusStrings;
|
|
65
|
-
};
|
|
66
|
-
type State = {
|
|
67
|
-
translationLintErrors: ReadonlyArray<string>;
|
|
68
|
-
widgetInfo: Readonly<PerseusWidgetsMap>;
|
|
69
|
-
jiptContent: string | null;
|
|
70
|
-
};
|
|
71
|
-
type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "images" | "linterContext" | "onRender" | "showSolutions" | "reviewMode" | "isScorable" | "widgets">>;
|
|
72
|
-
declare class Renderer extends React.Component<Props, State> implements GetPromptJSONInterface {
|
|
73
|
-
static contextType: React.Context<import("./components/i18n-context").I18nContextType>;
|
|
74
|
-
context: React.ContextType<typeof PerseusI18nContext>;
|
|
75
|
-
_currentFocus: FocusPath | null | undefined;
|
|
76
|
-
_foundTextNodes: boolean;
|
|
77
|
-
_interactionTrackers: {
|
|
78
|
-
[id: string]: InteractionTracker<any>;
|
|
79
|
-
};
|
|
80
|
-
_isMounted: boolean;
|
|
81
|
-
_isTwoColumn: boolean;
|
|
82
|
-
_translationLinter: TranslationLinter;
|
|
83
|
-
_widgetContainers: Map<string, WidgetContainer>;
|
|
84
|
-
translationIndex: number;
|
|
85
|
-
widgetIds: Array<string>;
|
|
86
|
-
static defaultProps: DefaultProps;
|
|
87
|
-
constructor(props: Props);
|
|
88
|
-
componentDidMount(): void;
|
|
89
|
-
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
90
|
-
shouldComponentUpdate(nextProps: Props, nextState: State): any | boolean;
|
|
91
|
-
componentDidUpdate(prevProps: Props, prevState: State): void;
|
|
92
|
-
componentWillUnmount(): void;
|
|
93
|
-
getApiOptions: () => APIOptionsWithDefaults;
|
|
94
|
-
_getInitialWidgetState: (props: Props) => {
|
|
95
|
-
widgetInfo: State["widgetInfo"];
|
|
96
|
-
};
|
|
97
|
-
_getDefaultWidgetInfo: (widgetId: string) => any;
|
|
98
|
-
_getWidgetInfo: (widgetId: string) => PerseusWidget;
|
|
99
|
-
_isAnswerable(): boolean;
|
|
100
|
-
renderWidget: (impliedType: string, id: string, state: WidgetState) => null | React.ReactNode;
|
|
101
|
-
_getWidgetIndexById(id: string): number;
|
|
102
|
-
getWidgetProps(widgetId: string): WidgetProps<PerseusWidgetOptions, UserInput>;
|
|
103
|
-
/**
|
|
104
|
-
* Serializes the questions state so it can be recovered.
|
|
105
|
-
*
|
|
106
|
-
* If an instance of widgetProps is passed in, it generates the serialized
|
|
107
|
-
* state from that instead of the current widget props.
|
|
108
|
-
*/
|
|
109
|
-
/**
|
|
110
|
-
* @deprecated - do not use in new code.
|
|
111
|
-
*/
|
|
112
|
-
getSerializedState(): Record<string, any>;
|
|
113
|
-
/**
|
|
114
|
-
* Allows inter-widget communication.
|
|
115
|
-
*
|
|
116
|
-
* This function yields this Renderer's own internal widgets, and it's used
|
|
117
|
-
* in two places.
|
|
118
|
-
*
|
|
119
|
-
* First, we expose our own internal widgets to each other by giving them
|
|
120
|
-
* a `findWidgets` function that, in turn, calls this function.
|
|
121
|
-
*
|
|
122
|
-
* Second, we expose our own internal widgets to this Renderer's parent,
|
|
123
|
-
* by allowing it to call this function directly. That way, it can hook us
|
|
124
|
-
* up to other Renderers on the page, by writing a `findExternalWidgets`
|
|
125
|
-
* prop that calls each other Renderer's `findInternalWidgets` function.
|
|
126
|
-
*
|
|
127
|
-
* Takes a `filterCriterion` on which widgets to return.
|
|
128
|
-
* `filterCriterion` can be one of:
|
|
129
|
-
* * A string widget id
|
|
130
|
-
* * A string widget type
|
|
131
|
-
* * a function from (id, widgetInfo, widgetComponent) to true or false
|
|
132
|
-
*
|
|
133
|
-
* Returns an array of the matching widget components.
|
|
134
|
-
*
|
|
135
|
-
* If you need to do logic with more than the components, it is possible
|
|
136
|
-
* to do such logic inside the filter, rather than on the result array.
|
|
137
|
-
*
|
|
138
|
-
* "Remember: abilities are not inherently good or evil, it's how you use
|
|
139
|
-
* them." ~ Kyle Katarn
|
|
140
|
-
* Please use this one with caution.
|
|
141
|
-
*/
|
|
142
|
-
findInternalWidgets: (filterCriterion: FilterCriterion) => ReadonlyArray<Widget | null | undefined>;
|
|
143
|
-
/**
|
|
144
|
-
* Allows inter-widget communication.
|
|
145
|
-
*
|
|
146
|
-
* Includes both widgets internal to this Renderer, and external widgets
|
|
147
|
-
* exposed by the `findExternalWidgets` prop.
|
|
148
|
-
*
|
|
149
|
-
* See `findInternalWidgets` for more information.
|
|
150
|
-
*/
|
|
151
|
-
findWidgets: (filterCriterion: FilterCriterion) => any;
|
|
152
|
-
getWidgetInstance: (id: string) => Widget | null | undefined;
|
|
153
|
-
_onWidgetFocus: (id: string, focusPath?: ReadonlyArray<string>) => void;
|
|
154
|
-
_onWidgetBlur: (id: string, blurPath: FocusPath) => void;
|
|
155
|
-
getContent: (props: Props, state: State) => any;
|
|
156
|
-
shouldRenderJiptPlaceholder: (props: Props, state: State) => boolean;
|
|
157
|
-
replaceJiptContent(content: string, paragraphIndex?: number): void;
|
|
158
|
-
outputMarkdown: (ast: ASTNode, state: WidgetState) => React.ReactNode;
|
|
159
|
-
outputNested: (ast: ASTNode, state: WidgetState) => React.ReactNode;
|
|
160
|
-
outputNode: (node: SingleASTNode, nestedOutput: (ast: SingleASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
|
|
161
|
-
handleRender: (prevProps: Props) => void;
|
|
162
|
-
_setCurrentFocus: (path: FocusPath) => void;
|
|
163
|
-
focus: () => boolean | null | undefined;
|
|
164
|
-
getDOMNodeForPath: (path: FocusPath) => Element | Text | null | undefined;
|
|
165
|
-
getInputPaths: () => ReadonlyArray<FocusPath>;
|
|
166
|
-
focusPath: (path: FocusPath) => void;
|
|
167
|
-
blurPath: (path: FocusPath) => void;
|
|
168
|
-
blur: () => void;
|
|
169
|
-
/**
|
|
170
|
-
* Returns an array of widget ids that are empty (meaning widgets where the
|
|
171
|
-
* learner has not interacted with the widget yet or has not filled in all
|
|
172
|
-
* fields). For example, the `interactive-graph` widget is considered
|
|
173
|
-
* empty if the graph is in the starting state.
|
|
174
|
-
*/
|
|
175
|
-
emptyWidgets(): ReadonlyArray<string>;
|
|
176
|
-
/**
|
|
177
|
-
* Returns an object of the widget `.getUserInput()` results
|
|
178
|
-
*/
|
|
179
|
-
getUserInputMap(): UserInputMap;
|
|
180
|
-
/**
|
|
181
|
-
* Returns an array of all widget IDs in the order they occur in
|
|
182
|
-
* the content.
|
|
183
|
-
*/
|
|
184
|
-
getWidgetIds: () => ReadonlyArray<string>;
|
|
185
|
-
/**
|
|
186
|
-
* Returns a JSON representation of the content and widgets
|
|
187
|
-
* that can be passed to an LLM for prompt context.
|
|
188
|
-
*/
|
|
189
|
-
getPromptJSON(): RendererPromptJSON;
|
|
190
|
-
/**
|
|
191
|
-
* Scores the content.
|
|
192
|
-
*
|
|
193
|
-
* @deprecated use scorePerseusItem
|
|
194
|
-
*/
|
|
195
|
-
score(): PerseusScore;
|
|
196
|
-
handletranslationLintErrors: (lintErrors: ReadonlyArray<string>) => void;
|
|
197
|
-
render(): React.ReactNode;
|
|
198
|
-
}
|
|
199
|
-
export default Renderer;
|
package/dist/renderer.old.d.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* WARNING!!!! THERE ARE ACTIVE CHANGES HAPPENING IN THE RENDERER! *
|
|
4
|
-
* *
|
|
5
|
-
***********************************************************************/
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
import { PerseusI18nContext } from "./components/i18n-context";
|
|
8
|
-
import InteractionTracker from "./interaction-tracker";
|
|
9
|
-
import TranslationLinter from "./translation-linter";
|
|
10
|
-
import WidgetContainer from "./widget-container.old";
|
|
11
|
-
import type { DependenciesContext } from "./dependencies";
|
|
12
|
-
import type { PerseusStrings } from "./strings";
|
|
13
|
-
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FindWidgetsFunction, FocusPath, Widget, WidgetProps } from "./types";
|
|
14
|
-
import type { HandleUserInputCallback, InitializeUserInputCallback } from "./user-input-manager";
|
|
15
|
-
import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
|
|
16
|
-
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
17
|
-
import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
|
|
18
|
-
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
19
|
-
import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
|
|
20
|
-
import "./styles/perseus-renderer.css";
|
|
21
|
-
type WidgetState = {
|
|
22
|
-
isMobile?: boolean;
|
|
23
|
-
inTable?: boolean;
|
|
24
|
-
key?: number;
|
|
25
|
-
paragraphIndex?: number;
|
|
26
|
-
foundFullWidth?: boolean;
|
|
27
|
-
baseElements?: any;
|
|
28
|
-
};
|
|
29
|
-
export type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
|
|
30
|
-
content: PerseusRenderer["content"];
|
|
31
|
-
widgets: PerseusRenderer["widgets"];
|
|
32
|
-
images: PerseusRenderer["images"];
|
|
33
|
-
apiOptions?: APIOptions;
|
|
34
|
-
userInput?: UserInputMap;
|
|
35
|
-
handleUserInput?: HandleUserInputCallback;
|
|
36
|
-
initializeUserInput?: InitializeUserInputCallback;
|
|
37
|
-
alwaysUpdate?: boolean;
|
|
38
|
-
findExternalWidgets: FindWidgetsFunction;
|
|
39
|
-
keypadElement?: KeypadAPI | null;
|
|
40
|
-
onRender: (node?: any) => void;
|
|
41
|
-
problemNum?: number;
|
|
42
|
-
reviewMode?: boolean | null | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Meant to differentiate between "scorable" contexts (exercises, GradedGroup)
|
|
45
|
-
* and non-"scorable" contexts (articles, hints)
|
|
46
|
-
*/
|
|
47
|
-
isScorable?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* If set to "all", all rationales or solutions will be shown. If set to
|
|
50
|
-
* "selected", soltions will only be shown for selected choices. If set to
|
|
51
|
-
* "none", solutions will not be shown-- equivalent to `undefined`.
|
|
52
|
-
*/
|
|
53
|
-
showSolutions?: ShowSolutions;
|
|
54
|
-
/**
|
|
55
|
-
* If linterContext.highlightLint is true, then content will be passed to
|
|
56
|
-
* the linter and any warnings will be highlighted in the rendered output.
|
|
57
|
-
*/
|
|
58
|
-
linterContext: LinterContextProps;
|
|
59
|
-
legacyPerseusLint?: ReadonlyArray<string>;
|
|
60
|
-
/**
|
|
61
|
-
* Skip adding paragraph class
|
|
62
|
-
*/
|
|
63
|
-
inline?: boolean;
|
|
64
|
-
strings: PerseusStrings;
|
|
65
|
-
};
|
|
66
|
-
type State = {
|
|
67
|
-
translationLintErrors: ReadonlyArray<string>;
|
|
68
|
-
widgetInfo: Readonly<PerseusWidgetsMap>;
|
|
69
|
-
jiptContent: string | null;
|
|
70
|
-
};
|
|
71
|
-
type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "images" | "linterContext" | "onRender" | "showSolutions" | "reviewMode" | "isScorable" | "widgets">>;
|
|
72
|
-
/**
|
|
73
|
-
* We want to be able to reset the question state when we go
|
|
74
|
-
* from one question to another question. However it's kind of tricky:
|
|
75
|
-
* 1. Content could be the same
|
|
76
|
-
* 2. Problem number could be the same
|
|
77
|
-
* 3. We don't want to reset when going from answerless to answerful data
|
|
78
|
-
* So compare the prev props to the next props, but use
|
|
79
|
-
* answerless for both for the comparison
|
|
80
|
-
*/
|
|
81
|
-
export type DifferentQuestionPartialProps = Pick<Props, "content" | "widgets" | "problemNum">;
|
|
82
|
-
export declare function isDifferentQuestion(propsA: DifferentQuestionPartialProps, propsB: DifferentQuestionPartialProps): boolean;
|
|
83
|
-
declare class Renderer extends React.Component<Props, State> implements GetPromptJSONInterface {
|
|
84
|
-
static contextType: React.Context<import("./components/i18n-context").I18nContextType>;
|
|
85
|
-
context: React.ContextType<typeof PerseusI18nContext>;
|
|
86
|
-
_currentFocus: FocusPath | null | undefined;
|
|
87
|
-
_foundTextNodes: boolean;
|
|
88
|
-
_interactionTrackers: {
|
|
89
|
-
[id: string]: InteractionTracker<any>;
|
|
90
|
-
};
|
|
91
|
-
_isMounted: boolean;
|
|
92
|
-
_isTwoColumn: boolean;
|
|
93
|
-
_translationLinter: TranslationLinter;
|
|
94
|
-
_widgetContainers: Map<string, WidgetContainer>;
|
|
95
|
-
translationIndex: number;
|
|
96
|
-
widgetIds: Array<string>;
|
|
97
|
-
static defaultProps: DefaultProps;
|
|
98
|
-
constructor(props: Props);
|
|
99
|
-
componentDidMount(): void;
|
|
100
|
-
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
101
|
-
shouldComponentUpdate(nextProps: Props, nextState: State): any | boolean;
|
|
102
|
-
componentDidUpdate(prevProps: Props, prevState: State): void;
|
|
103
|
-
componentWillUnmount(): void;
|
|
104
|
-
getApiOptions: () => APIOptionsWithDefaults;
|
|
105
|
-
_getInitialWidgetState: (props: Props) => {
|
|
106
|
-
widgetInfo: State["widgetInfo"];
|
|
107
|
-
};
|
|
108
|
-
_getDefaultWidgetInfo: (widgetId: string) => any;
|
|
109
|
-
_getWidgetInfo: (widgetId: string) => PerseusWidget;
|
|
110
|
-
_isAnswerable(): boolean;
|
|
111
|
-
renderWidget: (impliedType: string, id: string, state: WidgetState) => null | React.ReactNode;
|
|
112
|
-
_getWidgetIndexById(id: string): number;
|
|
113
|
-
getWidgetProps(widgetId: string): WidgetProps<PerseusWidgetOptions, UserInput>;
|
|
114
|
-
/**
|
|
115
|
-
* Serializes the questions state so it can be recovered.
|
|
116
|
-
*
|
|
117
|
-
* If an instance of widgetProps is passed in, it generates the serialized
|
|
118
|
-
* state from that instead of the current widget props.
|
|
119
|
-
*/
|
|
120
|
-
/**
|
|
121
|
-
* @deprecated - do not use in new code.
|
|
122
|
-
*/
|
|
123
|
-
getSerializedState(): Record<string, any>;
|
|
124
|
-
/**
|
|
125
|
-
* Allows inter-widget communication.
|
|
126
|
-
*
|
|
127
|
-
* This function yields this Renderer's own internal widgets, and it's used
|
|
128
|
-
* in two places.
|
|
129
|
-
*
|
|
130
|
-
* First, we expose our own internal widgets to each other by giving them
|
|
131
|
-
* a `findWidgets` function that, in turn, calls this function.
|
|
132
|
-
*
|
|
133
|
-
* Second, we expose our own internal widgets to this Renderer's parent,
|
|
134
|
-
* by allowing it to call this function directly. That way, it can hook us
|
|
135
|
-
* up to other Renderers on the page, by writing a `findExternalWidgets`
|
|
136
|
-
* prop that calls each other Renderer's `findInternalWidgets` function.
|
|
137
|
-
*
|
|
138
|
-
* Takes a `filterCriterion` on which widgets to return.
|
|
139
|
-
* `filterCriterion` can be one of:
|
|
140
|
-
* * A string widget id
|
|
141
|
-
* * A string widget type
|
|
142
|
-
* * a function from (id, widgetInfo, widgetComponent) to true or false
|
|
143
|
-
*
|
|
144
|
-
* Returns an array of the matching widget components.
|
|
145
|
-
*
|
|
146
|
-
* If you need to do logic with more than the components, it is possible
|
|
147
|
-
* to do such logic inside the filter, rather than on the result array.
|
|
148
|
-
*
|
|
149
|
-
* "Remember: abilities are not inherently good or evil, it's how you use
|
|
150
|
-
* them." ~ Kyle Katarn
|
|
151
|
-
* Please use this one with caution.
|
|
152
|
-
*/
|
|
153
|
-
findInternalWidgets: (filterCriterion: FilterCriterion) => ReadonlyArray<Widget | null | undefined>;
|
|
154
|
-
/**
|
|
155
|
-
* Allows inter-widget communication.
|
|
156
|
-
*
|
|
157
|
-
* Includes both widgets internal to this Renderer, and external widgets
|
|
158
|
-
* exposed by the `findExternalWidgets` prop.
|
|
159
|
-
*
|
|
160
|
-
* See `findInternalWidgets` for more information.
|
|
161
|
-
*/
|
|
162
|
-
findWidgets: (filterCriterion: FilterCriterion) => any;
|
|
163
|
-
getWidgetInstance: (id: string) => Widget | null | undefined;
|
|
164
|
-
_onWidgetFocus: (id: string, focusPath?: ReadonlyArray<string>) => void;
|
|
165
|
-
_onWidgetBlur: (id: string, blurPath: FocusPath) => void;
|
|
166
|
-
getContent: (props: Props, state: State) => any;
|
|
167
|
-
shouldRenderJiptPlaceholder: (props: Props, state: State) => boolean;
|
|
168
|
-
replaceJiptContent(content: string, paragraphIndex?: number): void;
|
|
169
|
-
outputMarkdown: (ast: ASTNode, state: WidgetState) => React.ReactNode;
|
|
170
|
-
outputNested: (ast: ASTNode, state: WidgetState) => React.ReactNode;
|
|
171
|
-
outputNode: (node: SingleASTNode, nestedOutput: (ast: SingleASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
|
|
172
|
-
handleRender: (prevProps: Props) => void;
|
|
173
|
-
_setCurrentFocus: (path: FocusPath) => void;
|
|
174
|
-
focus: () => boolean | null | undefined;
|
|
175
|
-
getDOMNodeForPath: (path: FocusPath) => Element | Text | null | undefined;
|
|
176
|
-
getInputPaths: () => ReadonlyArray<FocusPath>;
|
|
177
|
-
focusPath: (path: FocusPath) => void;
|
|
178
|
-
blurPath: (path: FocusPath) => void;
|
|
179
|
-
blur: () => void;
|
|
180
|
-
/**
|
|
181
|
-
* Returns an array of widget ids that are empty (meaning widgets where the
|
|
182
|
-
* learner has not interacted with the widget yet or has not filled in all
|
|
183
|
-
* fields). For example, the `interactive-graph` widget is considered
|
|
184
|
-
* empty if the graph is in the starting state.
|
|
185
|
-
*/
|
|
186
|
-
emptyWidgets(): ReadonlyArray<string>;
|
|
187
|
-
/**
|
|
188
|
-
* Returns an object of the widget `.getUserInput()` results
|
|
189
|
-
*/
|
|
190
|
-
getUserInputMap(): UserInputMap;
|
|
191
|
-
/**
|
|
192
|
-
* Returns an array of all widget IDs in the order they occur in
|
|
193
|
-
* the content.
|
|
194
|
-
*/
|
|
195
|
-
getWidgetIds: () => ReadonlyArray<string>;
|
|
196
|
-
/**
|
|
197
|
-
* Returns a JSON representation of the content and widgets
|
|
198
|
-
* that can be passed to an LLM for prompt context.
|
|
199
|
-
*/
|
|
200
|
-
getPromptJSON(): RendererPromptJSON;
|
|
201
|
-
/**
|
|
202
|
-
* Scores the content.
|
|
203
|
-
*
|
|
204
|
-
* @deprecated use scorePerseusItem
|
|
205
|
-
*/
|
|
206
|
-
score(): PerseusScore;
|
|
207
|
-
handletranslationLintErrors: (lintErrors: ReadonlyArray<string>) => void;
|
|
208
|
-
render(): React.ReactNode;
|
|
209
|
-
}
|
|
210
|
-
export default Renderer;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* WARNING!!!! THERE ARE ACTIVE CHANGES HAPPENING IN THE RENDERER! *
|
|
4
|
-
* *
|
|
5
|
-
***********************************************************************/
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
import type { WidgetProps } from "./types";
|
|
8
|
-
type Props = {
|
|
9
|
-
type: string;
|
|
10
|
-
id: string;
|
|
11
|
-
widgetProps: WidgetProps<any, any>;
|
|
12
|
-
};
|
|
13
|
-
type State = {
|
|
14
|
-
sizeClass: "small" | "medium" | "large" | "xlarge";
|
|
15
|
-
};
|
|
16
|
-
declare class WidgetContainerOld extends React.Component<Props, State> {
|
|
17
|
-
widgetRef: React.RefObject<React.ComponentType<any>>;
|
|
18
|
-
state: State;
|
|
19
|
-
componentDidMount(): void;
|
|
20
|
-
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
21
|
-
getWidget: () => any;
|
|
22
|
-
render(): React.ReactNode;
|
|
23
|
-
}
|
|
24
|
-
export default WidgetContainerOld;
|
|
File without changes
|