@cyberskill/cyber-editor
v4.1.2
Published
Update html content with a rich text editor based on Tiptap and React. Requires Tailwind CSS v4 as peer dependency.
Readme
@cyberskill/cyber-editor
A powerful, rich text editor based on Tiptap, designed for the CyberSkill ecosystem. It provides a seamless editing experience with advanced features like image resizing, video embedding, accordion components, and HTML block rendering.
📦 Installation
Install the package via your preferred package manager:
pnpm add @cyberskill/cyber-editor
# or
npm install @cyberskill/cyber-editor
# or
yarn add @cyberskill/cyber-editor🚀 Usage
The library exports two main components to distinguish between editing (Admin) and viewing (Client) modes.
1. Import Styles
First, import the necessary CSS in your root file (e.g., _app.tsx, layout.tsx, or main.tsx):
import '@cyberskill/cyber-editor/index.css';2. Admin / Edit Mode (CyberEditor)
Use CyberEditor when you want to provide a full editing interface with a toolbar.
import { CyberEditor } from '@cyberskill/cyber-editor';
import { useState } from 'react';
function AdminPage() {
const [content, setContent] = useState('<p>Hello World</p>');
return (
<CyberEditor
content={content}
onChange={(newContent) => setContent(newContent)}
className="my-editor"
/>
);
}3. Client / View Mode (CyberViewer)
Use CyberViewer when you just want to display the content. It is read-only and lightweight without the toolbar.
import { CyberViewer } from '@cyberskill/cyber-editor';
function PostPage({ content }) {
return (
<div className="article-content">
<CyberViewer content={content} />
</div>
);
}🛠 Development & Contribution
Project Structure
src/modules/*: Contains individual editor extensions (Image, Video, Table, etc.).src/shared/*: Shared utilities, providers, and styles.src/playground/*: A built-in playground for testing during development.src/index.ts: The main entry point for the library.
Common Commands
- Start Playground: Run the local dev server to test changes.
pnpm dev - Build Library: Build the package for distribution.
pnpm build
🔄 Versioning & Publishing
When the development team adds new components or fixes bugs, follow this workflow to update the package:
Develop & Test:
- Make changes in
src/modulesorsrc/shared. - Test using the playground (
pnpm dev).
- Make changes in
Commit Changes:
- Use conventional commits (e.g.,
feat: add new chart componentorfix: image resize bug).
- Use conventional commits (e.g.,
Update Version:
- Patch (Bug fixes):
0.0.xnpm version patch - Minor (New features, non-breaking):
0.x.0npm version minor - Major (Breaking changes):
x.0.0npm version major
This command automatically updates
package.jsonand creates a git tag.- Patch (Bug fixes):
Publish:
- Push the tag to the repository.
- Publish to the registry (if handled manually, or let CI/CD handle it).
pnpm publish
🧩 Adding New Components
To add a new feature (e.g., a Chart extension):
- Create a new folder in
src/modules/chart. - Implement the Tiptap node/extension.
- Create a React Component for the NodeView (if it has UI).
- Export the extension in
src/shared/utils/extensions.ts. - Test in
src/playground/App.tsx.
