@fnd-platform/cms 1.0.0-alpha.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/LICENSE +21 -0
- package/README.md +283 -0
- package/lib/cms-project.d.ts +127 -0
- package/lib/cms-project.d.ts.map +1 -0
- package/lib/cms-project.js +343 -0
- package/lib/cms-project.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/options.d.ts +59 -0
- package/lib/options.d.ts.map +1 -0
- package/lib/options.js +3 -0
- package/lib/options.js.map +1 -0
- package/lib/templates/admin-breadcrumbs.d.ts +13 -0
- package/lib/templates/admin-breadcrumbs.d.ts.map +1 -0
- package/lib/templates/admin-breadcrumbs.js +80 -0
- package/lib/templates/admin-breadcrumbs.js.map +1 -0
- package/lib/templates/admin-content-route.d.ts +18 -0
- package/lib/templates/admin-content-route.d.ts.map +1 -0
- package/lib/templates/admin-content-route.js +100 -0
- package/lib/templates/admin-content-route.js.map +1 -0
- package/lib/templates/admin-content-type-route.d.ts +9 -0
- package/lib/templates/admin-content-type-route.d.ts.map +1 -0
- package/lib/templates/admin-content-type-route.js +96 -0
- package/lib/templates/admin-content-type-route.js.map +1 -0
- package/lib/templates/admin-header.d.ts +13 -0
- package/lib/templates/admin-header.d.ts.map +1 -0
- package/lib/templates/admin-header.js +123 -0
- package/lib/templates/admin-header.js.map +1 -0
- package/lib/templates/admin-index.d.ts +9 -0
- package/lib/templates/admin-index.d.ts.map +1 -0
- package/lib/templates/admin-index.js +60 -0
- package/lib/templates/admin-index.js.map +1 -0
- package/lib/templates/admin-layout.d.ts +10 -0
- package/lib/templates/admin-layout.d.ts.map +1 -0
- package/lib/templates/admin-layout.js +46 -0
- package/lib/templates/admin-layout.js.map +1 -0
- package/lib/templates/admin-sidebar.d.ts +13 -0
- package/lib/templates/admin-sidebar.d.ts.map +1 -0
- package/lib/templates/admin-sidebar.js +149 -0
- package/lib/templates/admin-sidebar.js.map +1 -0
- package/lib/templates/content-editor.d.ts +10 -0
- package/lib/templates/content-editor.d.ts.map +1 -0
- package/lib/templates/content-editor.js +354 -0
- package/lib/templates/content-editor.js.map +1 -0
- package/lib/templates/content-schema.d.ts +10 -0
- package/lib/templates/content-schema.d.ts.map +1 -0
- package/lib/templates/content-schema.js +274 -0
- package/lib/templates/content-schema.js.map +1 -0
- package/lib/templates/content-table.d.ts +13 -0
- package/lib/templates/content-table.d.ts.map +1 -0
- package/lib/templates/content-table.js +177 -0
- package/lib/templates/content-table.js.map +1 -0
- package/lib/templates/content-types-examples.d.ts +19 -0
- package/lib/templates/content-types-examples.d.ts.map +1 -0
- package/lib/templates/content-types-examples.js +275 -0
- package/lib/templates/content-types-examples.js.map +1 -0
- package/lib/templates/content-types-registry.d.ts +10 -0
- package/lib/templates/content-types-registry.d.ts.map +1 -0
- package/lib/templates/content-types-registry.js +87 -0
- package/lib/templates/content-types-registry.js.map +1 -0
- package/lib/templates/content-types.d.ts +10 -0
- package/lib/templates/content-types.d.ts.map +1 -0
- package/lib/templates/content-types.js +384 -0
- package/lib/templates/content-types.js.map +1 -0
- package/lib/templates/dashboard-stats.d.ts +13 -0
- package/lib/templates/dashboard-stats.d.ts.map +1 -0
- package/lib/templates/dashboard-stats.js +117 -0
- package/lib/templates/dashboard-stats.js.map +1 -0
- package/lib/templates/editor/index.d.ts +6 -0
- package/lib/templates/editor/index.d.ts.map +1 -0
- package/lib/templates/editor/index.js +21 -0
- package/lib/templates/editor/index.js.map +1 -0
- package/lib/templates/editor/rich-text-editor.d.ts +7 -0
- package/lib/templates/editor/rich-text-editor.d.ts.map +1 -0
- package/lib/templates/editor/rich-text-editor.js +115 -0
- package/lib/templates/editor/rich-text-editor.js.map +1 -0
- package/lib/templates/editor/toolbar.d.ts +7 -0
- package/lib/templates/editor/toolbar.d.ts.map +1 -0
- package/lib/templates/editor/toolbar.js +272 -0
- package/lib/templates/editor/toolbar.js.map +1 -0
- package/lib/templates/form-fields/boolean-field.d.ts +7 -0
- package/lib/templates/form-fields/boolean-field.d.ts.map +1 -0
- package/lib/templates/form-fields/boolean-field.js +76 -0
- package/lib/templates/form-fields/boolean-field.js.map +1 -0
- package/lib/templates/form-fields/date-field.d.ts +7 -0
- package/lib/templates/form-fields/date-field.d.ts.map +1 -0
- package/lib/templates/form-fields/date-field.js +61 -0
- package/lib/templates/form-fields/date-field.js.map +1 -0
- package/lib/templates/form-fields/datetime-field.d.ts +7 -0
- package/lib/templates/form-fields/datetime-field.d.ts.map +1 -0
- package/lib/templates/form-fields/datetime-field.js +87 -0
- package/lib/templates/form-fields/datetime-field.js.map +1 -0
- package/lib/templates/form-fields/index.d.ts +23 -0
- package/lib/templates/form-fields/index.d.ts.map +1 -0
- package/lib/templates/form-fields/index.js +275 -0
- package/lib/templates/form-fields/index.js.map +1 -0
- package/lib/templates/form-fields/media-field.d.ts +10 -0
- package/lib/templates/form-fields/media-field.d.ts.map +1 -0
- package/lib/templates/form-fields/media-field.js +225 -0
- package/lib/templates/form-fields/media-field.js.map +1 -0
- package/lib/templates/form-fields/multiselect-field.d.ts +7 -0
- package/lib/templates/form-fields/multiselect-field.d.ts.map +1 -0
- package/lib/templates/form-fields/multiselect-field.js +121 -0
- package/lib/templates/form-fields/multiselect-field.js.map +1 -0
- package/lib/templates/form-fields/number-field.d.ts +7 -0
- package/lib/templates/form-fields/number-field.d.ts.map +1 -0
- package/lib/templates/form-fields/number-field.js +87 -0
- package/lib/templates/form-fields/number-field.js.map +1 -0
- package/lib/templates/form-fields/reference-field.d.ts +9 -0
- package/lib/templates/form-fields/reference-field.d.ts.map +1 -0
- package/lib/templates/form-fields/reference-field.js +145 -0
- package/lib/templates/form-fields/reference-field.js.map +1 -0
- package/lib/templates/form-fields/richtext-field.d.ts +9 -0
- package/lib/templates/form-fields/richtext-field.d.ts.map +1 -0
- package/lib/templates/form-fields/richtext-field.js +60 -0
- package/lib/templates/form-fields/richtext-field.js.map +1 -0
- package/lib/templates/form-fields/select-field.d.ts +7 -0
- package/lib/templates/form-fields/select-field.d.ts.map +1 -0
- package/lib/templates/form-fields/select-field.js +70 -0
- package/lib/templates/form-fields/select-field.js.map +1 -0
- package/lib/templates/form-fields/slug-field.d.ts +7 -0
- package/lib/templates/form-fields/slug-field.d.ts.map +1 -0
- package/lib/templates/form-fields/slug-field.js +143 -0
- package/lib/templates/form-fields/slug-field.js.map +1 -0
- package/lib/templates/form-fields/tags-field.d.ts +7 -0
- package/lib/templates/form-fields/tags-field.d.ts.map +1 -0
- package/lib/templates/form-fields/tags-field.js +172 -0
- package/lib/templates/form-fields/tags-field.js.map +1 -0
- package/lib/templates/form-fields/text-field.d.ts +7 -0
- package/lib/templates/form-fields/text-field.d.ts.map +1 -0
- package/lib/templates/form-fields/text-field.js +63 -0
- package/lib/templates/form-fields/text-field.js.map +1 -0
- package/lib/templates/form-fields/textarea-field.d.ts +7 -0
- package/lib/templates/form-fields/textarea-field.d.ts.map +1 -0
- package/lib/templates/form-fields/textarea-field.js +64 -0
- package/lib/templates/form-fields/textarea-field.js.map +1 -0
- package/lib/templates/index.d.ts +34 -0
- package/lib/templates/index.d.ts.map +1 -0
- package/lib/templates/index.js +92 -0
- package/lib/templates/index.js.map +1 -0
- package/lib/templates/media/index.d.ts +12 -0
- package/lib/templates/media/index.d.ts.map +1 -0
- package/lib/templates/media/index.js +50 -0
- package/lib/templates/media/index.js.map +1 -0
- package/lib/templates/media/media-api.d.ts +13 -0
- package/lib/templates/media/media-api.d.ts.map +1 -0
- package/lib/templates/media/media-api.js +274 -0
- package/lib/templates/media/media-api.js.map +1 -0
- package/lib/templates/media/media-grid.d.ts +14 -0
- package/lib/templates/media/media-grid.d.ts.map +1 -0
- package/lib/templates/media/media-grid.js +314 -0
- package/lib/templates/media/media-grid.js.map +1 -0
- package/lib/templates/media/media-library-route.d.ts +13 -0
- package/lib/templates/media/media-library-route.d.ts.map +1 -0
- package/lib/templates/media/media-library-route.js +105 -0
- package/lib/templates/media/media-library-route.js.map +1 -0
- package/lib/templates/media/media-picker.d.ts +13 -0
- package/lib/templates/media/media-picker.d.ts.map +1 -0
- package/lib/templates/media/media-picker.js +152 -0
- package/lib/templates/media/media-picker.js.map +1 -0
- package/lib/templates/media/media-uploader.d.ts +14 -0
- package/lib/templates/media/media-uploader.d.ts.map +1 -0
- package/lib/templates/media/media-uploader.js +318 -0
- package/lib/templates/media/media-uploader.js.map +1 -0
- package/lib/templates/recent-content.d.ts +13 -0
- package/lib/templates/recent-content.d.ts.map +1 -0
- package/lib/templates/recent-content.js +138 -0
- package/lib/templates/recent-content.js.map +1 -0
- package/lib/templates/slug-utils.d.ts +10 -0
- package/lib/templates/slug-utils.d.ts.map +1 -0
- package/lib/templates/slug-utils.js +194 -0
- package/lib/templates/slug-utils.js.map +1 -0
- package/lib/templates/ui-avatar.d.ts +8 -0
- package/lib/templates/ui-avatar.d.ts.map +1 -0
- package/lib/templates/ui-avatar.js +60 -0
- package/lib/templates/ui-avatar.js.map +1 -0
- package/lib/templates/ui-badge.d.ts +8 -0
- package/lib/templates/ui-badge.d.ts.map +1 -0
- package/lib/templates/ui-badge.js +52 -0
- package/lib/templates/ui-badge.js.map +1 -0
- package/lib/templates/ui-dialog.d.ts +10 -0
- package/lib/templates/ui-dialog.d.ts.map +1 -0
- package/lib/templates/ui-dialog.js +134 -0
- package/lib/templates/ui-dialog.js.map +1 -0
- package/lib/templates/ui-dropdown-menu.d.ts +8 -0
- package/lib/templates/ui-dropdown-menu.d.ts.map +1 -0
- package/lib/templates/ui-dropdown-menu.js +210 -0
- package/lib/templates/ui-dropdown-menu.js.map +1 -0
- package/lib/templates/ui-popover.d.ts +8 -0
- package/lib/templates/ui-popover.d.ts.map +1 -0
- package/lib/templates/ui-popover.js +43 -0
- package/lib/templates/ui-popover.js.map +1 -0
- package/lib/templates/ui-progress.d.ts +10 -0
- package/lib/templates/ui-progress.d.ts.map +1 -0
- package/lib/templates/ui-progress.js +40 -0
- package/lib/templates/ui-progress.js.map +1 -0
- package/lib/templates/ui-table.d.ts +8 -0
- package/lib/templates/ui-table.d.ts.map +1 -0
- package/lib/templates/ui-table.js +129 -0
- package/lib/templates/ui-table.js.map +1 -0
- package/lib/templates/ui-tabs.d.ts +10 -0
- package/lib/templates/ui-tabs.d.ts.map +1 -0
- package/lib/templates/ui-tabs.js +67 -0
- package/lib/templates/ui-tabs.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../../src/templates/editor/toolbar.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAsQjD"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.getEditorToolbarTemplate = getEditorToolbarTemplate;
|
|
4
|
+
/**
|
|
5
|
+
* Generates the editor toolbar component template.
|
|
6
|
+
*
|
|
7
|
+
* @returns Template string for app/components/editor/toolbar.tsx
|
|
8
|
+
*/
|
|
9
|
+
function getEditorToolbarTemplate() {
|
|
10
|
+
return `import * as React from 'react';
|
|
11
|
+
import type { Editor } from '@tiptap/react';
|
|
12
|
+
import {
|
|
13
|
+
Bold,
|
|
14
|
+
Italic,
|
|
15
|
+
Strikethrough,
|
|
16
|
+
Heading1,
|
|
17
|
+
Heading2,
|
|
18
|
+
Heading3,
|
|
19
|
+
List,
|
|
20
|
+
ListOrdered,
|
|
21
|
+
Code,
|
|
22
|
+
Link,
|
|
23
|
+
Unlink,
|
|
24
|
+
Image,
|
|
25
|
+
} from 'lucide-react';
|
|
26
|
+
import { Button } from '~/components/ui/button';
|
|
27
|
+
import { Input } from '~/components/ui/input';
|
|
28
|
+
import { Label } from '~/components/ui/label';
|
|
29
|
+
import {
|
|
30
|
+
Popover,
|
|
31
|
+
PopoverContent,
|
|
32
|
+
PopoverTrigger,
|
|
33
|
+
} from '~/components/ui/popover';
|
|
34
|
+
import { cn } from '~/lib/utils';
|
|
35
|
+
|
|
36
|
+
export interface EditorToolbarProps {
|
|
37
|
+
editor: Editor | null;
|
|
38
|
+
onImageSelect?: () => void;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface ToolbarButtonProps {
|
|
43
|
+
onClick: () => void;
|
|
44
|
+
isActive?: boolean;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
title: string;
|
|
47
|
+
children: React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function ToolbarButton({
|
|
51
|
+
onClick,
|
|
52
|
+
isActive,
|
|
53
|
+
disabled,
|
|
54
|
+
title,
|
|
55
|
+
children,
|
|
56
|
+
}: ToolbarButtonProps) {
|
|
57
|
+
return (
|
|
58
|
+
<Button
|
|
59
|
+
type="button"
|
|
60
|
+
variant="ghost"
|
|
61
|
+
size="sm"
|
|
62
|
+
onClick={onClick}
|
|
63
|
+
disabled={disabled}
|
|
64
|
+
title={title}
|
|
65
|
+
className={cn(
|
|
66
|
+
'h-8 w-8 p-0',
|
|
67
|
+
isActive && 'bg-accent text-accent-foreground'
|
|
68
|
+
)}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</Button>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function ToolbarDivider() {
|
|
76
|
+
return <div className="w-px h-6 bg-border mx-1" />;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function EditorToolbar({
|
|
80
|
+
editor,
|
|
81
|
+
onImageSelect,
|
|
82
|
+
disabled = false,
|
|
83
|
+
}: EditorToolbarProps) {
|
|
84
|
+
const [linkUrl, setLinkUrl] = React.useState('');
|
|
85
|
+
const [linkPopoverOpen, setLinkPopoverOpen] = React.useState(false);
|
|
86
|
+
|
|
87
|
+
if (!editor) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const handleSetLink = () => {
|
|
92
|
+
if (linkUrl) {
|
|
93
|
+
editor
|
|
94
|
+
.chain()
|
|
95
|
+
.focus()
|
|
96
|
+
.extendMarkRange('link')
|
|
97
|
+
.setLink({ href: linkUrl })
|
|
98
|
+
.run();
|
|
99
|
+
}
|
|
100
|
+
setLinkUrl('');
|
|
101
|
+
setLinkPopoverOpen(false);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const handleRemoveLink = () => {
|
|
105
|
+
editor.chain().focus().unsetLink().run();
|
|
106
|
+
setLinkPopoverOpen(false);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const openLinkPopover = () => {
|
|
110
|
+
const previousUrl = editor.getAttributes('link').href || '';
|
|
111
|
+
setLinkUrl(previousUrl);
|
|
112
|
+
setLinkPopoverOpen(true);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div className="flex flex-wrap items-center gap-0.5 border-b bg-muted/30 p-1">
|
|
117
|
+
{/* Text formatting */}
|
|
118
|
+
<ToolbarButton
|
|
119
|
+
onClick={() => editor.chain().focus().toggleBold().run()}
|
|
120
|
+
isActive={editor.isActive('bold')}
|
|
121
|
+
disabled={disabled}
|
|
122
|
+
title="Bold"
|
|
123
|
+
>
|
|
124
|
+
<Bold className="h-4 w-4" />
|
|
125
|
+
</ToolbarButton>
|
|
126
|
+
<ToolbarButton
|
|
127
|
+
onClick={() => editor.chain().focus().toggleItalic().run()}
|
|
128
|
+
isActive={editor.isActive('italic')}
|
|
129
|
+
disabled={disabled}
|
|
130
|
+
title="Italic"
|
|
131
|
+
>
|
|
132
|
+
<Italic className="h-4 w-4" />
|
|
133
|
+
</ToolbarButton>
|
|
134
|
+
<ToolbarButton
|
|
135
|
+
onClick={() => editor.chain().focus().toggleStrike().run()}
|
|
136
|
+
isActive={editor.isActive('strike')}
|
|
137
|
+
disabled={disabled}
|
|
138
|
+
title="Strikethrough"
|
|
139
|
+
>
|
|
140
|
+
<Strikethrough className="h-4 w-4" />
|
|
141
|
+
</ToolbarButton>
|
|
142
|
+
|
|
143
|
+
<ToolbarDivider />
|
|
144
|
+
|
|
145
|
+
{/* Headings */}
|
|
146
|
+
<ToolbarButton
|
|
147
|
+
onClick={() => editor.chain().focus().toggleHeading({ level: 1 }).run()}
|
|
148
|
+
isActive={editor.isActive('heading', { level: 1 })}
|
|
149
|
+
disabled={disabled}
|
|
150
|
+
title="Heading 1"
|
|
151
|
+
>
|
|
152
|
+
<Heading1 className="h-4 w-4" />
|
|
153
|
+
</ToolbarButton>
|
|
154
|
+
<ToolbarButton
|
|
155
|
+
onClick={() => editor.chain().focus().toggleHeading({ level: 2 }).run()}
|
|
156
|
+
isActive={editor.isActive('heading', { level: 2 })}
|
|
157
|
+
disabled={disabled}
|
|
158
|
+
title="Heading 2"
|
|
159
|
+
>
|
|
160
|
+
<Heading2 className="h-4 w-4" />
|
|
161
|
+
</ToolbarButton>
|
|
162
|
+
<ToolbarButton
|
|
163
|
+
onClick={() => editor.chain().focus().toggleHeading({ level: 3 }).run()}
|
|
164
|
+
isActive={editor.isActive('heading', { level: 3 })}
|
|
165
|
+
disabled={disabled}
|
|
166
|
+
title="Heading 3"
|
|
167
|
+
>
|
|
168
|
+
<Heading3 className="h-4 w-4" />
|
|
169
|
+
</ToolbarButton>
|
|
170
|
+
|
|
171
|
+
<ToolbarDivider />
|
|
172
|
+
|
|
173
|
+
{/* Lists */}
|
|
174
|
+
<ToolbarButton
|
|
175
|
+
onClick={() => editor.chain().focus().toggleBulletList().run()}
|
|
176
|
+
isActive={editor.isActive('bulletList')}
|
|
177
|
+
disabled={disabled}
|
|
178
|
+
title="Bullet List"
|
|
179
|
+
>
|
|
180
|
+
<List className="h-4 w-4" />
|
|
181
|
+
</ToolbarButton>
|
|
182
|
+
<ToolbarButton
|
|
183
|
+
onClick={() => editor.chain().focus().toggleOrderedList().run()}
|
|
184
|
+
isActive={editor.isActive('orderedList')}
|
|
185
|
+
disabled={disabled}
|
|
186
|
+
title="Numbered List"
|
|
187
|
+
>
|
|
188
|
+
<ListOrdered className="h-4 w-4" />
|
|
189
|
+
</ToolbarButton>
|
|
190
|
+
|
|
191
|
+
<ToolbarDivider />
|
|
192
|
+
|
|
193
|
+
{/* Code */}
|
|
194
|
+
<ToolbarButton
|
|
195
|
+
onClick={() => editor.chain().focus().toggleCodeBlock().run()}
|
|
196
|
+
isActive={editor.isActive('codeBlock')}
|
|
197
|
+
disabled={disabled}
|
|
198
|
+
title="Code Block"
|
|
199
|
+
>
|
|
200
|
+
<Code className="h-4 w-4" />
|
|
201
|
+
</ToolbarButton>
|
|
202
|
+
|
|
203
|
+
<ToolbarDivider />
|
|
204
|
+
|
|
205
|
+
{/* Link */}
|
|
206
|
+
<Popover open={linkPopoverOpen} onOpenChange={setLinkPopoverOpen}>
|
|
207
|
+
<PopoverTrigger asChild>
|
|
208
|
+
<Button
|
|
209
|
+
type="button"
|
|
210
|
+
variant="ghost"
|
|
211
|
+
size="sm"
|
|
212
|
+
disabled={disabled}
|
|
213
|
+
title="Insert Link"
|
|
214
|
+
onClick={openLinkPopover}
|
|
215
|
+
className={cn(
|
|
216
|
+
'h-8 w-8 p-0',
|
|
217
|
+
editor.isActive('link') && 'bg-accent text-accent-foreground'
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
220
|
+
<Link className="h-4 w-4" />
|
|
221
|
+
</Button>
|
|
222
|
+
</PopoverTrigger>
|
|
223
|
+
<PopoverContent className="w-80" align="start">
|
|
224
|
+
<div className="space-y-4">
|
|
225
|
+
<div className="space-y-2">
|
|
226
|
+
<Label htmlFor="link-url">URL</Label>
|
|
227
|
+
<Input
|
|
228
|
+
id="link-url"
|
|
229
|
+
placeholder="https://example.com"
|
|
230
|
+
value={linkUrl}
|
|
231
|
+
onChange={(e) => setLinkUrl(e.target.value)}
|
|
232
|
+
onKeyDown={(e) => {
|
|
233
|
+
if (e.key === 'Enter') {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
handleSetLink();
|
|
236
|
+
}
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
<div className="flex justify-between">
|
|
241
|
+
<Button
|
|
242
|
+
type="button"
|
|
243
|
+
variant="outline"
|
|
244
|
+
size="sm"
|
|
245
|
+
onClick={handleRemoveLink}
|
|
246
|
+
disabled={!editor.isActive('link')}
|
|
247
|
+
>
|
|
248
|
+
<Unlink className="h-4 w-4 mr-2" />
|
|
249
|
+
Remove
|
|
250
|
+
</Button>
|
|
251
|
+
<Button type="button" size="sm" onClick={handleSetLink}>
|
|
252
|
+
Apply
|
|
253
|
+
</Button>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</PopoverContent>
|
|
257
|
+
</Popover>
|
|
258
|
+
|
|
259
|
+
{/* Image placeholder for Sprint 5 */}
|
|
260
|
+
<ToolbarButton
|
|
261
|
+
onClick={() => onImageSelect?.()}
|
|
262
|
+
disabled={disabled || !onImageSelect}
|
|
263
|
+
title="Insert Image"
|
|
264
|
+
>
|
|
265
|
+
<Image className="h-4 w-4" />
|
|
266
|
+
</ToolbarButton>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
`;
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.js","sourceRoot":"","sources":["../../../src/templates/editor/toolbar.ts"],"names":[],"mappings":";;AAKA,4DAsQC;AA3QD;;;;GAIG;AACH,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoQR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-field.d.ts","sourceRoot":"","sources":["../../../src/templates/form-fields/boolean-field.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAkEhD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.getBooleanFieldTemplate = getBooleanFieldTemplate;
|
|
4
|
+
/**
|
|
5
|
+
* Generates the boolean field component template.
|
|
6
|
+
*
|
|
7
|
+
* @returns Template string for app/components/form-fields/boolean-field.tsx
|
|
8
|
+
*/
|
|
9
|
+
function getBooleanFieldTemplate() {
|
|
10
|
+
return `import type { BooleanFieldDefinition } from '~/lib/content-types';
|
|
11
|
+
import { Label } from '~/components/ui/label';
|
|
12
|
+
import { cn } from '~/lib/utils';
|
|
13
|
+
import type { FieldProps } from './index';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Boolean toggle/checkbox field.
|
|
17
|
+
*/
|
|
18
|
+
export function BooleanField({
|
|
19
|
+
field,
|
|
20
|
+
value,
|
|
21
|
+
onChange,
|
|
22
|
+
error,
|
|
23
|
+
disabled,
|
|
24
|
+
}: FieldProps<BooleanFieldDefinition>) {
|
|
25
|
+
const id = \`field-\${field.name}\`;
|
|
26
|
+
const isChecked = Boolean(value);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="space-y-2">
|
|
30
|
+
<div className="flex items-center gap-3">
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
role="switch"
|
|
34
|
+
id={id}
|
|
35
|
+
aria-checked={isChecked}
|
|
36
|
+
onClick={() => !disabled && onChange(!isChecked)}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
className={cn(
|
|
39
|
+
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
40
|
+
isChecked ? 'bg-primary' : 'bg-input',
|
|
41
|
+
disabled && 'cursor-not-allowed opacity-50'
|
|
42
|
+
)}
|
|
43
|
+
aria-describedby={error ? \`\${id}-error\` : field.description ? \`\${id}-description\` : undefined}
|
|
44
|
+
>
|
|
45
|
+
<span
|
|
46
|
+
className={cn(
|
|
47
|
+
'pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform',
|
|
48
|
+
isChecked ? 'translate-x-5' : 'translate-x-0'
|
|
49
|
+
)}
|
|
50
|
+
/>
|
|
51
|
+
</button>
|
|
52
|
+
<input
|
|
53
|
+
type="hidden"
|
|
54
|
+
name={field.name}
|
|
55
|
+
value={isChecked ? 'true' : 'false'}
|
|
56
|
+
/>
|
|
57
|
+
<Label htmlFor={id} className="cursor-pointer">
|
|
58
|
+
{field.label}
|
|
59
|
+
</Label>
|
|
60
|
+
</div>
|
|
61
|
+
{field.description && !error && (
|
|
62
|
+
<p id={\`\${id}-description\`} className="text-sm text-muted-foreground ml-14">
|
|
63
|
+
{field.description}
|
|
64
|
+
</p>
|
|
65
|
+
)}
|
|
66
|
+
{error && (
|
|
67
|
+
<p id={\`\${id}-error\`} className="text-sm text-destructive ml-14">
|
|
68
|
+
{error}
|
|
69
|
+
</p>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=boolean-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-field.js","sourceRoot":"","sources":["../../../src/templates/form-fields/boolean-field.ts"],"names":[],"mappings":";;AAKA,0DAkEC;AAvED;;;;GAIG;AACH,SAAgB,uBAAuB;IACrC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgER,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-field.d.ts","sourceRoot":"","sources":["../../../src/templates/form-fields/date-field.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAmD7C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.getDateFieldTemplate = getDateFieldTemplate;
|
|
4
|
+
/**
|
|
5
|
+
* Generates the date field component template.
|
|
6
|
+
*
|
|
7
|
+
* @returns Template string for app/components/form-fields/date-field.tsx
|
|
8
|
+
*/
|
|
9
|
+
function getDateFieldTemplate() {
|
|
10
|
+
return `import type { DateFieldDefinition } from '~/lib/content-types';
|
|
11
|
+
import { Input } from '~/components/ui/input';
|
|
12
|
+
import { Label } from '~/components/ui/label';
|
|
13
|
+
import { cn } from '~/lib/utils';
|
|
14
|
+
import type { FieldProps } from './index';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Date picker field.
|
|
18
|
+
*/
|
|
19
|
+
export function DateField({
|
|
20
|
+
field,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
error,
|
|
24
|
+
disabled,
|
|
25
|
+
}: FieldProps<DateFieldDefinition>) {
|
|
26
|
+
const id = \`field-\${field.name}\`;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="space-y-2">
|
|
30
|
+
<Label htmlFor={id} className={cn(field.required && "after:content-['*'] after:ml-0.5 after:text-destructive")}>
|
|
31
|
+
{field.label}
|
|
32
|
+
</Label>
|
|
33
|
+
<Input
|
|
34
|
+
id={id}
|
|
35
|
+
name={field.name}
|
|
36
|
+
type="date"
|
|
37
|
+
value={(value as string) ?? ''}
|
|
38
|
+
onChange={(e) => onChange(e.target.value)}
|
|
39
|
+
disabled={disabled}
|
|
40
|
+
min={field.min}
|
|
41
|
+
max={field.max}
|
|
42
|
+
className={cn(error && 'border-destructive')}
|
|
43
|
+
aria-invalid={!!error}
|
|
44
|
+
aria-describedby={error ? \`\${id}-error\` : field.description ? \`\${id}-description\` : undefined}
|
|
45
|
+
/>
|
|
46
|
+
{field.description && !error && (
|
|
47
|
+
<p id={\`\${id}-description\`} className="text-sm text-muted-foreground">
|
|
48
|
+
{field.description}
|
|
49
|
+
</p>
|
|
50
|
+
)}
|
|
51
|
+
{error && (
|
|
52
|
+
<p id={\`\${id}-error\`} className="text-sm text-destructive">
|
|
53
|
+
{error}
|
|
54
|
+
</p>
|
|
55
|
+
)}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=date-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-field.js","sourceRoot":"","sources":["../../../src/templates/form-fields/date-field.ts"],"names":[],"mappings":";;AAKA,oDAmDC;AAxDD;;;;GAIG;AACH,SAAgB,oBAAoB;IAClC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime-field.d.ts","sourceRoot":"","sources":["../../../src/templates/form-fields/datetime-field.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA6EjD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.getDatetimeFieldTemplate = getDatetimeFieldTemplate;
|
|
4
|
+
/**
|
|
5
|
+
* Generates the datetime field component template.
|
|
6
|
+
*
|
|
7
|
+
* @returns Template string for app/components/form-fields/datetime-field.tsx
|
|
8
|
+
*/
|
|
9
|
+
function getDatetimeFieldTemplate() {
|
|
10
|
+
return `import type { DatetimeFieldDefinition } from '~/lib/content-types';
|
|
11
|
+
import { Input } from '~/components/ui/input';
|
|
12
|
+
import { Label } from '~/components/ui/label';
|
|
13
|
+
import { cn } from '~/lib/utils';
|
|
14
|
+
import type { FieldProps } from './index';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Date and time picker field.
|
|
18
|
+
*/
|
|
19
|
+
export function DatetimeField({
|
|
20
|
+
field,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
error,
|
|
24
|
+
disabled,
|
|
25
|
+
}: FieldProps<DatetimeFieldDefinition>) {
|
|
26
|
+
const id = \`field-\${field.name}\`;
|
|
27
|
+
|
|
28
|
+
// Convert ISO string to datetime-local format
|
|
29
|
+
const formatValue = (isoString: string | undefined): string => {
|
|
30
|
+
if (!isoString) return '';
|
|
31
|
+
try {
|
|
32
|
+
const date = new Date(isoString);
|
|
33
|
+
// Format as YYYY-MM-DDTHH:mm for datetime-local input
|
|
34
|
+
return date.toISOString().slice(0, 16);
|
|
35
|
+
} catch {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Convert datetime-local format to ISO string
|
|
41
|
+
const handleChange = (localValue: string) => {
|
|
42
|
+
if (!localValue) {
|
|
43
|
+
onChange('');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const date = new Date(localValue);
|
|
48
|
+
onChange(date.toISOString());
|
|
49
|
+
} catch {
|
|
50
|
+
onChange(localValue);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="space-y-2">
|
|
56
|
+
<Label htmlFor={id} className={cn(field.required && "after:content-['*'] after:ml-0.5 after:text-destructive")}>
|
|
57
|
+
{field.label}
|
|
58
|
+
</Label>
|
|
59
|
+
<Input
|
|
60
|
+
id={id}
|
|
61
|
+
name={field.name}
|
|
62
|
+
type="datetime-local"
|
|
63
|
+
value={formatValue(value as string)}
|
|
64
|
+
onChange={(e) => handleChange(e.target.value)}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
min={field.min ? formatValue(field.min) : undefined}
|
|
67
|
+
max={field.max ? formatValue(field.max) : undefined}
|
|
68
|
+
className={cn(error && 'border-destructive')}
|
|
69
|
+
aria-invalid={!!error}
|
|
70
|
+
aria-describedby={error ? \`\${id}-error\` : field.description ? \`\${id}-description\` : undefined}
|
|
71
|
+
/>
|
|
72
|
+
{field.description && !error && (
|
|
73
|
+
<p id={\`\${id}-description\`} className="text-sm text-muted-foreground">
|
|
74
|
+
{field.description}
|
|
75
|
+
</p>
|
|
76
|
+
)}
|
|
77
|
+
{error && (
|
|
78
|
+
<p id={\`\${id}-error\`} className="text-sm text-destructive">
|
|
79
|
+
{error}
|
|
80
|
+
</p>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=datetime-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime-field.js","sourceRoot":"","sources":["../../../src/templates/form-fields/datetime-field.ts"],"names":[],"mappings":";;AAKA,4DA6EC;AAlFD;;;;GAIG;AACH,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ER,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form field template exports and DynamicField renderer.
|
|
3
|
+
*/
|
|
4
|
+
export { getTextFieldTemplate } from './text-field';
|
|
5
|
+
export { getTextareaFieldTemplate } from './textarea-field';
|
|
6
|
+
export { getRichtextFieldTemplate } from './richtext-field';
|
|
7
|
+
export { getSlugFieldTemplate } from './slug-field';
|
|
8
|
+
export { getMediaFieldTemplate } from './media-field';
|
|
9
|
+
export { getSelectFieldTemplate } from './select-field';
|
|
10
|
+
export { getMultiselectFieldTemplate } from './multiselect-field';
|
|
11
|
+
export { getDateFieldTemplate } from './date-field';
|
|
12
|
+
export { getDatetimeFieldTemplate } from './datetime-field';
|
|
13
|
+
export { getBooleanFieldTemplate } from './boolean-field';
|
|
14
|
+
export { getNumberFieldTemplate } from './number-field';
|
|
15
|
+
export { getTagsFieldTemplate } from './tags-field';
|
|
16
|
+
export { getReferenceFieldTemplate } from './reference-field';
|
|
17
|
+
/**
|
|
18
|
+
* Generates the form fields index with DynamicField component.
|
|
19
|
+
*
|
|
20
|
+
* @returns Template string for app/components/form-fields/index.ts
|
|
21
|
+
*/
|
|
22
|
+
export declare function getFormFieldsIndexTemplate(): string;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/form-fields/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CA6JnD"}
|