0.1.1 • Published 7 months ago
@docs.plus/extension-indent v0.1.1
@docs.plus/extension-indent
A professional Tiptap extension for text indentation management with customizable options.
Features
- Indent/outdent at cursor position or for text selections
- Configurable indentation characters and behavior
- Node-type filtering for targeted indentation
- Tab and Shift+Tab keyboard shortcuts (configurable)
- Typescript support with full type definitions
Installation
npm install @docs.plus/extension-indentUsage
Basic
import { Editor } from '@tiptap/core'
import { Indent } from '@docs.plus/extension-indent'
new Editor({
extensions: [
// ...other extensions
Indent,
],
})Configuration
Indent.configure({
// Character(s) for each indentation (default: ' ' - 2 spaces)
indentChars: ' ', // 4 spaces
// Enable/disable the extension (default: true)
enabled: true,
// Control which node types can be indented (default: paragraph, listItem, orderedList)
// Empty array allows all nodes to be indented
allowedNodeTypes: ['paragraph', 'listItem', 'orderedList'],
})Examples
// Use tabs instead of spaces
Indent.configure({
indentChars: '\t'
})
// Allow indentation only for paragraphs
Indent.configure({
allowedNodeTypes: ['paragraph']
})Commands
// Add indentation
editor.commands.indent()
// Remove indentation
editor.commands.outdent()Keyboard Shortcuts
Default keyboard bindings:
Tab- IndentShift+Tab- Outdent
Development
# Install dependencies
npm install
# Build
npm run build
# Development with auto-rebuild
npm run dev
# Lint code
npm run lintLicense
MIT