add getSchema & getHtml utility functions to generate HTML from a ProseMirror/tiptap document, without an Editor instance
This commit is contained in:
38
docs/src/demos/Api/Schema/index.vue
Normal file
38
docs/src/demos/Api/Schema/index.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<pre>{{ this.html }}</pre>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { generateHtml } from '@tiptap/core'
|
||||
import { defaultExtensions } from '@tiptap/vue-starter-kit'
|
||||
|
||||
export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
doc: {
|
||||
'type': 'document',
|
||||
'content': [{
|
||||
'type': 'paragraph',
|
||||
'attrs': {
|
||||
'align': 'left'
|
||||
},
|
||||
'content': [{
|
||||
'type': 'text',
|
||||
'text': 'My sample text'
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
html() {
|
||||
const extensions = defaultExtensions()
|
||||
|
||||
return generateHtml(this.doc, extensions)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -1,5 +1,19 @@
|
||||
# Schema
|
||||
|
||||
## Get the ProseMirror schema without initializing the editor
|
||||
|
||||
```js
|
||||
import { getSchema } from '@tiptap/core'
|
||||
|
||||
const schema = getSchema(extensions)
|
||||
```
|
||||
|
||||
## Generate HTML from ProseMirror JSON without initializing the editor
|
||||
|
||||
<demo name="Api/Schema" />
|
||||
|
||||
## Old Content
|
||||
|
||||
:::warning Out of date
|
||||
This content is written for tiptap 1 and needs an update.
|
||||
:::
|
||||
|
||||
Reference in New Issue
Block a user