add more content

This commit is contained in:
Hans Pagel
2020-09-30 16:16:15 +02:00
parent e67c041c31
commit 5d7435f3fe
6 changed files with 50 additions and 36 deletions

View File

@@ -14,7 +14,7 @@ Yes, its tedious work to upgrade your favorite text editor to a new API, but
## 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 need to know:
### 1. Explicitly register the Document, Text and Paragraph extensions
### Explicitly register the Document, Text and Paragraph extensions
Tiptap 1 tried to hide a few required extensions from you with the default setting `useBuiltInExtensions: true`. That setting has been removed and youre required to import all extensions. Be sure to explicitly import at least the [Document](/api/extensions/document), [Paragraph](/api/extensions/paragraph) and [Text](/api/extensions/text) extensions.
```js
@@ -32,7 +32,7 @@ new Editor({
})
```
### 2. New document type
### 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.
```js
@@ -48,7 +48,7 @@ new Editor({
})
```
### 3. New extension API
### New extension API
In case youve built some custom extensions for your project, youre required to rewrite them to fit the new API. No worries, you can keep a lot of your work though. The `schema`, `commands`, `keys`, `inputRules` and `pasteRules` all work like they did before. Its just different how you register them.
```js
@@ -79,7 +79,7 @@ const CustomExtension = new Node()
Dont forget to call `create()` in the end! Read more about [all the nifty details building custom extensions](/guide/custom-extensions) in our guide.
### 4. Renamed API methods
### Renamed API methods
[We renamed a lot of commands](/api/commands), hopefully you can migrate to the new API with search & replace. Here is a list of what changed:
| Old method name | New method name |
@@ -87,11 +87,11 @@ Dont forget to call `create()` in the end! Read more about [all the nifty det
| ~~`getHTML`~~ | `html` |
| ~~`getJSON`~~ | `json` |
### 5. Commands can be chained now
### Commands can be chained now
### 6. .focus() isnt called on every command anymore
### .focus() isnt called on every command anymore
We tried to hide the `.focus()` command from you with tiptap 1 and executed that on every other command. That led to issues in specific use cases, where you want to run a command, but dont want to focus the editor. With tiptap 2.x you have to explicitly call the `focus()` and you probably want to do that in a lot of places. Here is an example:
```js