pb-sxp-ui 1.0.25 → 1.0.27
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/dist/index.cjs +44 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -17
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +44 -17
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/FormatImage.js +7 -6
- package/es/core/components/SxpPageRender/VideoWidget/index.js +37 -10
- package/lib/core/components/SxpPageRender/FormatImage.js +6 -5
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +37 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -8311,21 +8311,22 @@ var ExpandableText$1 = React.memo(ExpandableText);
|
|
8311
8311
|
* @Author: binruan@chatlabs.com
|
8312
8312
|
* @Date: 2024-03-20 10:27:31
|
8313
8313
|
* @LastEditors: binruan@chatlabs.com
|
8314
|
-
* @LastEditTime: 2024-04-
|
8314
|
+
* @LastEditTime: 2024-04-19 14:12:55
|
8315
8315
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
|
8316
8316
|
*
|
8317
8317
|
*/
|
8318
8318
|
const FormatImage = React.forwardRef((props, ref) => {
|
8319
8319
|
const { src, onLoad, style, className, loading } = props;
|
8320
|
-
const [imgSrc, setImgSrc] = React.useState(
|
8320
|
+
const [imgSrc, setImgSrc] = React.useState();
|
8321
8321
|
React.useImperativeHandle(ref, () => ({
|
8322
8322
|
setSrc: (v) => {
|
8323
8323
|
setImgSrc(v);
|
8324
8324
|
}
|
8325
8325
|
}));
|
8326
|
-
|
8327
|
-
|
8328
|
-
|
8326
|
+
React.useEffect(() => {
|
8327
|
+
setImgSrc(src);
|
8328
|
+
}, [src]);
|
8329
|
+
return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
|
8329
8330
|
React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
|
8330
8331
|
React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
|
8331
8332
|
React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
|
@@ -8333,7 +8334,7 @@ const FormatImage = React.forwardRef((props, ref) => {
|
|
8333
8334
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
|
8334
8335
|
} }))) : (React.createElement("img", { className: className, src: imgSrc, style: style, loading: loading, onLoad: (e) => {
|
8335
8336
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
|
8336
|
-
} }));
|
8337
|
+
} }))));
|
8337
8338
|
});
|
8338
8339
|
var FormatImage$1 = React.memo(FormatImage);
|
8339
8340
|
|
@@ -11997,6 +11998,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
11997
11998
|
const [isLoadFinish, setIsLoadFinish] = React.useState(false);
|
11998
11999
|
const [isFirstPlay, setIsFirstPlay] = React.useState(true);
|
11999
12000
|
const { isActive } = useSwiperSlide();
|
12001
|
+
const canvasRef = React.useRef(null);
|
12002
|
+
const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
|
12000
12003
|
React.useEffect(() => {
|
12001
12004
|
if (!videoRef.current)
|
12002
12005
|
return;
|
@@ -12090,8 +12093,24 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
12090
12093
|
});
|
12091
12094
|
}
|
12092
12095
|
}, [data, index, bffEventReport]);
|
12096
|
+
const handLoadeddata = React.useCallback(() => {
|
12097
|
+
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
12098
|
+
if (!video)
|
12099
|
+
return;
|
12100
|
+
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
12101
|
+
if (!canvas)
|
12102
|
+
return;
|
12103
|
+
const ctx = canvas.getContext('2d');
|
12104
|
+
const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
|
12105
|
+
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
12106
|
+
canvas.height = targetHeight;
|
12107
|
+
canvas.width = targetWidth;
|
12108
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
12109
|
+
setFirstFrameSrc(canvas.toDataURL());
|
12110
|
+
canvas.remove();
|
12111
|
+
}, []);
|
12093
12112
|
React.useEffect(() => {
|
12094
|
-
var _a, _b;
|
12113
|
+
var _a, _b, _c;
|
12095
12114
|
if (!videoRef.current)
|
12096
12115
|
return;
|
12097
12116
|
setIsPauseVideo(false);
|
@@ -12116,12 +12135,14 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
12116
12135
|
}
|
12117
12136
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', handleLoadedMetadata);
|
12118
12137
|
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('playing', handlePlaying);
|
12138
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('loadeddata', handLoadeddata);
|
12119
12139
|
return () => {
|
12120
|
-
var _a, _b;
|
12140
|
+
var _a, _b, _c;
|
12121
12141
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', handleLoadedMetadata);
|
12122
12142
|
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('playing', handlePlaying);
|
12143
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('loadeddata', handLoadeddata);
|
12123
12144
|
};
|
12124
|
-
}, [handleLoadedMetadata, handlePlaying, rec.video]);
|
12145
|
+
}, [handleLoadedMetadata, handlePlaying, rec.video, handLoadeddata]);
|
12125
12146
|
React.useEffect(() => {
|
12126
12147
|
var _a;
|
12127
12148
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
@@ -12187,21 +12208,27 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
12187
12208
|
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
|
12188
12209
|
: 'translateY(-50%)';
|
12189
12210
|
}, [videoPostConfig]);
|
12211
|
+
const blurBgSrc = React.useMemo(() => {
|
12212
|
+
var _a;
|
12213
|
+
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
12214
|
+
}, [firstFrameSrc, rec]);
|
12190
12215
|
if (!rec.video) {
|
12191
12216
|
return null;
|
12192
12217
|
}
|
12193
12218
|
return (React.createElement(React.Fragment, null, blur ? (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
|
12194
12219
|
position: 'relative',
|
12195
12220
|
width: '100%',
|
12196
|
-
height
|
12221
|
+
height,
|
12222
|
+
overflow: 'hidden'
|
12197
12223
|
} },
|
12198
|
-
React.createElement(FormatImage$1, { src:
|
12224
|
+
React.createElement(FormatImage$1, { src: blurBgSrc, style: {
|
12199
12225
|
height: '100%',
|
12200
12226
|
width: '100%',
|
12201
12227
|
objectFit: 'cover',
|
12202
12228
|
filter: blur ? 'blur(10px)' : 'none',
|
12203
12229
|
transform: blur ? 'scale(1.2)' : 'none'
|
12204
12230
|
} }),
|
12231
|
+
React.createElement("canvas", { ref: canvasRef, style: { display: 'none' } }),
|
12205
12232
|
React.createElement("div", { style: {
|
12206
12233
|
position: 'absolute',
|
12207
12234
|
width: '100%',
|
@@ -12212,18 +12239,19 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
12212
12239
|
right: 0
|
12213
12240
|
} },
|
12214
12241
|
React.createElement("div", { style: { position: 'relative' } },
|
12215
|
-
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
|
12242
|
+
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
|
12216
12243
|
width: '100%',
|
12217
12244
|
height: 'auto',
|
12218
12245
|
objectFit: 'contain'
|
12219
12246
|
} }),
|
12220
|
-
|
12221
|
-
|
12247
|
+
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))),
|
12248
|
+
renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
|
12222
12249
|
position: 'relative',
|
12223
12250
|
width: '100%',
|
12224
|
-
height
|
12251
|
+
height,
|
12252
|
+
overflow: 'hidden'
|
12225
12253
|
} },
|
12226
|
-
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
|
12254
|
+
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
|
12227
12255
|
renderPoster,
|
12228
12256
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
|
12229
12257
|
};
|
@@ -13085,4 +13113,3 @@ exports.default = Pagebuilder;
|
|
13085
13113
|
exports.defaultSetting = defaultSetting;
|
13086
13114
|
exports.materials = _materials_;
|
13087
13115
|
exports.useEditorDataProvider = useEditorDataProvider;
|
13088
|
-
//# sourceMappingURL=index.cjs.map
|