@khanacademy/perseus 13.0.0 → 13.1.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 +11 -0
- package/dist/es/index.js +12 -1
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/widgets/__stories__/video.stories.tsx +9 -1
- package/src/widgets/__testdata__/video.testdata.ts +40 -0
- package/src/widgets/__tests__/video.test.ts +17 -1
- package/src/widgets/video.tsx +11 -0
- 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": "13.
|
|
6
|
+
"version": "13.1.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@khanacademy/kas": "^0.3.5",
|
|
26
26
|
"@khanacademy/kmath": "^0.1.6",
|
|
27
|
-
"@khanacademy/math-input": "^15.0.
|
|
27
|
+
"@khanacademy/math-input": "^15.0.1",
|
|
28
28
|
"@khanacademy/perseus-core": "1.3.0",
|
|
29
29
|
"@khanacademy/perseus-linter": "^0.3.8",
|
|
30
30
|
"@khanacademy/pure-markdown": "^0.2.10",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";
|
|
4
|
-
import {question1} from "../__testdata__/video.testdata";
|
|
4
|
+
import {question1, question2, question3} from "../__testdata__/video.testdata";
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: "Perseus/Widgets/Video",
|
|
@@ -12,3 +12,11 @@ type StoryArgs = Record<any, any>;
|
|
|
12
12
|
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
export const Question2 = (args: StoryArgs): React.ReactElement => {
|
|
17
|
+
return <RendererWithDebugUI question={question2} />;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Question3 = (args: StoryArgs): React.ReactElement => {
|
|
21
|
+
return <RendererWithDebugUI question={question3} />;
|
|
22
|
+
};
|
|
@@ -19,3 +19,43 @@ export const question1: PerseusRenderer = {
|
|
|
19
19
|
},
|
|
20
20
|
replace: false,
|
|
21
21
|
};
|
|
22
|
+
|
|
23
|
+
export const question2: PerseusRenderer = {
|
|
24
|
+
content:
|
|
25
|
+
"Watch the WMF at Angkor Wat video to find the answer.\n\n[[\u2603 video 1]]\n\n",
|
|
26
|
+
images: {},
|
|
27
|
+
widgets: {
|
|
28
|
+
"video 1": {
|
|
29
|
+
graded: true,
|
|
30
|
+
version: {major: 0, minor: 0},
|
|
31
|
+
static: false,
|
|
32
|
+
type: "video",
|
|
33
|
+
options: {
|
|
34
|
+
static: false,
|
|
35
|
+
location: "https://player.vimeo.com/video/4754041",
|
|
36
|
+
},
|
|
37
|
+
alignment: "block",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
replace: false,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const question3: PerseusRenderer = {
|
|
44
|
+
content:
|
|
45
|
+
"Watch the WMF at Angkor Wat video to find the answer.\n\n[[\u2603 video 1]]\n\n",
|
|
46
|
+
images: {},
|
|
47
|
+
widgets: {
|
|
48
|
+
"video 1": {
|
|
49
|
+
graded: true,
|
|
50
|
+
version: {major: 0, minor: 0},
|
|
51
|
+
static: false,
|
|
52
|
+
type: "video",
|
|
53
|
+
options: {
|
|
54
|
+
static: false,
|
|
55
|
+
location: "https://player.vimeo.com/video/4754041?h=64fbc32a6e",
|
|
56
|
+
},
|
|
57
|
+
alignment: "block",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
replace: false,
|
|
61
|
+
};
|
|
@@ -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/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";
|