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.js CHANGED
@@ -10192,34 +10192,36 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
10192
10192
  const [isShow, setIsShow] = useState(false);
10193
10193
  const _a = style || {}, { lineClamp } = _a, textStyle = __rest(_a, ["lineClamp"]);
10194
10194
  const textLineClamp = Number(lineClamp || 2);
10195
- const multiRow = useRef(null);
10195
+ const realRef = useRef(null);
10196
+ const clampRef = useRef(null);
10196
10197
  const observerRef = useRef();
10197
10198
  const handleClick = () => {
10198
10199
  setIsShowMore(!isShowMore);
10199
10200
  };
10200
10201
  const checkOverflow = useCallback(() => {
10201
- if (!multiRow.current || !isPost)
10202
+ if (!realRef.current || !clampRef.current || !isPost || !text || isShowMore)
10202
10203
  return;
10203
- const lineHeight = parseInt(getComputedStyle(multiRow.current).lineHeight) || 20;
10204
- const maxHeight = lineHeight * textLineClamp;
10205
- // 添加1px容错,解决部分机型计算误差
10206
- setIsShow(multiRow.current.scrollHeight > maxHeight + 1);
10207
- }, [isPost, text, textLineClamp]);
10204
+ requestAnimationFrame(() => {
10205
+ const realHeight = realRef.current.getBoundingClientRect().height;
10206
+ const clampHeight = clampRef.current.getBoundingClientRect().height;
10207
+ const isActuallyClamped = realHeight > clampHeight + 1;
10208
+ setIsShow(isActuallyClamped);
10209
+ });
10210
+ }, [isPost, text, isShowMore]);
10211
+ // 增强版监听(同时监听字体加载)
10208
10212
  useEffect(() => {
10209
- if (!multiRow.current)
10213
+ if (!realRef.current)
10210
10214
  return;
10211
- // 使用ResizeObserver监听尺寸变化
10212
10215
  observerRef.current = new ResizeObserver(checkOverflow);
10213
- observerRef.current.observe(multiRow.current);
10214
- // 初始检查
10216
+ observerRef.current.observe(realRef.current);
10215
10217
  checkOverflow();
10216
10218
  return () => {
10217
10219
  var _a;
10218
10220
  (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
10219
10221
  };
10220
10222
  }, [checkOverflow]);
10221
- return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, textStyle), { transform: 'translate3d(0px, 0px, 0px)' }), hidden: !text || text === '' },
10222
- React.createElement("div", { ref: multiRow, style: Object.assign(Object.assign({}, (!isShowMore &&
10223
+ return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, textStyle), { transform: 'translate3d(0px, 0px, 0px)', overflow: 'hidden' }), hidden: !text || text === '' },
10224
+ React.createElement("div", { ref: clampRef, style: Object.assign(Object.assign({}, (!isShowMore &&
10223
10225
  isPost && {
10224
10226
  WebkitLineClamp: textLineClamp,
10225
10227
  lineClamp: textLineClamp,
@@ -10227,7 +10229,19 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
10227
10229
  overflow: 'hidden',
10228
10230
  display: '-webkit-box',
10229
10231
  WebkitBoxOrient: 'vertical'
10230
- })), { wordBreak: 'break-word' }), dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), textStyle) } }),
10232
+ })), { 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) } }),
10233
+ React.createElement("div", { ref: realRef, style: {
10234
+ wordBreak: 'break-word',
10235
+ textRendering: 'geometricPrecision',
10236
+ fontKerning: 'none',
10237
+ textSizeAdjust: '100%',
10238
+ boxSizing: 'border-box',
10239
+ contain: 'content',
10240
+ visibility: 'hidden',
10241
+ position: 'absolute',
10242
+ opacity: 0,
10243
+ clipPath: 'inset(100%)'
10244
+ }, dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), textStyle) } }),
10231
10245
  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: {
10232
10246
  __html: setFontForText(isShowMore ? unfoldText || 'show less' : foldText || 'show more', textStyle)
10233
10247
  } }))));
@@ -20152,4 +20166,3 @@ var index = memo(SxpPageCore);
20152
20166
  */
20153
20167
 
20154
20168
  export { index$2 as DiyPortalPreview, index$1 as DiyStoryPreview, EditorDataProvider, Modal$1 as Modal, SxpDataSourceProvider$1 as SxpDataSourceProvider, index as SxpPageCore, SxpPageRender$1 as SxpPageRender, index$3 as core, Pagebuilder as default, _materials_ as materials, useEditorDataProvider };
20155
- //# sourceMappingURL=index.js.map