tiptap/docs/src/docPages/overview/upgrade-guide.md

61 lines
2.0 KiB
Markdown
Raw Normal View History

# Upgrade Guide
2020-09-15 23:26:27 +08:00
## Reasons to upgrade to tiptap 2.x
2020-09-16 03:07:16 +08:00
* autocomplete in your IDE (thanks to TypeScript)
* an amazing documentation with 100+ pages
* active development, new features in the making
* tons of new extensions planned
* well-tested code base
2020-09-09 21:57:30 +08:00
## Upgrading from 1.x to 2.x
2020-09-16 03:07:16 +08:00
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:
2020-09-15 23:26:27 +08:00
### 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
2020-09-09 21:57:30 +08:00
**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
import Document from '@tiptap/extension-document'
const CustomDocument = Document.name('doc').create()
new Editor({
extensions: [
CustomDocument(),
]
})
```
2020-09-15 23:26:27 +08:00
### 3. New extension API
2020-09-09 21:57:30 +08:00
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.
```js
const CustomExtension = …
```
2020-09-15 23:26:27 +08:00
### 4. Blockquotes must not be nested anymore
2020-09-16 03:07:16 +08:00
:::warning Breaking Change
Currently, blockquotes must not be nested anymore. That said, were working on bringing it back. If you use nested blockquotes in your app, dont upgrade yet.
:::