You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React-rte配置toolbarConfig时对齐按钮组的显示名称是什么?

React-rte 对齐按钮组配置名称

React-rte 工具栏中对齐(justify)功能按钮组对应的配置显示名称为 JUSTIFY_BUTTONS。

配置方式

直接在toolbarConfig的display数组中加入该配置项,即可按数组顺序在工具栏渲染对齐按钮组。如果需要自定义对齐按钮的文案、样式,可新增同名配置项覆盖默认配置,参考完整示例:

const toolbarConfig = {
    // 配置项按数组声明顺序渲染到工具栏
    display: [
      'INLINE_STYLE_BUTTONS', 
      'BLOCK_TYPE_BUTTONS', 
      'LINK_BUTTONS', 
      'BLOCK_TYPE_DROPDOWN',
      'JUSTIFY_BUTTONS', // 引入对齐按钮组
      'HISTORY_BUTTONS'
    ],
    INLINE_STYLE_BUTTONS: [
      {label: 'Bold', style: 'BOLD', className: 'custom-css-class'},
      {label: 'Italic', style: 'ITALIC'},
      {label: 'Underline', style: 'UNDERLINE'}
    ],
    BLOCK_TYPE_DROPDOWN: [
      {label: 'Normal', style: 'unstyled'},
      {label: 'Heading Large', style: 'header-one'},
      {label: 'Heading Medium', style: 'header-two'},
      {label: 'Heading Small', style: 'header-three'}
    ],
    BLOCK_TYPE_BUTTONS: [
      {label: 'UL', style: 'unordered-list-item'},
      {label: 'OL', style: 'ordered-list-item'}
    ],
    // 自定义对齐按钮配置,不声明则使用编辑器默认配置
    JUSTIFY_BUTTONS: [
      {label: '左对齐', style: 'ALIGN_LEFT'},
      {label: '居中对齐', style: 'ALIGN_CENTER'},
      {label: '右对齐', style: 'ALIGN_RIGHT'},
      {label: '两端对齐', style: 'ALIGN_JUSTIFY'}
    ]
  }

对齐按钮效果参考:
对齐按钮示例


内容的提问来源于stack exchange,提问作者Lucas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.30 08:27:20