@editora/toast 1.0.2 → 2.0.0

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 +901 -7
  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 +32 -7
  12. package/dist/index.esm.js +1061 -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 +45 -12
  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,908 @@
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
 
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
113
+ toast.success('Hello from CDN!');
114
+ toast.error('Something went wrong!', 1000);
115
+ toast.info('This is an info message');
116
+ toast.warning('This is a warning');
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
+
158
+ // Simple notifications
159
+ toast.success('File saved successfully!');
160
+ toast.error('Failed to save file');
14
161
  toast.info('Info message');
162
+ toast.warning('Warning message');
163
+ ```
164
+
165
+ ### Advanced Usage (v2.0.0 Features)
166
+
167
+ ```typescript
168
+ import { toastAdvanced as toast } from '@editora/toast';
169
+
170
+ // Rich notifications with actions and progress
171
+ const notification = toast.show({
172
+ message: 'Document uploaded successfully!',
173
+ level: 'success',
174
+ icon: '✓',
175
+ actions: [
176
+ { label: 'View Document', onClick: () => console.log('View clicked') },
177
+ { label: 'Share', onClick: () => console.log('Share clicked') },
178
+ { label: 'Dismiss', onClick: () => notification.dismiss() }
179
+ ],
180
+ progress: { value: 100, showPercentage: true },
181
+ duration: 6000
182
+ });
183
+
184
+ // Promise-based notifications with automatic state transitions
185
+ toast.promise(
186
+ uploadFile(file),
187
+ {
188
+ loading: 'Uploading file...',
189
+ success: (data) => `File "${data.name}" uploaded successfully!`,
190
+ error: (error) => `Upload failed: ${error.message}`
191
+ }
192
+ );
193
+
194
+ // Update existing toast dynamically
195
+ const loadingToast = toast.loading('Saving document...');
196
+ setTimeout(() => {
197
+ toast.update(loadingToast.id, {
198
+ message: 'Document saved successfully!',
199
+ level: 'success',
200
+ icon: '💾',
201
+ actions: [{ label: 'Open', onClick: () => {} }]
202
+ });
203
+ }, 2000);
204
+
205
+ // Group related notifications
206
+ toast.group('file-operations', {
207
+ message: 'File 1 processed',
208
+ level: 'success'
209
+ });
210
+
211
+ toast.group('file-operations', {
212
+ message: 'File 2 processed',
213
+ level: 'success'
214
+ });
215
+ ```
216
+
217
+ ## 🎛️ Configuration
218
+
219
+ ```typescript
220
+ import { toastAdvanced as toast } from '@editora/toast';
221
+
222
+ // Global configuration with all available options
223
+ toast.configure({
224
+ // Positioning
225
+ position: 'top-right', // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'
226
+
227
+ // Timing
228
+ duration: 5000, // Default duration in milliseconds
229
+ pauseOnHover: true, // Pause timer when hovering
230
+
231
+ // Display
232
+ maxVisible: 5, // Maximum visible toasts
233
+ theme: 'system', // Theme: 'light' | 'dark' | 'system' | 'colored' | 'minimal' | 'glass' | 'neon' | 'retro' | 'ocean' | 'forest' | 'sunset' | 'midnight' | 'custom'
234
+
235
+ // Accessibility
236
+ enableAccessibility: true, // Enable screen reader support
237
+ enableKeyboardNavigation: true, // Enable keyboard navigation
238
+
239
+ // Interactions
240
+ swipeDismiss: true, // Enable swipe to dismiss on mobile
241
+ dragDismiss: false, // Enable drag to dismiss
242
+ clickToDismiss: true, // Click anywhere to dismiss
243
+
244
+ // Queue Management
245
+ queueStrategy: 'priority', // 'fifo' | 'priority' | 'stack'
246
+ maxQueueSize: 10, // Maximum queued toasts
247
+
248
+ // Animations
249
+ animation: {
250
+ type: 'spring', // 'css' | 'spring' | 'custom'
251
+ config: {
252
+ stiffness: 120,
253
+ damping: 12,
254
+ mass: 1,
255
+ precision: 0.01
256
+ }
257
+ },
258
+
259
+ // Advanced
260
+ enableHtml: false, // Allow HTML in messages (use with caution)
261
+ sanitizeHtml: true, // Sanitize HTML content
262
+ zIndex: 9999, // Base z-index for toasts
263
+ containerClass: 'custom-container' // Custom container class
264
+ });
265
+ ```
266
+
267
+ ## 🎨 Theming
268
+
269
+ ![Beautiful Themes](toast-screenshots/beautiful-themes.png)
270
+
271
+ ### Built-in Themes
272
+
273
+ Editora Toast comes with 13 beautiful themes:
274
+
275
+ - **`light`** - Clean white background with subtle shadows
276
+ - **`dark`** - Dark background with high contrast text
277
+ - **`system`** - Automatically switches between light/dark based on system preference
278
+ - **`colored`** - Vibrant gradient backgrounds for each toast level
279
+ - **`minimal`** - Clean design with subtle borders and minimal styling
280
+ - **`glass`** - Frosted glass effect with backdrop blur
281
+ - **`neon`** - Bright neon colors with glowing effects
282
+ - **`retro`** - 80s/90s style with bold colors and gradients
283
+ - **`ocean`** - Blue aquatic theme with calming colors
284
+ - **`forest`** - Green natural theme with earthy tones
285
+ - **`sunset`** - Warm orange/pink sunset colors
286
+ - **`midnight`** - Deep blue dark theme with subtle gradients
287
+ - **`custom`** - Fully customizable with CSS variables
288
+
289
+ ### Usage
290
+
291
+ ```typescript
292
+ import { toastAdvanced as toast } from '@editora/toast';
293
+
294
+ // Set global theme
295
+ toast.configure({
296
+ theme: 'glass' // or 'neon', 'retro', 'ocean', etc.
297
+ });
298
+
299
+ // Per-toast theme
300
+ toast.show({
301
+ message: 'Hello World',
302
+ theme: 'colored'
303
+ });
304
+ ```
305
+
306
+ ### CSS Variables
307
+
308
+ ```css
309
+ :root {
310
+ --editora-toast-bg: rgba(0, 0, 0, 0.85);
311
+ --editora-toast-color: #fff;
312
+ --editora-toast-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
313
+ --editora-toast-border-radius: 6px;
314
+ --editora-toast-font-family: system-ui, -apple-system, 'Segoe UI', Roboto;
315
+ --editora-toast-font-size: 13px;
316
+ --editora-toast-padding: 10px 14px;
317
+ }
318
+ ```
319
+
320
+ ### Theme Classes
321
+
322
+ ```html
323
+ <!-- Apply theme globally -->
324
+ <div data-theme="glass">
325
+ <!-- All toasts will use glass theme -->
326
+ </div>
327
+
328
+ <!-- Or apply to specific container -->
329
+ <div class="editora-toast-container" data-theme="neon">
330
+ </div>
331
+ ```
332
+
333
+ ## 🎯 Advanced Features
334
+
335
+ ### Promise Lifecycle Toasts
336
+ ![Async Operations](toast-screenshots/async-operations.png)
337
+
338
+ Automatically handle async operations with state transitions:
339
+
340
+ ```typescript
341
+ import { toastAdvanced as toast } from '@editora/toast';
342
+
343
+ // Promise-based notifications
344
+ const uploadPromise = uploadFile(file);
345
+
346
+ toast.promise(uploadPromise, {
347
+ loading: {
348
+ message: 'Uploading file...',
349
+ icon: '⏳',
350
+ progress: { indeterminate: true }
351
+ },
352
+ success: {
353
+ message: 'File uploaded successfully!',
354
+ icon: '✅',
355
+ duration: 4000,
356
+ actions: [{ label: 'View', onClick: () => openFile() }]
357
+ },
358
+ error: {
359
+ message: 'Upload failed. Please try again.',
360
+ icon: '❌',
361
+ duration: 6000,
362
+ actions: [
363
+ { label: 'Retry', onClick: () => retryUpload() },
364
+ { label: 'Cancel', onClick: () => {} }
365
+ ]
366
+ }
367
+ });
368
+ ```
369
+
370
+ ### Interactive Actions
371
+ ![Interactive Actions](toast-screenshots/interactive-actions.png)
372
+
373
+ Add interactive buttons to your toasts:
374
+
375
+ ```typescript
376
+ import { toastAdvanced as toast } from '@editora/toast';
377
+
378
+ const notification = toast.show({
379
+ message: 'Document saved successfully!',
380
+ level: 'success',
381
+ icon: '💾',
382
+ actions: [
383
+ {
384
+ label: 'Open Document',
385
+ onClick: () => openDocument(),
386
+ primary: true // Primary action styling
387
+ },
388
+ {
389
+ label: 'Share',
390
+ onClick: () => shareDocument(),
391
+ variant: 'secondary'
392
+ },
393
+ {
394
+ label: 'Dismiss',
395
+ onClick: () => notification.dismiss(),
396
+ variant: 'ghost'
397
+ }
398
+ ],
399
+ duration: 8000 // Longer duration for actions
400
+ });
401
+ ```
402
+
403
+ ### Progress Tracking
404
+ ![Progress Scenarios](toast-screenshots/progress-scenarios.png)
405
+
406
+ Built-in progress bars with customizable display:
407
+
408
+ ```typescript
409
+ import { toastAdvanced as toast } from '@editora/toast';
410
+
411
+ // Determinate progress
412
+ const progressToast = toast.show({
413
+ message: 'Processing files...',
414
+ level: 'info',
415
+ progress: {
416
+ value: 0,
417
+ showPercentage: true,
418
+ color: '#007acc'
419
+ }
420
+ });
421
+
422
+ // Update progress
423
+ let progress = 0;
424
+ const interval = setInterval(() => {
425
+ progress += 10;
426
+ toast.update(progressToast.id, {
427
+ progress: { value: progress, showPercentage: true },
428
+ message: `Processing files... ${progress}%`
429
+ });
430
+
431
+ if (progress >= 100) {
432
+ clearInterval(interval);
433
+ toast.update(progressToast.id, {
434
+ message: 'Processing complete!',
435
+ level: 'success',
436
+ progress: { value: 100, showPercentage: true }
437
+ });
438
+ }
439
+ }, 500);
440
+ ```
441
+
442
+ ### Toast Updates
443
+ ![Advanced Features](toast-screenshots/advanced-features.png)
444
+
445
+ Modify existing toasts dynamically:
446
+
447
+ ```typescript
448
+ import { toastAdvanced as toast } from '@editora/toast';
449
+
450
+ // Create a loading toast
451
+ const loadingToast = toast.loading('Connecting to server...');
452
+
453
+ // Update with progress
454
+ setTimeout(() => {
455
+ toast.update(loadingToast.id, {
456
+ message: 'Authenticating...',
457
+ progress: { value: 25, showPercentage: true }
458
+ });
459
+ }, 1000);
460
+
461
+ // Update with success
462
+ setTimeout(() => {
463
+ toast.update(loadingToast.id, {
464
+ message: 'Connected successfully!',
465
+ level: 'success',
466
+ icon: '🔗',
467
+ progress: { value: 100, showPercentage: true },
468
+ actions: [{ label: 'Explore', onClick: () => {} }]
469
+ });
470
+ }, 2000);
471
+ ```
472
+
473
+ ### Toast Grouping
474
+ ![Error Handling](toast-screenshots/error-handling.png)
475
+
476
+ Group related notifications together:
477
+
478
+ ```typescript
479
+ import { toastAdvanced as toast } from '@editora/toast';
480
+
481
+ // Group file operations
482
+ const files = ['document.pdf', 'image.jpg', 'data.json'];
483
+
484
+ files.forEach((file, index) => {
485
+ setTimeout(() => {
486
+ toast.group('file-upload', {
487
+ message: `Uploaded ${file}`,
488
+ level: 'success',
489
+ icon: '📁',
490
+ duration: 3000
491
+ });
492
+ }, index * 500);
493
+ });
494
+
495
+ // Group error notifications
496
+ toast.group('validation-errors', {
497
+ message: 'Invalid email format',
498
+ level: 'error',
499
+ icon: '⚠️'
500
+ });
501
+
502
+ toast.group('validation-errors', {
503
+ message: 'Password too weak',
504
+ level: 'error',
505
+ icon: '🔒'
506
+ });
507
+ ```
508
+
509
+ ### Interactive Feedback Forms
510
+ ![Interactive Feedback Form](toast-screenshots/nteractive-feedback-form.png)
511
+
512
+ Create interactive forms within toasts:
513
+
514
+ ```typescript
515
+ import { toastAdvanced as toast } from '@editora/toast';
516
+
517
+ toast.show({
518
+ message: 'How was your experience?',
519
+ level: 'info',
520
+ icon: '⭐',
521
+ render: () => {
522
+ const container = document.createElement('div');
523
+ container.innerHTML = `
524
+ <div style="display: flex; gap: 8px; margin-top: 8px;">
525
+ <button class="feedback-btn" data-rating="1">😞</button>
526
+ <button class="feedback-btn" data-rating="2">😐</button>
527
+ <button class="feedback-btn" data-rating="3">😊</button>
528
+ <button class="feedback-btn" data-rating="4">😃</button>
529
+ <button class="feedback-btn" data-rating="5">😍</button>
530
+ </div>
531
+ `;
532
+
533
+ container.addEventListener('click', (e) => {
534
+ if (e.target.classList.contains('feedback-btn')) {
535
+ const rating = e.target.dataset.rating;
536
+ submitFeedback(rating);
537
+ toast.success('Thank you for your feedback!');
538
+ }
539
+ });
540
+
541
+ return container;
542
+ },
543
+ duration: 10000
544
+ });
545
+ ```
546
+
547
+ ## 🔌 Plugins
548
+
549
+ ```typescript
550
+ import { toastAdvanced as toast } from '@editora/toast';
551
+
552
+ const myPlugin = {
553
+ name: 'my-plugin',
554
+ install(manager) {
555
+ // Add custom functionality
556
+ manager.on('beforeShow', (toast) => {
557
+ console.log('Toast about to show:', toast.message);
558
+ });
559
+ }
560
+ };
561
+
562
+ toast.use(myPlugin);
563
+ ```
564
+
565
+ ## 📱 Positions
566
+
567
+ ```typescript
568
+ toast.show({
569
+ message: 'Hello World',
570
+ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'
571
+ });
572
+ ```
573
+
574
+ ## 🎪 Advanced Features
575
+
576
+ ### Spring Physics Animations
577
+
578
+ ```typescript
579
+ import { toastAdvanced as toast } from '@editora/toast';
580
+
581
+ // Spring animation with custom physics
582
+ toast.show({
583
+ message: 'Spring animated toast!',
584
+ level: 'success',
585
+ animation: {
586
+ type: 'spring',
587
+ config: {
588
+ stiffness: 120, // Spring stiffness (default: 100)
589
+ damping: 12, // Spring damping (default: 10)
590
+ mass: 1, // Spring mass (default: 1)
591
+ precision: 0.01 // Animation precision (default: 0.01)
592
+ }
593
+ }
594
+ });
595
+ ```
596
+
597
+ ### Custom Animation Hooks
598
+
599
+ ```typescript
600
+ import { toastAdvanced as toast } from '@editora/toast';
601
+
602
+ // Custom animation functions
603
+ toast.show({
604
+ message: 'Custom animated toast!',
605
+ level: 'info',
606
+ animation: {
607
+ type: 'custom',
608
+ show: async (element, toast) => {
609
+ // Custom show animation
610
+ element.style.opacity = '0';
611
+ element.style.transform = 'rotateX(90deg)';
612
+
613
+ await new Promise(resolve => {
614
+ element.style.transition = 'all 0.5s ease';
615
+ element.style.opacity = '1';
616
+ element.style.transform = 'rotateX(0deg)';
617
+ element.addEventListener('transitionend', resolve, { once: true });
618
+ });
619
+ },
620
+ hide: async (element, toast) => {
621
+ // Custom hide animation
622
+ element.style.transition = 'all 0.3s ease';
623
+ element.style.opacity = '0';
624
+ element.style.transform = 'scale(0.8)';
625
+
626
+ return new Promise(resolve => {
627
+ setTimeout(resolve, 300);
628
+ });
629
+ },
630
+ update: async (element, toast, updates) => {
631
+ // Custom update animation
632
+ element.style.transform = 'scale(1.05)';
633
+ setTimeout(() => {
634
+ element.style.transform = 'scale(1)';
635
+ }, 150);
636
+ }
637
+ }
638
+ });
639
+ ```
640
+
641
+ ### Global Animation Configuration
642
+
643
+ ```typescript
644
+ import { toastAdvanced as toast } from '@editora/toast';
645
+
646
+ // Set default animation for all toasts
647
+ toast.configure({
648
+ animation: {
649
+ type: 'spring',
650
+ config: { stiffness: 150, damping: 15 }
651
+ }
652
+ });
653
+ ```
654
+
655
+ ### Toast Groups
656
+
657
+ ```typescript
658
+ // Group related notifications
659
+ toast.group('upload-group', {
660
+ message: 'Upload 1 complete',
661
+ level: 'success'
662
+ });
663
+
664
+ toast.group('upload-group', {
665
+ message: 'Upload 2 complete',
666
+ level: 'success'
667
+ });
668
+ ```
669
+
670
+ ### Custom Render Function
671
+
672
+ ```typescript
673
+ toast.show({
674
+ render: () => {
675
+ const div = document.createElement('div');
676
+ div.innerHTML = '<strong>Custom</strong> content';
677
+ return div;
678
+ }
679
+ });
680
+ ```
681
+
682
+ ### Editor Integration
683
+
684
+ ```typescript
685
+ import { toastAdvanced as toast } from '@editora/toast';
686
+
687
+ // Listen for editor events
688
+ toast.onEditorEvent('spellcheck-error', (error) => {
689
+ toast.error(`Spelling error: ${error.word}`);
690
+ });
691
+
692
+ // Trigger editor events
693
+ toast.triggerEditorEvent('media-upload-progress', { progress: 50 });
694
+ ```
695
+
696
+ ## 📋 API Reference
697
+
698
+ ### Core Methods
699
+
700
+ - `toast.show(options)` - Show a toast with full options
701
+ - `toast.update(id, options)` - Update an existing toast dynamically
702
+ - `toast.dismiss(id?)` - Dismiss a specific toast or all toasts
703
+ - `toast.clear()` - Clear all visible toasts
704
+
705
+ ### Convenience Methods
706
+
707
+ - `toast.info(message, options?)` - Info level toast
708
+ - `toast.success(message, options?)` - Success level toast
709
+ - `toast.error(message, options?)` - Error level toast
710
+ - `toast.warning(message, options?)` - Warning level toast
711
+ - `toast.loading(message, options?)` - Loading state toast
712
+
713
+ ### Advanced Methods (v2.0.0)
714
+
715
+ - `toast.promise(promise, options)` - Promise lifecycle toasts with automatic state transitions
716
+ - `toast.group(id, options)` - Group related toasts with stacking behavior
717
+ - `toast.configure(config)` - Update global configuration
718
+ - `toast.use(plugin)` - Install a plugin
719
+ - `toast.onEditorEvent(event, handler)` - Listen for editor integration events
720
+ - `toast.triggerEditorEvent(event, data)` - Trigger editor integration events
721
+
722
+ ### Toast Options Interface
723
+
724
+ ```typescript
725
+ interface ToastOptions {
726
+ // Content
727
+ message: string;
728
+ level?: 'info' | 'success' | 'error' | 'warning' | 'loading' | 'progress' | 'promise' | 'custom';
729
+ icon?: string;
730
+ html?: boolean;
731
+ render?: () => HTMLElement;
732
+
733
+ // Behavior
734
+ duration?: number;
735
+ pauseOnHover?: boolean;
736
+ clickToDismiss?: boolean;
737
+
738
+ // Positioning
739
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
740
+
741
+ // Interactions
742
+ actions?: ToastAction[];
743
+ swipeDismiss?: boolean;
744
+ dragDismiss?: boolean;
745
+
746
+ // Progress
747
+ progress?: ToastProgress;
748
+
749
+ // Styling
750
+ theme?: string;
751
+ className?: string;
752
+
753
+ // Advanced
754
+ groupId?: string;
755
+ priority?: number;
756
+ animation?: ToastAnimation;
757
+ onShow?: (toast: Toast) => void;
758
+ onHide?: (toast: Toast) => void;
759
+ onUpdate?: (toast: Toast, updates: Partial<ToastOptions>) => void;
760
+ }
761
+
762
+ interface ToastAction {
763
+ label: string;
764
+ onClick: (toast: Toast) => void;
765
+ variant?: 'primary' | 'secondary' | 'ghost';
766
+ primary?: boolean;
767
+ }
768
+
769
+ interface ToastProgress {
770
+ value: number; // 0-100
771
+ showPercentage?: boolean;
772
+ indeterminate?: boolean;
773
+ color?: string;
774
+ size?: 'sm' | 'md' | 'lg';
775
+ }
776
+
777
+ interface ToastAnimation {
778
+ type: 'css' | 'spring' | 'custom';
779
+ config?: SpringConfig;
780
+ show?: AnimationFunction;
781
+ hide?: AnimationFunction;
782
+ update?: AnimationFunction;
783
+ }
784
+ ```
785
+
786
+ ## 🎮 Live Demo & Examples
787
+
788
+ Try out all the features with our comprehensive demo:
789
+
790
+ ```bash
791
+ # Clone the repository
792
+ git clone https://github.com/ajaykr089/Editora.git
793
+ cd Editora/packages/editora-toast
794
+
795
+ # Install dependencies
796
+ npm install
797
+
798
+ # Start the demo server
799
+ npm run demo
800
+ # or
801
+ python3 -m http.server 8086
802
+ # Then open: http://localhost:8086/examples/web/toast-demo.html
803
+ ```
804
+
805
+ The demo showcases:
806
+ - ✅ All 13 built-in themes
807
+ - 🎯 Interactive actions and buttons
808
+ - 📊 Progress bars and indicators
809
+ - 🔄 Promise lifecycle management
810
+ - 🎪 Spring physics animations
811
+ - 📱 Mobile gestures and touch support
812
+ - ♿ Accessibility features
813
+ - 🎨 Custom rendering and HTML content
814
+ - 📱 Responsive design across devices
815
+
816
+ ## 🔧 Build & Development
817
+
818
+ ```bash
819
+ # Install dependencies
820
+ npm install
821
+
822
+ # Build
823
+ npm run build
824
+
825
+ # Development watch
826
+ npm run dev
827
+
828
+ # Clean
829
+ npm run clean
830
+ ```
831
+
832
+ ## 🌍 Browser Support
833
+
834
+ - Chrome 60+
835
+ - Firefox 55+
836
+ - Safari 12+
837
+ - Edge 79+
838
+
839
+ ## 📄 License
840
+
841
+ MIT © [Ajay Kumar](https://github.com/ajaykr089)
842
+
843
+ ## 🤝 Contributing
844
+
845
+ Contributions welcome! Please see the [main repository](https://github.com/ajaykr089/Editora) for contribution guidelines.
846
+
847
+ ## 📚 Migration Guide
848
+
849
+ ### From v1.x to v2.0.0
850
+
851
+ The v2.0.0 release introduces powerful new features while maintaining **full backward compatibility**. Your existing code will continue to work without changes.
852
+
853
+ #### ✨ New Features in v2.0.0
854
+
855
+ ```typescript
856
+ // v1.x (still works)
857
+ import { toast } from '@editora/toast';
858
+ toast.success('Hello World');
859
+
860
+ // v2.0.0 advanced features
861
+ import { toastAdvanced as toast } from '@editora/toast';
862
+
863
+ // Promise lifecycle toasts
864
+ toast.promise(fetchData(), {
865
+ loading: 'Loading...',
866
+ success: 'Data loaded!',
867
+ error: 'Failed to load'
868
+ });
869
+
870
+ // Rich content with actions
871
+ toast.show({
872
+ message: 'File uploaded!',
873
+ level: 'success',
874
+ icon: '✅',
875
+ actions: [
876
+ { label: 'View', onClick: () => {} },
877
+ { label: 'Share', onClick: () => {} }
878
+ ],
879
+ progress: { value: 100, showPercentage: true }
880
+ });
881
+
882
+ // Dynamic toast updates
883
+ const toast = toast.loading('Saving...');
884
+ toast.update(toast.id, { message: 'Saved!', level: 'success' });
885
+
886
+ // Toast grouping
887
+ toast.group('operations', { message: 'Task 1 complete', level: 'success' });
888
+ toast.group('operations', { message: 'Task 2 complete', level: 'success' });
889
+ ```
890
+
891
+ #### Configuration Changes
892
+
893
+ ```typescript
894
+ // New configuration options in v2.0.0
895
+ toast.configure({
896
+ theme: 'system', // New themes: glass, neon, retro, ocean, etc.
897
+ swipeDismiss: true, // Mobile gesture support
898
+ dragDismiss: false,
899
+ animation: {
900
+ type: 'spring', // New spring physics animations
901
+ config: { stiffness: 120, damping: 12 }
902
+ },
903
+ queueStrategy: 'priority', // Priority-based queuing
904
+ enableKeyboardNavigation: true // Enhanced accessibility
905
+ });
906
+ ```
907
+
908
+ For more detailed migration information, see the [migration guide](./MIGRATION_GUIDE.md).