mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-04 17:07:50 +08:00
8c6751f0c6
* chore: add precommit hook for eslint fixes, fix linting issues * chore: add eslint import sort plugin
13 lines
386 B
TypeScript
13 lines
386 B
TypeScript
import { Extensions, getSchema } from '@tiptap/core'
|
|
import { DOMParser } from 'prosemirror-model'
|
|
import { parseHTML } from 'zeed-dom'
|
|
|
|
export function generateJSON(html: string, extensions: Extensions): Record<string, any> {
|
|
const schema = getSchema(extensions)
|
|
const dom = parseHTML(html) as unknown as Node
|
|
|
|
return DOMParser.fromSchema(schema)
|
|
.parse(dom)
|
|
.toJSON()
|
|
}
|