improve the documentation
This commit is contained in:
15
docs/src/docPages/api/schema/generate-html.md
Normal file
15
docs/src/docPages/api/schema/generate-html.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# 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, you’ll probably need a way to do just that without an actual editor instance.
|
||||
|
||||
<demo name="Api/Schema" />
|
||||
|
||||
That should work in the browser (client side) and in Node.js (browser side).
|
||||
|
||||
## Converting JSON<>HTML with PHP
|
||||
|
||||
We needed to do the same thing in PHP at some point, so we published libraries to convert ProseMirror JSON to HTML and vice-versa:
|
||||
|
||||
* [ueberdosis/prosemirror-php](https://github.com/ueberdosis/prosemirror-php) (PHP)
|
||||
* [ueberdosis/prosemirror-to-html](https://github.com/ueberdosis/prosemirror-to-html) (PHP)
|
||||
* [ueberdosis/html-to-prosemirror](https://github.com/ueberdosis/html-to-prosemirror) (PHP)
|
||||
41
docs/src/docPages/api/schema/get-schema.md
Normal file
41
docs/src/docPages/api/schema/get-schema.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Get the underlying ProseMirror schema
|
||||
|
||||
There are a few use cases where you need to work with the underlying schema. You’ll need that if you’re using the tiptap collaborative text editing features or if you want to manually render your content as HTML.
|
||||
|
||||
## With an Editor
|
||||
If you need this on the client side and need an editor instance anyway, it’s available through the editor:
|
||||
|
||||
```js
|
||||
import { Editor } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
new Document,
|
||||
new Paragraph,
|
||||
new Text,
|
||||
// add more extensions here
|
||||
])
|
||||
})
|
||||
|
||||
const schema = editor.schema
|
||||
```
|
||||
|
||||
## Without an Editor
|
||||
If you just want to have the schema *without* initializing an actual editor, you can use the `getSchema` helper function. It needs an array of available extensions and conveniently generates a ProseMirror schema for you:
|
||||
|
||||
```js
|
||||
import { getSchema } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
|
||||
const schema = getSchema([
|
||||
new Document,
|
||||
new Paragraph,
|
||||
new Text,
|
||||
// add more extensions here
|
||||
])
|
||||
```
|
||||
Reference in New Issue
Block a user