智能客服
你问我答,随时在线为你解决问题

























CustomSpan 是最小单位的组件。若需实现特定功能,建议在多个 CustomSpan 上分别进行。如果必须在同一 CustomSpan 上实现,可从点击事件回调的 ClickEvent 中,根据属性判断实际点击位置,从而做出差异化响应。示例代码如下:
- @Entry
- @Component
- struct Index {
- controller: RichEditorController = new RichEditorController();
- option: RichEditorOptions = { controller: this.controller };
-
- @Builder
- comment() {
- Row() {
- Text() {
- Span('123123123')
- ImageSpan($r('app.media.startIcon')).width(20).height(20)
- Span('ggggggggggggggggggggggxxxxxxxxxxxxxxxxxxxxxxx')
- }
- .maxLines(1)
- .wordBreak(WordBreak.BREAK_ALL)
- .textOverflow({ overflow: TextOverflow.Ellipsis })
- .constraintSize({
- maxWidth: '90%'
- })
-
- Image($r('app.media.startIcon'))
- .width(25)
- .height(25)
- .onClick(() => {
- this.getUIContext().getPromptAction().showToast({
- message: 'Click to delete'
- })
- })
- }
- .width('100%')
- .align(Alignment.Center)
- .padding({
- top: 5,
- bottom: 5
- })
- .borderRadius(20)
- .backgroundColor(Color.Gray)
- }
-
- build() {
- Column() {
- Column() {
- RichEditor(this.option)
- .onReady(() => {
- this.controller.addBuilderSpan(() => this.comment())
- })
- .borderWidth(1)
- .borderColor(Color.Green)
- .width('100%')
- .height('30%')
- }
- .borderWidth(1)
- .borderColor(Color.Red)
- .width('100%')
- .height('70%')
- }
- }
- }
智能客服
你问我答,随时在线为你解决问题
合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功