Open
Conversation
hiyuki
reviewed
Nov 25, 2025
| overflow: 'hidden', | ||
| whiteSpace: (${parsed.result}) <= 1 ? 'nowrap' : '', | ||
| textOverflow: (${parsed.result}) <= 1 ? 'ellipsis' : '', | ||
| WebkitBoxOrient: 'vertical', |
hiyuki
reviewed
Nov 25, 2025
|
|
||
| // 处理 max-lines 跨平台属性 | ||
| function processMaxLines (el) { | ||
| const maxLinesAttr = getAndRemoveAttr(el, 'enable-max-lines') |
Collaborator
There was a problem hiding this comment.
processTextMaxLines,只处理Text节点
hiyuki
reviewed
Nov 25, 2025
| let children = inlineTextProps.children | ||
|
|
||
| // 如果启用了 enable-add-space,在末尾追加一个空格节点 | ||
| if (enableAddSpace) { |
Collaborator
There was a problem hiding this comment.
inlineText不需要支持吧
多个地方使用抽一个公共方法
测试性能开销
Collaborator
Author
There was a problem hiding this comment.
iphone 13,渲染 1000 个 text 组件
<text class="perf-text" enable-add-space="{{enableAddSpace}}">{{ text }}</text>
enableAddSpace = true:
- useAddSpace hook 平均耗时 0.0086 ms
- mpx-text 组件平均耗时 0.0795 ms
enableAddSpace = false
- useAddSpace hook 平均耗时 0.0006ms
- mpx-text 组件平均耗时 0.0673 ms
hiyuki
reviewed
Nov 25, 2025
| // 如果启用了 enable-add-space,在末尾追加一个空格节点 | ||
| if (enableAddSpace) { | ||
| const spaceNode = createElement(Text, { | ||
| style: spaceFontSize ? { fontSize: spaceFontSize } : undefined |
Collaborator
There was a problem hiding this comment.
spaceFontSize判断放到外面,没有这个都不需要传递props
hiyuki
reviewed
Jan 13, 2026
| return invokeCallback | ||
| } | ||
|
|
||
| export function useAddSpace (children: ReactNode, { enableAddSpace, spaceFontSize }: { enableAddSpace?: boolean, spaceFontSize?: number }) { |
hiyuki
reviewed
Jan 13, 2026
| processMpxTagName(el) | ||
|
|
||
| // 处理 enable-max-lines 跨平台属性(在平台规则处理之前) | ||
| processTextMaxLines(el) |
Collaborator
There was a problem hiding this comment.
放在平台规则处理之后,支持overflow属性,同时平台规则处理可以校验overfolow属性
Collaborator
There was a problem hiding this comment.
继续放在平台转换之前,函数名统一改为preProcessXXX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
小程序 / Web / RN 的 Text 组件新增 enable-max-lines 属性,支持单行及多行文本的省略打点样式。
RN 的 Text 组件新增 enable-add-space、space-font-size 属性,支持在文本尾部补空格能力,用于规避小米 HyperOS 系统下 Text 组件出现的“吞字”问题。
RN 的 Text 组件新增 enable-android-align-center 属性,开启后组件样式将默认增加 includeFontPadding: false 与 textAlignVertical: 'center' 配置
以上扩展能力直接使用 View 包裹文本节点的场景均不支持