@editora/toast 1.0.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +904 -8
  2. package/dist/core/AnimationUtils.d.ts +36 -0
  3. package/dist/core/ToastLifecycle.d.ts +25 -0
  4. package/dist/core/ToastManager.d.ts +36 -0
  5. package/dist/core/ToastQueue.d.ts +19 -0
  6. package/dist/core/ToastRenderer.d.ts +20 -0
  7. package/dist/core/ToastStore.d.ts +31 -0
  8. package/dist/core/types.d.ts +168 -0
  9. package/dist/index.cjs.js +2 -0
  10. package/dist/index.cjs.js.map +1 -0
  11. package/dist/index.d.ts +39 -10
  12. package/dist/index.esm.js +1075 -0
  13. package/dist/index.esm.js.map +1 -0
  14. package/dist/index.umd.js +2 -0
  15. package/dist/index.umd.js.map +1 -0
  16. package/dist/toast.css +783 -18
  17. package/package.json +50 -13
  18. package/LICENSE +0 -21
  19. package/dist/index.js +0 -70
  20. package/dist/packages/core/src/Editor.d.ts +0 -15
  21. package/dist/packages/core/src/Editor.js +0 -37
  22. package/dist/packages/core/src/EditorState.d.ts +0 -13
  23. package/dist/packages/core/src/EditorState.js +0 -14
  24. package/dist/packages/core/src/Selection.d.ts +0 -126
  25. package/dist/packages/core/src/Selection.js +0 -232
  26. package/dist/packages/core/src/commands/CommandManager.d.ts +0 -56
  27. package/dist/packages/core/src/commands/CommandManager.js +0 -166
  28. package/dist/packages/core/src/index.d.ts +0 -7
  29. package/dist/packages/core/src/index.js +0 -4
  30. package/dist/packages/core/src/model/Fragment.d.ts +0 -80
  31. package/dist/packages/core/src/model/Fragment.js +0 -172
  32. package/dist/packages/core/src/model/Mark.d.ts +0 -108
  33. package/dist/packages/core/src/model/Mark.js +0 -138
  34. package/dist/packages/core/src/model/Node.d.ts +0 -172
  35. package/dist/packages/core/src/model/Node.js +0 -458
  36. package/dist/packages/core/src/model/types.d.ts +0 -29
  37. package/dist/packages/core/src/model/types.js +0 -1
  38. package/dist/packages/core/src/plugins/Plugin.d.ts +0 -37
  39. package/dist/packages/core/src/plugins/Plugin.js +0 -31
  40. package/dist/packages/core/src/plugins/PluginManager.d.ts +0 -75
  41. package/dist/packages/core/src/plugins/PluginManager.js +0 -185
  42. package/dist/packages/core/src/schema/Node.d.ts +0 -26
  43. package/dist/packages/core/src/schema/Node.js +0 -12
  44. package/dist/packages/core/src/schema/Schema.d.ts +0 -52
  45. package/dist/packages/core/src/schema/Schema.js +0 -296
  46. package/dist/packages/core/src/security/Sanitizer.d.ts +0 -81
  47. package/dist/packages/core/src/security/Sanitizer.js +0 -200
  48. package/dist/packages/editora-toast/src/index.d.ts +0 -18
  49. package/dist/packages/editora-toast/src/index.js +0 -70
  50. package/src/index.ts +0 -83
  51. package/src/toast.css +0 -42
package/README.md CHANGED
@@ -1,14 +1,910 @@
1
- # editora-toast
1
+ # Editora Toast
2
2
 
3
- A tiny, dependency-free toast notification library for the Editora suite.
3
+ > Advanced toast notification system with enterprise features, backward compatibility, and rich customization options.
4
4
 
5
- Author: Ajay Kumar <ajaykr089@gmail.com>
5
+ [![Version](https://img.shields.io/npm/v/@editora/toast)](https://www.npmjs.com/package/@editora/toast)
6
+ [![License](https://img.shields.io/npm/l/@editora/toast)](https://github.com/ajaykr089/Editora/blob/main/LICENSE)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
8
+ [![Size](https://img.shields.io/bundlephobia/minzip/@editora/toast)](https://bundlephobia.com/package/@editora/toast)
6
9
 
7
- Usage:
10
+ A modern, framework-agnostic toast notification library designed for enterprise applications. Features advanced UX patterns, accessibility compliance, plugin architecture, and seamless integration with rich text editors.
8
11
 
9
- import { toast } from 'editora-toast';
12
+ ## 📸 Screenshots
10
13
 
11
- toast.error('Anchor ID already exists');
12
- toast.success('Saved');
14
+ ### Hero Section
15
+ ![Hero Section](toast-screenshots/hero-section.png)
13
16
 
14
- toast.info('Info message');
17
+ ### Basic Toast Types
18
+ ![Basic Toast Types](toast-screenshots/basic-toast-types.png)
19
+
20
+ ### Beautiful Themes
21
+ ![Beautiful Themes](toast-screenshots/beautiful-themes.png)
22
+
23
+ ### Interactive Actions
24
+ ![Interactive Actions](toast-screenshots/interactive-actions.png)
25
+
26
+ ### Interactive Feedback Form
27
+ ![Interactive Feedback Form](toast-screenshots/nteractive-feedback-form.png)
28
+
29
+ ### Progress Scenarios
30
+ ![Progress Scenarios](toast-screenshots/progress-scenarios.png)
31
+
32
+ ### Advanced Features
33
+ ![Advanced Features](toast-screenshots/advanced-features.png)
34
+
35
+ ### Async Operations
36
+ ![Async Operations](toast-screenshots/async-operations.png)
37
+
38
+ ### Error Handling
39
+ ![Error Handling](toast-screenshots/error-handling.png)
40
+
41
+ ## ✨ Features
42
+
43
+ ### Core Features
44
+ - 🚀 **Framework Agnostic** - Works with any JavaScript framework or vanilla JS
45
+ - ♿ **Accessibility First** - WCAG AA compliant with screen reader support
46
+ - 🔄 **Promise Lifecycle** - Automatic state transitions for async operations
47
+ - 📱 **Mobile Optimized** - Touch gestures, swipe-to-dismiss, and responsive design
48
+ - 🎨 **Advanced Theming** - 13 built-in themes with CSS variables and custom themes
49
+ - 🔌 **Plugin Architecture** - Extensible with custom plugins and hooks
50
+ - 📊 **Smart Queue Management** - Priority-based queuing with overflow strategies
51
+ - 🎯 **Rich Content Support** - HTML, icons, actions, progress bars, and custom rendering
52
+ - 🎪 **Spring Physics Animations** - Realistic animations with customizable physics parameters
53
+ - 🏗️ **SSR Safe** - Server-side rendering compatible
54
+ - 🪝 **Editor Integration** - Built-in hooks for rich text editors
55
+ - 🔒 **Security** - HTML sanitization and XSS protection
56
+ - 📦 **Zero Dependencies** - Lightweight and self-contained
57
+
58
+ ### Advanced Features (v2.0.0)
59
+ - 🔄 **Toast Updates** - Modify existing toasts dynamically with smooth transitions
60
+ - 🎯 **Toast Grouping** - Group related notifications with stacking and management
61
+ - 🎪 **Custom Animation Hooks** - User-defined animation functions for complete control
62
+ - 📍 **Multiple Positions** - Support for all screen corners and center positioning
63
+ - 🎨 **Animation Manager** - Centralized system supporting CSS, spring, and custom animations
64
+ - 📱 **Gesture Support** - Swipe and drag gestures for mobile interaction
65
+ - 🎯 **Focus Management** - Proper keyboard navigation and focus handling
66
+ - 🔄 **Promise Integration** - Seamless integration with async operations and promises
67
+ - 📊 **Progress Tracking** - Built-in progress bars with percentage display
68
+ - 🎯 **Action Buttons** - Interactive buttons within toasts for user actions
69
+ - 🎨 **Theme Variants** - Light, dark, system, colored, minimal, glass, neon, retro, ocean, forest, sunset, midnight themes
70
+ - 🔧 **Global Configuration** - Comprehensive configuration system for all aspects
71
+
72
+ ### Performance & Architecture
73
+
74
+ - ⚡ **Optimized Queue Management** - O(1) insertion with priority-based queuing
75
+ - 🎯 **Batched DOM Updates** - Efficient rendering with minimal reflows
76
+ - 🧠 **Memory Safe** - Automatic cleanup and leak prevention
77
+ - 🚀 **Virtualized Rendering** - Handles large queues without performance degradation
78
+ - 🔄 **Event-Driven Architecture** - Plugin system with comprehensive hooks
79
+ - 📦 **Tree-Shakable** - Import only what you need for smaller bundles
80
+
81
+ ## 📦 Installation
82
+
83
+ ```bash
84
+ npm install @editora/toast
85
+ ```
86
+
87
+ ## 🌐 CDN Usage
88
+
89
+ You can also use Editora Toast directly from a CDN without installing it via npm. Include the following scripts in your HTML:
90
+ ### Examples
91
+ ``` https://editora-free.netlify.app/toast-demo.html ```
92
+ ### Basic CDN Setup
93
+
94
+ ```html
95
+ <!DOCTYPE html>
96
+ <html lang="en">
97
+ <head>
98
+ <meta charset="UTF-8">
99
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
100
+ <title>My App</title>
101
+
102
+ <!-- Include the CSS -->
103
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/toast.css">
104
+ </head>
105
+ <body>
106
+ <!-- Your content here -->
107
+
108
+ <!-- Include the JavaScript -->
109
+ <script src="https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/index.umd.js"></script>
110
+
111
+ <script>
112
+ // Now you can use the toast functions (legacy API supports an optional options object)
113
+ toast.success('Hello from CDN!', { theme: 'light', position: 'top-right' });
114
+ toast.error('Something went wrong!', { duration: 1000 });
115
+ toast.info('This is an info message', { theme: 'light', position: 'top-right' });
116
+ toast.warning('This is a warning', { theme: 'light', position: 'top-right' });
117
+
118
+ // Advanced usage (toastAdvanced, toastPro)
119
+ // global window.toastPro.show()
120
+ // global window.toastAdvanced.show()
121
+ const notification = toastAdvanced.show({
122
+ message: 'File uploaded successfully!',
123
+ level: 'success',
124
+ icon: '✓',
125
+ actions: [
126
+ { label: 'View', onClick: () => console.log('View clicked') },
127
+ { label: 'Dismiss', onClick: () => notification.dismiss() }
128
+ ]
129
+ });
130
+ const notification = toastPro.show({
131
+ message: 'File uploaded successfully!',
132
+ level: 'success',
133
+ icon: '✓',
134
+ actions: [
135
+ { label: 'View', onClick: () => console.log('View clicked') },
136
+ { label: 'Dismiss', onClick: () => notification.dismiss() }
137
+ ]
138
+ });
139
+ </script>
140
+ </body>
141
+ </html>
142
+ ```
143
+
144
+ ### CDN URLs
145
+
146
+ - **JavaScript**: `https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/index.umd.js`
147
+ - **CSS**: `https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/toast.css`
148
+
149
+ > **Note**: Replace `@latest` with a specific version number (e.g., `@2.0.0`) for production use to avoid unexpected updates.
150
+
151
+ ## 🚀 Quick Start
152
+
153
+ ### Basic Usage (Backward Compatible)
154
+
155
+ ```typescript
156
+ import { toast } from '@editora/toast';
157
+ import "@editora/toast/toast.css";
158
+
159
+ // Simple notifications (migrated to optional advanced options)
160
+ toast.success('File saved successfully!', { theme: 'light', position: 'top-right' });
161
+ toast.error('Failed to save file', { theme: 'light', position: 'top-right' });
162
+ toast.info('Info message', { theme: 'light', position: 'top-right' });
163
+ toast.warning('Warning message', { theme: 'light', position: 'top-right' });
164
+ ```
165
+
166
+ ### Advanced Usage (v2.0.0 Features)
167
+
168
+ ```typescript
169
+ import { toastAdvanced as toast } from '@editora/toast';
170
+ import "@editora/toast/toast.css";
171
+ // Rich notifications with actions and progress
172
+ const notification = toast.show({
173
+ message: 'Document uploaded successfully!',
174
+ level: 'success',
175
+ icon: '✓',
176
+ actions: [
177
+ { label: 'View Document', onClick: () => console.log('View clicked') },
178
+ { label: 'Share', onClick: () => console.log('Share clicked') },
179
+ { label: 'Dismiss', onClick: () => notification.dismiss() }
180
+ ],
181
+ progress: { value: 100, showPercentage: true },
182
+ duration: 6000
183
+ });
184
+
185
+ // Promise-based notifications with automatic state transitions
186
+ toast.promise(
187
+ uploadFile(file),
188
+ {
189
+ loading: 'Uploading file...',
190
+ success: (data) => `File "${data.name}" uploaded successfully!`,
191
+ error: (error) => `Upload failed: ${error.message}`
192
+ }
193
+ );
194
+
195
+ // Update existing toast dynamically
196
+ const loadingToast = toast.loading('Saving document...');
197
+ setTimeout(() => {
198
+ toast.update(loadingToast.id, {
199
+ message: 'Document saved successfully!',
200
+ level: 'success',
201
+ icon: '💾',
202
+ actions: [{ label: 'Open', onClick: () => {} }]
203
+ });
204
+ }, 2000);
205
+
206
+ // Group related notifications
207
+ toast.group('file-operations', {
208
+ message: 'File 1 processed',
209
+ level: 'success'
210
+ });
211
+
212
+ toast.group('file-operations', {
213
+ message: 'File 2 processed',
214
+ level: 'success'
215
+ });
216
+ ```
217
+
218
+ ## 🎛️ Configuration
219
+
220
+ ```typescript
221
+ import { toastAdvanced as toast } from '@editora/toast';
222
+ import "@editora/toast/toast.css";
223
+ // Global configuration with all available options
224
+ toast.configure({
225
+ // Positioning
226
+ position: 'top-right', // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'
227
+
228
+ // Timing
229
+ duration: 5000, // Default duration in milliseconds
230
+ pauseOnHover: true, // Pause timer when hovering
231
+
232
+ // Display
233
+ maxVisible: 5, // Maximum visible toasts
234
+ theme: 'system', // Theme: 'light' | 'dark' | 'system' | 'colored' | 'minimal' | 'glass' | 'neon' | 'retro' | 'ocean' | 'forest' | 'sunset' | 'midnight' | 'custom'
235
+
236
+ // Accessibility
237
+ enableAccessibility: true, // Enable screen reader support
238
+ enableKeyboardNavigation: true, // Enable keyboard navigation
239
+
240
+ // Interactions
241
+ swipeDismiss: true, // Enable swipe to dismiss on mobile
242
+ dragDismiss: false, // Enable drag to dismiss
243
+ clickToDismiss: true, // Click anywhere to dismiss
244
+
245
+ // Queue Management
246
+ queueStrategy: 'priority', // 'fifo' | 'priority' | 'stack'
247
+ maxQueueSize: 10, // Maximum queued toasts
248
+
249
+ // Animations
250
+ animation: {
251
+ type: 'spring', // 'css' | 'spring' | 'custom'
252
+ config: {
253
+ stiffness: 120,
254
+ damping: 12,
255
+ mass: 1,
256
+ precision: 0.01
257
+ }
258
+ },
259
+
260
+ // Advanced
261
+ enableHtml: false, // Allow HTML in messages (use with caution)
262
+ sanitizeHtml: true, // Sanitize HTML content
263
+ zIndex: 9999, // Base z-index for toasts
264
+ containerClass: 'custom-container' // Custom container class
265
+ });
266
+ ```
267
+
268
+ ## 🎨 Theming
269
+
270
+ ![Beautiful Themes](toast-screenshots/beautiful-themes.png)
271
+
272
+ ### Built-in Themes
273
+
274
+ Editora Toast comes with 13 beautiful themes:
275
+
276
+ - **`light`** - Clean white background with subtle shadows
277
+ - **`dark`** - Dark background with high contrast text
278
+ - **`system`** - Automatically switches between light/dark based on system preference
279
+ - **`colored`** - Vibrant gradient backgrounds for each toast level
280
+ - **`minimal`** - Clean design with subtle borders and minimal styling
281
+ - **`glass`** - Frosted glass effect with backdrop blur
282
+ - **`neon`** - Bright neon colors with glowing effects
283
+ - **`retro`** - 80s/90s style with bold colors and gradients
284
+ - **`ocean`** - Blue aquatic theme with calming colors
285
+ - **`forest`** - Green natural theme with earthy tones
286
+ - **`sunset`** - Warm orange/pink sunset colors
287
+ - **`midnight`** - Deep blue dark theme with subtle gradients
288
+ - **`custom`** - Fully customizable with CSS variables
289
+
290
+ ### Usage
291
+
292
+ ```typescript
293
+ import { toastAdvanced as toast } from '@editora/toast';
294
+ import "@editora/toast/toast.css";
295
+ // Set global theme
296
+ toast.configure({
297
+ theme: 'glass' // or 'neon', 'retro', 'ocean', etc.
298
+ });
299
+
300
+ // Per-toast theme
301
+ toast.show({
302
+ message: 'Hello World',
303
+ theme: 'colored'
304
+ });
305
+ ```
306
+
307
+ ### CSS Variables
308
+
309
+ ```css
310
+ :root {
311
+ --editora-toast-bg: rgba(0, 0, 0, 0.85);
312
+ --editora-toast-color: #fff;
313
+ --editora-toast-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
314
+ --editora-toast-border-radius: 6px;
315
+ --editora-toast-font-family: system-ui, -apple-system, 'Segoe UI', Roboto;
316
+ --editora-toast-font-size: 13px;
317
+ --editora-toast-padding: 10px 14px;
318
+ }
319
+ ```
320
+
321
+ ### Theme Classes
322
+
323
+ ```html
324
+ <!-- Apply theme globally -->
325
+ <div data-theme="glass">
326
+ <!-- All toasts will use glass theme -->
327
+ </div>
328
+
329
+ <!-- Or apply to specific container -->
330
+ <div class="editora-toast-container" data-theme="neon">
331
+ </div>
332
+ ```
333
+
334
+ ## 🎯 Advanced Features
335
+
336
+ ### Promise Lifecycle Toasts
337
+ ![Async Operations](toast-screenshots/async-operations.png)
338
+
339
+ Automatically handle async operations with state transitions:
340
+
341
+ ```typescript
342
+ import { toastAdvanced as toast } from '@editora/toast';
343
+
344
+ // Promise-based notifications
345
+ const uploadPromise = uploadFile(file);
346
+
347
+ toast.promise(uploadPromise, {
348
+ loading: {
349
+ message: 'Uploading file...',
350
+ icon: '⏳',
351
+ progress: { indeterminate: true }
352
+ },
353
+ success: {
354
+ message: 'File uploaded successfully!',
355
+ icon: '✅',
356
+ duration: 4000,
357
+ actions: [{ label: 'View', onClick: () => openFile() }]
358
+ },
359
+ error: {
360
+ message: 'Upload failed. Please try again.',
361
+ icon: '❌',
362
+ duration: 6000,
363
+ actions: [
364
+ { label: 'Retry', onClick: () => retryUpload() },
365
+ { label: 'Cancel', onClick: () => {} }
366
+ ]
367
+ }
368
+ });
369
+ ```
370
+
371
+ ### Interactive Actions
372
+ ![Interactive Actions](toast-screenshots/interactive-actions.png)
373
+
374
+ Add interactive buttons to your toasts:
375
+
376
+ ```typescript
377
+ import { toastAdvanced as toast } from '@editora/toast';
378
+ import "@editora/toast/toast.css";
379
+ const notification = toast.show({
380
+ message: 'Document saved successfully!',
381
+ level: 'success',
382
+ icon: '💾',
383
+ actions: [
384
+ {
385
+ label: 'Open Document',
386
+ onClick: () => openDocument(),
387
+ primary: true // Primary action styling
388
+ },
389
+ {
390
+ label: 'Share',
391
+ onClick: () => shareDocument(),
392
+ variant: 'secondary'
393
+ },
394
+ {
395
+ label: 'Dismiss',
396
+ onClick: () => notification.dismiss(),
397
+ variant: 'ghost'
398
+ }
399
+ ],
400
+ duration: 8000 // Longer duration for actions
401
+ });
402
+ ```
403
+
404
+ ### Progress Tracking
405
+ ![Progress Scenarios](toast-screenshots/progress-scenarios.png)
406
+
407
+ Built-in progress bars with customizable display:
408
+
409
+ ```typescript
410
+ import { toastAdvanced as toast } from '@editora/toast';
411
+ import "@editora/toast/toast.css";
412
+ // Determinate progress
413
+ const progressToast = toast.show({
414
+ message: 'Processing files...',
415
+ level: 'info',
416
+ progress: {
417
+ value: 0,
418
+ showPercentage: true,
419
+ color: '#007acc'
420
+ }
421
+ });
422
+
423
+ // Update progress
424
+ let progress = 0;
425
+ const interval = setInterval(() => {
426
+ progress += 10;
427
+ toast.update(progressToast.id, {
428
+ progress: { value: progress, showPercentage: true },
429
+ message: `Processing files... ${progress}%`
430
+ });
431
+
432
+ if (progress >= 100) {
433
+ clearInterval(interval);
434
+ toast.update(progressToast.id, {
435
+ message: 'Processing complete!',
436
+ level: 'success',
437
+ progress: { value: 100, showPercentage: true }
438
+ });
439
+ }
440
+ }, 500);
441
+ ```
442
+
443
+ ### Toast Updates
444
+ ![Advanced Features](toast-screenshots/advanced-features.png)
445
+
446
+ Modify existing toasts dynamically:
447
+
448
+ ```typescript
449
+ import { toastAdvanced as toast } from '@editora/toast';
450
+ import "@editora/toast/toast.css";
451
+ // Create a loading toast
452
+ const loadingToast = toast.loading('Connecting to server...');
453
+
454
+ // Update with progress
455
+ setTimeout(() => {
456
+ toast.update(loadingToast.id, {
457
+ message: 'Authenticating...',
458
+ progress: { value: 25, showPercentage: true }
459
+ });
460
+ }, 1000);
461
+
462
+ // Update with success
463
+ setTimeout(() => {
464
+ toast.update(loadingToast.id, {
465
+ message: 'Connected successfully!',
466
+ level: 'success',
467
+ icon: '🔗',
468
+ progress: { value: 100, showPercentage: true },
469
+ actions: [{ label: 'Explore', onClick: () => {} }]
470
+ });
471
+ }, 2000);
472
+ ```
473
+
474
+ ### Toast Grouping
475
+ ![Error Handling](toast-screenshots/error-handling.png)
476
+
477
+ Group related notifications together:
478
+
479
+ ```typescript
480
+ import { toastAdvanced as toast } from '@editora/toast';
481
+ import "@editora/toast/toast.css";
482
+ // Group file operations
483
+ const files = ['document.pdf', 'image.jpg', 'data.json'];
484
+
485
+ files.forEach((file, index) => {
486
+ setTimeout(() => {
487
+ toast.group('file-upload', {
488
+ message: `Uploaded ${file}`,
489
+ level: 'success',
490
+ icon: '📁',
491
+ duration: 3000
492
+ });
493
+ }, index * 500);
494
+ });
495
+
496
+ // Group error notifications
497
+ toast.group('validation-errors', {
498
+ message: 'Invalid email format',
499
+ level: 'error',
500
+ icon: '⚠️'
501
+ });
502
+
503
+ toast.group('validation-errors', {
504
+ message: 'Password too weak',
505
+ level: 'error',
506
+ icon: '🔒'
507
+ });
508
+ ```
509
+
510
+ ### Interactive Feedback Forms
511
+ ![Interactive Feedback Form](toast-screenshots/nteractive-feedback-form.png)
512
+
513
+ Create interactive forms within toasts:
514
+
515
+ ```typescript
516
+ import { toastAdvanced as toast } from '@editora/toast';
517
+ import "@editora/toast/toast.css";
518
+ toast.show({
519
+ message: 'How was your experience?',
520
+ level: 'info',
521
+ icon: '⭐',
522
+ render: () => {
523
+ const container = document.createElement('div');
524
+ container.innerHTML = `
525
+ <div style="display: flex; gap: 8px; margin-top: 8px;">
526
+ <button class="feedback-btn" data-rating="1">😞</button>
527
+ <button class="feedback-btn" data-rating="2">😐</button>
528
+ <button class="feedback-btn" data-rating="3">😊</button>
529
+ <button class="feedback-btn" data-rating="4">😃</button>
530
+ <button class="feedback-btn" data-rating="5">😍</button>
531
+ </div>
532
+ `;
533
+
534
+ container.addEventListener('click', (e) => {
535
+ if (e.target.classList.contains('feedback-btn')) {
536
+ const rating = e.target.dataset.rating;
537
+ submitFeedback(rating);
538
+ toast.success('Thank you for your feedback!');
539
+ }
540
+ });
541
+
542
+ return container;
543
+ },
544
+ duration: 10000
545
+ });
546
+ ```
547
+
548
+ ## 🔌 Plugins
549
+
550
+ ```typescript
551
+ import { toastAdvanced as toast } from '@editora/toast';
552
+ import "@editora/toast/toast.css";
553
+ const myPlugin = {
554
+ name: 'my-plugin',
555
+ install(manager) {
556
+ // Add custom functionality
557
+ manager.on('beforeShow', (toast) => {
558
+ console.log('Toast about to show:', toast.message);
559
+ });
560
+ }
561
+ };
562
+
563
+ toast.use(myPlugin);
564
+ ```
565
+
566
+ ## 📱 Positions
567
+
568
+ ```typescript
569
+ toast.show({
570
+ message: 'Hello World',
571
+ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'
572
+ });
573
+ ```
574
+
575
+ ## 🎪 Advanced Features
576
+
577
+ ### Spring Physics Animations
578
+
579
+ ```typescript
580
+ import { toastAdvanced as toast } from '@editora/toast';
581
+ import "@editora/toast/toast.css";
582
+ // Spring animation with custom physics
583
+ toast.show({
584
+ message: 'Spring animated toast!',
585
+ level: 'success',
586
+ animation: {
587
+ type: 'spring',
588
+ config: {
589
+ stiffness: 120, // Spring stiffness (default: 100)
590
+ damping: 12, // Spring damping (default: 10)
591
+ mass: 1, // Spring mass (default: 1)
592
+ precision: 0.01 // Animation precision (default: 0.01)
593
+ }
594
+ }
595
+ });
596
+ ```
597
+
598
+ ### Custom Animation Hooks
599
+
600
+ ```typescript
601
+ import { toastAdvanced as toast } from '@editora/toast';
602
+ import "@editora/toast/toast.css";
603
+ // Custom animation functions
604
+ toast.show({
605
+ message: 'Custom animated toast!',
606
+ level: 'info',
607
+ animation: {
608
+ type: 'custom',
609
+ show: async (element, toast) => {
610
+ // Custom show animation
611
+ element.style.opacity = '0';
612
+ element.style.transform = 'rotateX(90deg)';
613
+
614
+ await new Promise(resolve => {
615
+ element.style.transition = 'all 0.5s ease';
616
+ element.style.opacity = '1';
617
+ element.style.transform = 'rotateX(0deg)';
618
+ element.addEventListener('transitionend', resolve, { once: true });
619
+ });
620
+ },
621
+ hide: async (element, toast) => {
622
+ // Custom hide animation
623
+ element.style.transition = 'all 0.3s ease';
624
+ element.style.opacity = '0';
625
+ element.style.transform = 'scale(0.8)';
626
+
627
+ return new Promise(resolve => {
628
+ setTimeout(resolve, 300);
629
+ });
630
+ },
631
+ update: async (element, toast, updates) => {
632
+ // Custom update animation
633
+ element.style.transform = 'scale(1.05)';
634
+ setTimeout(() => {
635
+ element.style.transform = 'scale(1)';
636
+ }, 150);
637
+ }
638
+ }
639
+ });
640
+ ```
641
+
642
+ ### Global Animation Configuration
643
+
644
+ ```typescript
645
+ import { toastAdvanced as toast } from '@editora/toast';
646
+ import "@editora/toast/toast.css";
647
+ // Set default animation for all toasts
648
+ toast.configure({
649
+ animation: {
650
+ type: 'spring',
651
+ config: { stiffness: 150, damping: 15 }
652
+ }
653
+ });
654
+ ```
655
+
656
+ ### Toast Groups
657
+
658
+ ```typescript
659
+ // Group related notifications
660
+ toast.group('upload-group', {
661
+ message: 'Upload 1 complete',
662
+ level: 'success'
663
+ });
664
+
665
+ toast.group('upload-group', {
666
+ message: 'Upload 2 complete',
667
+ level: 'success'
668
+ });
669
+ ```
670
+
671
+ ### Custom Render Function
672
+
673
+ ```typescript
674
+ toast.show({
675
+ render: () => {
676
+ const div = document.createElement('div');
677
+ div.innerHTML = '<strong>Custom</strong> content';
678
+ return div;
679
+ }
680
+ });
681
+ ```
682
+
683
+ ### Editor Integration
684
+
685
+ ```typescript
686
+ import { toastAdvanced as toast } from '@editora/toast';
687
+ import "@editora/toast/toast.css";
688
+ // Listen for editor events
689
+ toast.onEditorEvent('spellcheck-error', (error) => {
690
+ toast.error(`Spelling error: ${error.word}`, { theme: 'light', position: 'top-right' });
691
+ });
692
+
693
+ // Trigger editor events
694
+ toast.triggerEditorEvent('media-upload-progress', { progress: 50 });
695
+ ```
696
+
697
+ ## 📋 API Reference
698
+
699
+ ### Core Methods
700
+
701
+ - `toast.show(options)` - Show a toast with full options
702
+ - `toast.update(id, options)` - Update an existing toast dynamically
703
+ - `toast.dismiss(id?)` - Dismiss a specific toast or all toasts
704
+ - `toast.clear()` - Clear all visible toasts
705
+
706
+ ### Convenience Methods
707
+
708
+ - `toast.info(message, options?)` - Info level toast
709
+ - `toast.success(message, options?)` - Success level toast
710
+ - `toast.error(message, options?)` - Error level toast
711
+ - `toast.warning(message, options?)` - Warning level toast
712
+ - `toast.loading(message, options?)` - Loading state toast
713
+
714
+ ### Advanced Methods (v2.0.0)
715
+
716
+ - `toast.promise(promise, options)` - Promise lifecycle toasts with automatic state transitions
717
+ - `toast.group(id, options)` - Group related toasts with stacking behavior
718
+ - `toast.configure(config)` - Update global configuration
719
+ - `toast.use(plugin)` - Install a plugin
720
+ - `toast.onEditorEvent(event, handler)` - Listen for editor integration events
721
+ - `toast.triggerEditorEvent(event, data)` - Trigger editor integration events
722
+
723
+ ### Toast Options Interface
724
+
725
+ ```typescript
726
+ interface ToastOptions {
727
+ // Content
728
+ message: string;
729
+ level?: 'info' | 'success' | 'error' | 'warning' | 'loading' | 'progress' | 'promise' | 'custom';
730
+ icon?: string;
731
+ html?: boolean;
732
+ render?: () => HTMLElement;
733
+
734
+ // Behavior
735
+ duration?: number;
736
+ pauseOnHover?: boolean;
737
+ clickToDismiss?: boolean;
738
+
739
+ // Positioning
740
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
741
+
742
+ // Interactions
743
+ actions?: ToastAction[];
744
+ swipeDismiss?: boolean;
745
+ dragDismiss?: boolean;
746
+
747
+ // Progress
748
+ progress?: ToastProgress;
749
+
750
+ // Styling
751
+ theme?: string;
752
+ className?: string;
753
+
754
+ // Advanced
755
+ groupId?: string;
756
+ priority?: number;
757
+ animation?: ToastAnimation;
758
+ onShow?: (toast: Toast) => void;
759
+ onHide?: (toast: Toast) => void;
760
+ onUpdate?: (toast: Toast, updates: Partial<ToastOptions>) => void;
761
+ }
762
+
763
+ interface ToastAction {
764
+ label: string;
765
+ onClick: (toast: Toast) => void;
766
+ variant?: 'primary' | 'secondary' | 'ghost';
767
+ primary?: boolean;
768
+ }
769
+
770
+ interface ToastProgress {
771
+ value: number; // 0-100
772
+ showPercentage?: boolean;
773
+ indeterminate?: boolean;
774
+ color?: string;
775
+ size?: 'sm' | 'md' | 'lg';
776
+ }
777
+
778
+ interface ToastAnimation {
779
+ type: 'css' | 'spring' | 'custom';
780
+ config?: SpringConfig;
781
+ show?: AnimationFunction;
782
+ hide?: AnimationFunction;
783
+ update?: AnimationFunction;
784
+ }
785
+ ```
786
+
787
+ ## 🎮 Live Demo & Examples
788
+
789
+ Try out all the features with our comprehensive demo:
790
+
791
+ ```bash
792
+ # Clone the repository
793
+ git clone https://github.com/ajaykr089/Editora.git
794
+ cd Editora/packages/editora-toast
795
+
796
+ # Install dependencies
797
+ npm install
798
+
799
+ # Start the demo server
800
+ npm run demo
801
+ # or
802
+ python3 -m http.server 8086
803
+ # Then open: http://localhost:8086/examples/web/toast-demo.html
804
+ ```
805
+
806
+ The demo showcases:
807
+ - ✅ All 13 built-in themes
808
+ - 🎯 Interactive actions and buttons
809
+ - 📊 Progress bars and indicators
810
+ - 🔄 Promise lifecycle management
811
+ - 🎪 Spring physics animations
812
+ - 📱 Mobile gestures and touch support
813
+ - ♿ Accessibility features
814
+ - 🎨 Custom rendering and HTML content
815
+ - 📱 Responsive design across devices
816
+
817
+ ## 🔧 Build & Development
818
+
819
+ ```bash
820
+ # Install dependencies
821
+ npm install
822
+
823
+ # Build
824
+ npm run build
825
+
826
+ # Development watch
827
+ npm run dev
828
+
829
+ # Clean
830
+ npm run clean
831
+ ```
832
+
833
+ ## 🌍 Browser Support
834
+
835
+ - Chrome 60+
836
+ - Firefox 55+
837
+ - Safari 12+
838
+ - Edge 79+
839
+
840
+ ## 📄 License
841
+
842
+ MIT © [Ajay Kumar](https://github.com/ajaykr089)
843
+
844
+ ## 🤝 Contributing
845
+
846
+ Contributions welcome! Please see the [main repository](https://github.com/ajaykr089/Editora) for contribution guidelines.
847
+
848
+ ## 📚 Migration Guide
849
+
850
+ ### From v1.x to v2.0.0
851
+
852
+ The v2.0.0 release introduces powerful new features while maintaining **full backward compatibility**. Your existing code will continue to work without changes.
853
+
854
+ #### ✨ New Features in v2.0.0
855
+
856
+ ```typescript
857
+ // v1.x (still works)
858
+ import { toast } from '@editora/toast';
859
+ import "@editora/toast/toast.css";
860
+ toast.success('Hello World', { theme: 'light', position: 'top-right' });
861
+
862
+ // v2.0.0 advanced features
863
+ import { toastAdvanced as toast } from '@editora/toast';
864
+ import "@editora/toast/toast.css";
865
+ // Promise lifecycle toasts
866
+ toast.promise(fetchData(), {
867
+ loading: 'Loading...',
868
+ success: 'Data loaded!',
869
+ error: 'Failed to load'
870
+ });
871
+
872
+ // Rich content with actions
873
+ toast.show({
874
+ message: 'File uploaded!',
875
+ level: 'success',
876
+ icon: '✅',
877
+ actions: [
878
+ { label: 'View', onClick: () => {} },
879
+ { label: 'Share', onClick: () => {} }
880
+ ],
881
+ progress: { value: 100, showPercentage: true }
882
+ });
883
+
884
+ // Dynamic toast updates
885
+ const toast = toast.loading('Saving...');
886
+ toast.update(toast.id, { message: 'Saved!', level: 'success' });
887
+
888
+ // Toast grouping
889
+ toast.group('operations', { message: 'Task 1 complete', level: 'success' });
890
+ toast.group('operations', { message: 'Task 2 complete', level: 'success' });
891
+ ```
892
+
893
+ #### Configuration Changes
894
+
895
+ ```typescript
896
+ // New configuration options in v2.0.0
897
+ toast.configure({
898
+ theme: 'system', // New themes: glass, neon, retro, ocean, etc.
899
+ swipeDismiss: true, // Mobile gesture support
900
+ dragDismiss: false,
901
+ animation: {
902
+ type: 'spring', // New spring physics animations
903
+ config: { stiffness: 120, damping: 12 }
904
+ },
905
+ queueStrategy: 'priority', // Priority-based queuing
906
+ enableKeyboardNavigation: true // Enhanced accessibility
907
+ });
908
+ ```
909
+
910
+ For more detailed migration information, see the [migration guide](./MIGRATION_GUIDE.md).