docs: use regular case for Tiptap
This commit is contained in:
@@ -10,7 +10,7 @@ You can store your content as a JSON object or as a good old HTML string. Both w
|
||||
## Export
|
||||
|
||||
### Option 1: JSON
|
||||
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:
|
||||
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.getJSON()
|
||||
@@ -82,14 +82,14 @@ Unfortunately, **tiptap doesn’t support Markdown as an input or output format*
|
||||
|
||||
* Both, HTML and JSON, can have deeply nested structures, Markdown is flat.
|
||||
* Markdown standards vary.
|
||||
* tiptap’s strength is customization, that doesn’t work very well with Markdown.
|
||||
* Tiptap’s strength is customization, that doesn’t work very well with Markdown.
|
||||
* There are enough packages to convert HTML to Markdown and vice-versa.
|
||||
|
||||
You should really consider to work with HTML or JSON to store your content, they are perfectly fine for most use cases.
|
||||
|
||||
If you still think you need Markdown, ProseMirror has an [example on how to deal with Markdown](https://prosemirror.net/examples/markdown/), [Nextcloud Text](https://github.com/nextcloud/text) uses tiptap 1 to work with Markdown. Maybe you can learn from them. Or if you are looking for a really good Markdown editor, try [CodeMirror](https://codemirror.net/).
|
||||
If you still think you need Markdown, ProseMirror has an [example on how to deal with Markdown](https://prosemirror.net/examples/markdown/), [Nextcloud Text](https://github.com/nextcloud/text) uses Tiptap 1 to work with Markdown. Maybe you can learn from them. Or if you are looking for a really good Markdown editor, try [CodeMirror](https://codemirror.net/).
|
||||
|
||||
That said, tiptap does support [Markdown shortcuts](/examples/markdown-shortcuts) to format your content. Also you’re free to let your content look like Markdown, for example add a `#` before an `<h1>` with CSS.
|
||||
That said, Tiptap does support [Markdown shortcuts](/examples/markdown-shortcuts) to format your content. Also you’re free to let your content look like Markdown, for example add a `#` before an `<h1>` with CSS.
|
||||
|
||||
## Listening for changes
|
||||
If you want to continuously store the updated content while people write, you can [hook into events](/api/events). Here is an example how that could look like:
|
||||
@@ -109,13 +109,13 @@ const editor = new Editor({
|
||||
|
||||
## Rendering
|
||||
|
||||
### Option 1: Read-only instance of tiptap
|
||||
### Option 1: Read-only instance of Tiptap
|
||||
To render the saved content, set the editor to read-only. That’s how you can achieve the exact same rendering as it’s in the editor, without duplicating your CSS and other code.
|
||||
|
||||
https://embed.tiptap.dev/preview/GuideContent/ReadOnly
|
||||
|
||||
### Option 2: Generate HTML from ProseMirror JSON
|
||||
If you need to render the content on the server side, for example to generate the HTML for a blog post which has been written in tiptap, you’ll probably want to do just that without an actual editor instance.
|
||||
If you need to render the content on the server side, for example to generate the HTML for a blog post which has been written in Tiptap, you’ll probably want to do just that without an actual editor instance.
|
||||
|
||||
That’s what the `generateHTML()` is for. It’s a helper function which renders HTML without an actual editor instance.
|
||||
|
||||
@@ -126,11 +126,11 @@ By the way, the other way is possible, too. The below examples shows how to gene
|
||||
https://embed.tiptap.dev/preview/GuideContent/GenerateJSON
|
||||
|
||||
## Migration
|
||||
If you’re migrating existing content to tiptap we would recommend to get your existing output to HTML. That’s probably the best format to get your initial content into tiptap, because ProseMirror ensures there is nothing wrong with it. Even if there are some tags or attributes that aren’t allowed (based on your configuration), tiptap just throws them away quietly.
|
||||
If you’re migrating existing content to Tiptap we would recommend to get your existing output to HTML. That’s probably the best format to get your initial content into Tiptap, because ProseMirror ensures there is nothing wrong with it. Even if there are some tags or attributes that aren’t allowed (based on your configuration), Tiptap just throws them away quietly.
|
||||
|
||||
We’re about to go through a few cases to help with that, for example we provide a PHP package to convert HTML to a compatible JSON structure: [ueberdosis/prosemirror-to-html](https://github.com/ueberdosis/html-to-prosemirror).
|
||||
|
||||
[Share your experiences with us!](mailto:humans@tiptap.dev) We’d like to add more information here.
|
||||
|
||||
## Security
|
||||
There is no reason to use one or the other because of security concerns. If someone wants to send malicious content to your server, it doesn’t matter if it’s JSON or HTML. It doesn’t even matter if you’re using tiptap or not. You should always validate user input.
|
||||
There is no reason to use one or the other because of security concerns. If someone wants to send malicious content to your server, it doesn’t matter if it’s JSON or HTML. It doesn’t even matter if you’re using Tiptap or not. You should always validate user input.
|
||||
|
||||
Reference in New Issue
Block a user