mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 11:45:15 +08:00

This maintains backwards-compatibility with the existing packages by making them into re-exports
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import './styles.scss'
|
|
|
|
import Document from '@tiptap/extension-document'
|
|
import { BulletList, ListItem } from '@tiptap/extension-list'
|
|
import Paragraph from '@tiptap/extension-paragraph'
|
|
import Text from '@tiptap/extension-text'
|
|
import { EditorContent, useEditor } from '@tiptap/react'
|
|
import React from 'react'
|
|
|
|
export default () => {
|
|
const editor = useEditor({
|
|
extensions: [Document, Paragraph, Text, BulletList, ListItem],
|
|
content: `
|
|
<ul>
|
|
<li>A list item</li>
|
|
<li>And another one</li>
|
|
</ul>
|
|
`,
|
|
})
|
|
|
|
if (!editor) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<div className="control-group">
|
|
<div className="button-group">
|
|
<button
|
|
onClick={() => editor.chain().focus().toggleBulletList().run()}
|
|
className={editor.isActive('bulletList') ? 'is-active' : ''}
|
|
>
|
|
Toggle bullet list
|
|
</button>
|
|
<button
|
|
onClick={() => editor.chain().focus().splitListItem('listItem').run()}
|
|
disabled={!editor.can().splitListItem('listItem')}
|
|
>
|
|
Split list item
|
|
</button>
|
|
<button
|
|
onClick={() => editor.chain().focus().sinkListItem('listItem').run()}
|
|
disabled={!editor.can().sinkListItem('listItem')}
|
|
>
|
|
Sink list item
|
|
</button>
|
|
<button
|
|
onClick={() => editor.chain().focus().liftListItem('listItem').run()}
|
|
disabled={!editor.can().liftListItem('listItem')}
|
|
>
|
|
Lift list item
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<EditorContent editor={editor} />
|
|
</>
|
|
)
|
|
}
|