Appearance
下划线 Underline
定制版下划线,支持装饰线样式属性,渲染为 <u class="qp-underline">,装饰线样式由 qp-underline--<style> 修饰类区分。
用法
ts
import { Underline } from '@qingpai/core'
const editor = new Editor({
extensions: [Underline],
})属性
| 名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
decorationStyle | UnderlineDecorationStyle | 'solid' | 装饰线样式,不渲染为 HTML 属性(rendered: false),仅内部逻辑使用;渲染输出通过 qp-underline--<style> 修饰类区分 |
UnderlineDecorationStyle 取值
| 值 | 说明 |
|---|---|
'solid' | 实线 |
'double' | 双线 |
'dotted' | 点线 |
'dashed' | 虚线 |
'wavy' | 波浪线 |
配置
| 名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
HTMLAttributes | Record<string, any> | {} | 渲染到下划线元素上的额外 HTML 属性 |
命令
ts
// 设置下划线(可指定装饰线样式)
editor.commands.setUnderline({ decorationStyle: 'wavy' })
// 切换下划线
editor.commands.toggleUnderline()
// 取消下划线
editor.commands.unsetUnderline()键盘快捷键
| 快捷键 | 描述 |
|---|---|
Mod-U | 切换下划线 |
Mod-u | 切换下划线 |
Markdown
支持 Markdown 双向转换:++下划线文字++。
导出的常量
| 名称 | 说明 |
|---|---|
underlineDecorationStyle | 装饰线样式常量数组 ['solid', 'double', 'dotted', 'dashed', 'wavy'] |
导出的类型
ts
type UnderlineDecorationStyle = 'solid' | 'double' | 'dotted' | 'dashed' | 'wavy'
interface SetUnderlineOptions {
decorationStyle?: string
}配套 UI
| 名称 | 说明 |
|---|---|
UnderlineButton | 工具栏下划线按钮 |
Source code
packages/core/src/marks/underline/