add more to the upgrade guide

This commit is contained in:
Hans Pagel
2020-09-15 17:26:27 +02:00
parent 2f9ee7fbbd
commit 6b606f376f

View File

@@ -1,7 +1,8 @@
# Upgrade Guide # Upgrade Guide
## Reasons to upgrade to tiptap 2.x The new API will look pretty familiar too you, but there are a ton of changes though. To make the upgrade a little bit easier, here is everything you need to know:
## Reasons to upgrade to tiptap 2.x
* TypeScript: auto complete, less bugs, generated API documentation * TypeScript: auto complete, less bugs, generated API documentation
* Amazing documentation with 100+ pages * Amazing documentation with 100+ pages
* Active maintenance, no more updates to 1.x * Active maintenance, no more updates to 1.x
@@ -9,9 +10,27 @@
* Less bugs, tested code based * Less bugs, tested code based
## Upgrading from 1.x to 2.x ## Upgrading from 1.x to 2.x
The new API will look pretty familiar too you, but there are a ton of changes though. To make the upgrade a little bit easier, here is everything you should do:
### New document type ### 1. Explicitly register the Document, Text and Paragraph extensions
Tiptap 1 tried to hide a few required extensions from you. Be sure to explicitly import the [Document](/api/extensions/document), [Paragraph](/api/extensions/paragraph) and [Text](/api/extensions/text) extensions.
```js
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
]
})
```
### 2. New document type
**We renamed the default `Document` type from `doc` to `document`.** To keep it like that, use your own implementation of the `Document` node or migrate the stored JSON to use the new name. **We renamed the default `Document` type from `doc` to `document`.** To keep it like that, use your own implementation of the `Document` node or migrate the stored JSON to use the new name.
```js ```js
@@ -26,7 +45,7 @@ new Editor({
}) })
``` ```
### New extension API ### 3. New extension API
In case youve built some custom extensions for your project, youll need to rewrite them to fit the new API. No worries, though, you can keep a lot of your work though. The schema, commands, keys, inputRules, pasteRules all work like they did before. Its just different how you register them. In case youve built some custom extensions for your project, youll need to rewrite them to fit the new API. No worries, though, you can keep a lot of your work though. The schema, commands, keys, inputRules, pasteRules all work like they did before. Its just different how you register them.
@@ -34,5 +53,5 @@ In case youve built some custom extensions for your project, youll need to
const CustomExtension = const CustomExtension =
``` ```
### Blockquotes must not be nested anymore ### 4. Blockquotes must not be nested anymore