pb-sxp-ui 1.15.23 → 1.15.24
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 +39 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +39 -16
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- 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/pb-ui.js
CHANGED
@@ -10208,30 +10208,53 @@
|
|
10208
10208
|
const _a = style || {}, { lineClamp } = _a, textStyle = __rest(_a, ["lineClamp"]);
|
10209
10209
|
const textLineClamp = Number(lineClamp || 2);
|
10210
10210
|
const multiRow = React.useRef(null);
|
10211
|
-
|
10211
|
+
React.useRef();
|
10212
10212
|
const handleClick = () => {
|
10213
10213
|
setIsShowMore(!isShowMore);
|
10214
10214
|
};
|
10215
10215
|
const checkOverflow = React.useCallback(() => {
|
10216
|
-
if (!multiRow.current || !isPost)
|
10216
|
+
if (!multiRow.current || !isPost || !text)
|
10217
10217
|
return;
|
10218
|
-
|
10219
|
-
const
|
10220
|
-
//
|
10221
|
-
|
10218
|
+
// 强制同步布局(消除浏览器优化导致的误差)
|
10219
|
+
const triggerReflow = (el) => el.offsetHeight;
|
10220
|
+
// 分三步精确测量
|
10221
|
+
requestAnimationFrame(() => {
|
10222
|
+
// 第一步:获取干净状态
|
10223
|
+
const el = multiRow.current;
|
10224
|
+
triggerReflow(el);
|
10225
|
+
// 第二步:测量无约束状态的真实高度
|
10226
|
+
const originalStyle = el.style.cssText;
|
10227
|
+
el.style.webkitLineClamp = 'unset';
|
10228
|
+
el.style.display = 'block';
|
10229
|
+
triggerReflow(el);
|
10230
|
+
const realHeight = el.getBoundingClientRect().height;
|
10231
|
+
// 第三步:恢复约束状态
|
10232
|
+
el.style.cssText = originalStyle;
|
10233
|
+
triggerReflow(el);
|
10234
|
+
const clampHeight = el.getBoundingClientRect().height;
|
10235
|
+
// 精准比较(考虑亚像素渲染)
|
10236
|
+
const isActuallyClamped = realHeight > clampHeight + 1;
|
10237
|
+
// 防抖处理
|
10238
|
+
console.log('[精确测量]', { realHeight, clampHeight, isActuallyClamped });
|
10239
|
+
setIsShow(isActuallyClamped);
|
10240
|
+
});
|
10222
10241
|
}, [isPost, text, textLineClamp]);
|
10242
|
+
// 增强版监听(同时监听字体加载)
|
10223
10243
|
React.useEffect(() => {
|
10224
|
-
|
10244
|
+
const el = multiRow.current;
|
10245
|
+
if (!el)
|
10225
10246
|
return;
|
10226
|
-
|
10227
|
-
|
10228
|
-
observerRef.current.observe(multiRow.current);
|
10229
|
-
// 初始检查
|
10230
|
-
checkOverflow();
|
10231
|
-
return () => {
|
10232
|
-
var _a;
|
10233
|
-
(_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
10247
|
+
const fontCheck = () => {
|
10248
|
+
document.fonts.ready.then(checkOverflow);
|
10234
10249
|
};
|
10250
|
+
const observer = new ResizeObserver((entries) => {
|
10251
|
+
entries.forEach((entry) => {
|
10252
|
+
if (entry.contentBoxSize) ;
|
10253
|
+
});
|
10254
|
+
});
|
10255
|
+
fontCheck();
|
10256
|
+
observer.observe(el);
|
10257
|
+
return () => observer.disconnect();
|
10235
10258
|
}, [checkOverflow]);
|
10236
10259
|
return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, textStyle), { transform: 'translate3d(0px, 0px, 0px)' }), hidden: !text || text === '' },
|
10237
10260
|
React.createElement("div", { ref: multiRow, style: Object.assign(Object.assign({}, (!isShowMore &&
|
@@ -10242,7 +10265,7 @@
|
|
10242
10265
|
overflow: 'hidden',
|
10243
10266
|
display: '-webkit-box',
|
10244
10267
|
WebkitBoxOrient: 'vertical'
|
10245
|
-
})), { wordBreak: 'break-word' }), dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), textStyle) } }),
|
10268
|
+
})), { 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) } }),
|
10246
10269
|
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: {
|
10247
10270
|
__html: setFontForText(isShowMore ? unfoldText || 'show less' : foldText || 'show more', textStyle)
|
10248
10271
|
} }))));
|