pb-sxp-ui 1.15.23 → 1.15.25
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 +28 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -15
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -5
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -5
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +28 -15
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -5
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/ExpandableText.js +31 -12
- package/lib/core/components/SxpPageRender/ExpandableText.js +31 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -10214,34 +10214,36 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
|
|
10214
10214
|
const [isShow, setIsShow] = React.useState(false);
|
10215
10215
|
const _a = style || {}, { lineClamp } = _a, textStyle = __rest(_a, ["lineClamp"]);
|
10216
10216
|
const textLineClamp = Number(lineClamp || 2);
|
10217
|
-
const
|
10217
|
+
const realRef = React.useRef(null);
|
10218
|
+
const clampRef = React.useRef(null);
|
10218
10219
|
const observerRef = React.useRef();
|
10219
10220
|
const handleClick = () => {
|
10220
10221
|
setIsShowMore(!isShowMore);
|
10221
10222
|
};
|
10222
10223
|
const checkOverflow = React.useCallback(() => {
|
10223
|
-
if (!
|
10224
|
+
if (!realRef.current || !clampRef.current || !isPost || !text || isShowMore)
|
10224
10225
|
return;
|
10225
|
-
|
10226
|
-
|
10227
|
-
|
10228
|
-
|
10229
|
-
|
10226
|
+
requestAnimationFrame(() => {
|
10227
|
+
const realHeight = realRef.current.getBoundingClientRect().height;
|
10228
|
+
const clampHeight = clampRef.current.getBoundingClientRect().height;
|
10229
|
+
const isActuallyClamped = realHeight > clampHeight + 1;
|
10230
|
+
setIsShow(isActuallyClamped);
|
10231
|
+
});
|
10232
|
+
}, [isPost, text, isShowMore]);
|
10233
|
+
// 增强版监听(同时监听字体加载)
|
10230
10234
|
React.useEffect(() => {
|
10231
|
-
if (!
|
10235
|
+
if (!realRef.current)
|
10232
10236
|
return;
|
10233
|
-
// 使用ResizeObserver监听尺寸变化
|
10234
10237
|
observerRef.current = new ResizeObserver(checkOverflow);
|
10235
|
-
observerRef.current.observe(
|
10236
|
-
// 初始检查
|
10238
|
+
observerRef.current.observe(realRef.current);
|
10237
10239
|
checkOverflow();
|
10238
10240
|
return () => {
|
10239
10241
|
var _a;
|
10240
10242
|
(_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
10241
10243
|
};
|
10242
10244
|
}, [checkOverflow]);
|
10243
|
-
return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, textStyle), { transform: 'translate3d(0px, 0px, 0px)' }), hidden: !text || text === '' },
|
10244
|
-
React.createElement("div", { ref:
|
10245
|
+
return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, textStyle), { transform: 'translate3d(0px, 0px, 0px)', overflow: 'hidden' }), hidden: !text || text === '' },
|
10246
|
+
React.createElement("div", { ref: clampRef, style: Object.assign(Object.assign({}, (!isShowMore &&
|
10245
10247
|
isPost && {
|
10246
10248
|
WebkitLineClamp: textLineClamp,
|
10247
10249
|
lineClamp: textLineClamp,
|
@@ -10249,7 +10251,19 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
|
|
10249
10251
|
overflow: 'hidden',
|
10250
10252
|
display: '-webkit-box',
|
10251
10253
|
WebkitBoxOrient: 'vertical'
|
10252
|
-
})), { wordBreak: 'break-word' }), dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), textStyle) } }),
|
10254
|
+
})), { wordBreak: 'break-word', textRendering: 'geometricPrecision', fontKerning: 'none', textSizeAdjust: '100%', boxSizing: 'border-box', contain: 'content' }), dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), textStyle) } }),
|
10255
|
+
React.createElement("div", { ref: realRef, style: {
|
10256
|
+
wordBreak: 'break-word',
|
10257
|
+
textRendering: 'geometricPrecision',
|
10258
|
+
fontKerning: 'none',
|
10259
|
+
textSizeAdjust: '100%',
|
10260
|
+
boxSizing: 'border-box',
|
10261
|
+
contain: 'content',
|
10262
|
+
visibility: 'hidden',
|
10263
|
+
position: 'absolute',
|
10264
|
+
opacity: 0,
|
10265
|
+
clipPath: 'inset(100%)'
|
10266
|
+
}, dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), textStyle) } }),
|
10253
10267
|
text && isPost && isShow && (React.createElement("button", { "aria-label": isShowMore ? unfoldText || 'show less' : foldText || 'show more', style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick, dangerouslySetInnerHTML: {
|
10254
10268
|
__html: setFontForText(isShowMore ? unfoldText || 'show less' : foldText || 'show more', textStyle)
|
10255
10269
|
} }))));
|
@@ -20184,4 +20198,3 @@ exports.core = index$3;
|
|
20184
20198
|
exports.default = Pagebuilder;
|
20185
20199
|
exports.materials = _materials_;
|
20186
20200
|
exports.useEditorDataProvider = useEditorDataProvider;
|
20187
|
-
//# sourceMappingURL=index.cjs.map
|