1.5.1 • Published 5 months ago
@tugkanpilka/tiptap-utils v1.5.1
Tiptap Utils
A collection of utility functions and helpers for the Tiptap editor.
Installation
npm install @tugkanpilka/tiptap-utils
# or
yarn add @tugkanpilka/tiptap-utils
# or
pnpm add @tugkanpilka/tiptap-utils
Requirements
This package has the following peer dependencies:
@tiptap/core
: ^2.0.0@tiptap/pm
: ^2.0.0@tiptap/extension-task-item
: ^2.0.0@tiptap/extension-task-list
: ^2.0.0@tiptap/react
: ^2.0.0
Usage
import {
TiptapContentAdapter,
TodoContentAdapter,
DefaultNodeCreationStrategy,
TodoNodeCreationStrategy,
BaseContentVisitor,
TodoVisitor,
UncompletedTodoFilter,
TiptapContentValidator
} from '@tugkanpilka/tiptap-utils';
// Create a content adapter
const adapter = new TiptapContentAdapter(
traversalStrategy,
visitor,
[new TodoNodeCreationStrategy()],
[new UncompletedTodoFilter()],
new TiptapContentValidator()
);
// Extract content
const items = adapter.extract(tiptapContent);
// Create content
const content = adapter.create(items);
Features
- Content Adapters for converting between Tiptap and domain models
- Node Creation Strategies for different content types
- Content Visitors for traversing Tiptap document structure
- Content Filters for filtering content items
- Content Validation for ensuring valid Tiptap JSON structure
Documentation
Detailed documentation for each utility can be found in the docs directory.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
- Tuğkan Pilka (tugkanpilka@gmail.com)