Merge pull request #1273 from ueberdosis/feature/generate-json-from-html
New Feature: Generate JSON from HTML
This commit is contained in:
7
docs/src/demos/Guide/Content/GenerateJSON/index.spec.js
Normal file
7
docs/src/demos/Guide/Content/GenerateJSON/index.spec.js
Normal file
@@ -0,0 +1,7 @@
|
||||
context('/demos/Guide/Content/GenerateJSON', () => {
|
||||
before(() => {
|
||||
cy.visit('/demos/Guide/Content/GenerateJSON')
|
||||
})
|
||||
|
||||
// TODO: Write tests
|
||||
})
|
||||
30
docs/src/demos/Guide/Content/GenerateJSON/index.vue
Normal file
30
docs/src/demos/Guide/Content/GenerateJSON/index.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<pre><code>{{ output }}</code></pre>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// Option 1: Browser + server-side
|
||||
import { generateJSON } from '@tiptap/html'
|
||||
// Option 2: Browser-only (lightweight)
|
||||
// import { generateJSON } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
import Bold from '@tiptap/extension-bold'
|
||||
|
||||
const html = '<p>Example <strong>Text</strong></p>'
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
output() {
|
||||
return generateJSON(html, [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
Bold,
|
||||
// other extensions …
|
||||
])
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user