@gravity-ui/page-constructor 2.2.0 → 2.2.1
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
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.1](https://github.com/gravity-ui/page-constructor/compare/v2.2.0...v2.2.1) (2023-03-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **ReactPlayer:** transform youtube url for single video src ([#262](https://github.com/gravity-ui/page-constructor/issues/262)) ([5bd86fd](https://github.com/gravity-ui/page-constructor/commit/5bd86fd0e5b62e309fcf656f251007cd8e4efd68))
|
|
9
|
+
|
|
3
10
|
## [2.2.0](https://github.com/gravity-ui/page-constructor/compare/v2.1.1...v2.2.0) (2023-03-29)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -4,20 +4,21 @@ exports.checkYoutubeVideos = void 0;
|
|
|
4
4
|
// the file serves to support live video with react-player@2.9
|
|
5
5
|
const LIVE_YUOTUBE_VIDEO_REGEX = /(?:youtu\.be\/live\/|youtube(?:-nocookie)?\.com\/(?:live\/))((\w|-){11})/;
|
|
6
6
|
const YOUTUBE_VIDEO_TEMPLATE = 'https://www.youtube.com/watch?v=';
|
|
7
|
+
const transformYoutubeUrl = (src) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (LIVE_YUOTUBE_VIDEO_REGEX.test(src)) {
|
|
10
|
+
const youtubeLiveId = (_a = src.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
|
|
11
|
+
if (!youtubeLiveId) {
|
|
12
|
+
return src;
|
|
13
|
+
}
|
|
14
|
+
return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
|
|
15
|
+
}
|
|
16
|
+
return src;
|
|
17
|
+
};
|
|
7
18
|
const checkYoutubeVideos = (src) => {
|
|
8
19
|
if (Array.isArray(src)) {
|
|
9
|
-
return src.map((videoUrl) =>
|
|
10
|
-
var _a;
|
|
11
|
-
if (LIVE_YUOTUBE_VIDEO_REGEX.test(videoUrl)) {
|
|
12
|
-
const youtubeLiveId = (_a = videoUrl.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
|
|
13
|
-
if (!youtubeLiveId) {
|
|
14
|
-
return videoUrl;
|
|
15
|
-
}
|
|
16
|
-
return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
|
|
17
|
-
}
|
|
18
|
-
return videoUrl;
|
|
19
|
-
});
|
|
20
|
+
return src.map((videoUrl) => transformYoutubeUrl(videoUrl));
|
|
20
21
|
}
|
|
21
|
-
return src;
|
|
22
|
+
return transformYoutubeUrl(src);
|
|
22
23
|
};
|
|
23
24
|
exports.checkYoutubeVideos = checkYoutubeVideos;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// the file serves to support live video with react-player@2.9
|
|
2
2
|
const LIVE_YUOTUBE_VIDEO_REGEX = /(?:youtu\.be\/live\/|youtube(?:-nocookie)?\.com\/(?:live\/))((\w|-){11})/;
|
|
3
3
|
const YOUTUBE_VIDEO_TEMPLATE = 'https://www.youtube.com/watch?v=';
|
|
4
|
+
const transformYoutubeUrl = (src) => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (LIVE_YUOTUBE_VIDEO_REGEX.test(src)) {
|
|
7
|
+
const youtubeLiveId = (_a = src.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
|
|
8
|
+
if (!youtubeLiveId) {
|
|
9
|
+
return src;
|
|
10
|
+
}
|
|
11
|
+
return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
|
|
12
|
+
}
|
|
13
|
+
return src;
|
|
14
|
+
};
|
|
4
15
|
export const checkYoutubeVideos = (src) => {
|
|
5
16
|
if (Array.isArray(src)) {
|
|
6
|
-
return src.map((videoUrl) =>
|
|
7
|
-
var _a;
|
|
8
|
-
if (LIVE_YUOTUBE_VIDEO_REGEX.test(videoUrl)) {
|
|
9
|
-
const youtubeLiveId = (_a = videoUrl.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
|
|
10
|
-
if (!youtubeLiveId) {
|
|
11
|
-
return videoUrl;
|
|
12
|
-
}
|
|
13
|
-
return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
|
|
14
|
-
}
|
|
15
|
-
return videoUrl;
|
|
16
|
-
});
|
|
17
|
+
return src.map((videoUrl) => transformYoutubeUrl(videoUrl));
|
|
17
18
|
}
|
|
18
|
-
return src;
|
|
19
|
+
return transformYoutubeUrl(src);
|
|
19
20
|
};
|