@khanacademy/perseus 11.1.0 → 11.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/CHANGELOG.md +36 -0
- package/dist/error-boundary.d.ts +1 -0
- package/dist/es/index.css +0 -2
- package/dist/es/index.js +27 -7
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +0 -2
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/__testdata__/article-renderer.testdata.ts +2 -1
- package/src/error-boundary.tsx +5 -1
- package/src/mixins/provide-keypad.tsx +5 -0
- package/src/renderer.tsx +4 -1
- package/src/styles/articles.less +0 -1
- package/src/styles/widgets/image.less +0 -1
- package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +5 -0
- package/src/widgets/__tests__/__snapshots__/image.test.ts.snap +2 -0
- package/src/widgets/expression.tsx +5 -0
- package/src/widgets/image.tsx +12 -2
- package/tsconfig-build.tsbuildinfo +1 -1
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": "11.
|
|
6
|
+
"version": "11.3.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@khanacademy/kas": "^0.3.1",
|
|
26
26
|
"@khanacademy/kmath": "^0.1.2",
|
|
27
|
-
"@khanacademy/math-input": "^
|
|
27
|
+
"@khanacademy/math-input": "^12.1.0",
|
|
28
28
|
"@khanacademy/perseus-core": "1.0.0",
|
|
29
|
-
"@khanacademy/perseus-linter": "^0.3.
|
|
30
|
-
"@khanacademy/pure-markdown": "^0.2.
|
|
29
|
+
"@khanacademy/perseus-linter": "^0.3.3",
|
|
30
|
+
"@khanacademy/pure-markdown": "^0.2.5",
|
|
31
31
|
"@khanacademy/simple-markdown": "^0.10.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
48
48
|
"@khanacademy/wonder-blocks-tooltip": "^2.1.2",
|
|
49
49
|
"@khanacademy/wonder-blocks-typography": "^2.1.3",
|
|
50
|
-
"@khanacademy/wonder-stuff-core": "^1.
|
|
50
|
+
"@khanacademy/wonder-stuff-core": "^1.5.1",
|
|
51
51
|
"aphrodite": "^1.2.5",
|
|
52
52
|
"classnames": "^1.1.4",
|
|
53
53
|
"create-react-class": "^15.6.3",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
81
81
|
"@khanacademy/wonder-blocks-tooltip": "^2.1.2",
|
|
82
82
|
"@khanacademy/wonder-blocks-typography": "^2.1.3",
|
|
83
|
-
"@khanacademy/wonder-stuff-core": "^1.
|
|
83
|
+
"@khanacademy/wonder-stuff-core": "^1.5.1",
|
|
84
84
|
"aphrodite": "^1.2.5",
|
|
85
85
|
"classnames": "^1.1.4",
|
|
86
86
|
"create-react-class": "^15.6.3",
|
|
@@ -25,7 +25,8 @@ export const singleSectionArticle: PerseusRenderer = {
|
|
|
25
25
|
},
|
|
26
26
|
labels: [],
|
|
27
27
|
alt: 'A scene from Pixar\'s film "Toy Story 3" where the characters are swimming in a sea of trash and look very afraid.',
|
|
28
|
-
caption:
|
|
28
|
+
caption:
|
|
29
|
+
'A scene from Pixar\'s film "Toy Story 3" where the characters are swimming in a sea of trash and look very afraid."',
|
|
29
30
|
},
|
|
30
31
|
version: {major: 0, minor: 0},
|
|
31
32
|
},
|
package/src/error-boundary.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {Errors, Log} from "./logging/log";
|
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
children: React.ReactNode;
|
|
7
|
+
metadata?: Record<string, string>;
|
|
7
8
|
};
|
|
8
9
|
type State = {
|
|
9
10
|
error: string;
|
|
@@ -19,7 +20,10 @@ class ErrorBoundary extends React.Component<Props, State> {
|
|
|
19
20
|
this.setState({error: error.toString()});
|
|
20
21
|
Log.error("Perseus error boundary caught error", Errors.Internal, {
|
|
21
22
|
cause: error,
|
|
22
|
-
loggedMetadata: {
|
|
23
|
+
loggedMetadata: {
|
|
24
|
+
componentStack: info.componentStack,
|
|
25
|
+
...this.props.metadata,
|
|
26
|
+
},
|
|
23
27
|
});
|
|
24
28
|
}
|
|
25
29
|
|
|
@@ -103,6 +103,11 @@ const ProvideKeypad = {
|
|
|
103
103
|
// @ts-expect-error - TS2339 - Property 'props' does not exist on type '{ readonly propTypes: { readonly apiOptions: React.PropType<{ customKeypad?: boolean | undefined; nativeKeypadProxy?: ((...a: readonly any[]) => unknown) | undefined; }>; readonly keypadStyle: Requireable<any>; }; readonly getInitialState: () => { ...; }; readonly componentDidMount: () => void; readonly componentWil...'.
|
|
104
104
|
style={_this.props.keypadStyle}
|
|
105
105
|
useV2Keypad={apiOptions.useV2Keypad}
|
|
106
|
+
onAnalyticsEvent={async () => {
|
|
107
|
+
// Intentionally left empty. This component is
|
|
108
|
+
// deprecated and so we don't want/need to instrument
|
|
109
|
+
// it.
|
|
110
|
+
}}
|
|
106
111
|
/>,
|
|
107
112
|
_this._keypadContainer,
|
|
108
113
|
);
|
package/src/renderer.tsx
CHANGED
|
@@ -550,7 +550,10 @@ class Renderer extends React.Component<Props, State> {
|
|
|
550
550
|
// filtered out in this.render(), so we shouldn't have to
|
|
551
551
|
// worry about using this widget key and ref:
|
|
552
552
|
return (
|
|
553
|
-
<ErrorBoundary
|
|
553
|
+
<ErrorBoundary
|
|
554
|
+
key={"container:" + id}
|
|
555
|
+
metadata={{widget_type: type, widget_id: id}}
|
|
556
|
+
>
|
|
554
557
|
<WidgetContainer
|
|
555
558
|
ref={"container:" + id}
|
|
556
559
|
type={type}
|
package/src/styles/articles.less
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {KeypadContext, MobileKeypad} from "@khanacademy/math-input";
|
|
2
2
|
import {View} from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import {action} from "@storybook/addon-actions";
|
|
3
4
|
import {StyleSheet} from "aphrodite";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
|
|
@@ -12,6 +13,10 @@ const Footer = (): React.ReactElement => {
|
|
|
12
13
|
onElementMounted={setKeypadElement}
|
|
13
14
|
onDismiss={() => renderer && renderer.blur()}
|
|
14
15
|
style={styles.keypad}
|
|
16
|
+
useV2Keypad={true}
|
|
17
|
+
onAnalyticsEvent={async (e) => {
|
|
18
|
+
action("onAnalyticsEvent")(e);
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
)}
|
|
17
22
|
</KeypadContext.Consumer>
|
|
@@ -75,6 +75,7 @@ exports[`image widget - isMobile %b should snapshot: first render 1`] = `
|
|
|
75
75
|
</span>
|
|
76
76
|
<figcaption
|
|
77
77
|
class="perseus-image-caption has-title"
|
|
78
|
+
style="max-width: 420px;"
|
|
78
79
|
>
|
|
79
80
|
<div>
|
|
80
81
|
<div
|
|
@@ -273,6 +274,7 @@ exports[`image widget - isMobile %b should snapshot: first render 2`] = `
|
|
|
273
274
|
</span>
|
|
274
275
|
<figcaption
|
|
275
276
|
class="perseus-image-caption"
|
|
277
|
+
style="max-width: 420px;"
|
|
276
278
|
>
|
|
277
279
|
<div
|
|
278
280
|
class="perseus-renderer perseus-renderer-responsive"
|
|
@@ -422,6 +422,11 @@ export class Expression extends React.Component<Props, ExpressionState> {
|
|
|
422
422
|
};
|
|
423
423
|
|
|
424
424
|
_handleFocus: () => void = () => {
|
|
425
|
+
this.props.analytics.onAnalyticsEvent({
|
|
426
|
+
type: "perseus:expression-focused",
|
|
427
|
+
payload: null,
|
|
428
|
+
});
|
|
429
|
+
|
|
425
430
|
/* c8 ignore next */
|
|
426
431
|
this.props.onFocus([]);
|
|
427
432
|
};
|
package/src/widgets/image.tsx
CHANGED
|
@@ -197,7 +197,12 @@ class ImageWidget extends React.Component<Props> {
|
|
|
197
197
|
const minWidth = isImageFullWidth ? null : "0 !important";
|
|
198
198
|
|
|
199
199
|
titleAndCaption = (
|
|
200
|
-
<figcaption
|
|
200
|
+
<figcaption
|
|
201
|
+
className={className}
|
|
202
|
+
style={{
|
|
203
|
+
maxWidth: backgroundImage.width,
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
201
206
|
<div
|
|
202
207
|
style={{
|
|
203
208
|
// @ts-expect-error - TS2322 - Type 'string | null' is not assignable to type 'MinWidth<string | number> | undefined'.
|
|
@@ -239,7 +244,12 @@ class ImageWidget extends React.Component<Props> {
|
|
|
239
244
|
|
|
240
245
|
if (this.props.caption) {
|
|
241
246
|
caption = (
|
|
242
|
-
<figcaption
|
|
247
|
+
<figcaption
|
|
248
|
+
className="perseus-image-caption"
|
|
249
|
+
style={{
|
|
250
|
+
maxWidth: backgroundImage.width,
|
|
251
|
+
}}
|
|
252
|
+
>
|
|
243
253
|
<Renderer
|
|
244
254
|
content={this.props.caption}
|
|
245
255
|
apiOptions={apiOptions}
|