add the strike extension documentation

This commit is contained in:
Hans Pagel
2020-09-10 11:53:03 +02:00
parent 236ad6e21a
commit 868ffb4d66
5 changed files with 72 additions and 46 deletions

View File

@@ -0,0 +1,5 @@
context('/api/extensions/strike', () => {
beforeEach(() => {
cy.visit('/api/extensions/strike')
})
})

View File

@@ -0,0 +1,54 @@
<template>
<div v-if="editor">
<button @click="editor.focus().strike()" :class="{ 'is-active': editor.isActive('strike') }">
strike
</button>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor } from '@tiptap/core'
import { EditorContent } from '@tiptap/vue'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
// import Strike from '@tiptap/extension-strike'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
// Strike(),
],
content: `
<p>This isnt striked through.</s></p>
<p><s>But thats striked through.</s></p>
<p><del>And this.</del></p>
<p><strike>This too.</strike></p>
<p style="text-decoration: line-through">This as well.</p>
`,
})
window.editor = this.editor
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>

View File

@@ -1,5 +1,5 @@
# Bold # Bold
This extension is used to render text in **bold**. If you pass `<strong>`, `<b>` tags, or text with inline `style` attributes setting the `font-weight` CSS rule in the editors initial content, they will all be rendered accordingly. This extension is used to render text in **bold**. If you pass `<strong>`, `<b>` tags, or text with inline `style` attributes setting the `font-weight` CSS rule in the editors initial content, they all will be rendered accordingly.
Type `**two asterisks**` or `__two underlines__` and the it will be magically transformed to **bold** text while you type. Type `**two asterisks**` or `__two underlines__` and the it will be magically transformed to **bold** text while you type.

View File

@@ -1,5 +1,5 @@
# Italic # Italic
This extension is used to render text in *italic*. If you pass `<em>`, `<i>` tags, or text with inline `style` attributes setting `font-style: italic` in the editors initial content, they will all be rendered accordingly. This extension is used to render text in *italic*. If you pass `<em>`, `<i>` tags, or text with inline `style` attributes setting `font-style: italic` in the editors initial content, they all will be rendered accordingly.
::: warning Restrictions ::: warning Restrictions
The extension will generate the corresponding `<em>` HTML tags when reading contents of the `Editor` instance. All text marked italic, regardless of the method will be normalized to `<em>` HTML tags. The extension will generate the corresponding `<em>` HTML tags when reading contents of the `Editor` instance. All text marked italic, regardless of the method will be normalized to `<em>` HTML tags.

View File

@@ -1,5 +1,11 @@
# Strike # Strike
Enables you to use the `<s>` HTML tag in the editor. This extension is used to render ~~striked text~~. If you pass `<s>`, `<del>`, `<strike>` tags, or text with inline `style` attributes setting `text-decoration: line-through` in the editors initial content, they all will be rendered accordingly.
Type `~~two tildes~~` and the it will be magically ~~striked through~~ while you type.
::: warning Restrictions
The extension will generate the corresponding `<s>` HTML tags when reading contents of the `Editor` instance. All text striked through, regardless of the method will be normalized to `<s>` HTML tags.
:::
## Options ## Options
| Option | Type | Default | Description | | Option | Type | Default | Description |
@@ -15,47 +21,8 @@ Enables you to use the `<s>` HTML tag in the editor.
* Windows & Linux: `Control` + `D` * Windows & Linux: `Control` + `D`
* macOS: `Command` + `D` * macOS: `Command` + `D`
## Source Code
[packages/extension-strike/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-strike/)
## Usage ## Usage
```markup <demo name="Extensions/Strike" highlight="3-5,17,36" />
<template>
<div>
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<button type="button" :class="{ 'is-active': isActive.strike() }" @click="commands.strike">
Strike
</button>
</editor-menu-bar>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import { Strike } from 'tiptap-extensions'
export default {
components: {
EditorMenuBar,
EditorContent,
},
data() {
return {
editor: new Editor({
extensions: [
Strike(),
],
content: `
<p><s>That's strikethrough.</s></p>
<p><del>This too.</del></p>
<p><strike>And this.</strike></p>
<p style="text-decoration: line-through">This as well.</p>
`,
}),
}
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>
```