mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-18 08:36:32 +08:00

Some checks failed
build / build (20) (push) Has been cancelled
Publish / Release (20) (push) Has been cancelled
build / test (20, map[name:Demos/Commands spec:./demos/src/Commands/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/Examples spec:./demos/src/Examples/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/Experiments spec:./demos/src/Experiments/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/Extensions spec:./demos/src/Extensions/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/GuideContent spec:./demos/src/GuideContent/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/GuideGettingStarted spec:./demos/src/GuideGettingStarted/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/Marks spec:./demos/src/Marks/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Demos/Nodes spec:./demos/src/Nodes/**/*.spec.{js,ts}]) (push) Has been cancelled
build / test (20, map[name:Integration spec:./tests/cypress/integration/**/*.spec.{js,ts}]) (push) Has been cancelled
build / release (20) (push) Has been cancelled
63 lines
1.2 KiB
JavaScript
63 lines
1.2 KiB
JavaScript
import { generateText } from '@tiptap/core'
|
|
import Document from '@tiptap/extension-document'
|
|
import HardBreak from '@tiptap/extension-hard-break'
|
|
import Paragraph from '@tiptap/extension-paragraph'
|
|
import Text from '@tiptap/extension-text'
|
|
import React, { useMemo } from 'react'
|
|
|
|
const json = {
|
|
type: 'doc',
|
|
content: [
|
|
{
|
|
type: 'paragraph',
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: 'This is a paragraph.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'paragraph',
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: 'Here is another paragraph …',
|
|
},
|
|
{
|
|
type: 'hardBreak',
|
|
},
|
|
{
|
|
type: 'text',
|
|
text: '… with an hard break.',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|
|
|
|
export default () => {
|
|
const output = useMemo(() => {
|
|
return generateText(
|
|
json,
|
|
[
|
|
Document,
|
|
Paragraph,
|
|
Text,
|
|
HardBreak,
|
|
// other extensions …
|
|
],
|
|
{
|
|
// define a custom block separator if you want to
|
|
blockSeparator: '\n\n',
|
|
},
|
|
)
|
|
}, [])
|
|
|
|
return (
|
|
<pre>
|
|
<code>{output}</code>
|
|
</pre>
|
|
)
|
|
}
|