add getSchema & getHtml utility functions to generate HTML from a ProseMirror/tiptap document, without an Editor instance

This commit is contained in:
Hans Pagel
2020-09-03 16:22:08 +02:00
parent 7988be813b
commit e94714a345
5 changed files with 112 additions and 1 deletions

View 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>