This commit is contained in:
@@ -34,7 +34,7 @@ Have a look at all of the core commands listed below. They should give you a goo
|
||||
| Command | Description |
|
||||
| --------------- | ----------------------------------------------------------- |
|
||||
| .clearContent() | Clear the whole document. |
|
||||
| .insertHTML() | Insert a string of HTML at the currently selected position. |
|
||||
| .insertgetHTML() | Insert a string of HTML at the currently selected position. |
|
||||
| .insertText() | Insert a string of text at the currently selected position. |
|
||||
| .setContent() | Replace the whole document with new content. |
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ This class is a central building block of tiptap. It does most of the heavy lift
|
||||
| `onBlur` | `Function` | `undefined` | Returns an object with the `event` and current `state` and `view` of Prosemirror on blur. |
|
||||
| `onFocus` | `Function` | `undefined` | Returns an object with the `event` and current `state` and `view` of Prosemirror on focus. |
|
||||
| `onInit` | `Function` | `undefined` | Returns an object with the current `state` and `view` of Prosemirror on init. |
|
||||
| `onUpdate` | `Function` | `undefined` | Returns an object with the current `state` of Prosemirror, a `json()` and `html()` function and the `transaction` on every change. |
|
||||
| `onUpdate` | `Function` | `undefined` | Returns an object with the current `state` of Prosemirror, a `getJSON()` and `getHTML()` function and the `transaction` on every change. |
|
||||
|
||||
## Methods
|
||||
| Method | Parameters | Description |
|
||||
| -------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
|
||||
| `html()` | – | Returns the current content as HTML. |
|
||||
| `json()` | – | Returns the current content as JSON. |
|
||||
| `getHTML()` | – | Returns the current content as HTML. |
|
||||
| `getJSON()` | – | Returns the current content as JSON. |
|
||||
| `destroy()` | – | Stops the editor instance and unbinds all events. |
|
||||
| `chain()` | - | Create a command chain to call multiple commands at once. |
|
||||
| `setOptions()` | `options` A list of options | Update editor options. |
|
||||
|
||||
@@ -128,7 +128,7 @@ const schema = getSchema([
|
||||
|
||||
If you need to render the content on the server side, e. g. for a blog post that was written with tiptap, you’ll probably need a way to do just that without an actual editor instance.
|
||||
|
||||
That’s what `generateHtml()` is for. It’s a utility function that renders HTML without an actual editor instance.
|
||||
That’s what `generategetHTML()` is for. It’s a utility function that renders HTML without an actual editor instance.
|
||||
|
||||
:::warning Work in progress
|
||||
Currently, that works only in the browser (client side), but we plan to bring this to Node.js (to use it on the server side).
|
||||
|
||||
@@ -11,7 +11,7 @@ You can store your content as JSON and restore the content from HTML, or the oth
|
||||
JSON is probably easier to loop through, for example to look for a mention and it’s more like what tiptap uses under the hood. Anyway, if you want to use JSON to store the content we provide a method to retrieve the content as JSON:
|
||||
|
||||
```js
|
||||
const json = editor.json()
|
||||
const json = editor.getJSON()
|
||||
```
|
||||
|
||||
You can store that in your database (or send it to an API) and restore the document initially like that:
|
||||
@@ -59,7 +59,7 @@ editor.setContent({
|
||||
HTML can be easily rendered in other places, for example in emails and it’s wildly used, so it’s probably easier to switch the editor at some point. Anyway, every editor instance provides a method to get HTML from the current document:
|
||||
|
||||
```js
|
||||
const html = editor.html()
|
||||
const html = editor.getHTML()
|
||||
```
|
||||
|
||||
This can then be used to restore the document initially:
|
||||
|
||||
Reference in New Issue
Block a user