rename demo, add more content

This commit is contained in:
Hans Pagel
2020-10-28 17:31:51 +01:00
parent 4dad818f7d
commit 83eac2ddd8
2 changed files with 6 additions and 19 deletions

View File

@@ -1,13 +1,9 @@
<template> <template>
<div> <pre>{{ html }}</pre>
<pre>{{ html }}</pre>
<pre>{{ otherHtml }}</pre>
</div>
</template> </template>
<script> <script>
import { generateHTML } from '@tiptap/core' import { generateHTML } from '@tiptap/html'
import { generateHTML as generateHTMLWithoutEditor } from '@tiptap/html'
import Document from '@tiptap/extension-document' import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph' import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text' import Text from '@tiptap/extension-text'
@@ -26,7 +22,6 @@ export default {
}], }],
}, },
html: '', html: '',
otherHtml: '',
} }
}, },
@@ -36,12 +31,6 @@ export default {
Paragraph(), Paragraph(),
Text(), Text(),
]) ])
this.otherHtml = generateHTMLWithoutEditor(this.json, [
Document(),
Paragraph(),
Text(),
])
}, },
} }
</script> </script>

View File

@@ -126,15 +126,13 @@ const schema = getSchema([
## Generate HTML from ProseMirror JSON ## Generate HTML from ProseMirror JSON
If you need to render the content on the server side, e. g. for a blog post that was written with tiptap, youll probably need a way to do just that without an actual editor instance. If you need to render the content on the server side, for example to render a blog post which was written with tiptap, youll probably need a way to do just that without an actual editor instance. Thats what `generateHTML()` is for. Its a utility function that renders HTML without an actual editor instance.
Thats what `generategetHTML()` is for. Its a utility function that renders HTML without an actual editor instance. :::info Browser-only rendering
Import a lightweight implementation from `@tiptap/core` if youre using the function in a browser context only.
:::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).
::: :::
<demo name="Api/Schema/GenerateHtml" highlight="6,29-33"/> <demo name="Api/Schema/GenerateHTML" highlight="6,29-33"/>
### Converting JSON<>HTML with PHP ### Converting JSON<>HTML with PHP