@ginia/ui 0.1.19 → 0.1.20

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.cts CHANGED
@@ -44,7 +44,7 @@ export { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover
44
44
  export { Progress, ProgressProps } from './components/ui/progress/progress.cjs';
45
45
  export { RadioGroup, RadioGroupItem } from './components/ui/radio-group/radio-group.cjs';
46
46
  export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from './components/ui/resizable/resizable.cjs';
47
- export { RichTextEditor, RichTextEditorProps } from './components/ui/rich-text-editor/rich-text-editor.cjs';
47
+ export { RichTextEditor, RichTextEditorProps } from './components/ui/index.cjs';
48
48
  export { ScrollArea, ScrollBar } from './components/ui/scroll-area/scroll-area.cjs';
49
49
  export { SectionLoader, SectionLoaderProps, TabLoadingState, TabLoadingStateProps } from './components/ui/section-loader/section-loader.cjs';
50
50
  export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from './components/ui/select/select.cjs';
package/dist/index.d.ts CHANGED
@@ -44,7 +44,7 @@ export { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover
44
44
  export { Progress, ProgressProps } from './components/ui/progress/progress.js';
45
45
  export { RadioGroup, RadioGroupItem } from './components/ui/radio-group/radio-group.js';
46
46
  export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from './components/ui/resizable/resizable.js';
47
- export { RichTextEditor, RichTextEditorProps } from './components/ui/rich-text-editor/rich-text-editor.js';
47
+ export { RichTextEditor, RichTextEditorProps } from './components/ui/index.js';
48
48
  export { ScrollArea, ScrollBar } from './components/ui/scroll-area/scroll-area.js';
49
49
  export { SectionLoader, SectionLoaderProps, TabLoadingState, TabLoadingStateProps } from './components/ui/section-loader/section-loader.js';
50
50
  export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from './components/ui/select/select.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ginia/ui",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Ginia Design System — Unified UI component library for all Ginia hubs",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,2 +0,0 @@
1
- export { RichTextEditor, RichTextEditorProps } from './rich-text-editor.cjs';
2
- import 'react/jsx-runtime';
@@ -1,2 +0,0 @@
1
- export { RichTextEditor, RichTextEditorProps } from './rich-text-editor.js';
2
- import 'react/jsx-runtime';
@@ -1,282 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var rich_text_editor_exports = {};
31
- __export(rich_text_editor_exports, {
32
- RichTextEditor: () => RichTextEditor
33
- });
34
- module.exports = __toCommonJS(rich_text_editor_exports);
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_react = __toESM(require("react"), 1);
37
- var import_react2 = require("@tiptap/react");
38
- var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
39
- var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
40
- var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
41
- var import_extension_text_style = require("@tiptap/extension-text-style");
42
- var import_extension_image = __toESM(require("@tiptap/extension-image"), 1);
43
- var import_extension_link = __toESM(require("@tiptap/extension-link"), 1);
44
- var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
45
- var import_lucide_react = require("lucide-react");
46
- var import_utils = require("../../../lib/utils");
47
- function ToolbarButton({
48
- onClick,
49
- children,
50
- title,
51
- isActive = false
52
- }) {
53
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
- "button",
55
- {
56
- type: "button",
57
- onClick,
58
- title,
59
- className: (0, import_utils.cn)(
60
- "rounded p-2 transition-colors",
61
- isActive ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted"
62
- ),
63
- children
64
- }
65
- );
66
- }
67
- function RichTextEditor({
68
- value,
69
- onChange,
70
- placeholder = "Escribe aqu\xED...",
71
- height = 200,
72
- className = "",
73
- readOnly = false
74
- }) {
75
- const editor = (0, import_react2.useEditor)({
76
- extensions: [
77
- import_starter_kit.default,
78
- import_extension_text_align.default.configure({
79
- types: ["heading", "paragraph"]
80
- }),
81
- import_extension_color.default.configure({ types: [import_extension_text_style.TextStyle.name] }),
82
- import_extension_text_style.TextStyle,
83
- import_extension_image.default.configure({
84
- HTMLAttributes: {
85
- class: "max-w-full h-auto rounded-lg"
86
- }
87
- }),
88
- import_extension_link.default.configure({
89
- openOnClick: false
90
- }),
91
- import_extension_placeholder.default.configure({
92
- placeholder
93
- })
94
- ],
95
- content: value,
96
- editable: !readOnly,
97
- immediatelyRender: false,
98
- onUpdate: ({ editor: e }) => {
99
- onChange(e.getHTML());
100
- },
101
- editorProps: {
102
- attributes: {
103
- class: "prose prose-sm mx-auto focus:outline-none max-w-none",
104
- style: `min-height: ${height}px;`
105
- }
106
- }
107
- });
108
- import_react.default.useEffect(() => {
109
- if (editor && editor.getHTML() !== value) {
110
- editor.commands.setContent(value);
111
- }
112
- }, [value, editor]);
113
- if (!editor) {
114
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("overflow-hidden rounded-lg border border-border", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex h-32 animate-pulse items-center justify-center rounded bg-muted text-muted-foreground", children: "Cargando editor..." }) });
115
- }
116
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
117
- "div",
118
- {
119
- "data-slot": "rich-text-editor",
120
- className: (0, import_utils.cn)("overflow-hidden rounded-lg border border-border", className),
121
- children: [
122
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap gap-1 border-b border-border bg-muted/50 p-2", children: [
123
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
- ToolbarButton,
125
- {
126
- onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
127
- title: "T\xEDtulo 1",
128
- isActive: editor.isActive("heading", { level: 1 }),
129
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Heading1, { className: "h-4 w-4" })
130
- }
131
- ),
132
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
- ToolbarButton,
134
- {
135
- onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
136
- title: "T\xEDtulo 2",
137
- isActive: editor.isActive("heading", { level: 2 }),
138
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Heading2, { className: "h-4 w-4" })
139
- }
140
- ),
141
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
- ToolbarButton,
143
- {
144
- onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
145
- title: "T\xEDtulo 3",
146
- isActive: editor.isActive("heading", { level: 3 }),
147
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Heading3, { className: "h-4 w-4" })
148
- }
149
- ),
150
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-1 h-6 w-px bg-border" }),
151
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
- ToolbarButton,
153
- {
154
- onClick: () => editor.chain().focus().toggleBold().run(),
155
- title: "Negrita",
156
- isActive: editor.isActive("bold"),
157
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Bold, { className: "h-4 w-4" })
158
- }
159
- ),
160
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
- ToolbarButton,
162
- {
163
- onClick: () => editor.chain().focus().toggleItalic().run(),
164
- title: "Cursiva",
165
- isActive: editor.isActive("italic"),
166
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Italic, { className: "h-4 w-4" })
167
- }
168
- ),
169
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
170
- ToolbarButton,
171
- {
172
- onClick: () => editor.chain().focus().toggleStrike().run(),
173
- title: "Tachado",
174
- isActive: editor.isActive("strike"),
175
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Strikethrough, { className: "h-4 w-4" })
176
- }
177
- ),
178
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-1 h-6 w-px bg-border" }),
179
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
- "input",
181
- {
182
- type: "color",
183
- className: "h-8 w-8 cursor-pointer rounded border border-border",
184
- onChange: (e) => {
185
- editor.chain().focus().setColor(e.target.value).run();
186
- },
187
- title: "Color del texto"
188
- }
189
- ) }),
190
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-1 h-6 w-px bg-border" }),
191
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
192
- ToolbarButton,
193
- {
194
- onClick: () => editor.chain().focus().toggleBulletList().run(),
195
- title: "Lista con vi\xF1etas",
196
- isActive: editor.isActive("bulletList"),
197
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.List, { className: "h-4 w-4" })
198
- }
199
- ),
200
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
201
- ToolbarButton,
202
- {
203
- onClick: () => editor.chain().focus().toggleOrderedList().run(),
204
- title: "Lista numerada",
205
- isActive: editor.isActive("orderedList"),
206
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ListOrdered, { className: "h-4 w-4" })
207
- }
208
- ),
209
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-1 h-6 w-px bg-border" }),
210
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
- ToolbarButton,
212
- {
213
- onClick: () => editor.chain().focus().setTextAlign("left").run(),
214
- title: "Alinear izquierda",
215
- isActive: editor.isActive({ textAlign: "left" }),
216
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlignLeft, { className: "h-4 w-4" })
217
- }
218
- ),
219
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
- ToolbarButton,
221
- {
222
- onClick: () => editor.chain().focus().setTextAlign("center").run(),
223
- title: "Centrar",
224
- isActive: editor.isActive({ textAlign: "center" }),
225
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlignCenter, { className: "h-4 w-4" })
226
- }
227
- ),
228
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
- ToolbarButton,
230
- {
231
- onClick: () => editor.chain().focus().setTextAlign("right").run(),
232
- title: "Alinear derecha",
233
- isActive: editor.isActive({ textAlign: "right" }),
234
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlignRight, { className: "h-4 w-4" })
235
- }
236
- ),
237
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-1 h-6 w-px bg-border" }),
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
239
- ToolbarButton,
240
- {
241
- onClick: () => {
242
- const url = prompt("Ingresa la URL:");
243
- if (url) {
244
- editor.chain().focus().setLink({ href: url }).run();
245
- }
246
- },
247
- title: "Insertar enlace",
248
- isActive: editor.isActive("link"),
249
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Link, { className: "h-4 w-4" })
250
- }
251
- ),
252
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
253
- ToolbarButton,
254
- {
255
- onClick: () => {
256
- const url = prompt("Ingresa la URL de la imagen:");
257
- if (url) {
258
- editor.chain().focus().setImage({ src: url }).run();
259
- }
260
- },
261
- title: "Insertar imagen",
262
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Image, { className: "h-4 w-4" })
263
- }
264
- )
265
- ] }),
266
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
267
- import_react2.EditorContent,
268
- {
269
- editor,
270
- className: "prose prose-sm max-w-none bg-card p-3",
271
- style: { minHeight: `${height}px` }
272
- }
273
- )
274
- ]
275
- }
276
- );
277
- }
278
- // Annotate the CommonJS export names for ESM import in node:
279
- 0 && (module.exports = {
280
- RichTextEditor
281
- });
282
- //# sourceMappingURL=rich-text-editor.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/ui/rich-text-editor/rich-text-editor.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport TextAlign from \"@tiptap/extension-text-align\";\nimport Color from \"@tiptap/extension-color\";\nimport { TextStyle } from \"@tiptap/extension-text-style\";\nimport ImageExtension from \"@tiptap/extension-image\";\nimport LinkExtension from \"@tiptap/extension-link\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport {\n Bold,\n Italic,\n Strikethrough,\n List,\n ListOrdered,\n Link,\n AlignLeft,\n AlignCenter,\n AlignRight,\n Image as ImageIcon,\n Heading1,\n Heading2,\n Heading3,\n} from \"lucide-react\";\n\nimport { cn } from \"../../../lib/utils\";\n\ninterface RichTextEditorProps {\n value: string;\n onChange: (content: string) => void;\n placeholder?: string;\n height?: number;\n className?: string;\n readOnly?: boolean;\n}\n\nfunction ToolbarButton({\n onClick,\n children,\n title,\n isActive = false,\n}: {\n onClick: () => void;\n children: React.ReactNode;\n title: string;\n isActive?: boolean;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n title={title}\n className={cn(\n \"rounded p-2 transition-colors\",\n isActive ? \"bg-primary text-primary-foreground\" : \"text-muted-foreground hover:bg-muted\",\n )}\n >\n {children}\n </button>\n );\n}\n\nfunction RichTextEditor({\n value,\n onChange,\n placeholder = \"Escribe aquí...\",\n height = 200,\n className = \"\",\n readOnly = false,\n}: RichTextEditorProps) {\n const editor = useEditor({\n extensions: [\n StarterKit,\n TextAlign.configure({\n types: [\"heading\", \"paragraph\"],\n }),\n Color.configure({ types: [TextStyle.name] }),\n TextStyle,\n ImageExtension.configure({\n HTMLAttributes: {\n class: \"max-w-full h-auto rounded-lg\",\n },\n }),\n LinkExtension.configure({\n openOnClick: false,\n }),\n Placeholder.configure({\n placeholder: placeholder,\n }),\n ],\n content: value,\n editable: !readOnly,\n immediatelyRender: false,\n onUpdate: ({ editor: e }) => {\n onChange(e.getHTML());\n },\n editorProps: {\n attributes: {\n class:\n \"prose prose-sm mx-auto focus:outline-none max-w-none\",\n style: `min-height: ${height}px;`,\n },\n },\n });\n\n React.useEffect(() => {\n if (editor && editor.getHTML() !== value) {\n editor.commands.setContent(value);\n }\n }, [value, editor]);\n\n if (!editor) {\n return (\n <div className={cn(\"overflow-hidden rounded-lg border border-border\", className)}>\n <div className=\"flex h-32 animate-pulse items-center justify-center rounded bg-muted text-muted-foreground\">\n Cargando editor...\n </div>\n </div>\n );\n }\n\n return (\n <div\n data-slot=\"rich-text-editor\"\n className={cn(\"overflow-hidden rounded-lg border border-border\", className)}\n >\n {!readOnly && (\n <div className=\"flex flex-wrap gap-1 border-b border-border bg-muted/50 p-2\">\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleHeading({ level: 1 }).run()}\n title=\"Título 1\"\n isActive={editor.isActive(\"heading\", { level: 1 })}\n >\n <Heading1 className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleHeading({ level: 2 }).run()}\n title=\"Título 2\"\n isActive={editor.isActive(\"heading\", { level: 2 })}\n >\n <Heading2 className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleHeading({ level: 3 }).run()}\n title=\"Título 3\"\n isActive={editor.isActive(\"heading\", { level: 3 })}\n >\n <Heading3 className=\"h-4 w-4\" />\n </ToolbarButton>\n <div className=\"mx-1 h-6 w-px bg-border\" />\n\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleBold().run()}\n title=\"Negrita\"\n isActive={editor.isActive(\"bold\")}\n >\n <Bold className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleItalic().run()}\n title=\"Cursiva\"\n isActive={editor.isActive(\"italic\")}\n >\n <Italic className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleStrike().run()}\n title=\"Tachado\"\n isActive={editor.isActive(\"strike\")}\n >\n <Strikethrough className=\"h-4 w-4\" />\n </ToolbarButton>\n <div className=\"mx-1 h-6 w-px bg-border\" />\n\n <div className=\"relative\">\n <input\n type=\"color\"\n className=\"h-8 w-8 cursor-pointer rounded border border-border\"\n onChange={(e) => {\n editor.chain().focus().setColor(e.target.value).run();\n }}\n title=\"Color del texto\"\n />\n </div>\n\n <div className=\"mx-1 h-6 w-px bg-border\" />\n\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleBulletList().run()}\n title=\"Lista con viñetas\"\n isActive={editor.isActive(\"bulletList\")}\n >\n <List className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().toggleOrderedList().run()}\n title=\"Lista numerada\"\n isActive={editor.isActive(\"orderedList\")}\n >\n <ListOrdered className=\"h-4 w-4\" />\n </ToolbarButton>\n <div className=\"mx-1 h-6 w-px bg-border\" />\n\n <ToolbarButton\n onClick={() => editor.chain().focus().setTextAlign(\"left\").run()}\n title=\"Alinear izquierda\"\n isActive={editor.isActive({ textAlign: \"left\" })}\n >\n <AlignLeft className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().setTextAlign(\"center\").run()}\n title=\"Centrar\"\n isActive={editor.isActive({ textAlign: \"center\" })}\n >\n <AlignCenter className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => editor.chain().focus().setTextAlign(\"right\").run()}\n title=\"Alinear derecha\"\n isActive={editor.isActive({ textAlign: \"right\" })}\n >\n <AlignRight className=\"h-4 w-4\" />\n </ToolbarButton>\n <div className=\"mx-1 h-6 w-px bg-border\" />\n\n <ToolbarButton\n onClick={() => {\n const url = prompt(\"Ingresa la URL:\");\n if (url) {\n editor.chain().focus().setLink({ href: url }).run();\n }\n }}\n title=\"Insertar enlace\"\n isActive={editor.isActive(\"link\")}\n >\n <Link className=\"h-4 w-4\" />\n </ToolbarButton>\n <ToolbarButton\n onClick={() => {\n const url = prompt(\"Ingresa la URL de la imagen:\");\n if (url) {\n editor.chain().focus().setImage({ src: url }).run();\n }\n }}\n title=\"Insertar imagen\"\n >\n <ImageIcon className=\"h-4 w-4\" />\n </ToolbarButton>\n </div>\n )}\n <EditorContent\n editor={editor}\n className=\"prose prose-sm max-w-none bg-card p-3\"\n style={{ minHeight: `${height}px` }}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oBAAI,KAAK;AACP,yBAAO,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE,IAAI;AAAA,gBACpD;AAAA,cACF;AAAA,cACA,OAAM;AAAA,cACN,UAAU,OAAO,SAAS,MAAM;AAAA,cAEhC,sDAAC,4BAAK,WAAU,WAAU;AAAA;AAAA,UAC5B;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,SAAS,MAAM;AACb,sBAAM,MAAM,OAAO,8BAA8B;AACjD,oBAAI,KAAK;AACP,yBAAO,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC,EAAE,IAAI;AAAA,gBACpD;AAAA,cACF;AAAA,cACA,OAAM;AAAA,cAEN,sDAAC,oBAAAC,OAAA,EAAU,WAAU,WAAU;AAAA;AAAA,UACjC;AAAA,WACF;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,WAAU;AAAA,YACV,OAAO,EAAE,WAAW,GAAG,MAAM,KAAK;AAAA;AAAA,QACpC;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","StarterKit","TextAlign","Color","ImageExtension","LinkExtension","Placeholder","React","ImageIcon"]}
@@ -1,13 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface RichTextEditorProps {
4
- value: string;
5
- onChange: (content: string) => void;
6
- placeholder?: string;
7
- height?: number;
8
- className?: string;
9
- readOnly?: boolean;
10
- }
11
- declare function RichTextEditor({ value, onChange, placeholder, height, className, readOnly, }: RichTextEditorProps): react_jsx_runtime.JSX.Element;
12
-
13
- export { RichTextEditor, type RichTextEditorProps };
@@ -1,13 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface RichTextEditorProps {
4
- value: string;
5
- onChange: (content: string) => void;
6
- placeholder?: string;
7
- height?: number;
8
- className?: string;
9
- readOnly?: boolean;
10
- }
11
- declare function RichTextEditor({ value, onChange, placeholder, height, className, readOnly, }: RichTextEditorProps): react_jsx_runtime.JSX.Element;
12
-
13
- export { RichTextEditor, type RichTextEditorProps };
@@ -1,262 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import React from "react";
4
- import { useEditor, EditorContent } from "@tiptap/react";
5
- import StarterKit from "@tiptap/starter-kit";
6
- import TextAlign from "@tiptap/extension-text-align";
7
- import Color from "@tiptap/extension-color";
8
- import { TextStyle } from "@tiptap/extension-text-style";
9
- import ImageExtension from "@tiptap/extension-image";
10
- import LinkExtension from "@tiptap/extension-link";
11
- import Placeholder from "@tiptap/extension-placeholder";
12
- import {
13
- Bold,
14
- Italic,
15
- Strikethrough,
16
- List,
17
- ListOrdered,
18
- Link,
19
- AlignLeft,
20
- AlignCenter,
21
- AlignRight,
22
- Image as ImageIcon,
23
- Heading1,
24
- Heading2,
25
- Heading3
26
- } from "lucide-react";
27
- import { cn } from "../../../lib/utils";
28
- function ToolbarButton({
29
- onClick,
30
- children,
31
- title,
32
- isActive = false
33
- }) {
34
- return /* @__PURE__ */ jsx(
35
- "button",
36
- {
37
- type: "button",
38
- onClick,
39
- title,
40
- className: cn(
41
- "rounded p-2 transition-colors",
42
- isActive ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted"
43
- ),
44
- children
45
- }
46
- );
47
- }
48
- function RichTextEditor({
49
- value,
50
- onChange,
51
- placeholder = "Escribe aqu\xED...",
52
- height = 200,
53
- className = "",
54
- readOnly = false
55
- }) {
56
- const editor = useEditor({
57
- extensions: [
58
- StarterKit,
59
- TextAlign.configure({
60
- types: ["heading", "paragraph"]
61
- }),
62
- Color.configure({ types: [TextStyle.name] }),
63
- TextStyle,
64
- ImageExtension.configure({
65
- HTMLAttributes: {
66
- class: "max-w-full h-auto rounded-lg"
67
- }
68
- }),
69
- LinkExtension.configure({
70
- openOnClick: false
71
- }),
72
- Placeholder.configure({
73
- placeholder
74
- })
75
- ],
76
- content: value,
77
- editable: !readOnly,
78
- immediatelyRender: false,
79
- onUpdate: ({ editor: e }) => {
80
- onChange(e.getHTML());
81
- },
82
- editorProps: {
83
- attributes: {
84
- class: "prose prose-sm mx-auto focus:outline-none max-w-none",
85
- style: `min-height: ${height}px;`
86
- }
87
- }
88
- });
89
- React.useEffect(() => {
90
- if (editor && editor.getHTML() !== value) {
91
- editor.commands.setContent(value);
92
- }
93
- }, [value, editor]);
94
- if (!editor) {
95
- return /* @__PURE__ */ jsx("div", { className: cn("overflow-hidden rounded-lg border border-border", className), children: /* @__PURE__ */ jsx("div", { className: "flex h-32 animate-pulse items-center justify-center rounded bg-muted text-muted-foreground", children: "Cargando editor..." }) });
96
- }
97
- return /* @__PURE__ */ jsxs(
98
- "div",
99
- {
100
- "data-slot": "rich-text-editor",
101
- className: cn("overflow-hidden rounded-lg border border-border", className),
102
- children: [
103
- !readOnly && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1 border-b border-border bg-muted/50 p-2", children: [
104
- /* @__PURE__ */ jsx(
105
- ToolbarButton,
106
- {
107
- onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
108
- title: "T\xEDtulo 1",
109
- isActive: editor.isActive("heading", { level: 1 }),
110
- children: /* @__PURE__ */ jsx(Heading1, { className: "h-4 w-4" })
111
- }
112
- ),
113
- /* @__PURE__ */ jsx(
114
- ToolbarButton,
115
- {
116
- onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
117
- title: "T\xEDtulo 2",
118
- isActive: editor.isActive("heading", { level: 2 }),
119
- children: /* @__PURE__ */ jsx(Heading2, { className: "h-4 w-4" })
120
- }
121
- ),
122
- /* @__PURE__ */ jsx(
123
- ToolbarButton,
124
- {
125
- onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
126
- title: "T\xEDtulo 3",
127
- isActive: editor.isActive("heading", { level: 3 }),
128
- children: /* @__PURE__ */ jsx(Heading3, { className: "h-4 w-4" })
129
- }
130
- ),
131
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-border" }),
132
- /* @__PURE__ */ jsx(
133
- ToolbarButton,
134
- {
135
- onClick: () => editor.chain().focus().toggleBold().run(),
136
- title: "Negrita",
137
- isActive: editor.isActive("bold"),
138
- children: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" })
139
- }
140
- ),
141
- /* @__PURE__ */ jsx(
142
- ToolbarButton,
143
- {
144
- onClick: () => editor.chain().focus().toggleItalic().run(),
145
- title: "Cursiva",
146
- isActive: editor.isActive("italic"),
147
- children: /* @__PURE__ */ jsx(Italic, { className: "h-4 w-4" })
148
- }
149
- ),
150
- /* @__PURE__ */ jsx(
151
- ToolbarButton,
152
- {
153
- onClick: () => editor.chain().focus().toggleStrike().run(),
154
- title: "Tachado",
155
- isActive: editor.isActive("strike"),
156
- children: /* @__PURE__ */ jsx(Strikethrough, { className: "h-4 w-4" })
157
- }
158
- ),
159
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-border" }),
160
- /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(
161
- "input",
162
- {
163
- type: "color",
164
- className: "h-8 w-8 cursor-pointer rounded border border-border",
165
- onChange: (e) => {
166
- editor.chain().focus().setColor(e.target.value).run();
167
- },
168
- title: "Color del texto"
169
- }
170
- ) }),
171
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-border" }),
172
- /* @__PURE__ */ jsx(
173
- ToolbarButton,
174
- {
175
- onClick: () => editor.chain().focus().toggleBulletList().run(),
176
- title: "Lista con vi\xF1etas",
177
- isActive: editor.isActive("bulletList"),
178
- children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
179
- }
180
- ),
181
- /* @__PURE__ */ jsx(
182
- ToolbarButton,
183
- {
184
- onClick: () => editor.chain().focus().toggleOrderedList().run(),
185
- title: "Lista numerada",
186
- isActive: editor.isActive("orderedList"),
187
- children: /* @__PURE__ */ jsx(ListOrdered, { className: "h-4 w-4" })
188
- }
189
- ),
190
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-border" }),
191
- /* @__PURE__ */ jsx(
192
- ToolbarButton,
193
- {
194
- onClick: () => editor.chain().focus().setTextAlign("left").run(),
195
- title: "Alinear izquierda",
196
- isActive: editor.isActive({ textAlign: "left" }),
197
- children: /* @__PURE__ */ jsx(AlignLeft, { className: "h-4 w-4" })
198
- }
199
- ),
200
- /* @__PURE__ */ jsx(
201
- ToolbarButton,
202
- {
203
- onClick: () => editor.chain().focus().setTextAlign("center").run(),
204
- title: "Centrar",
205
- isActive: editor.isActive({ textAlign: "center" }),
206
- children: /* @__PURE__ */ jsx(AlignCenter, { className: "h-4 w-4" })
207
- }
208
- ),
209
- /* @__PURE__ */ jsx(
210
- ToolbarButton,
211
- {
212
- onClick: () => editor.chain().focus().setTextAlign("right").run(),
213
- title: "Alinear derecha",
214
- isActive: editor.isActive({ textAlign: "right" }),
215
- children: /* @__PURE__ */ jsx(AlignRight, { className: "h-4 w-4" })
216
- }
217
- ),
218
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-border" }),
219
- /* @__PURE__ */ jsx(
220
- ToolbarButton,
221
- {
222
- onClick: () => {
223
- const url = prompt("Ingresa la URL:");
224
- if (url) {
225
- editor.chain().focus().setLink({ href: url }).run();
226
- }
227
- },
228
- title: "Insertar enlace",
229
- isActive: editor.isActive("link"),
230
- children: /* @__PURE__ */ jsx(Link, { className: "h-4 w-4" })
231
- }
232
- ),
233
- /* @__PURE__ */ jsx(
234
- ToolbarButton,
235
- {
236
- onClick: () => {
237
- const url = prompt("Ingresa la URL de la imagen:");
238
- if (url) {
239
- editor.chain().focus().setImage({ src: url }).run();
240
- }
241
- },
242
- title: "Insertar imagen",
243
- children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-4 w-4" })
244
- }
245
- )
246
- ] }),
247
- /* @__PURE__ */ jsx(
248
- EditorContent,
249
- {
250
- editor,
251
- className: "prose prose-sm max-w-none bg-card p-3",
252
- style: { minHeight: `${height}px` }
253
- }
254
- )
255
- ]
256
- }
257
- );
258
- }
259
- export {
260
- RichTextEditor
261
- };
262
- //# sourceMappingURL=rich-text-editor.js.map