@moontra/moonui-pro 2.20.1 → 2.20.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/dist/index.d.ts +691 -261
- package/dist/index.mjs +7418 -4934
- package/package.json +11 -5
- package/plugin/index.d.ts +86 -0
- package/plugin/index.js +308 -0
- package/scripts/postbuild.js +27 -0
- package/scripts/postinstall.js +176 -23
- package/src/__tests__/use-intersection-observer.test.tsx +0 -216
- package/src/__tests__/use-local-storage.test.tsx +0 -174
- package/src/__tests__/use-pro-access.test.tsx +0 -183
- package/src/components/advanced-chart/advanced-chart.test.tsx +0 -281
- package/src/components/advanced-chart/index.tsx +0 -1242
- package/src/components/advanced-forms/index.tsx +0 -426
- package/src/components/animated-button/index.tsx +0 -385
- package/src/components/calendar/event-dialog.tsx +0 -372
- package/src/components/calendar/index.tsx +0 -1073
- package/src/components/calendar-pro/index.tsx +0 -1697
- package/src/components/color-picker/index.tsx +0 -432
- package/src/components/credit-card-input/index.tsx +0 -406
- package/src/components/dashboard/dashboard-grid.tsx +0 -462
- package/src/components/dashboard/demo.tsx +0 -425
- package/src/components/dashboard/index.tsx +0 -1046
- package/src/components/dashboard/time-range-picker.tsx +0 -336
- package/src/components/dashboard/types.ts +0 -222
- package/src/components/dashboard/widgets/activity-feed.tsx +0 -344
- package/src/components/dashboard/widgets/chart-widget.tsx +0 -418
- package/src/components/dashboard/widgets/metric-card.tsx +0 -343
- package/src/components/data-table/data-table-bulk-actions.tsx +0 -204
- package/src/components/data-table/data-table-column-toggle.tsx +0 -169
- package/src/components/data-table/data-table-export.ts +0 -156
- package/src/components/data-table/data-table-filter-drawer.tsx +0 -448
- package/src/components/data-table/data-table.test.tsx +0 -187
- package/src/components/data-table/index.tsx +0 -845
- package/src/components/draggable-list/index.tsx +0 -100
- package/src/components/enhanced/badge.tsx +0 -191
- package/src/components/enhanced/button.tsx +0 -362
- package/src/components/enhanced/card.tsx +0 -266
- package/src/components/enhanced/dialog.tsx +0 -246
- package/src/components/enhanced/index.ts +0 -4
- package/src/components/error-boundary/index.tsx +0 -109
- package/src/components/file-upload/file-upload.test.tsx +0 -243
- package/src/components/file-upload/index.tsx +0 -1660
- package/src/components/floating-action-button/index.tsx +0 -206
- package/src/components/form-wizard/form-wizard-context.tsx +0 -307
- package/src/components/form-wizard/form-wizard-navigation.tsx +0 -118
- package/src/components/form-wizard/form-wizard-progress.tsx +0 -298
- package/src/components/form-wizard/form-wizard-step.tsx +0 -111
- package/src/components/form-wizard/index.tsx +0 -102
- package/src/components/form-wizard/types.ts +0 -76
- package/src/components/gesture-drawer/index.tsx +0 -551
- package/src/components/github-stars/github-api.ts +0 -426
- package/src/components/github-stars/hooks.ts +0 -516
- package/src/components/github-stars/index.tsx +0 -375
- package/src/components/github-stars/types.ts +0 -148
- package/src/components/github-stars/variants.tsx +0 -513
- package/src/components/health-check/index.tsx +0 -439
- package/src/components/hover-card-3d/index.tsx +0 -530
- package/src/components/index.ts +0 -128
- package/src/components/internal/index.ts +0 -78
- package/src/components/kanban/add-card-modal.tsx +0 -502
- package/src/components/kanban/card-detail-modal.tsx +0 -761
- package/src/components/kanban/index.ts +0 -13
- package/src/components/kanban/kanban.tsx +0 -1684
- package/src/components/kanban/types.ts +0 -168
- package/src/components/lazy-component/index.tsx +0 -823
- package/src/components/license-error/index.tsx +0 -29
- package/src/components/magnetic-button/index.tsx +0 -167
- package/src/components/memory-efficient-data/index.tsx +0 -1016
- package/src/components/moonui-quiz-form/index.tsx +0 -817
- package/src/components/optimized-image/index.tsx +0 -425
- package/src/components/performance-debugger/index.tsx +0 -589
- package/src/components/performance-monitor/index.tsx +0 -794
- package/src/components/phone-number-input/index.tsx +0 -338
- package/src/components/pinch-zoom/index.tsx +0 -566
- package/src/components/quiz-form/index.tsx +0 -479
- package/src/components/rich-text-editor/index-old-backup.tsx +0 -437
- package/src/components/rich-text-editor/index.tsx +0 -2324
- package/src/components/rich-text-editor/slash-commands-extension.ts +0 -220
- package/src/components/rich-text-editor/slash-commands.css +0 -35
- package/src/components/rich-text-editor/table-styles.css +0 -65
- package/src/components/sidebar/index.tsx +0 -865
- package/src/components/spotlight-card/index.tsx +0 -191
- package/src/components/swipeable-card/index.tsx +0 -100
- package/src/components/timeline/index.tsx +0 -1148
- package/src/components/ui/accordion.tsx +0 -73
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -141
- package/src/components/ui/aspect-ratio.tsx +0 -245
- package/src/components/ui/avatar.tsx +0 -153
- package/src/components/ui/badge.tsx +0 -228
- package/src/components/ui/breadcrumb.tsx +0 -214
- package/src/components/ui/button.tsx +0 -222
- package/src/components/ui/calendar.tsx +0 -387
- package/src/components/ui/card.tsx +0 -214
- package/src/components/ui/checkbox.tsx +0 -259
- package/src/components/ui/collapsible.tsx +0 -135
- package/src/components/ui/color-picker.tsx +0 -97
- package/src/components/ui/command.tsx +0 -225
- package/src/components/ui/dialog.tsx +0 -334
- package/src/components/ui/dropdown-menu.tsx +0 -218
- package/src/components/ui/gesture-drawer.tsx +0 -11
- package/src/components/ui/hover-card.tsx +0 -29
- package/src/components/ui/index.ts +0 -190
- package/src/components/ui/input.tsx +0 -222
- package/src/components/ui/label.tsx +0 -29
- package/src/components/ui/lightbox.tsx +0 -606
- package/src/components/ui/magnetic-button.tsx +0 -129
- package/src/components/ui/media-gallery.tsx +0 -612
- package/src/components/ui/pagination.tsx +0 -123
- package/src/components/ui/popover.tsx +0 -185
- package/src/components/ui/progress.tsx +0 -30
- package/src/components/ui/radio-group.tsx +0 -257
- package/src/components/ui/scroll-area.tsx +0 -47
- package/src/components/ui/select.tsx +0 -374
- package/src/components/ui/separator.tsx +0 -145
- package/src/components/ui/sheet.tsx +0 -139
- package/src/components/ui/skeleton.tsx +0 -20
- package/src/components/ui/slider.tsx +0 -354
- package/src/components/ui/spotlight-card.tsx +0 -119
- package/src/components/ui/switch.tsx +0 -86
- package/src/components/ui/table.tsx +0 -329
- package/src/components/ui/tabs.tsx +0 -198
- package/src/components/ui/textarea.tsx +0 -28
- package/src/components/ui/toast.tsx +0 -317
- package/src/components/ui/toggle.tsx +0 -119
- package/src/components/ui/tooltip.tsx +0 -151
- package/src/components/virtual-list/index.tsx +0 -668
- package/src/hooks/use-chart.ts +0 -205
- package/src/hooks/use-data-table.ts +0 -182
- package/src/hooks/use-docs-pro-access.ts +0 -13
- package/src/hooks/use-license-check.ts +0 -65
- package/src/hooks/use-subscription.ts +0 -19
- package/src/hooks/use-toast.ts +0 -15
- package/src/index.ts +0 -14
- package/src/lib/ai-providers.ts +0 -377
- package/src/lib/component-metadata.ts +0 -18
- package/src/lib/micro-interactions.ts +0 -255
- package/src/lib/paddle.ts +0 -17
- package/src/lib/utils.ts +0 -6
- package/src/patterns/login-form/index.tsx +0 -276
- package/src/patterns/login-form/types.ts +0 -67
- package/src/setupTests.ts +0 -41
- package/src/styles/advanced-chart.css +0 -239
- package/src/styles/calendar.css +0 -35
- package/src/styles/design-system.css +0 -363
- package/src/styles/index.css +0 -85
- package/src/styles/tailwind.css +0 -7
- package/src/styles/tokens.css +0 -455
- package/src/types/moonui.d.ts +0 -22
- package/src/types/next-auth.d.ts +0 -21
- package/src/use-intersection-observer.tsx +0 -154
- package/src/use-local-storage.tsx +0 -71
- package/src/use-paddle.ts +0 -138
- package/src/use-performance-optimizer.ts +0 -389
- package/src/use-pro-access.ts +0 -141
- package/src/use-scroll-animation.ts +0 -219
- package/src/use-subscription.ts +0 -37
- package/src/use-toast.ts +0 -32
- package/src/utils/chart-helpers.ts +0 -357
- package/src/utils/cn.ts +0 -6
- package/src/utils/data-processing.ts +0 -151
- package/src/utils/license-validator.tsx +0 -183
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
// BACKUP - OLD RICH TEXT EDITOR IMPLEMENTATION
|
|
2
|
-
// This was the previous implementation before the advanced Tiptap-based version
|
|
3
|
-
// Kept for reference and potential markdown editor features
|
|
4
|
-
|
|
5
|
-
"use client"
|
|
6
|
-
|
|
7
|
-
import React from 'react'
|
|
8
|
-
import { useSubscription } from '../../hooks/use-subscription'
|
|
9
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './card'
|
|
10
|
-
import { Button } from './button'
|
|
11
|
-
import {
|
|
12
|
-
Bold,
|
|
13
|
-
Italic,
|
|
14
|
-
Underline,
|
|
15
|
-
AlignLeft,
|
|
16
|
-
AlignCenter,
|
|
17
|
-
AlignRight,
|
|
18
|
-
List,
|
|
19
|
-
ListOrdered,
|
|
20
|
-
Quote,
|
|
21
|
-
Link,
|
|
22
|
-
Image,
|
|
23
|
-
Code,
|
|
24
|
-
Undo,
|
|
25
|
-
Redo,
|
|
26
|
-
Type,
|
|
27
|
-
Lock,
|
|
28
|
-
Sparkles
|
|
29
|
-
} from 'lucide-react'
|
|
30
|
-
import { cn } from '../../lib/utils'
|
|
31
|
-
|
|
32
|
-
interface OldRichTextEditorProps {
|
|
33
|
-
value?: string
|
|
34
|
-
onChange?: (value: string) => void
|
|
35
|
-
placeholder?: string
|
|
36
|
-
className?: string
|
|
37
|
-
disabled?: boolean
|
|
38
|
-
minHeight?: number
|
|
39
|
-
maxHeight?: number
|
|
40
|
-
showToolbar?: boolean
|
|
41
|
-
readonly?: boolean
|
|
42
|
-
autoFocus?: boolean
|
|
43
|
-
features?: {
|
|
44
|
-
bold?: boolean
|
|
45
|
-
italic?: boolean
|
|
46
|
-
underline?: boolean
|
|
47
|
-
heading?: boolean
|
|
48
|
-
lists?: boolean
|
|
49
|
-
link?: boolean
|
|
50
|
-
image?: boolean
|
|
51
|
-
quote?: boolean
|
|
52
|
-
code?: boolean
|
|
53
|
-
undo?: boolean
|
|
54
|
-
redo?: boolean
|
|
55
|
-
ai?: boolean
|
|
56
|
-
}
|
|
57
|
-
height?: number
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function OldRichTextEditor({
|
|
61
|
-
value = '',
|
|
62
|
-
onChange,
|
|
63
|
-
placeholder = 'Start typing...',
|
|
64
|
-
className,
|
|
65
|
-
disabled = false,
|
|
66
|
-
minHeight = 200,
|
|
67
|
-
maxHeight = 600,
|
|
68
|
-
showToolbar = true,
|
|
69
|
-
readonly = false,
|
|
70
|
-
autoFocus = false,
|
|
71
|
-
features = {},
|
|
72
|
-
height
|
|
73
|
-
}: OldRichTextEditorProps) {
|
|
74
|
-
const { hasProAccess, isLoading } = useSubscription()
|
|
75
|
-
|
|
76
|
-
// If no pro access, show upgrade prompt
|
|
77
|
-
if (!isLoading && !hasProAccess) {
|
|
78
|
-
return (
|
|
79
|
-
<Card className={cn("w-full", className)}>
|
|
80
|
-
<CardContent className="py-12 text-center">
|
|
81
|
-
<div className="max-w-md mx-auto space-y-4">
|
|
82
|
-
<div className="rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto">
|
|
83
|
-
<Lock className="h-6 w-6 text-purple-600 dark:text-purple-400" />
|
|
84
|
-
</div>
|
|
85
|
-
<div>
|
|
86
|
-
<h3 className="font-semibold text-lg mb-2">Pro Feature</h3>
|
|
87
|
-
<p className="text-muted-foreground text-sm mb-4">
|
|
88
|
-
Rich Text Editor is available exclusively to MoonUI Pro subscribers.
|
|
89
|
-
</p>
|
|
90
|
-
<div className="flex gap-3 justify-center">
|
|
91
|
-
<a href="/pricing">
|
|
92
|
-
<Button size="sm">
|
|
93
|
-
<Sparkles className="mr-2 h-4 w-4" />
|
|
94
|
-
Upgrade to Pro
|
|
95
|
-
</Button>
|
|
96
|
-
</a>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</CardContent>
|
|
101
|
-
</Card>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
const [content, setContent] = React.useState(value)
|
|
105
|
-
const [isFormatting, setIsFormatting] = React.useState({
|
|
106
|
-
bold: false,
|
|
107
|
-
italic: false,
|
|
108
|
-
underline: false,
|
|
109
|
-
align: 'left' as 'left' | 'center' | 'right'
|
|
110
|
-
})
|
|
111
|
-
const editorRef = React.useRef<HTMLDivElement>(null)
|
|
112
|
-
|
|
113
|
-
React.useEffect(() => {
|
|
114
|
-
setContent(value)
|
|
115
|
-
}, [value])
|
|
116
|
-
|
|
117
|
-
React.useEffect(() => {
|
|
118
|
-
if (autoFocus && editorRef.current) {
|
|
119
|
-
editorRef.current.focus()
|
|
120
|
-
}
|
|
121
|
-
}, [autoFocus])
|
|
122
|
-
|
|
123
|
-
const handleContentChange = () => {
|
|
124
|
-
if (editorRef.current) {
|
|
125
|
-
const newContent = editorRef.current.innerHTML
|
|
126
|
-
setContent(newContent)
|
|
127
|
-
onChange?.(newContent)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const execCommand = (command: string, value: string = '') => {
|
|
132
|
-
document.execCommand(command, false, value)
|
|
133
|
-
editorRef.current?.focus()
|
|
134
|
-
handleContentChange()
|
|
135
|
-
updateFormattingState()
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const updateFormattingState = () => {
|
|
139
|
-
setIsFormatting({
|
|
140
|
-
bold: document.queryCommandState('bold'),
|
|
141
|
-
italic: document.queryCommandState('italic'),
|
|
142
|
-
underline: document.queryCommandState('underline'),
|
|
143
|
-
align: document.queryCommandValue('justifyLeft') ? 'left' :
|
|
144
|
-
document.queryCommandValue('justifyCenter') ? 'center' :
|
|
145
|
-
document.queryCommandValue('justifyRight') ? 'right' : 'left'
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const handleSelectionChange = () => {
|
|
150
|
-
updateFormattingState()
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
React.useEffect(() => {
|
|
154
|
-
document.addEventListener('selectionchange', handleSelectionChange)
|
|
155
|
-
return () => {
|
|
156
|
-
document.removeEventListener('selectionchange', handleSelectionChange)
|
|
157
|
-
}
|
|
158
|
-
}, [])
|
|
159
|
-
|
|
160
|
-
const insertLink = () => {
|
|
161
|
-
const url = prompt('Enter URL:')
|
|
162
|
-
if (url) {
|
|
163
|
-
execCommand('createLink', url)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const insertImage = () => {
|
|
168
|
-
const url = prompt('Enter image URL:')
|
|
169
|
-
if (url) {
|
|
170
|
-
execCommand('insertImage', url)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const formatText = (command: string) => {
|
|
175
|
-
execCommand(command)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const alignText = (alignment: 'left' | 'center' | 'right') => {
|
|
179
|
-
const commands = {
|
|
180
|
-
left: 'justifyLeft',
|
|
181
|
-
center: 'justifyCenter',
|
|
182
|
-
right: 'justifyRight'
|
|
183
|
-
}
|
|
184
|
-
execCommand(commands[alignment])
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
188
|
-
if (e.ctrlKey || e.metaKey) {
|
|
189
|
-
switch (e.key) {
|
|
190
|
-
case 'b':
|
|
191
|
-
e.preventDefault()
|
|
192
|
-
formatText('bold')
|
|
193
|
-
break
|
|
194
|
-
case 'i':
|
|
195
|
-
e.preventDefault()
|
|
196
|
-
formatText('italic')
|
|
197
|
-
break
|
|
198
|
-
case 'u':
|
|
199
|
-
e.preventDefault()
|
|
200
|
-
formatText('underline')
|
|
201
|
-
break
|
|
202
|
-
case 'z':
|
|
203
|
-
e.preventDefault()
|
|
204
|
-
if (e.shiftKey) {
|
|
205
|
-
execCommand('redo')
|
|
206
|
-
} else {
|
|
207
|
-
execCommand('undo')
|
|
208
|
-
}
|
|
209
|
-
break
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<Card className={cn("w-full", className)}>
|
|
216
|
-
<CardHeader className="pb-3">
|
|
217
|
-
<CardTitle className="flex items-center gap-2">
|
|
218
|
-
<Type className="h-5 w-5" />
|
|
219
|
-
Rich Text Editor (Old Version)
|
|
220
|
-
</CardTitle>
|
|
221
|
-
<CardDescription>
|
|
222
|
-
Create and edit rich text content with formatting options
|
|
223
|
-
</CardDescription>
|
|
224
|
-
</CardHeader>
|
|
225
|
-
<CardContent className="space-y-4">
|
|
226
|
-
{/* Toolbar */}
|
|
227
|
-
{showToolbar && (
|
|
228
|
-
<div className="flex flex-wrap items-center gap-1 p-2 border rounded-lg bg-muted/50">
|
|
229
|
-
{/* Text Formatting */}
|
|
230
|
-
<div className="flex items-center gap-1">
|
|
231
|
-
{features.bold !== false && (
|
|
232
|
-
<Button
|
|
233
|
-
variant={isFormatting.bold ? "default" : "ghost"}
|
|
234
|
-
size="sm"
|
|
235
|
-
onClick={() => formatText('bold')}
|
|
236
|
-
disabled={disabled || readonly}
|
|
237
|
-
>
|
|
238
|
-
<Bold className="h-4 w-4" />
|
|
239
|
-
</Button>
|
|
240
|
-
)}
|
|
241
|
-
{features.italic !== false && (
|
|
242
|
-
<Button
|
|
243
|
-
variant={isFormatting.italic ? "default" : "ghost"}
|
|
244
|
-
size="sm"
|
|
245
|
-
onClick={() => formatText('italic')}
|
|
246
|
-
disabled={disabled || readonly}
|
|
247
|
-
>
|
|
248
|
-
<Italic className="h-4 w-4" />
|
|
249
|
-
</Button>
|
|
250
|
-
)}
|
|
251
|
-
{features.underline !== false && (
|
|
252
|
-
<Button
|
|
253
|
-
variant={isFormatting.underline ? "default" : "ghost"}
|
|
254
|
-
size="sm"
|
|
255
|
-
onClick={() => formatText('underline')}
|
|
256
|
-
disabled={disabled || readonly}
|
|
257
|
-
>
|
|
258
|
-
<Underline className="h-4 w-4" />
|
|
259
|
-
</Button>
|
|
260
|
-
)}
|
|
261
|
-
</div>
|
|
262
|
-
|
|
263
|
-
<div className="h-4 w-px bg-border mx-1" />
|
|
264
|
-
|
|
265
|
-
{/* Alignment */}
|
|
266
|
-
<div className="flex items-center gap-1">
|
|
267
|
-
<Button
|
|
268
|
-
variant={isFormatting.align === 'left' ? "default" : "ghost"}
|
|
269
|
-
size="sm"
|
|
270
|
-
onClick={() => alignText('left')}
|
|
271
|
-
disabled={disabled || readonly}
|
|
272
|
-
>
|
|
273
|
-
<AlignLeft className="h-4 w-4" />
|
|
274
|
-
</Button>
|
|
275
|
-
<Button
|
|
276
|
-
variant={isFormatting.align === 'center' ? "default" : "ghost"}
|
|
277
|
-
size="sm"
|
|
278
|
-
onClick={() => alignText('center')}
|
|
279
|
-
disabled={disabled || readonly}
|
|
280
|
-
>
|
|
281
|
-
<AlignCenter className="h-4 w-4" />
|
|
282
|
-
</Button>
|
|
283
|
-
<Button
|
|
284
|
-
variant={isFormatting.align === 'right' ? "default" : "ghost"}
|
|
285
|
-
size="sm"
|
|
286
|
-
onClick={() => alignText('right')}
|
|
287
|
-
disabled={disabled || readonly}
|
|
288
|
-
>
|
|
289
|
-
<AlignRight className="h-4 w-4" />
|
|
290
|
-
</Button>
|
|
291
|
-
</div>
|
|
292
|
-
|
|
293
|
-
<div className="h-4 w-px bg-border mx-1" />
|
|
294
|
-
|
|
295
|
-
{/* Lists */}
|
|
296
|
-
{features.lists !== false && (
|
|
297
|
-
<div className="flex items-center gap-1">
|
|
298
|
-
<Button
|
|
299
|
-
variant="ghost"
|
|
300
|
-
size="sm"
|
|
301
|
-
onClick={() => execCommand('insertUnorderedList')}
|
|
302
|
-
disabled={disabled || readonly}
|
|
303
|
-
>
|
|
304
|
-
<List className="h-4 w-4" />
|
|
305
|
-
</Button>
|
|
306
|
-
<Button
|
|
307
|
-
variant="ghost"
|
|
308
|
-
size="sm"
|
|
309
|
-
onClick={() => execCommand('insertOrderedList')}
|
|
310
|
-
disabled={disabled || readonly}
|
|
311
|
-
>
|
|
312
|
-
<ListOrdered className="h-4 w-4" />
|
|
313
|
-
</Button>
|
|
314
|
-
</div>
|
|
315
|
-
)}
|
|
316
|
-
|
|
317
|
-
<div className="h-4 w-px bg-border mx-1" />
|
|
318
|
-
|
|
319
|
-
{/* Quote and Code */}
|
|
320
|
-
<div className="flex items-center gap-1">
|
|
321
|
-
{features.quote !== false && (
|
|
322
|
-
<Button
|
|
323
|
-
variant="ghost"
|
|
324
|
-
size="sm"
|
|
325
|
-
onClick={() => execCommand('formatBlock', 'blockquote')}
|
|
326
|
-
disabled={disabled || readonly}
|
|
327
|
-
>
|
|
328
|
-
<Quote className="h-4 w-4" />
|
|
329
|
-
</Button>
|
|
330
|
-
)}
|
|
331
|
-
{features.code !== false && (
|
|
332
|
-
<Button
|
|
333
|
-
variant="ghost"
|
|
334
|
-
size="sm"
|
|
335
|
-
onClick={() => execCommand('formatBlock', 'pre')}
|
|
336
|
-
disabled={disabled || readonly}
|
|
337
|
-
>
|
|
338
|
-
<Code className="h-4 w-4" />
|
|
339
|
-
</Button>
|
|
340
|
-
)}
|
|
341
|
-
</div>
|
|
342
|
-
|
|
343
|
-
<div className="h-4 w-px bg-border mx-1" />
|
|
344
|
-
|
|
345
|
-
{/* Insert */}
|
|
346
|
-
<div className="flex items-center gap-1">
|
|
347
|
-
{features.link !== false && (
|
|
348
|
-
<Button
|
|
349
|
-
variant="ghost"
|
|
350
|
-
size="sm"
|
|
351
|
-
onClick={insertLink}
|
|
352
|
-
disabled={disabled || readonly}
|
|
353
|
-
>
|
|
354
|
-
<Link className="h-4 w-4" />
|
|
355
|
-
</Button>
|
|
356
|
-
)}
|
|
357
|
-
{features.image !== false && (
|
|
358
|
-
<Button
|
|
359
|
-
variant="ghost"
|
|
360
|
-
size="sm"
|
|
361
|
-
onClick={insertImage}
|
|
362
|
-
disabled={disabled || readonly}
|
|
363
|
-
>
|
|
364
|
-
<Image className="h-4 w-4" />
|
|
365
|
-
</Button>
|
|
366
|
-
)}
|
|
367
|
-
</div>
|
|
368
|
-
|
|
369
|
-
<div className="h-4 w-px bg-border mx-1" />
|
|
370
|
-
|
|
371
|
-
{/* Undo/Redo */}
|
|
372
|
-
{(features.undo !== false || features.redo !== false) && (
|
|
373
|
-
<div className="flex items-center gap-1">
|
|
374
|
-
{features.undo !== false && (
|
|
375
|
-
<Button
|
|
376
|
-
variant="ghost"
|
|
377
|
-
size="sm"
|
|
378
|
-
onClick={() => execCommand('undo')}
|
|
379
|
-
disabled={disabled || readonly}
|
|
380
|
-
>
|
|
381
|
-
<Undo className="h-4 w-4" />
|
|
382
|
-
</Button>
|
|
383
|
-
)}
|
|
384
|
-
{features.redo !== false && (
|
|
385
|
-
<Button
|
|
386
|
-
variant="ghost"
|
|
387
|
-
size="sm"
|
|
388
|
-
onClick={() => execCommand('redo')}
|
|
389
|
-
disabled={disabled || readonly}
|
|
390
|
-
>
|
|
391
|
-
<Redo className="h-4 w-4" />
|
|
392
|
-
</Button>
|
|
393
|
-
)}
|
|
394
|
-
</div>
|
|
395
|
-
)}
|
|
396
|
-
</div>
|
|
397
|
-
)}
|
|
398
|
-
|
|
399
|
-
{/* Editor */}
|
|
400
|
-
<div className="border rounded-lg">
|
|
401
|
-
<div
|
|
402
|
-
ref={editorRef}
|
|
403
|
-
contentEditable={!disabled && !readonly}
|
|
404
|
-
onInput={handleContentChange}
|
|
405
|
-
onKeyDown={handleKeyDown}
|
|
406
|
-
className={cn(
|
|
407
|
-
"w-full p-4 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-lg",
|
|
408
|
-
"prose prose-sm max-w-none",
|
|
409
|
-
disabled && "cursor-not-allowed opacity-50",
|
|
410
|
-
readonly && "cursor-default"
|
|
411
|
-
)}
|
|
412
|
-
style={{
|
|
413
|
-
minHeight: height ? `${height}px` : `${minHeight}px`,
|
|
414
|
-
maxHeight: height ? `${height}px` : `${maxHeight}px`,
|
|
415
|
-
overflowY: 'auto'
|
|
416
|
-
}}
|
|
417
|
-
dangerouslySetInnerHTML={{ __html: content }}
|
|
418
|
-
data-placeholder={placeholder}
|
|
419
|
-
suppressContentEditableWarning={true}
|
|
420
|
-
/>
|
|
421
|
-
</div>
|
|
422
|
-
|
|
423
|
-
{/* Status */}
|
|
424
|
-
<div className="flex items-center justify-between text-xs text-muted-foreground">
|
|
425
|
-
<span>
|
|
426
|
-
{content.replace(/<[^>]*>/g, '').length} characters
|
|
427
|
-
</span>
|
|
428
|
-
<span>
|
|
429
|
-
Press Ctrl+B for bold, Ctrl+I for italic, Ctrl+U for underline
|
|
430
|
-
</span>
|
|
431
|
-
</div>
|
|
432
|
-
</CardContent>
|
|
433
|
-
</Card>
|
|
434
|
-
)
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export default OldRichTextEditor
|