下划线
为选中的文字添加下划线。
试一试
选中 “Yurich” 并点击 下划线。结果为 <u>Yurich</u>。再次点击可取消。
交互示例
示例结果
添加到编辑器
启用 Underline,令按钮调用 toggleUnderline。
import { EditorContent, EditorProvider, Underline, useEditor, useIsActive } from 'yurich';
export function UnderlineEditor() {
const editor = useEditor({
extensions: [Underline],
initialValue: "<p>在 Yurich 下面画一条线。</p>",
});
const active = useIsActive(editor, 'toggleUnderline');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleUnderline')}
>
下划线
</button>
<EditorContent ariaLabel="编辑器" />
</EditorProvider>
);
}
行为说明
快捷键是 Mod+U。需要点击后跳转时,请使用 Link。