add content to the custom extension page

This commit is contained in:
Hans Pagel
2020-09-22 16:09:24 +02:00
parent 4c6dbe1a80
commit 570091fb95

View File

@@ -1,7 +1,31 @@
# Custom Extensions # Custom Extensions
Lets extend tiptap with a custom extension!
## Option 1: Change defaults ## Option 1: Change defaults
Lets say you want to change the keyboard shortcuts for the bullet list. You should start by looking at [the source code of the `Bold` extension](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-bold/index.ts) and find the default youd like to change. In that case, the keyboard shortcut.
```js
// 1. Import the extension
import BulletList from '@tiptap/extension-bullet-list'
// 2. Overwrite the keyboard shortcuts
const CustomBulletList = new Node()
.keys(({ editor }) => ({
'Mod-l': () => editor.bulletList(),
}))
.create() // Dont forget that!
// 3. Add the custom extension to your editor
new Editor({
extensions: [
CustomBulletList(),
// …
]
})
```
## Option 2: Extend existing extensions ## Option 2: Extend existing extensions
## Option 3: Start from scratch ## Option 3: Start from scratch