@iclips/ui 4.2.0 → 4.4.0
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/components/ui/data/document-editor.cjs +1 -1
- package/dist/components/ui/data/document-editor.cjs.map +1 -1
- package/dist/components/ui/data/document-editor.js +175 -169
- package/dist/components/ui/data/document-editor.js.map +1 -1
- package/dist/components/ui/forms/month-range-picker.cjs +1 -1
- package/dist/components/ui/forms/month-range-picker.cjs.map +1 -1
- package/dist/components/ui/forms/month-range-picker.js +180 -155
- package/dist/components/ui/forms/month-range-picker.js.map +1 -1
- package/dist/components/ui/forms/number-input.cjs +1 -1
- package/dist/components/ui/forms/number-input.cjs.map +1 -1
- package/dist/components/ui/forms/number-input.js +123 -110
- package/dist/components/ui/forms/number-input.js.map +1 -1
- package/dist/editor.d.cts +9 -1
- package/dist/editor.d.ts +9 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/docs/formularios.md +1 -1
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsxs as u, jsx as e, Fragment as
|
|
2
|
-
import * as
|
|
3
|
-
import { useEditor as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { TableKit as
|
|
10
|
-
import { cn as
|
|
11
|
-
import { Button as
|
|
12
|
-
import { Separator as
|
|
13
|
-
import { Undo as
|
|
14
|
-
import { Toggle as
|
|
15
|
-
import { Select as
|
|
16
|
-
import { DropdownMenu as
|
|
17
|
-
import { Tooltip as
|
|
18
|
-
import { toast as
|
|
19
|
-
const
|
|
1
|
+
import { jsxs as u, jsx as e, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import * as P from "react";
|
|
3
|
+
import { useEditor as re, EditorContent as ne } from "@tiptap/react";
|
|
4
|
+
import ae from "@tiptap/starter-kit";
|
|
5
|
+
import K from "@tiptap/extension-image";
|
|
6
|
+
import oe from "@tiptap/extension-placeholder";
|
|
7
|
+
import le from "@tiptap/extension-text-align";
|
|
8
|
+
import se from "@tiptap/extension-file-handler";
|
|
9
|
+
import { TableKit as ce } from "@tiptap/extension-table";
|
|
10
|
+
import { cn as L } from "../utils.js";
|
|
11
|
+
import { Button as U } from "../primitives/button.js";
|
|
12
|
+
import { Separator as E } from "../primitives/separator.js";
|
|
13
|
+
import { Undo as ue, Redo as me, Bold as he, Italic as de, Underline as ge, Strikethrough as fe, List as pe, ListOrdered as be, AlignLeft as Ae, AlignCenter as we, AlignRight as xe, Quote as ve, Link as Me, Table as Ne, Image as j, Minus as ke, Plus as Te } from "lucide-react";
|
|
14
|
+
import { Toggle as Le } from "../forms/toggle.js";
|
|
15
|
+
import { Select as Ie, SelectTrigger as Pe, SelectValue as Ce, SelectContent as _e, SelectItem as Se } from "../forms/select.js";
|
|
16
|
+
import { DropdownMenu as Re, DropdownMenuTrigger as Ee, DropdownMenuContent as ye, DropdownMenuItem as T, DropdownMenuSeparator as W } from "../overlays/dropdown-menu.js";
|
|
17
|
+
import { Tooltip as z, TooltipTrigger as H, TooltipContent as O } from "../overlays/tooltip.js";
|
|
18
|
+
import { toast as F } from "../feedback/toast.js";
|
|
19
|
+
const q = 96 / 2.54, ze = Math.round(5 * q), He = Math.round(2 * q), J = Math.round(1 * q), Oe = ["image/png", "image/jpeg", "image/webp"], De = 2 * 1024 * 1024, Q = 0.1, w = {
|
|
20
20
|
larguraPx: 794,
|
|
21
21
|
alturaMinPx: 1123,
|
|
22
22
|
margemPx: 40 / 72 * 96
|
|
23
|
-
},
|
|
24
|
-
function
|
|
23
|
+
}, A = Math.round(w.larguraPx - 2 * w.margemPx), Fe = `${(11 / 0.75 / w.larguraPx * 100).toFixed(3)}cqw`, Ue = `${((w.alturaMinPx - 2 * w.margemPx) / w.larguraPx * 100).toFixed(3)}cqw`, qe = `${(w.margemPx / w.larguraPx * 100).toFixed(3)}cqw`;
|
|
24
|
+
function V(t) {
|
|
25
25
|
if (t == null) return null;
|
|
26
26
|
const i = Number.parseInt(t, 10);
|
|
27
27
|
return Number.isFinite(i) && i > 0 ? i : null;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const Be = ["left", "center", "right"], Ge = K.extend({
|
|
30
30
|
addAttributes() {
|
|
31
31
|
var t;
|
|
32
32
|
return {
|
|
@@ -37,25 +37,25 @@ const Ue = ["left", "center", "right"], qe = Q.extend({
|
|
|
37
37
|
default: null,
|
|
38
38
|
parseHTML: (i) => {
|
|
39
39
|
const r = i.getAttribute("data-align");
|
|
40
|
-
return
|
|
40
|
+
return Be.includes(r ?? "") && r !== "left" ? r : null;
|
|
41
41
|
},
|
|
42
42
|
renderHTML: (i) => i.align ? { "data-align": i.align } : {}
|
|
43
43
|
},
|
|
44
44
|
width: {
|
|
45
45
|
default: null,
|
|
46
|
-
parseHTML: (i) =>
|
|
46
|
+
parseHTML: (i) => V(i.getAttribute("width")),
|
|
47
47
|
renderHTML: (i) => {
|
|
48
48
|
const r = Number(i.width);
|
|
49
|
-
return !Number.isFinite(r) || r <= 0 ? {} : { width: Math.min(Math.round(r),
|
|
49
|
+
return !Number.isFinite(r) || r <= 0 ? {} : { width: Math.min(Math.round(r), A) };
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
height: {
|
|
53
53
|
default: null,
|
|
54
|
-
parseHTML: (i) =>
|
|
54
|
+
parseHTML: (i) => V(i.getAttribute("height")),
|
|
55
55
|
renderHTML: (i) => {
|
|
56
56
|
const r = Number(i.width), a = Number(i.height);
|
|
57
57
|
if (!Number.isFinite(a) || a <= 0) return {};
|
|
58
|
-
const n = Number.isFinite(r) && r >
|
|
58
|
+
const n = Number.isFinite(r) && r > A ? A / r : 1;
|
|
59
59
|
return { height: Math.round(a * n) };
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -67,16 +67,16 @@ const Ue = ["left", "center", "right"], qe = Q.extend({
|
|
|
67
67
|
var i;
|
|
68
68
|
const t = (i = this.parent) == null ? void 0 : i.call(this);
|
|
69
69
|
return t ? (r) => {
|
|
70
|
-
var
|
|
70
|
+
var g;
|
|
71
71
|
const a = t(r), n = a;
|
|
72
|
-
("maxSize" in n || "minSize" in n) && (n.maxSize = { ...n.maxSize, width:
|
|
72
|
+
("maxSize" in n || "minSize" in n) && (n.maxSize = { ...n.maxSize, width: A }, a.dom.addEventListener(
|
|
73
73
|
"mousedown",
|
|
74
74
|
() => {
|
|
75
75
|
var l;
|
|
76
76
|
const s = (l = a.dom.closest(".ProseMirror")) == null ? void 0 : l.clientWidth;
|
|
77
77
|
n.maxSize = {
|
|
78
78
|
...n.maxSize,
|
|
79
|
-
width: s ? Math.min(
|
|
79
|
+
width: s ? Math.min(A, s) : A
|
|
80
80
|
};
|
|
81
81
|
},
|
|
82
82
|
!0
|
|
@@ -84,9 +84,9 @@ const Ue = ["left", "center", "right"], qe = Q.extend({
|
|
|
84
84
|
const m = (s, l) => {
|
|
85
85
|
const h = a.dom.querySelector("img");
|
|
86
86
|
if (!h || !s || !l) return;
|
|
87
|
-
const
|
|
88
|
-
h.style.width = `${Math.round(s *
|
|
89
|
-
}, p = (
|
|
87
|
+
const x = s > A ? A / s : 1;
|
|
88
|
+
h.style.width = `${Math.round(s * x)}px`, h.style.height = `${Math.round(l * x)}px`;
|
|
89
|
+
}, p = (g = a.update) == null ? void 0 : g.bind(a);
|
|
90
90
|
return a.update = (s, ...l) => {
|
|
91
91
|
const h = p ? p(s, ...l) : !0;
|
|
92
92
|
return h && m(s.attrs.width, s.attrs.height), h;
|
|
@@ -94,7 +94,7 @@ const Ue = ["left", "center", "right"], qe = Q.extend({
|
|
|
94
94
|
} : null;
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
-
async function
|
|
97
|
+
async function $e(t) {
|
|
98
98
|
var i;
|
|
99
99
|
if (typeof createImageBitmap != "function") return null;
|
|
100
100
|
try {
|
|
@@ -104,11 +104,11 @@ async function Be(t) {
|
|
|
104
104
|
return null;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function Xe(t, i) {
|
|
108
108
|
const r = t.largura / t.altura, a = Math.min(t.largura, i.width, i.maxHeight * r), n = Math.max(1, Math.round(a));
|
|
109
109
|
return { width: n, height: Math.max(1, Math.round(n / r)) };
|
|
110
110
|
}
|
|
111
|
-
const
|
|
111
|
+
const d = ({
|
|
112
112
|
onClick: t,
|
|
113
113
|
isActive: i = !1,
|
|
114
114
|
disabled: r = !1,
|
|
@@ -117,7 +117,7 @@ const g = ({
|
|
|
117
117
|
tooltip: m = !1
|
|
118
118
|
}) => {
|
|
119
119
|
const p = /* @__PURE__ */ e(
|
|
120
|
-
|
|
120
|
+
Le,
|
|
121
121
|
{
|
|
122
122
|
pressed: i,
|
|
123
123
|
onPressedChange: t,
|
|
@@ -129,38 +129,38 @@ const g = ({
|
|
|
129
129
|
children: a
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
|
-
return !m || !n ? p : /* @__PURE__ */ u(
|
|
133
|
-
/* @__PURE__ */ e(
|
|
134
|
-
/* @__PURE__ */ e(
|
|
132
|
+
return !m || !n ? p : /* @__PURE__ */ u(z, { children: [
|
|
133
|
+
/* @__PURE__ */ e(H, { asChild: !0, children: p }),
|
|
134
|
+
/* @__PURE__ */ e(O, { children: n })
|
|
135
135
|
] });
|
|
136
|
-
},
|
|
136
|
+
}, y = ({
|
|
137
137
|
onClick: t,
|
|
138
138
|
disabled: i,
|
|
139
139
|
label: r,
|
|
140
140
|
tooltip: a,
|
|
141
141
|
children: n
|
|
142
142
|
}) => {
|
|
143
|
-
const m = /* @__PURE__ */ e(
|
|
144
|
-
return a ? /* @__PURE__ */ u(
|
|
145
|
-
/* @__PURE__ */ e(
|
|
146
|
-
/* @__PURE__ */ e(
|
|
143
|
+
const m = /* @__PURE__ */ e(U, { variant: "ghost", size: "icon", className: "h-8 w-8", onClick: t, disabled: i, "aria-label": r, children: n });
|
|
144
|
+
return a ? /* @__PURE__ */ u(z, { children: [
|
|
145
|
+
/* @__PURE__ */ e(H, { asChild: !0, children: m }),
|
|
146
|
+
/* @__PURE__ */ e(O, { children: r })
|
|
147
147
|
] }) : m;
|
|
148
|
-
},
|
|
148
|
+
}, je = [
|
|
149
149
|
{ valor: "paragraph", rotulo: "Parágrafo" },
|
|
150
150
|
{ valor: "h1", rotulo: "Título 1" },
|
|
151
151
|
{ valor: "h2", rotulo: "Título 2" },
|
|
152
152
|
{ valor: "h3", rotulo: "Título 3" }
|
|
153
153
|
];
|
|
154
|
-
function
|
|
154
|
+
function We(t) {
|
|
155
155
|
for (const i of [1, 2, 3])
|
|
156
156
|
if (t.isActive("heading", { level: i })) return `h${i}`;
|
|
157
157
|
return "paragraph";
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function Qe(t, i) {
|
|
160
160
|
const r = t.chain().focus();
|
|
161
161
|
i === "paragraph" ? r.setParagraph().run() : r.setHeading({ level: Number(i.slice(1)) }).run();
|
|
162
162
|
}
|
|
163
|
-
const
|
|
163
|
+
const Ve = ({
|
|
164
164
|
editor: t,
|
|
165
165
|
variant: i,
|
|
166
166
|
onPickImage: r,
|
|
@@ -168,84 +168,84 @@ const We = ({
|
|
|
168
168
|
}) => {
|
|
169
169
|
if (!t) return null;
|
|
170
170
|
const n = i === "full", m = () => {
|
|
171
|
-
const o = t.getAttributes("link").href,
|
|
172
|
-
if (
|
|
173
|
-
if (
|
|
171
|
+
const o = t.getAttributes("link").href, b = window.prompt("URL", o);
|
|
172
|
+
if (b !== null) {
|
|
173
|
+
if (b === "") {
|
|
174
174
|
t.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
|
-
t.chain().focus().extendMarkRange("link").setLink({ href:
|
|
177
|
+
t.chain().focus().extendMarkRange("link").setLink({ href: b }).run();
|
|
178
178
|
}
|
|
179
179
|
}, p = () => {
|
|
180
180
|
const o = window.prompt("URL da imagem");
|
|
181
181
|
o && t.chain().focus().setImage({ src: o }).run();
|
|
182
|
-
},
|
|
183
|
-
const { width:
|
|
184
|
-
if (!
|
|
185
|
-
const
|
|
186
|
-
t.chain().focus().updateAttributes("image", { width:
|
|
187
|
-
}, l = t.isActive("table"), h = (o) =>
|
|
188
|
-
|
|
182
|
+
}, g = t.isActive("image"), s = (o) => {
|
|
183
|
+
const { width: b, height: f } = t.getAttributes("image");
|
|
184
|
+
if (!b || !f) return;
|
|
185
|
+
const M = Math.min(A, Math.max(J, Math.round(b * o)));
|
|
186
|
+
t.chain().focus().updateAttributes("image", { width: M, height: Math.round(f * M / b) }).run();
|
|
187
|
+
}, l = t.isActive("table"), h = (o) => g ? (t.getAttributes("image").align ?? "left") === o : t.isActive({ textAlign: o }), x = (o) => {
|
|
188
|
+
g ? t.chain().focus().updateAttributes("image", { align: o === "left" ? null : o }).run() : t.chain().focus().setTextAlign(o).run();
|
|
189
189
|
};
|
|
190
|
-
return /* @__PURE__ */ u("div", { className:
|
|
190
|
+
return /* @__PURE__ */ u("div", { className: L(
|
|
191
191
|
"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30 sticky top-0 z-10",
|
|
192
192
|
n ? "px-4 py-2" : "px-2 py-1"
|
|
193
193
|
), children: [
|
|
194
194
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-0.5 mr-2", children: [
|
|
195
|
-
/* @__PURE__ */ e(
|
|
196
|
-
/* @__PURE__ */ e(
|
|
195
|
+
/* @__PURE__ */ e(y, { tooltip: n, label: "Desfazer", onClick: () => t.chain().focus().undo().run(), disabled: !t.can().undo(), children: /* @__PURE__ */ e(ue, { className: "h-4 w-4" }) }),
|
|
196
|
+
/* @__PURE__ */ e(y, { tooltip: n, label: "Refazer", onClick: () => t.chain().focus().redo().run(), disabled: !t.can().redo(), children: /* @__PURE__ */ e(me, { className: "h-4 w-4" }) })
|
|
197
197
|
] }),
|
|
198
|
-
/* @__PURE__ */ e(
|
|
199
|
-
n && /* @__PURE__ */ u(
|
|
200
|
-
/* @__PURE__ */ u(
|
|
201
|
-
/* @__PURE__ */ e(
|
|
202
|
-
/* @__PURE__ */ e(
|
|
198
|
+
/* @__PURE__ */ e(E, { orientation: "vertical", className: "h-6 mx-1" }),
|
|
199
|
+
n && /* @__PURE__ */ u(D, { children: [
|
|
200
|
+
/* @__PURE__ */ u(Ie, { value: We(t), onValueChange: (o) => Qe(t, o), children: [
|
|
201
|
+
/* @__PURE__ */ e(Pe, { size: "sm", className: "w-[130px]", "aria-label": "Estilo do texto", children: /* @__PURE__ */ e(Ce, {}) }),
|
|
202
|
+
/* @__PURE__ */ e(_e, { children: je.map((o) => /* @__PURE__ */ e(Se, { value: o.valor, children: o.rotulo }, o.valor)) })
|
|
203
203
|
] }),
|
|
204
|
-
/* @__PURE__ */ e(
|
|
204
|
+
/* @__PURE__ */ e(E, { orientation: "vertical", className: "h-6 mx-1" })
|
|
205
205
|
] }),
|
|
206
|
-
/* @__PURE__ */ e(
|
|
207
|
-
/* @__PURE__ */ e(
|
|
208
|
-
/* @__PURE__ */ e(
|
|
209
|
-
n && /* @__PURE__ */ e(
|
|
210
|
-
/* @__PURE__ */ e(
|
|
211
|
-
/* @__PURE__ */ e(
|
|
212
|
-
/* @__PURE__ */ e(
|
|
213
|
-
n && /* @__PURE__ */ u(
|
|
214
|
-
/* @__PURE__ */ e(
|
|
215
|
-
/* @__PURE__ */ e(
|
|
216
|
-
/* @__PURE__ */ e(
|
|
206
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: () => t.chain().focus().toggleBold().run(), isActive: t.isActive("bold"), title: "Negrito", children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) }),
|
|
207
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: () => t.chain().focus().toggleItalic().run(), isActive: t.isActive("italic"), title: "Itálico", children: /* @__PURE__ */ e(de, { className: "h-4 w-4" }) }),
|
|
208
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: () => t.chain().focus().toggleUnderline().run(), isActive: t.isActive("underline"), title: "Sublinhado", children: /* @__PURE__ */ e(ge, { className: "h-4 w-4" }) }),
|
|
209
|
+
n && /* @__PURE__ */ e(d, { tooltip: !0, onClick: () => t.chain().focus().toggleStrike().run(), isActive: t.isActive("strike"), title: "Tachado", children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" }) }),
|
|
210
|
+
/* @__PURE__ */ e(E, { orientation: "vertical", className: "h-6 mx-1" }),
|
|
211
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: () => t.chain().focus().toggleBulletList().run(), isActive: t.isActive("bulletList"), title: "Lista com marcadores", children: /* @__PURE__ */ e(pe, { className: "h-4 w-4" }) }),
|
|
212
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: () => t.chain().focus().toggleOrderedList().run(), isActive: t.isActive("orderedList"), title: "Lista numerada", children: /* @__PURE__ */ e(be, { className: "h-4 w-4" }) }),
|
|
213
|
+
n && /* @__PURE__ */ u(D, { children: [
|
|
214
|
+
/* @__PURE__ */ e(d, { tooltip: !0, onClick: () => x("left"), isActive: h("left"), title: "Alinhar à esquerda", children: /* @__PURE__ */ e(Ae, { className: "h-4 w-4" }) }),
|
|
215
|
+
/* @__PURE__ */ e(d, { tooltip: !0, onClick: () => x("center"), isActive: h("center"), title: "Centralizar", children: /* @__PURE__ */ e(we, { className: "h-4 w-4" }) }),
|
|
216
|
+
/* @__PURE__ */ e(d, { tooltip: !0, onClick: () => x("right"), isActive: h("right"), title: "Alinhar à direita", children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" }) })
|
|
217
217
|
] }),
|
|
218
|
-
/* @__PURE__ */ e(
|
|
219
|
-
/* @__PURE__ */ e(
|
|
220
|
-
/* @__PURE__ */ e(
|
|
221
|
-
n && /* @__PURE__ */ u(
|
|
222
|
-
/* @__PURE__ */ u(
|
|
223
|
-
/* @__PURE__ */ e(
|
|
224
|
-
/* @__PURE__ */ e(
|
|
218
|
+
/* @__PURE__ */ e(E, { orientation: "vertical", className: "h-6 mx-1" }),
|
|
219
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: () => t.chain().focus().toggleBlockquote().run(), isActive: t.isActive("blockquote"), title: "Citação", children: /* @__PURE__ */ e(ve, { className: "h-4 w-4" }) }),
|
|
220
|
+
/* @__PURE__ */ e(d, { tooltip: n, onClick: m, isActive: t.isActive("link"), title: "Link", children: /* @__PURE__ */ e(Me, { className: "h-4 w-4" }) }),
|
|
221
|
+
n && /* @__PURE__ */ u(Re, { children: [
|
|
222
|
+
/* @__PURE__ */ u(z, { children: [
|
|
223
|
+
/* @__PURE__ */ e(H, { asChild: !0, children: /* @__PURE__ */ e(Ee, { asChild: !0, children: /* @__PURE__ */ e(U, { variant: "ghost", size: "icon", className: L("h-8 w-8", l && "bg-secondary text-secondary-foreground"), "aria-label": "Tabela", children: /* @__PURE__ */ e(Ne, { className: "h-4 w-4" }) }) }) }),
|
|
224
|
+
/* @__PURE__ */ e(O, { children: "Tabela" })
|
|
225
225
|
] }),
|
|
226
|
-
/* @__PURE__ */ u(
|
|
227
|
-
/* @__PURE__ */ e(
|
|
228
|
-
/* @__PURE__ */ e(
|
|
229
|
-
/* @__PURE__ */ e(
|
|
230
|
-
/* @__PURE__ */ e(
|
|
231
|
-
/* @__PURE__ */ e(
|
|
232
|
-
/* @__PURE__ */ e(
|
|
233
|
-
/* @__PURE__ */ e(
|
|
234
|
-
/* @__PURE__ */ e(
|
|
226
|
+
/* @__PURE__ */ u(ye, { align: "start", children: [
|
|
227
|
+
/* @__PURE__ */ e(T, { onSelect: () => t.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run(), children: "Inserir tabela" }),
|
|
228
|
+
/* @__PURE__ */ e(W, {}),
|
|
229
|
+
/* @__PURE__ */ e(T, { disabled: !l, onSelect: () => t.chain().focus().addRowAfter().run(), children: "Adicionar linha" }),
|
|
230
|
+
/* @__PURE__ */ e(T, { disabled: !l, onSelect: () => t.chain().focus().addColumnAfter().run(), children: "Adicionar coluna" }),
|
|
231
|
+
/* @__PURE__ */ e(T, { disabled: !l, onSelect: () => t.chain().focus().deleteRow().run(), children: "Remover linha" }),
|
|
232
|
+
/* @__PURE__ */ e(T, { disabled: !l, onSelect: () => t.chain().focus().deleteColumn().run(), children: "Remover coluna" }),
|
|
233
|
+
/* @__PURE__ */ e(W, {}),
|
|
234
|
+
/* @__PURE__ */ e(T, { disabled: !l, onSelect: () => t.chain().focus().deleteTable().run(), children: "Remover tabela" })
|
|
235
235
|
] })
|
|
236
236
|
] }),
|
|
237
|
-
n && r && /* @__PURE__ */ u(
|
|
238
|
-
/* @__PURE__ */ u(
|
|
239
|
-
/* @__PURE__ */ e(
|
|
240
|
-
/* @__PURE__ */ e(
|
|
237
|
+
n && r && /* @__PURE__ */ u(D, { children: [
|
|
238
|
+
/* @__PURE__ */ u(z, { children: [
|
|
239
|
+
/* @__PURE__ */ e(H, { asChild: !0, children: /* @__PURE__ */ e(U, { variant: "ghost", size: "icon", className: "h-8 w-8", onClick: r, "aria-label": "Inserir imagem", children: /* @__PURE__ */ e(j, { className: "h-4 w-4" }) }) }),
|
|
240
|
+
/* @__PURE__ */ e(O, { className: "max-w-64", children: a ?? "Inserir imagem" })
|
|
241
241
|
] }),
|
|
242
|
-
/* @__PURE__ */ e(
|
|
243
|
-
/* @__PURE__ */ e(
|
|
242
|
+
/* @__PURE__ */ e(y, { tooltip: !0, label: "Diminuir imagem", onClick: () => s(1 - Q), disabled: !g, children: /* @__PURE__ */ e(ke, { className: "h-4 w-4" }) }),
|
|
243
|
+
/* @__PURE__ */ e(y, { tooltip: !0, label: "Aumentar imagem", onClick: () => s(1 + Q), disabled: !g, children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" }) })
|
|
244
244
|
] }),
|
|
245
|
-
n && !r && /* @__PURE__ */ e(
|
|
245
|
+
n && !r && /* @__PURE__ */ e(d, { tooltip: !0, onClick: p, title: "Imagem", children: /* @__PURE__ */ e(j, { className: "h-4 w-4" }) })
|
|
246
246
|
] });
|
|
247
247
|
};
|
|
248
|
-
function
|
|
248
|
+
function dt({
|
|
249
249
|
content: t = "",
|
|
250
250
|
onChange: i,
|
|
251
251
|
placeholder: r = "Comece a escrever...",
|
|
@@ -253,59 +253,60 @@ function mt({
|
|
|
253
253
|
className: n,
|
|
254
254
|
readOnly: m = !1,
|
|
255
255
|
label: p,
|
|
256
|
-
onImageUpload:
|
|
256
|
+
onImageUpload: g,
|
|
257
257
|
imageDefaults: s,
|
|
258
|
-
imageAcceptedTypes: l =
|
|
259
|
-
imageMaxBytes: h =
|
|
260
|
-
imageHint:
|
|
261
|
-
page: o
|
|
258
|
+
imageAcceptedTypes: l = Oe,
|
|
259
|
+
imageMaxBytes: h = De,
|
|
260
|
+
imageHint: x,
|
|
261
|
+
page: o,
|
|
262
|
+
onReady: b
|
|
262
263
|
}) {
|
|
263
|
-
const
|
|
264
|
+
const f = a === "full", M = f && o === "a4", B = s ?? { width: ze, maxHeight: He }, Y = B.width, Z = B.maxHeight, C = f && !!g, _ = P.useRef(async () => {
|
|
264
265
|
});
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
for (const
|
|
268
|
-
if (!l.includes(
|
|
269
|
-
|
|
266
|
+
_.current = async (c, v, I) => {
|
|
267
|
+
if (g)
|
|
268
|
+
for (const k of v) {
|
|
269
|
+
if (!l.includes(k.type)) {
|
|
270
|
+
F.error("Imagem não inserida", { description: "Use uma imagem PNG, JPG ou WEBP." });
|
|
270
271
|
continue;
|
|
271
272
|
}
|
|
272
|
-
if (
|
|
273
|
-
|
|
273
|
+
if (k.size > h) {
|
|
274
|
+
F.error("Imagem não inserida", {
|
|
274
275
|
description: `A imagem deve ter no máximo ${Math.round(h / 1024 / 1024)} MB.`
|
|
275
276
|
});
|
|
276
277
|
continue;
|
|
277
278
|
}
|
|
278
279
|
try {
|
|
279
|
-
const [
|
|
280
|
-
|
|
281
|
-
} catch (
|
|
282
|
-
|
|
280
|
+
const [R, X] = await Promise.all([g(k), $e(k)]), ie = X ? Xe(X, { width: Y, maxHeight: Z }) : {};
|
|
281
|
+
c.chain().insertContentAt(I ?? c.state.selection.anchor, { type: "image", attrs: { src: R, ...ie } }).focus().run();
|
|
282
|
+
} catch (R) {
|
|
283
|
+
F.error("Não foi possível inserir a imagem", { description: R instanceof Error ? R.message : void 0 });
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
286
|
};
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
|
|
287
|
+
const ee = P.useMemo(() => {
|
|
288
|
+
const c = f ? [
|
|
289
|
+
Ge.configure({
|
|
289
290
|
allowBase64: !0,
|
|
290
291
|
HTMLAttributes: { class: "max-w-full h-auto" },
|
|
291
292
|
resize: {
|
|
292
293
|
enabled: !0,
|
|
293
294
|
directions: ["top-left", "top-right", "bottom-left", "bottom-right"],
|
|
294
|
-
minWidth:
|
|
295
|
+
minWidth: J,
|
|
295
296
|
minHeight: 1,
|
|
296
297
|
alwaysPreserveAspectRatio: !0
|
|
297
298
|
}
|
|
298
299
|
}),
|
|
299
|
-
|
|
300
|
+
ce.configure({ table: { resizable: !0 } })
|
|
300
301
|
] : [
|
|
301
|
-
|
|
302
|
+
K.configure({
|
|
302
303
|
HTMLAttributes: {
|
|
303
304
|
class: "rounded-lg border shadow-sm max-w-full"
|
|
304
305
|
}
|
|
305
306
|
})
|
|
306
307
|
];
|
|
307
308
|
return [
|
|
308
|
-
|
|
309
|
+
ae.configure({
|
|
309
310
|
heading: {
|
|
310
311
|
levels: [1, 2, 3]
|
|
311
312
|
}
|
|
@@ -319,98 +320,103 @@ function mt({
|
|
|
319
320
|
// class: 'text-primary underline decoration-primary/30 hover:decoration-primary transition-colors cursor-pointer',
|
|
320
321
|
// },
|
|
321
322
|
// }),
|
|
322
|
-
...
|
|
323
|
-
|
|
323
|
+
...c,
|
|
324
|
+
oe.configure({
|
|
324
325
|
placeholder: r
|
|
325
326
|
}),
|
|
326
|
-
|
|
327
|
+
le.configure({
|
|
327
328
|
types: ["heading", "paragraph"]
|
|
328
329
|
}),
|
|
329
|
-
...
|
|
330
|
-
|
|
330
|
+
...C ? [
|
|
331
|
+
se.configure({
|
|
331
332
|
allowedMimeTypes: l,
|
|
332
|
-
onDrop: (
|
|
333
|
-
|
|
333
|
+
onDrop: (v, I, k) => {
|
|
334
|
+
_.current(v, I, k);
|
|
334
335
|
},
|
|
335
|
-
onPaste: (
|
|
336
|
-
|
|
336
|
+
onPaste: (v, I) => {
|
|
337
|
+
_.current(v, I);
|
|
337
338
|
}
|
|
338
339
|
})
|
|
339
340
|
] : []
|
|
340
341
|
];
|
|
341
|
-
}, [r,
|
|
342
|
-
extensions:
|
|
342
|
+
}, [r, f, C, l.join(",")]), N = re({
|
|
343
|
+
extensions: ee,
|
|
343
344
|
content: t,
|
|
344
345
|
editable: !m,
|
|
345
346
|
shouldRerenderOnTransaction: !0,
|
|
346
|
-
onUpdate: ({ editor:
|
|
347
|
-
i == null || i(
|
|
347
|
+
onUpdate: ({ editor: c }) => {
|
|
348
|
+
i == null || i(c.getHTML());
|
|
348
349
|
},
|
|
349
350
|
editorProps: {
|
|
350
351
|
attributes: {
|
|
351
|
-
class:
|
|
352
|
-
|
|
352
|
+
class: L(
|
|
353
|
+
M ? "prose prose-stone max-w-none focus:outline-none" : "prose prose-stone dark:prose-invert max-w-none focus:outline-none",
|
|
353
354
|
"prose-headings:font-semibold prose-headings:tracking-tight",
|
|
354
355
|
"prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl",
|
|
355
356
|
"prose-p:leading-7 prose-p:my-3",
|
|
356
357
|
"prose-blockquote:border-l-4 prose-blockquote:border-primary/50 prose-blockquote:pl-4 prose-blockquote:italic",
|
|
357
358
|
"prose-ul:list-disc prose-ul:pl-6 prose-ol:list-decimal prose-ol:pl-6",
|
|
358
|
-
!
|
|
359
|
+
!f && "prose-img:rounded-lg prose-img:shadow-md prose-img:my-6",
|
|
359
360
|
// O contêiner do node view de redimensionamento é um flex: o alinhamento da imagem é dele.
|
|
360
|
-
|
|
361
|
-
|
|
361
|
+
f && "[&_[data-resize-container]:has([data-align=center])]:justify-center [&_[data-resize-container]:has([data-align=right])]:justify-end",
|
|
362
|
+
M ? void 0 : f ? "min-h-[400px] p-8" : "min-h-[120px] px-3 py-2"
|
|
362
363
|
),
|
|
363
|
-
...
|
|
364
|
+
...M ? { style: `font-size: ${Fe}; min-height: ${Ue}` } : {}
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
|
-
}),
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
367
|
+
}), S = P.useRef(b);
|
|
368
|
+
S.current = b, P.useEffect(() => {
|
|
369
|
+
var c;
|
|
370
|
+
N && ((c = S.current) == null || c.call(S, N));
|
|
371
|
+
}, [N]);
|
|
372
|
+
const G = P.useRef(null);
|
|
373
|
+
if (!N) return null;
|
|
374
|
+
const te = C ? () => {
|
|
375
|
+
var c;
|
|
376
|
+
return (c = G.current) == null ? void 0 : c.click();
|
|
377
|
+
} : void 0, $ = /* @__PURE__ */ e(ne, { editor: N });
|
|
378
|
+
return /* @__PURE__ */ u("div", { "data-slot": "document-editor", className: L("flex flex-col w-full", n), children: [
|
|
373
379
|
p && /* @__PURE__ */ e("label", { className: "text-sm font-medium mb-1.5 block", children: p }),
|
|
374
|
-
/* @__PURE__ */ u("div", { className:
|
|
380
|
+
/* @__PURE__ */ u("div", { className: L(
|
|
375
381
|
// flex-1/min-h-0: se o consumidor limita a altura (className="h-full"), a folha rola por dentro e a barra fica fixa.
|
|
376
382
|
"flex flex-col flex-1 min-h-0 border rounded-lg bg-background overflow-hidden transition-shadow focus-within:ring-2 focus-within:ring-primary/20",
|
|
377
383
|
m && "opacity-80 bg-muted/30 pointer-events-none border-transparent"
|
|
378
384
|
), children: [
|
|
379
|
-
!m && /* @__PURE__ */ e(
|
|
380
|
-
|
|
385
|
+
!m && /* @__PURE__ */ e(Ve, { editor: N, variant: a, onPickImage: te, imageHint: x }),
|
|
386
|
+
C && /* @__PURE__ */ e(
|
|
381
387
|
"input",
|
|
382
388
|
{
|
|
383
|
-
ref:
|
|
389
|
+
ref: G,
|
|
384
390
|
type: "file",
|
|
385
391
|
className: "hidden",
|
|
386
392
|
accept: l.join(","),
|
|
387
393
|
"aria-label": "Escolher imagem",
|
|
388
|
-
onChange: (
|
|
389
|
-
const
|
|
390
|
-
|
|
394
|
+
onChange: (c) => {
|
|
395
|
+
const v = Array.from(c.target.files ?? []);
|
|
396
|
+
c.target.value = "", v.length > 0 && _.current(N, v);
|
|
391
397
|
}
|
|
392
398
|
}
|
|
393
399
|
),
|
|
394
|
-
|
|
400
|
+
M ? (
|
|
395
401
|
// Folha A4: a cor é do papel (branca também no escuro) e o conteúdo escala com a largura da folha.
|
|
396
402
|
/* @__PURE__ */ e("div", { className: "bg-muted/40 p-3 sm:p-6 overflow-auto flex-1 min-h-0", "data-slot": "document-sheet-area", children: /* @__PURE__ */ e(
|
|
397
403
|
"div",
|
|
398
404
|
{
|
|
399
405
|
"data-slot": "document-sheet",
|
|
400
406
|
className: "mx-auto bg-white text-black shadow-md [container-type:inline-size]",
|
|
401
|
-
style: { width: `min(100%, ${
|
|
402
|
-
children: /* @__PURE__ */ e("div", { style: { padding:
|
|
407
|
+
style: { width: `min(100%, ${w.larguraPx}px)` },
|
|
408
|
+
children: /* @__PURE__ */ e("div", { style: { padding: qe }, className: "[&_img]:max-w-full [&_img]:h-auto", children: $ })
|
|
403
409
|
}
|
|
404
410
|
) })
|
|
405
|
-
) : /* @__PURE__ */ e("div", { className:
|
|
411
|
+
) : /* @__PURE__ */ e("div", { className: L(
|
|
406
412
|
"bg-background relative",
|
|
407
|
-
|
|
408
|
-
), children:
|
|
413
|
+
f ? "bg-card" : ""
|
|
414
|
+
), children: $ })
|
|
409
415
|
] })
|
|
410
416
|
] });
|
|
411
417
|
}
|
|
412
418
|
export {
|
|
413
|
-
|
|
414
|
-
|
|
419
|
+
dt as DocumentEditor,
|
|
420
|
+
Xe as tamanhoDeEntrada
|
|
415
421
|
};
|
|
416
422
|
//# sourceMappingURL=document-editor.js.map
|