docs: update content

This commit is contained in:
Hans Pagel 2021-04-03 13:49:36 +02:00
parent f1dac9aaef
commit 0e6c79a761
2 changed files with 7 additions and 10 deletions

View File

@ -3,7 +3,10 @@
</template>
<script>
// Option 1: Browser + server-side
import { generateHTML } from '@tiptap/html'
// Option 2: Browser-only (lightweight)
// import { generateHTML } from '@tiptap/core'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
@ -45,6 +48,7 @@ export default {
Paragraph,
Text,
Bold,
// other extensions
])
},
}

View File

@ -110,18 +110,14 @@ const editor = new Editor({
### Option 1: Read-only instance of tiptap
To render the saved content, set the editor to read-only. Thats how you can achieve the exact same rendering as its in the editor, without duplicating your CSS and other code.
<demo name="Guide/Content/ReadOnly" highlight="3-6,22,28,41-47" />
<demo name="Guide/Content/ReadOnly" highlight="3-6,22,28,42-46" />
### 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, youll probably want to do just that without an actual editor instance.
Thats what the `generateHTML()` is for. Its a helper function which renders HTML without an actual editor instance.
:::info Browser-only rendering
Import a lightweight implementation of `generateHTML()` from `@tiptap/core` if youre using the function in a browser context only.
:::
<demo name="Guide/Content/GenerateHTML" highlight="6,43-48"/>
<demo name="Guide/Content/GenerateHTML" highlight="6-7,46-52"/>
## Migration
If youre migrating existing content to tiptap we would recommend to get your existing output to HTML. Thats 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 arent allowed (based on your configuration), tiptap just throws them away quietly.
@ -131,7 +127,4 @@ Were about to go through a few cases to help with that, for example we provid
[Share your experiences with us!](mailto:humans@tiptap.dev) Wed like to add more information here.
## Security
Theres no reason to use on or the other because of security concerns.
### Validation
Always validate user input sent to an API. Attackers dont need to use tiptap to send malicious HTML or JSON to an API endpoint.
Theres no reason to use on or the other because of security concerns. If someone wants to send malicious content to your server, it doesnt matter if its JSON or HTML. You should always validate user input.