smartrte-react 0.1.17 → 0.2.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 (45) hide show
  1. package/README.md +89 -13
  2. package/dist/components/ClassicEditor.d.ts +14 -1
  3. package/dist/components/ClassicEditor.js +165 -158
  4. package/dist/components/MediaManager.js +21 -16
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +1 -0
  7. package/dist/standalone/classic-editor-embed.js +1 -1
  8. package/dist/theme.d.ts +3 -0
  9. package/dist/theme.js +61 -0
  10. package/package.json +1 -2
  11. package/dist/QuillEditor.d.ts +0 -8
  12. package/dist/QuillEditor.js +0 -34
  13. package/dist/app.d.ts +0 -6
  14. package/dist/app.js +0 -6
  15. package/dist/blots/CommentBlot.d.ts +0 -8
  16. package/dist/blots/CommentBlot.js +0 -17
  17. package/dist/blots/FormulaBlot.d.ts +0 -12
  18. package/dist/blots/FormulaBlot.js +0 -36
  19. package/dist/blots/MediaBlot.d.ts +0 -11
  20. package/dist/blots/MediaBlot.js +0 -37
  21. package/dist/blots/TableBlot.d.ts +0 -10
  22. package/dist/blots/TableBlot.js +0 -54
  23. package/dist/blots/index.d.ts +0 -5
  24. package/dist/blots/index.js +0 -12
  25. package/dist/components/DiagramEditor.d.ts +0 -5
  26. package/dist/components/DiagramEditor.js +0 -73
  27. package/dist/components/FormulaEditor.d.ts +0 -6
  28. package/dist/components/FormulaEditor.js +0 -86
  29. package/dist/components/InfoBox.d.ts +0 -7
  30. package/dist/components/InfoBox.js +0 -18
  31. package/dist/components/MCQBlock.d.ts +0 -13
  32. package/dist/components/MCQBlock.js +0 -29
  33. package/dist/components/SmartEditor.d.ts +0 -0
  34. package/dist/components/SmartEditor.js +0 -1
  35. package/dist/components/SmartTable.d.ts +0 -22
  36. package/dist/components/SmartTable.js +0 -629
  37. package/dist/components/TableContextMenu.d.ts +0 -11
  38. package/dist/components/TableContextMenu.js +0 -15
  39. package/dist/components/TableInsertDialog.d.ts +0 -7
  40. package/dist/components/TableInsertDialog.js +0 -42
  41. package/dist/hooks/useEditorSync.d.ts +0 -5
  42. package/dist/hooks/useEditorSync.js +0 -53
  43. package/dist/smart-editor.d.ts +0 -0
  44. package/dist/smart-editor.js +0 -1
  45. package/dist/standalone/editor.js +0 -241
package/README.md CHANGED
@@ -40,6 +40,13 @@ pnpm add smartrte-react
40
40
 
41
41
  ## 🚀 Quick Start
42
42
 
43
+ ### 🎮 Live Demo
44
+
45
+ Try the editor instantly in your browser:
46
+
47
+ - **[Live Demo](https://playground-k9l44ah7t-ayush1852017s-projects.vercel.app/)** (Deployed Version)
48
+ - **[CodeSandbox Playground](https://codesandbox.io/s/github/ayush1852017/smart-rte/tree/master/packages/react/playground)** (Interactive)
49
+
43
50
  ### Basic Usage
44
51
 
45
52
  ```tsx
@@ -81,6 +88,10 @@ export default App;
81
88
  | `media` | `boolean` | `true` | Enable/disable media/image functionality |
82
89
  | `formula` | `boolean` | `true` | Enable/disable formula/LaTeX functionality |
83
90
  | `mediaManager` | `MediaManagerAdapter` | `undefined` | Custom media manager for handling images |
91
+ | `fonts` | `{ name: string; value: string }[]` | Default web-safe fonts | Custom font list for the toolbar |
92
+ | `defaultFont` | `string` | `undefined` | Default font family for the editor content |
93
+ | `theme` | `"light" \| "dark"` | `"light"` | Built-in theme mode |
94
+ | `className` | `string` | `undefined` | Custom CSS class for theming via CSS variable overrides |
84
95
 
85
96
  ### Advanced Examples
86
97
 
@@ -307,23 +318,87 @@ const myMediaManager: MediaManagerAdapter = {
307
318
  };
308
319
  ```
309
320
 
310
- ## 🎨 Styling
321
+ ## 🎨 Theming & Dark Mode
322
+
323
+ The editor uses CSS custom properties (CSS variables) for all colors, making it fully customizable. No hardcoded colors — everything can be themed.
311
324
 
312
- The editor comes with built-in styles. You can customize the appearance by wrapping it in a container:
325
+ ### Quick Start: Dark Mode
313
326
 
314
327
  ```tsx
315
- <div style={{
316
- border: '1px solid #ddd',
317
- borderRadius: '8px',
318
- overflow: 'hidden',
319
- }}>
320
- <ClassicEditor
321
- value={content}
322
- onChange={setContent}
323
- />
324
- </div>
328
+ <ClassicEditor theme="dark" onChange={handleChange} />
329
+ ```
330
+
331
+ ### Custom Themes via CSS
332
+
333
+ Apply a custom class and override any CSS variables:
334
+
335
+ ```tsx
336
+ <ClassicEditor className="my-theme" onChange={handleChange} />
337
+ ```
338
+
339
+ ```css
340
+ .my-theme {
341
+ --srte-bg: #1a1a2e;
342
+ --srte-text: #eaeaea;
343
+ --srte-border: #3a3a5c;
344
+ /* Override only the variables you need */
345
+ }
325
346
  ```
326
347
 
348
+ ### Responding to System Preference
349
+
350
+ ```tsx
351
+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
352
+
353
+ <ClassicEditor theme={prefersDark ? 'dark' : 'light'} />
354
+ ```
355
+
356
+ Or purely via CSS (without the `theme` prop):
357
+
358
+ ```css
359
+ @media (prefers-color-scheme: dark) {
360
+ .srte-editor {
361
+ --srte-bg: #1e1e1e;
362
+ --srte-text: #e0e0e0;
363
+ --srte-border: #3a3a3a;
364
+ /* ... */
365
+ }
366
+ }
367
+ ```
368
+
369
+ ### Available CSS Custom Properties
370
+
371
+ | Variable | Default (Light) | Description |
372
+ |---|---|---|
373
+ | `--srte-bg` | `#ffffff` | Editor container & content background |
374
+ | `--srte-text` | `#111111` | Primary UI text color |
375
+ | `--srte-text-muted` | `#4b5563` | Secondary/subtle text |
376
+ | `--srte-border` | `#dddddd` | Standard border color |
377
+ | `--srte-border-light` | `#eeeeee` | Light separator borders |
378
+ | `--srte-toolbar-bg` | `#ffffff` | Toolbar background |
379
+ | `--srte-input-bg` | `#ffffff` | Button, input, select backgrounds |
380
+ | `--srte-input-text` | `#111111` | Button, input, select text |
381
+ | `--srte-input-border` | `#e5e7eb` | Button, input, select borders |
382
+ | `--srte-modal-backdrop` | `rgba(0,0,0,0.35)` | Modal overlay background |
383
+ | `--srte-modal-bg` | `#ffffff` | Modal/dialog background |
384
+ | `--srte-modal-text` | `#000000` | Modal text color |
385
+ | `--srte-menu-bg` | `#ffffff` | Context menu background |
386
+ | `--srte-menu-text` | `#111111` | Context menu text |
387
+ | `--srte-menu-shadow` | `0 8px 24px rgba(0,0,0,0.18)` | Menu box-shadow |
388
+ | `--srte-accent` | `#1e90ff` | Accent/selection color |
389
+ | `--srte-accent-bg` | `rgba(30,144,255,0.15)` | Accent background (translucent) |
390
+ | `--srte-danger` | `#dc2626` | Destructive action color |
391
+ | `--srte-primary` | `#2563eb` | Primary action button color |
392
+ | `--srte-surface-subtle` | `#f3f4f6` | Subtle surface (dropzone, preset buttons) |
393
+ | `--srte-on-primary` | `#ffffff` | Text on primary/danger buttons |
394
+ | `--srte-cancel-bg` | `#f3f4f6` | Cancel button background |
395
+
396
+ ### Important Notes
397
+
398
+ - **User content colors are preserved** — colors set via the color picker (text/background) are inline styles on content elements and are not affected by theming.
399
+ - **Color picker swatches are not themed** — they display actual color values regardless of theme.
400
+ - **The theme only affects editor chrome** — toolbar, dialogs, menus, and container. User content remains unchanged.
401
+
327
402
  ## 🛠️ Development
328
403
 
329
404
  ### Prerequisites
@@ -619,13 +694,14 @@ See the list of [contributors](https://github.com/ayush1852017/smart-rte/contrib
619
694
 
620
695
  ## 🗺️ Roadmap
621
696
 
622
- ### Current Version (0.1.x)
697
+ ### Current Version (0.2.x)
623
698
 
624
699
  - ✅ Rich text editing
625
700
  - ✅ Table support
626
701
  - ✅ Formula support (LaTeX/KaTeX)
627
702
  - ✅ Media management
628
703
  - ✅ TypeScript support
704
+ - ✅ Dark mode & theming (CSS custom properties)
629
705
 
630
706
  ### Upcoming Features
631
707
 
@@ -1,4 +1,5 @@
1
1
  import { MediaManagerAdapter } from "./MediaManager";
2
+ import { SrteTheme } from '../theme';
2
3
  type ClassicEditorProps = {
3
4
  value?: string;
4
5
  onChange?: (html: string) => void;
@@ -25,6 +26,18 @@ type ClassicEditorProps = {
25
26
  * Example: "Arial, sans-serif"
26
27
  */
27
28
  defaultFont?: string;
29
+ /**
30
+ * Theme mode for the editor.
31
+ * - "light" (default): Uses the built-in light theme.
32
+ * - "dark": Uses the built-in dark theme.
33
+ */
34
+ theme?: SrteTheme;
35
+ /**
36
+ * Additional CSS class name(s) to apply to the editor's root element.
37
+ * Useful for custom theming by overriding CSS custom properties.
38
+ * Example: className="my-editor-theme"
39
+ */
40
+ className?: string;
28
41
  };
29
- export declare function ClassicEditor({ value, onChange, placeholder, minHeight, maxHeight, readOnly, table, media, formula, mediaManager, fonts, defaultFont, }: ClassicEditorProps): import("react/jsx-runtime").JSX.Element;
42
+ export declare function ClassicEditor({ value, onChange, placeholder, minHeight, maxHeight, readOnly, table, media, formula, mediaManager, fonts, defaultFont, theme, className, }: ClassicEditorProps): import("react/jsx-runtime").JSX.Element;
30
43
  export {};