tiptap/docs/src/docPages/api/extensions/underline.md

59 lines
1.4 KiB
Markdown
Raw Normal View History

2020-08-19 03:39:41 +08:00
# Underline
2020-08-20 21:33:16 +08:00
Enables you to use the `<u>` HTML tag in the editor.
2020-08-19 03:39:41 +08:00
2020-08-20 21:33:16 +08:00
## Options
2020-09-10 16:21:24 +08:00
| Option | Type | Default | Description |
| ------ | ------ | ------- | -------------------------------------------- |
| class | string | | Add a custom class to the rendered HTML tag. |
2020-08-19 03:39:41 +08:00
2020-08-20 21:33:16 +08:00
## Commands
2020-09-10 16:21:24 +08:00
| Command | Options | Description |
| --------- | ------- | ------------------------ |
| underline | — | Mark text as underlined. |
2020-08-19 03:39:41 +08:00
2020-08-20 21:33:16 +08:00
## Keybindings
2020-08-19 03:39:41 +08:00
* Windows & Linux: `Control` + `U`
* macOS: `Command` + `U`
2020-08-20 21:33:16 +08:00
## Usage
2020-08-19 03:39:41 +08:00
```markup
<template>
<div>
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<button type="button" :class="{ 'is-active': isActive.underline() }" @click="commands.underline">
Underline
</button>
</editor-menu-bar>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import { Underline } from 'tiptap-extensions'
export default {
components: {
EditorMenuBar,
EditorContent,
},
data() {
return {
editor: new Editor({
extensions: [
2020-09-09 16:58:10 +08:00
Underline(),
2020-08-19 03:39:41 +08:00
],
content: `
<p><u>This is underlined.</u></p>
<p style="text-decoration: underline">This as well.</p>
`,
}),
}
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>
```