markdown-wysiwyg-editor 0.3.0 → 0.3.3
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 +60 -39
- package/dist/bundle.css +2339 -0
- package/dist/components/EditorChrome.d.ts +1 -0
- package/dist/components/EditorChrome.d.ts.map +1 -1
- package/dist/components/FloatingToolbar.d.ts +2 -0
- package/dist/components/FloatingToolbar.d.ts.map +1 -1
- package/dist/components/ImagePicker.d.ts +1 -0
- package/dist/components/ImagePicker.d.ts.map +1 -1
- package/dist/components/MarkdownEditor.d.ts +2 -2
- package/dist/components/MarkdownEditor.d.ts.map +1 -1
- package/dist/components/MarkdownToolbar.d.ts +1 -0
- package/dist/components/MarkdownToolbar.d.ts.map +1 -1
- package/dist/components/toolbar/ToolbarButton.d.ts +1 -1
- package/dist/components/toolbar/ToolbarButton.d.ts.map +1 -1
- package/dist/hooks/useMarkdownEditor.d.ts +5 -1
- package/dist/hooks/useMarkdownEditor.d.ts.map +1 -1
- package/dist/hooks/useMarkdownInsertion.d.ts +1 -0
- package/dist/hooks/useMarkdownInsertion.d.ts.map +1 -1
- package/dist/index.css +82 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5640 -5449
- package/dist/index.js.map +1 -1
- package/dist/theme.css +36 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -25,24 +25,36 @@ Lightweight Markdown WYSIWYG editor for React, powered by TipTap.
|
|
|
25
25
|
|
|
26
26
|
## Installation
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
> [!WARNING]
|
|
29
|
+
> This package requires **Tailwind CSS v4** or later.
|
|
30
|
+
> It uses v4's CSS-first configuration. If you are using Tailwind v3, you must upgrade.
|
|
31
|
+
|
|
32
|
+
This editor is a React component targeting **React 19+ / ReactDOM 19+**.
|
|
29
33
|
|
|
30
34
|
This package is **Tailwind CSS v4 + shadcn/ui token compatible**. It uses Tailwind utility classes (e.g. `bg-background`, `text-foreground`, `bg-popover`) that are compiled by your host app's Tailwind.
|
|
31
35
|
|
|
32
36
|
```bash
|
|
33
|
-
pnpm add markdown-wysiwyg-editor
|
|
37
|
+
pnpm add markdown-wysiwyg-editor tailwindcss@^4.0.0
|
|
34
38
|
# or
|
|
35
|
-
npm install markdown-wysiwyg-editor
|
|
39
|
+
npm install markdown-wysiwyg-editor tailwindcss@^4.0.0
|
|
36
40
|
# or
|
|
37
|
-
yarn add markdown-wysiwyg-editor
|
|
41
|
+
yarn add markdown-wysiwyg-editor tailwindcss@^4.0.0
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
## Quick Start
|
|
41
45
|
|
|
42
46
|
**⚠️ IMPORTANT**
|
|
43
47
|
|
|
44
|
-
- **
|
|
45
|
-
- **
|
|
48
|
+
- **Tailwind CSS v4** is required.
|
|
49
|
+
- **React 19** or later is required.
|
|
50
|
+
|
|
51
|
+
1. **Import the CSS bundle** in your app's entry point (e.g., `main.tsx`, `App.tsx`, or `index.css`):
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
@import "markdown-wysiwyg-editor/dist/bundle.css";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2. **Use the component**:
|
|
46
58
|
|
|
47
59
|
```tsx
|
|
48
60
|
import { useState } from 'react';
|
|
@@ -55,51 +67,58 @@ function App() {
|
|
|
55
67
|
}
|
|
56
68
|
```
|
|
57
69
|
|
|
58
|
-
##
|
|
70
|
+
## CSS Integration Guide
|
|
71
|
+
|
|
72
|
+
Since version 0.3.0, the CSS integration strategy has changed to support Tailwind CSS v4.
|
|
73
|
+
|
|
74
|
+
### ✅ Recommended: Zero-Config (Pre-built Bundle)
|
|
59
75
|
|
|
60
|
-
|
|
76
|
+
Builds are simplified by using the pre-compiled bundle. This file includes:
|
|
77
|
+
- All required Tailwind utilities
|
|
78
|
+
- The default shadcn/ui-compatible theme
|
|
79
|
+
- Core editor styles
|
|
80
|
+
- Dark mode support
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
Just import it once:
|
|
83
|
+
|
|
84
|
+
```css
|
|
85
|
+
@import "markdown-wysiwyg-editor/dist/bundle.css";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 🛠️ Advanced: Custom Tailwind Integration
|
|
89
|
+
|
|
90
|
+
Only use this method if you want to:
|
|
91
|
+
- Share your application's `theme` configuration with the editor.
|
|
92
|
+
- Minimize bundle size by compiling only utilized classes (though the bundle is already optimized).
|
|
93
|
+
|
|
94
|
+
**Requirements:**
|
|
95
|
+
- Tailwind CSS v4 installed in your project.
|
|
96
|
+
- `@tailwindcss/vite` or `@tailwindcss/postcss` configured.
|
|
97
|
+
|
|
98
|
+
In your CSS entry point:
|
|
63
99
|
|
|
64
100
|
```css
|
|
65
101
|
@import "tailwindcss";
|
|
66
102
|
|
|
67
|
-
/* Scan package source for Tailwind classes */
|
|
103
|
+
/* 1. Scan package source for Tailwind classes */
|
|
68
104
|
@source "./node_modules/markdown-wysiwyg-editor/dist/*.js";
|
|
69
105
|
|
|
70
|
-
/* Import package theme (
|
|
106
|
+
/* 2. Import package theme (Optional: If you have your own theme, skip this) */
|
|
71
107
|
@import "markdown-wysiwyg-editor/theme.css";
|
|
72
108
|
|
|
73
|
-
/* Import editor
|
|
109
|
+
/* 3. Import core editor styles */
|
|
74
110
|
@import "markdown-wysiwyg-editor/style.css";
|
|
75
111
|
|
|
76
|
-
/*
|
|
112
|
+
/* 4. Ensure your theme defines the required shadcn variables (see below) */
|
|
77
113
|
@theme {
|
|
78
114
|
--color-background: hsl(var(--background));
|
|
79
115
|
--color-foreground: hsl(var(--foreground));
|
|
80
|
-
|
|
81
|
-
--color-card-foreground: hsl(var(--card-foreground));
|
|
82
|
-
--color-popover: hsl(var(--popover));
|
|
83
|
-
--color-popover-foreground: hsl(var(--popover-foreground));
|
|
84
|
-
--color-primary: hsl(var(--primary));
|
|
85
|
-
--color-primary-foreground: hsl(var(--primary-foreground));
|
|
86
|
-
--color-secondary: hsl(var(--secondary));
|
|
87
|
-
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
|
88
|
-
--color-muted: hsl(var(--muted));
|
|
89
|
-
--color-muted-foreground: hsl(var(--muted-foreground));
|
|
90
|
-
--color-accent: hsl(var(--accent));
|
|
91
|
-
--color-accent-foreground: hsl(var(--accent-foreground));
|
|
92
|
-
--color-destructive: hsl(var(--destructive));
|
|
93
|
-
--color-destructive-foreground: hsl(var(--destructive-foreground));
|
|
94
|
-
--color-border: hsl(var(--border));
|
|
95
|
-
--color-input: hsl(var(--input));
|
|
96
|
-
--color-ring: hsl(var(--ring));
|
|
97
|
-
|
|
116
|
+
/* ... map other variables as needed ... */
|
|
98
117
|
--variant-dark: .dark &;
|
|
99
118
|
}
|
|
100
119
|
```
|
|
101
120
|
|
|
102
|
-
###
|
|
121
|
+
### Theming Options
|
|
103
122
|
|
|
104
123
|
#### Option A: Use Package Default Theme
|
|
105
124
|
|
|
@@ -161,7 +180,7 @@ The editor expects these shadcn-style CSS variables (HSL triplets without `hsl()
|
|
|
161
180
|
| `--ring` | `222.2 84% 4.9%` | Focus ring |
|
|
162
181
|
| `--radius` | `0.5rem` | Border radius |
|
|
163
182
|
|
|
164
|
-
###
|
|
183
|
+
### Dark Mode
|
|
165
184
|
|
|
166
185
|
Dark mode works automatically when you add the `.dark` class to `<html>` or `<body>`:
|
|
167
186
|
|
|
@@ -171,9 +190,8 @@ document.documentElement.classList.toggle('dark');
|
|
|
171
190
|
```
|
|
172
191
|
|
|
173
192
|
If you imported `theme.css`, dark mode colors are already defined. Otherwise, define them under `.dark` selector in your CSS.
|
|
174
|
-
```
|
|
175
193
|
|
|
176
|
-
###
|
|
194
|
+
### Height and Scroll Configuration
|
|
177
195
|
|
|
178
196
|
The editor needs proper height configuration to enable scrolling. Choose one approach:
|
|
179
197
|
|
|
@@ -213,7 +231,7 @@ The editor needs proper height configuration to enable scrolling. Choose one app
|
|
|
213
231
|
/>
|
|
214
232
|
```
|
|
215
233
|
|
|
216
|
-
###
|
|
234
|
+
### Common Issues and Solutions
|
|
217
235
|
|
|
218
236
|
#### Issue: Lists not displaying correctly
|
|
219
237
|
|
|
@@ -461,13 +479,16 @@ import TextAlign from '@tiptap/extension-text-align';
|
|
|
461
479
|
|
|
462
480
|
### Styles not loading
|
|
463
481
|
|
|
464
|
-
```
|
|
465
|
-
|
|
482
|
+
```css
|
|
483
|
+
/* Recommended */
|
|
484
|
+
@import "markdown-wysiwyg-editor/dist/bundle.css";
|
|
466
485
|
```
|
|
467
486
|
|
|
468
487
|
Ensure the CSS is imported in your app entry.
|
|
469
488
|
|
|
470
|
-
If
|
|
489
|
+
If using Custom Integration (Advanced) and the toolbar is unstyled:
|
|
490
|
+
- Verify `@source` is pointing correctly to `node_modules/markdown-wysiwyg-editor/dist/*.js`.
|
|
491
|
+
- Check that your `theme.css` imports or `@theme` configuration are correct.
|
|
471
492
|
|
|
472
493
|
### "ReferenceError: global is not defined"
|
|
473
494
|
|