1 | initial version |
To create an indent in tiptap 2, you can use the built-in indent extension. Here's an example of how to use it:
import Indent from '@tiptap/extension-indent'
const editor = new Editor({
extensions: [
// other extensions...
Indent,
],
})
const IndentButton = ({ editor }) => {
const indent = () => editor.chain().focus().indent().run()
return (
<button onClick={indent}>Indent</button>
)
}
// add the button to your toolbar
const editor = new Editor({
// other config...
content: '<p>Sample text</p>',
editorProps: {
// add a toolbar with the indent button
renderToolbar: (props, editor) => {
return (
<Toolbar>
<IndentButton editor={editor} />
</Toolbar>
)
},
},
})
Now when you click the "Indent" button in the editor's toolbar, the selected text will be indented by one level.