mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-24 01:17:50 +08:00
14 lines
391 B
TypeScript
14 lines
391 B
TypeScript
|
import { DOMParser } from 'prosemirror-model'
|
||
|
import { getSchema, Extensions } from '@tiptap/core'
|
||
|
// @ts-ignore
|
||
|
import { parseHTML } from 'hostic-dom'
|
||
|
|
||
|
export default function generateJSON(html: string, extensions: Extensions): Record<string, any> {
|
||
|
const schema = getSchema(extensions)
|
||
|
const dom = parseHTML(html)
|
||
|
|
||
|
return DOMParser.fromSchema(schema)
|
||
|
.parse(dom)
|
||
|
.toJSON()
|
||
|
}
|