Appearance
着重号 Emphasis
在文字上方或下方加着重号,渲染为 <span class="qp-emphasis">,样式由 qp-emphasis--<style> 修饰类区分(默认下方圆点不带修饰类)。
用法
ts
import { Emphasis } from '@qingpai/core'
const editor = new Editor({
extensions: [Emphasis],
})属性
| 名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
emphasisStyle | EmphasisStyle | 'dot' | 着重号样式,不渲染为 HTML 属性(rendered: false),仅内部逻辑使用;渲染输出通过 qp-emphasis--<style> 修饰类区分 |
EmphasisStyle 取值
| 值 | 说明 |
|---|---|
'dot' | 下方圆点(默认) |
'dot-top' | 上方圆点 |
'circle' | 圆圈 |
'circle-fill' | 实心圈 |
'accent' | 重音符 |
配置
| 名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
HTMLAttributes | Record<string, any> | {} | 渲染到着重号元素上的额外 HTML 属性 |
命令
ts
// 设置着重号(可指定样式,缺省为下方圆点)
editor.commands.setEmphasis({ emphasisStyle: 'circle-fill' })
// 切换着重号(已应用相同样式时取消,未选中时回退默认样式)
editor.commands.toggleEmphasis({ emphasisStyle: 'dot-top' })
// 取消着重号
editor.commands.unsetEmphasis()导出的常量
| 名称 | 说明 |
|---|---|
emphasisStyle | 着重号样式常量数组 ['dot', 'dot-top', 'circle', 'circle-fill', 'accent'] |
导出的类型
ts
type EmphasisStyle = 'dot' | 'dot-top' | 'circle' | 'circle-fill' | 'accent'
interface SetEmphasisOptions {
emphasisStyle?: string
}配套 UI
| 名称 | 说明 |
|---|---|
EmphasisButton | 工具栏着重号按钮 |
EmphasisDropdown | 工具栏着重号样式下拉 |
Source code
packages/core/src/marks/emphasis/