@khanacademy/perseus 13.0.0 → 13.2.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 +32 -0
- package/dist/es/index.css +0 -7
- package/dist/es/index.js +13 -1
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +0 -7
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +2 -2
- package/dist/widgets/matcher.d.ts +1 -1
- package/package.json +35 -35
- package/src/__stories__/hints-renderer.stories.tsx +41 -44
- package/src/__tests__/__snapshots__/renderer.test.tsx.snap +9 -33
- package/src/__tests__/renderer-api.test.tsx +35 -52
- package/src/renderer.tsx +2 -2
- package/src/styles/khan-exercise.css +0 -2
- package/src/styles/perseus-renderer.less +0 -7
- package/src/widgets/__stories__/video.stories.tsx +9 -1
- package/src/widgets/__testdata__/video.testdata.ts +40 -0
- package/src/widgets/__tests__/__snapshots__/dropdown.test.ts.snap +6 -22
- package/src/widgets/__tests__/__snapshots__/graded-group-set-jipt.test.ts.snap +3 -3
- package/src/widgets/__tests__/__snapshots__/graded-group-set.test.ts.snap +1 -1
- package/src/widgets/__tests__/__snapshots__/graded-group.test.ts.snap +1 -1
- package/src/widgets/__tests__/__snapshots__/radio.test.ts.snap +4 -4
- package/src/widgets/__tests__/matcher.test.tsx +1 -1
- package/src/widgets/__tests__/video.test.ts +17 -1
- package/src/widgets/matcher.tsx +1 -1
- package/src/widgets/radio/choice.tsx +1 -0
- package/src/widgets/video.tsx +11 -0
- package/tsconfig-build.tsbuildinfo +1 -1
|
@@ -242,7 +242,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
|
|
|
242
242
|
type="button"
|
|
243
243
|
>
|
|
244
244
|
<span
|
|
245
|
-
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-
|
|
245
|
+
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-text_6kf3xs"
|
|
246
246
|
>
|
|
247
247
|
Check
|
|
248
248
|
</span>
|
|
@@ -470,7 +470,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
|
|
|
470
470
|
type="button"
|
|
471
471
|
>
|
|
472
472
|
<span
|
|
473
|
-
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-
|
|
473
|
+
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-text_6kf3xs"
|
|
474
474
|
>
|
|
475
475
|
Check
|
|
476
476
|
</span>
|
|
@@ -698,7 +698,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
|
|
|
698
698
|
type="button"
|
|
699
699
|
>
|
|
700
700
|
<span
|
|
701
|
-
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-
|
|
701
|
+
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-text_6kf3xs"
|
|
702
702
|
>
|
|
703
703
|
Check
|
|
704
704
|
</span>
|
|
@@ -443,7 +443,7 @@ exports[`graded-group should snapshot: initial render (mobile: false) 1`] = `
|
|
|
443
443
|
type="button"
|
|
444
444
|
>
|
|
445
445
|
<span
|
|
446
|
-
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-
|
|
446
|
+
class="text_f1191h-o_O-LabelLarge_5s82ln-o_O-text_6kf3xs"
|
|
447
447
|
>
|
|
448
448
|
Check
|
|
449
449
|
</span>
|
|
@@ -3638,7 +3638,7 @@ exports[`single-choice question reviewMode: true should snapshot the same: first
|
|
|
3638
3638
|
</button>
|
|
3639
3639
|
</div>
|
|
3640
3640
|
<div
|
|
3641
|
-
class="perseus-radio-rationale-content
|
|
3641
|
+
class="perseus-radio-rationale-content rationale_1ctj0s0"
|
|
3642
3642
|
data-test-id="perseus-radio-rationale-content-0"
|
|
3643
3643
|
>
|
|
3644
3644
|
<div
|
|
@@ -3834,7 +3834,7 @@ exports[`single-choice question reviewMode: true should snapshot the same: first
|
|
|
3834
3834
|
</button>
|
|
3835
3835
|
</div>
|
|
3836
3836
|
<div
|
|
3837
|
-
class="perseus-radio-rationale-content
|
|
3837
|
+
class="perseus-radio-rationale-content rationale_1ctj0s0"
|
|
3838
3838
|
data-test-id="perseus-radio-rationale-content-1"
|
|
3839
3839
|
>
|
|
3840
3840
|
<div
|
|
@@ -4014,7 +4014,7 @@ exports[`single-choice question reviewMode: true should snapshot the same: first
|
|
|
4014
4014
|
</button>
|
|
4015
4015
|
</div>
|
|
4016
4016
|
<div
|
|
4017
|
-
class="perseus-radio-rationale-content
|
|
4017
|
+
class="perseus-radio-rationale-content rationale_1ctj0s0"
|
|
4018
4018
|
data-test-id="perseus-radio-rationale-content-2"
|
|
4019
4019
|
>
|
|
4020
4020
|
<div
|
|
@@ -4195,7 +4195,7 @@ exports[`single-choice question reviewMode: true should snapshot the same: first
|
|
|
4195
4195
|
</button>
|
|
4196
4196
|
</div>
|
|
4197
4197
|
<div
|
|
4198
|
-
class="perseus-radio-rationale-content
|
|
4198
|
+
class="perseus-radio-rationale-content rationale_1ctj0s0"
|
|
4199
4199
|
data-test-id="perseus-radio-rationale-content-3"
|
|
4200
4200
|
>
|
|
4201
4201
|
<div
|
|
@@ -9,7 +9,7 @@ import {question1} from "../__testdata__/matcher.testdata";
|
|
|
9
9
|
import {renderQuestion} from "./renderQuestion";
|
|
10
10
|
|
|
11
11
|
import type {APIOptions} from "../../types";
|
|
12
|
-
import type {Matcher} from "
|
|
12
|
+
import type {Matcher} from "../matcher";
|
|
13
13
|
|
|
14
14
|
describe("matcher widget", () => {
|
|
15
15
|
beforeEach(() => {
|
|
@@ -2,7 +2,7 @@ import "@testing-library/jest-dom";
|
|
|
2
2
|
|
|
3
3
|
import {testDependencies} from "../../../../../testing/test-dependencies";
|
|
4
4
|
import * as Dependencies from "../../dependencies";
|
|
5
|
-
import {question1} from "../__testdata__/video.testdata";
|
|
5
|
+
import {question1, question2} from "../__testdata__/video.testdata";
|
|
6
6
|
|
|
7
7
|
import {renderQuestion} from "./renderQuestion";
|
|
8
8
|
|
|
@@ -50,4 +50,20 @@ describe("video widget", () => {
|
|
|
50
50
|
// Assert
|
|
51
51
|
expect(container).toMatchSnapshot("first mobile render");
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
it("vimeo widget should contain dnt param", () => {
|
|
55
|
+
// Arrange
|
|
56
|
+
const apiOptions: APIOptions = {
|
|
57
|
+
isMobile: false,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Act
|
|
61
|
+
renderQuestion(question2, apiOptions);
|
|
62
|
+
|
|
63
|
+
// Assert
|
|
64
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
65
|
+
expect(document.getElementsByTagName("iframe")[0].src).toContain(
|
|
66
|
+
"dnt=1",
|
|
67
|
+
);
|
|
68
|
+
});
|
|
53
69
|
});
|
package/src/widgets/matcher.tsx
CHANGED
package/src/widgets/video.tsx
CHANGED
|
@@ -24,6 +24,7 @@ const DEFAULT_HEIGHT = 720;
|
|
|
24
24
|
const KA_EMBED = "{host}/embed_video?slug={slug}" + "&internal_video_only=1";
|
|
25
25
|
const IS_URL = /^https?:\/\//;
|
|
26
26
|
const IS_KA_SITE = /(khanacademy\.org|localhost)/;
|
|
27
|
+
const IS_VIMEO = /(vimeo\.com)/;
|
|
27
28
|
|
|
28
29
|
type UserInput = null;
|
|
29
30
|
type Rubric = PerseusVideoWidgetOptions;
|
|
@@ -75,6 +76,16 @@ class Video extends React.Component<Props> {
|
|
|
75
76
|
|
|
76
77
|
if (IS_URL.test(location)) {
|
|
77
78
|
url = location;
|
|
79
|
+
if (IS_VIMEO.test(url)) {
|
|
80
|
+
// If this is a vimeo video, we need to add the query string
|
|
81
|
+
// parameter "dnt" so that analytics/tracking cookies aren't set.
|
|
82
|
+
// https://help.vimeo.com/hc/en-us/articles/12426260232977-Player-parameters-overview
|
|
83
|
+
if (url.indexOf("?") === -1) {
|
|
84
|
+
url += "?dnt=1";
|
|
85
|
+
} else {
|
|
86
|
+
url += "&dnt=1";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
78
89
|
} else {
|
|
79
90
|
url = KA_EMBED.replace("{slug}", location);
|
|
80
91
|
let embedHostname = "https://www.khanacademy.org";
|