smartrte-react 0.1.18 β 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.
- package/README.md +83 -15
- package/dist/components/ClassicEditor.d.ts +14 -1
- package/dist/components/ClassicEditor.js +165 -158
- package/dist/components/MediaManager.js +21 -16
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/standalone/classic-editor-embed.js +1 -1
- package/dist/theme.d.ts +3 -0
- package/dist/theme.js +61 -0
- package/package.json +1 -2
- package/dist/QuillEditor.d.ts +0 -8
- package/dist/QuillEditor.js +0 -34
- package/dist/app.d.ts +0 -6
- package/dist/app.js +0 -6
- package/dist/blots/CommentBlot.d.ts +0 -8
- package/dist/blots/CommentBlot.js +0 -17
- package/dist/blots/FormulaBlot.d.ts +0 -12
- package/dist/blots/FormulaBlot.js +0 -36
- package/dist/blots/MediaBlot.d.ts +0 -11
- package/dist/blots/MediaBlot.js +0 -37
- package/dist/blots/TableBlot.d.ts +0 -10
- package/dist/blots/TableBlot.js +0 -54
- package/dist/blots/index.d.ts +0 -5
- package/dist/blots/index.js +0 -12
- package/dist/components/DiagramEditor.d.ts +0 -5
- package/dist/components/DiagramEditor.js +0 -73
- package/dist/components/FormulaEditor.d.ts +0 -6
- package/dist/components/FormulaEditor.js +0 -86
- package/dist/components/InfoBox.d.ts +0 -7
- package/dist/components/InfoBox.js +0 -18
- package/dist/components/MCQBlock.d.ts +0 -13
- package/dist/components/MCQBlock.js +0 -29
- package/dist/components/SmartEditor.d.ts +0 -0
- package/dist/components/SmartEditor.js +0 -1
- package/dist/components/SmartTable.d.ts +0 -22
- package/dist/components/SmartTable.js +0 -629
- package/dist/components/TableContextMenu.d.ts +0 -11
- package/dist/components/TableContextMenu.js +0 -15
- package/dist/components/TableInsertDialog.d.ts +0 -7
- package/dist/components/TableInsertDialog.js +0 -42
- package/dist/hooks/useEditorSync.d.ts +0 -5
- package/dist/hooks/useEditorSync.js +0 -53
- package/dist/smart-editor.d.ts +0 -0
- package/dist/smart-editor.js +0 -1
- package/dist/standalone/editor.js +0 -241
package/README.md
CHANGED
|
@@ -45,8 +45,7 @@ pnpm add smartrte-react
|
|
|
45
45
|
Try the editor instantly in your browser:
|
|
46
46
|
|
|
47
47
|
- **[Live Demo](https://playground-k9l44ah7t-ayush1852017s-projects.vercel.app/)** (Deployed Version)
|
|
48
|
-
- **[CodeSandbox Playground](https://codesandbox.io/s/
|
|
49
|
-
- **[RunKit Example](https://npm.runkit.com/smartrte-react)** (Node.js import check)
|
|
48
|
+
- **[CodeSandbox Playground](https://codesandbox.io/s/github/ayush1852017/smart-rte/tree/master/packages/react/playground)** (Interactive)
|
|
50
49
|
|
|
51
50
|
### Basic Usage
|
|
52
51
|
|
|
@@ -89,6 +88,10 @@ export default App;
|
|
|
89
88
|
| `media` | `boolean` | `true` | Enable/disable media/image functionality |
|
|
90
89
|
| `formula` | `boolean` | `true` | Enable/disable formula/LaTeX functionality |
|
|
91
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 |
|
|
92
95
|
|
|
93
96
|
### Advanced Examples
|
|
94
97
|
|
|
@@ -315,23 +318,87 @@ const myMediaManager: MediaManagerAdapter = {
|
|
|
315
318
|
};
|
|
316
319
|
```
|
|
317
320
|
|
|
318
|
-
## π¨
|
|
321
|
+
## π¨ Theming & Dark Mode
|
|
319
322
|
|
|
320
|
-
The editor
|
|
323
|
+
The editor uses CSS custom properties (CSS variables) for all colors, making it fully customizable. No hardcoded colors β everything can be themed.
|
|
324
|
+
|
|
325
|
+
### Quick Start: Dark Mode
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
<ClassicEditor theme="dark" onChange={handleChange} />
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Custom Themes via CSS
|
|
332
|
+
|
|
333
|
+
Apply a custom class and override any CSS variables:
|
|
321
334
|
|
|
322
335
|
```tsx
|
|
323
|
-
<
|
|
324
|
-
border: '1px solid #ddd',
|
|
325
|
-
borderRadius: '8px',
|
|
326
|
-
overflow: 'hidden',
|
|
327
|
-
}}>
|
|
328
|
-
<ClassicEditor
|
|
329
|
-
value={content}
|
|
330
|
-
onChange={setContent}
|
|
331
|
-
/>
|
|
332
|
-
</div>
|
|
336
|
+
<ClassicEditor className="my-theme" onChange={handleChange} />
|
|
333
337
|
```
|
|
334
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
|
+
}
|
|
346
|
+
```
|
|
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
|
+
|
|
335
402
|
## π οΈ Development
|
|
336
403
|
|
|
337
404
|
### Prerequisites
|
|
@@ -627,13 +694,14 @@ See the list of [contributors](https://github.com/ayush1852017/smart-rte/contrib
|
|
|
627
694
|
|
|
628
695
|
## πΊοΈ Roadmap
|
|
629
696
|
|
|
630
|
-
### Current Version (0.
|
|
697
|
+
### Current Version (0.2.x)
|
|
631
698
|
|
|
632
699
|
- β
Rich text editing
|
|
633
700
|
- β
Table support
|
|
634
701
|
- β
Formula support (LaTeX/KaTeX)
|
|
635
702
|
- β
Media management
|
|
636
703
|
- β
TypeScript support
|
|
704
|
+
- β
Dark mode & theming (CSS custom properties)
|
|
637
705
|
|
|
638
706
|
### Upcoming Features
|
|
639
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 {};
|