@gravity-ui/page-constructor 5.31.0 → 5.31.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.
@@ -53,9 +53,22 @@ const VideoBlock = (props) => {
53
53
  const fullId = (0, react_1.useMemo)(() => id || (0, uuid_1.v4)(), [id]);
54
54
  const buttonId = (0, uikit_1.useUniqId)();
55
55
  const [isPlaying, setIsPlaying] = (0, react_1.useState)(!previewImg);
56
- const iframeSrc = src && isPlaying
57
- ? `${src}?${(0, utils_1.getPageSearchParams)(Object.assign(Object.assign({}, (attributes || {})), (previewImg || autoplay ? exports.AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES)))}`
58
- : undefined;
56
+ const iframeSrc = (0, react_1.useMemo)(() => {
57
+ if (src && isPlaying) {
58
+ try {
59
+ const url = new URL(src);
60
+ const searchParams = (0, utils_1.getPageSearchParams)(Object.assign(Object.assign({}, (attributes || {})), (previewImg || autoplay ? exports.AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES)));
61
+ searchParams.forEach((value, key) => {
62
+ url.searchParams.set(key, value);
63
+ });
64
+ return url.href;
65
+ }
66
+ catch (e) {
67
+ return src;
68
+ }
69
+ }
70
+ return undefined;
71
+ }, [attributes, autoplay, isPlaying, previewImg, src]);
59
72
  const onPreviewClick = (0, react_1.useCallback)(() => {
60
73
  handleAnalytics(analyticsEvents);
61
74
  setIsPlaying(true);
@@ -49,9 +49,22 @@ const VideoBlock = (props) => {
49
49
  const fullId = useMemo(() => id || uuidv4(), [id]);
50
50
  const buttonId = useUniqId();
51
51
  const [isPlaying, setIsPlaying] = useState(!previewImg);
52
- const iframeSrc = src && isPlaying
53
- ? `${src}?${getPageSearchParams(Object.assign(Object.assign({}, (attributes || {})), (previewImg || autoplay ? AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES)))}`
54
- : undefined;
52
+ const iframeSrc = useMemo(() => {
53
+ if (src && isPlaying) {
54
+ try {
55
+ const url = new URL(src);
56
+ const searchParams = getPageSearchParams(Object.assign(Object.assign({}, (attributes || {})), (previewImg || autoplay ? AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES)));
57
+ searchParams.forEach((value, key) => {
58
+ url.searchParams.set(key, value);
59
+ });
60
+ return url.href;
61
+ }
62
+ catch (e) {
63
+ return src;
64
+ }
65
+ }
66
+ return undefined;
67
+ }, [attributes, autoplay, isPlaying, previewImg, src]);
55
68
  const onPreviewClick = useCallback(() => {
56
69
  handleAnalytics(analyticsEvents);
57
70
  setIsPlaying(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "5.31.0",
3
+ "version": "5.31.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {