Merge branch 'main' of github.com:ueberdosis/tiptap-next into main

This commit is contained in:
Hans Pagel
2020-09-24 21:41:46 +02:00
4 changed files with 27 additions and 5 deletions

View File

@@ -28,6 +28,9 @@
<button @click="editor.chain().focus().codeBlock().run()" :class="{ 'is-active': editor.isActive('codeBlock') }">
code block
</button>
<button @click="editor.chain().focus().paragraph().run()" :class="{ 'is-active': editor.isActive('paragraph') }">
paragraph
</button>
<button @click="editor.chain().focus().heading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
h1
</button>

View File

@@ -23,7 +23,7 @@ yarn add @tiptap/extension-ordered-list @tiptap/extension-list-item
## Commands
| Command | Options | Description |
| ----------- | ------- | --------------------- |
| ------------ | ------- | ---------------------- |
| ordered_list | — | Toggle a ordered list. |
## Keyboard shortcuts

View File

@@ -20,10 +20,13 @@ yarn add @tiptap/extension-paragraph
| class | string | | Add a custom class to the rendered HTML tag. |
## Commands
*None*
| Command | Options | Description |
| --------- | ------- | -------------------------------------------- |
| paragraph | — | Transforms all selected nodes to paragraphs. |
## Keyboard shortcuts
*None*
* Windows & Linux: `Control` `Alt` `0`
* macOS: `Cmd` `Alt` `0`
## Source code
[packages/extension-paragraph/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-paragraph/)

View File

@@ -1,6 +1,14 @@
import { Node } from '@tiptap/core'
import { Command, Node } from '@tiptap/core'
// import ParagraphComponent from './paragraph.vue'
export type ParagraphCommand = () => Command
declare module '@tiptap/core/src/Editor' {
interface Commands {
paragraph: ParagraphCommand,
}
}
export default new Node()
.name('paragraph')
.schema(() => ({
@@ -10,4 +18,12 @@ export default new Node()
toDOM: () => ['p', 0],
// toVue: ParagraphComponent,
}))
.commands(({ name }) => ({
[name]: () => ({ commands }) => {
return commands.toggleNode(name, 'paragraph')
},
}))
.keys(({ editor }) => ({
'Mod-Alt-0': () => editor.paragraph(),
}))
.create()