Comprehensive guide covering all features, extensions, APIs, and advanced usage patterns for Akhlaq Digital Editor. From basic setup to expert customization.
For React, Vue, Angular, or any JavaScript framework
For vanilla JavaScript or quick prototyping
<script src="https://cdn.jsdelivr.net/npm/@akhlaqdigital/editor/dist/ad-editor.js"></script>// React
import { Editor } from '@akhlaqdigital/editor';
<Editor
content="<p>Hello World!</p>"
onChange={(html) => console.log(html)}
placeholder="Start typing..."
/>Complete WYSIWYG editor with formatting, lists, headings, and more.
Insert and edit tables with resizable columns and responsive design.
Drag & drop image uploads with automatic resizing and optimization.
User mentions with autocomplete and customizable user lists.
Rich emoji selection with 9 categories: smileys, food, nature, activities, travel, objects, celebrations, symbols, and flags.
Easy link insertion with preview and validation.
Automatic content saving with customizable intervals.
import { SimpleEditor } from '@akhlaqdigital/editor';
function AdvancedEditor() {
const [content, setContent] = useState('');
const mentions = [
{ id: 1, label: 'John Doe' },
{ id: 2, label: 'Jane Smith' }
];
const handleImageUpload = async ({ file, onProgress, abortSignal }) => {
// Your upload logic here
const formData = new FormData();
formData.append('image', file.file);
const response = await fetch('/api/upload', {
method: 'POST',
body: formData,
signal: abortSignal
});
const { url } = await response.json();
return url;
};
return (
<SimpleEditor
content={content}
onChange={setContent}
placeholder="Write something amazing..."
height={500}
mentions={mentions}
handleImageInsertion={handleImageUpload}
/>
);
}| Method | Parameters | Description |
|---|---|---|
| getContent() | - | Returns current HTML content |
| setContent(html) | html: string | Sets editor content |
| focus() | - | Focuses the editor |
| blur() | - | Removes focus from editor |
| destroy() | - | Destroys editor instance |
| Prop | Type | Default | Description |
|---|---|---|---|
| content | string | "" | Initial HTML content |
| onChange | (html: string) => void | - | Callback when content changes |
| placeholder | string | "Start typing..." | Placeholder text |
| className | string | - | CSS classes for the editor container |
| isAutoFocus | boolean | false | Enable auto focus on editor |
| isEditable | boolean | true | Enable editing capabilities |
| isShowMention | boolean | true | Enable @mention functionality |
| isFileUpload | boolean | true | Enable file upload features |
| isBottomToolbar | boolean | false | Position toolbar at the bottom |
| acceptedFileTypes | string | "*" | Accepted file types for upload |
| mentions | Array<{id, label}> | [] | List of mentionable users |
| onInit | (editor: any) => void | - | Callback when editor is initialized |
| handleImageInsertion | function | - | Custom image upload handler |
| handleFilesChange | function | - | Custom file upload handler |
| editor | Editor | - | Custom editor instance |
editor.chain().focus().toggleBold().run()
editor.chain().focus().toggleItalic().run()
editor.chain().focus().toggleUnderline().run()
editor.chain().focus().toggleStrike().run()editor.chain().focus().toggleHeading({level: 1}).run()
editor.chain().focus().toggleBulletList().run()
editor.chain().focus().toggleOrderedList().run()
editor.chain().focus().toggleBlockquote().run()/* Custom CSS Variables */
:root {
--editor-bg: #ffffff;
--editor-text: #1a1a1a;
--editor-border: #e2e8f0;
--editor-focus: #3b82f6;
--toolbar-bg: #f8fafc;
--button-hover: #e2e8f0;
}
/* Dark theme */
[data-theme="dark"] {
--editor-bg: #1a1a1a;
--editor-text: #ffffff;
--editor-border: #374151;
--editor-focus: #60a5fa;
--toolbar-bg: #111827;
--button-hover: #374151;
}
.akd {
background: var(--editor-bg);
color: var(--editor-text);
border: 1px solid var(--editor-border);
}
.akd:focus-within {
border-color: var(--editor-focus);
}import { SimpleEditor } from '@akhlaqdigital/editor';
function EditorWithEvents() {
const [content, setContent] = useState('');
const handleContentChange = (newContent) => {
console.log('Content changed:', newContent);
setContent(newContent);
// Save to localStorage or send to server
localStorage.setItem('editorContent', newContent);
};
const handleEditorReady = (editor) => {
console.log('Editor is ready:', editor);
// Load saved content
const saved = localStorage.getItem('editorContent');
if (saved) {
editor.commands.setContent(saved);
}
};
return (
<SimpleEditor
content={content}
onChange={handleContentChange}
onInit={handleEditorReady}
placeholder="Start writing..."
/>
);
}Here's how you can create a blog post editor with title input and rich text content:
Features:
• Title input field
• Rich text editor with file upload
• Custom styling for blog posts
• Publish button integration
Perfect for building comment systems with mentions and compact design:
Features:
• Compact editor for comments
• @mention functionality
• Cancel and submit buttons
• No file uploads for simple comments
Ensure you have the latest version which includes full TypeScript definitions.
npm update @akhlaqdigital/editorUse dynamic imports to avoid SSR conflicts.
const Editor = dynamic(() => import('@akhlaqdigital/editor'), { ssr: false });If you're still experiencing issues, check out these resources: