@iclips/ui 4.3.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.
@@ -1,32 +1,32 @@
1
- import { jsxs as u, jsx as e, Fragment as H } from "react/jsx-runtime";
2
- import * as O from "react";
3
- import { useEditor as te, EditorContent as ie } from "@tiptap/react";
4
- import re from "@tiptap/starter-kit";
5
- import Q from "@tiptap/extension-image";
6
- import ne from "@tiptap/extension-placeholder";
7
- import ae from "@tiptap/extension-text-align";
8
- import oe from "@tiptap/extension-file-handler";
9
- import { TableKit as le } from "@tiptap/extension-table";
10
- import { cn as k } from "../utils.js";
11
- import { Button as F } from "../primitives/button.js";
12
- import { Separator as R } from "../primitives/separator.js";
13
- import { Undo as se, Redo as ce, Bold as ue, Italic as me, Underline as he, Strikethrough as de, List as ge, ListOrdered as fe, AlignLeft as pe, AlignCenter as be, AlignRight as Ae, Quote as we, Link as xe, Table as ve, Image as $, Minus as Me, Plus as Ne } from "lucide-react";
14
- import { Toggle as ke } from "../forms/toggle.js";
15
- import { Select as Te, SelectTrigger as Le, SelectValue as Ie, SelectContent as Pe, SelectItem as Ce } from "../forms/select.js";
16
- import { DropdownMenu as _e, DropdownMenuTrigger as Re, DropdownMenuContent as Se, DropdownMenuItem as N, DropdownMenuSeparator as X } from "../overlays/dropdown-menu.js";
17
- import { Tooltip as y, TooltipTrigger as E, TooltipContent as z } from "../overlays/tooltip.js";
18
- import { toast as D } from "../feedback/toast.js";
19
- const U = 96 / 2.54, ye = Math.round(5 * U), Ee = Math.round(2 * U), V = Math.round(1 * U), ze = ["image/png", "image/jpeg", "image/webp"], He = 2 * 1024 * 1024, j = 0.1, A = {
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
- }, b = Math.round(A.larguraPx - 2 * A.margemPx), Oe = `${(11 / 0.75 / A.larguraPx * 100).toFixed(3)}cqw`, De = `${((A.alturaMinPx - 2 * A.margemPx) / A.larguraPx * 100).toFixed(3)}cqw`, Fe = `${(A.margemPx / A.larguraPx * 100).toFixed(3)}cqw`;
24
- function W(t) {
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 Ue = ["left", "center", "right"], qe = Q.extend({
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 Ue.includes(r ?? "") && r !== "left" ? r : null;
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) => W(i.getAttribute("width")),
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), b) };
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) => W(i.getAttribute("height")),
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 > b ? b / r : 1;
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 f;
70
+ var g;
71
71
  const a = t(r), n = a;
72
- ("maxSize" in n || "minSize" in n) && (n.maxSize = { ...n.maxSize, width: b }, a.dom.addEventListener(
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(b, s) : b
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 w = s > b ? b / s : 1;
88
- h.style.width = `${Math.round(s * w)}px`, h.style.height = `${Math.round(l * w)}px`;
89
- }, p = (f = a.update) == null ? void 0 : f.bind(a);
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 Be(t) {
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 Ge(t, i) {
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 g = ({
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
- ke,
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(y, { children: [
133
- /* @__PURE__ */ e(E, { asChild: !0, children: p }),
134
- /* @__PURE__ */ e(z, { children: n })
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
- }, S = ({
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(F, { variant: "ghost", size: "icon", className: "h-8 w-8", onClick: t, disabled: i, "aria-label": r, children: n });
144
- return a ? /* @__PURE__ */ u(y, { children: [
145
- /* @__PURE__ */ e(E, { asChild: !0, children: m }),
146
- /* @__PURE__ */ e(z, { children: r })
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
- }, $e = [
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 Xe(t) {
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 je(t, i) {
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 We = ({
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, c = window.prompt("URL", o);
172
- if (c !== null) {
173
- if (c === "") {
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: c }).run();
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
- }, f = t.isActive("image"), s = (o) => {
183
- const { width: c, height: v } = t.getAttributes("image");
184
- if (!c || !v) return;
185
- const T = Math.min(b, Math.max(V, Math.round(c * o)));
186
- t.chain().focus().updateAttributes("image", { width: T, height: Math.round(v * T / c) }).run();
187
- }, l = t.isActive("table"), h = (o) => f ? (t.getAttributes("image").align ?? "left") === o : t.isActive({ textAlign: o }), w = (o) => {
188
- f ? t.chain().focus().updateAttributes("image", { align: o === "left" ? null : o }).run() : t.chain().focus().setTextAlign(o).run();
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: k(
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(S, { tooltip: n, label: "Desfazer", onClick: () => t.chain().focus().undo().run(), disabled: !t.can().undo(), children: /* @__PURE__ */ e(se, { className: "h-4 w-4" }) }),
196
- /* @__PURE__ */ e(S, { tooltip: n, label: "Refazer", onClick: () => t.chain().focus().redo().run(), disabled: !t.can().redo(), children: /* @__PURE__ */ e(ce, { className: "h-4 w-4" }) })
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(R, { orientation: "vertical", className: "h-6 mx-1" }),
199
- n && /* @__PURE__ */ u(H, { children: [
200
- /* @__PURE__ */ u(Te, { value: Xe(t), onValueChange: (o) => je(t, o), children: [
201
- /* @__PURE__ */ e(Le, { size: "sm", className: "w-[130px]", "aria-label": "Estilo do texto", children: /* @__PURE__ */ e(Ie, {}) }),
202
- /* @__PURE__ */ e(Pe, { children: $e.map((o) => /* @__PURE__ */ e(Ce, { value: o.valor, children: o.rotulo }, o.valor)) })
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(R, { orientation: "vertical", className: "h-6 mx-1" })
204
+ /* @__PURE__ */ e(E, { orientation: "vertical", className: "h-6 mx-1" })
205
205
  ] }),
206
- /* @__PURE__ */ e(g, { tooltip: n, onClick: () => t.chain().focus().toggleBold().run(), isActive: t.isActive("bold"), title: "Negrito", children: /* @__PURE__ */ e(ue, { className: "h-4 w-4" }) }),
207
- /* @__PURE__ */ e(g, { tooltip: n, onClick: () => t.chain().focus().toggleItalic().run(), isActive: t.isActive("italic"), title: "Itálico", children: /* @__PURE__ */ e(me, { className: "h-4 w-4" }) }),
208
- /* @__PURE__ */ e(g, { tooltip: n, onClick: () => t.chain().focus().toggleUnderline().run(), isActive: t.isActive("underline"), title: "Sublinhado", children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) }),
209
- n && /* @__PURE__ */ e(g, { tooltip: !0, onClick: () => t.chain().focus().toggleStrike().run(), isActive: t.isActive("strike"), title: "Tachado", children: /* @__PURE__ */ e(de, { className: "h-4 w-4" }) }),
210
- /* @__PURE__ */ e(R, { orientation: "vertical", className: "h-6 mx-1" }),
211
- /* @__PURE__ */ e(g, { tooltip: n, onClick: () => t.chain().focus().toggleBulletList().run(), isActive: t.isActive("bulletList"), title: "Lista com marcadores", children: /* @__PURE__ */ e(ge, { className: "h-4 w-4" }) }),
212
- /* @__PURE__ */ e(g, { tooltip: n, onClick: () => t.chain().focus().toggleOrderedList().run(), isActive: t.isActive("orderedList"), title: "Lista numerada", children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" }) }),
213
- n && /* @__PURE__ */ u(H, { children: [
214
- /* @__PURE__ */ e(g, { tooltip: !0, onClick: () => w("left"), isActive: h("left"), title: "Alinhar à esquerda", children: /* @__PURE__ */ e(pe, { className: "h-4 w-4" }) }),
215
- /* @__PURE__ */ e(g, { tooltip: !0, onClick: () => w("center"), isActive: h("center"), title: "Centralizar", children: /* @__PURE__ */ e(be, { className: "h-4 w-4" }) }),
216
- /* @__PURE__ */ e(g, { tooltip: !0, onClick: () => w("right"), isActive: h("right"), title: "Alinhar à direita", children: /* @__PURE__ */ e(Ae, { className: "h-4 w-4" }) })
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(R, { orientation: "vertical", className: "h-6 mx-1" }),
219
- /* @__PURE__ */ e(g, { tooltip: n, onClick: () => t.chain().focus().toggleBlockquote().run(), isActive: t.isActive("blockquote"), title: "Citação", children: /* @__PURE__ */ e(we, { className: "h-4 w-4" }) }),
220
- /* @__PURE__ */ e(g, { tooltip: n, onClick: m, isActive: t.isActive("link"), title: "Link", children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" }) }),
221
- n && /* @__PURE__ */ u(_e, { children: [
222
- /* @__PURE__ */ u(y, { children: [
223
- /* @__PURE__ */ e(E, { asChild: !0, children: /* @__PURE__ */ e(Re, { asChild: !0, children: /* @__PURE__ */ e(F, { variant: "ghost", size: "icon", className: k("h-8 w-8", l && "bg-secondary text-secondary-foreground"), "aria-label": "Tabela", children: /* @__PURE__ */ e(ve, { className: "h-4 w-4" }) }) }) }),
224
- /* @__PURE__ */ e(z, { children: "Tabela" })
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(Se, { align: "start", children: [
227
- /* @__PURE__ */ e(N, { onSelect: () => t.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run(), children: "Inserir tabela" }),
228
- /* @__PURE__ */ e(X, {}),
229
- /* @__PURE__ */ e(N, { disabled: !l, onSelect: () => t.chain().focus().addRowAfter().run(), children: "Adicionar linha" }),
230
- /* @__PURE__ */ e(N, { disabled: !l, onSelect: () => t.chain().focus().addColumnAfter().run(), children: "Adicionar coluna" }),
231
- /* @__PURE__ */ e(N, { disabled: !l, onSelect: () => t.chain().focus().deleteRow().run(), children: "Remover linha" }),
232
- /* @__PURE__ */ e(N, { disabled: !l, onSelect: () => t.chain().focus().deleteColumn().run(), children: "Remover coluna" }),
233
- /* @__PURE__ */ e(X, {}),
234
- /* @__PURE__ */ e(N, { disabled: !l, onSelect: () => t.chain().focus().deleteTable().run(), children: "Remover tabela" })
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(H, { children: [
238
- /* @__PURE__ */ u(y, { children: [
239
- /* @__PURE__ */ e(E, { asChild: !0, children: /* @__PURE__ */ e(F, { variant: "ghost", size: "icon", className: "h-8 w-8", onClick: r, "aria-label": "Inserir imagem", children: /* @__PURE__ */ e($, { className: "h-4 w-4" }) }) }),
240
- /* @__PURE__ */ e(z, { className: "max-w-64", children: a ?? "Inserir imagem" })
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(S, { tooltip: !0, label: "Diminuir imagem", onClick: () => s(1 - j), disabled: !f, children: /* @__PURE__ */ e(Me, { className: "h-4 w-4" }) }),
243
- /* @__PURE__ */ e(S, { tooltip: !0, label: "Aumentar imagem", onClick: () => s(1 + j), disabled: !f, children: /* @__PURE__ */ e(Ne, { className: "h-4 w-4" }) })
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(g, { tooltip: !0, onClick: p, title: "Imagem", children: /* @__PURE__ */ e($, { className: "h-4 w-4" }) })
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 mt({
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: f,
256
+ onImageUpload: g,
257
257
  imageDefaults: s,
258
- imageAcceptedTypes: l = ze,
259
- imageMaxBytes: h = He,
260
- imageHint: w,
261
- page: o
258
+ imageAcceptedTypes: l = Oe,
259
+ imageMaxBytes: h = De,
260
+ imageHint: x,
261
+ page: o,
262
+ onReady: b
262
263
  }) {
263
- const c = a === "full", v = c && o === "a4", T = s ?? { width: ye, maxHeight: Ee }, K = T.width, J = T.maxHeight, I = c && !!f, P = O.useRef(async () => {
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
- P.current = async (d, x, L) => {
266
- if (f)
267
- for (const M of x) {
268
- if (!l.includes(M.type)) {
269
- D.error("Imagem não inserida", { description: "Use uma imagem PNG, JPG ou WEBP." });
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 (M.size > h) {
273
- D.error("Imagem não inserida", {
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 [_, G] = await Promise.all([f(M), Be(M)]), ee = G ? Ge(G, { width: K, maxHeight: J }) : {};
280
- d.chain().insertContentAt(L ?? d.state.selection.anchor, { type: "image", attrs: { src: _, ...ee } }).focus().run();
281
- } catch (_) {
282
- D.error("Não foi possível inserir a imagem", { description: _ instanceof Error ? _.message : void 0 });
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 Y = O.useMemo(() => {
287
- const d = c ? [
288
- qe.configure({
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: V,
295
+ minWidth: J,
295
296
  minHeight: 1,
296
297
  alwaysPreserveAspectRatio: !0
297
298
  }
298
299
  }),
299
- le.configure({ table: { resizable: !0 } })
300
+ ce.configure({ table: { resizable: !0 } })
300
301
  ] : [
301
- Q.configure({
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
- re.configure({
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
- ...d,
323
- ne.configure({
323
+ ...c,
324
+ oe.configure({
324
325
  placeholder: r
325
326
  }),
326
- ae.configure({
327
+ le.configure({
327
328
  types: ["heading", "paragraph"]
328
329
  }),
329
- ...I ? [
330
- oe.configure({
330
+ ...C ? [
331
+ se.configure({
331
332
  allowedMimeTypes: l,
332
- onDrop: (x, L, M) => {
333
- P.current(x, L, M);
333
+ onDrop: (v, I, k) => {
334
+ _.current(v, I, k);
334
335
  },
335
- onPaste: (x, L) => {
336
- P.current(x, L);
336
+ onPaste: (v, I) => {
337
+ _.current(v, I);
337
338
  }
338
339
  })
339
340
  ] : []
340
341
  ];
341
- }, [r, c, I, l.join(",")]), C = te({
342
- extensions: Y,
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: d }) => {
347
- i == null || i(d.getHTML());
347
+ onUpdate: ({ editor: c }) => {
348
+ i == null || i(c.getHTML());
348
349
  },
349
350
  editorProps: {
350
351
  attributes: {
351
- class: k(
352
- v ? "prose prose-stone max-w-none focus:outline-none" : "prose prose-stone dark:prose-invert max-w-none focus:outline-none",
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
- !c && "prose-img:rounded-lg prose-img:shadow-md prose-img:my-6",
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
- c && "[&_[data-resize-container]:has([data-align=center])]:justify-center [&_[data-resize-container]:has([data-align=right])]:justify-end",
361
- v ? void 0 : c ? "min-h-[400px] p-8" : "min-h-[120px] px-3 py-2"
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
- ...v ? { style: `font-size: ${Oe}; min-height: ${De}` } : {}
364
+ ...M ? { style: `font-size: ${Fe}; min-height: ${Ue}` } : {}
364
365
  }
365
366
  }
366
- }), q = O.useRef(null);
367
- if (!C) return null;
368
- const Z = I ? () => {
369
- var d;
370
- return (d = q.current) == null ? void 0 : d.click();
371
- } : void 0, B = /* @__PURE__ */ e(ie, { editor: C });
372
- return /* @__PURE__ */ u("div", { "data-slot": "document-editor", className: k("flex flex-col w-full", n), children: [
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: k(
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(We, { editor: C, variant: a, onPickImage: Z, imageHint: w }),
380
- I && /* @__PURE__ */ e(
385
+ !m && /* @__PURE__ */ e(Ve, { editor: N, variant: a, onPickImage: te, imageHint: x }),
386
+ C && /* @__PURE__ */ e(
381
387
  "input",
382
388
  {
383
- ref: q,
389
+ ref: G,
384
390
  type: "file",
385
391
  className: "hidden",
386
392
  accept: l.join(","),
387
393
  "aria-label": "Escolher imagem",
388
- onChange: (d) => {
389
- const x = Array.from(d.target.files ?? []);
390
- d.target.value = "", x.length > 0 && P.current(C, x);
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
- v ? (
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%, ${A.larguraPx}px)` },
402
- children: /* @__PURE__ */ e("div", { style: { padding: Fe }, className: "[&_img]:max-w-full [&_img]:h-auto", children: B })
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: k(
411
+ ) : /* @__PURE__ */ e("div", { className: L(
406
412
  "bg-background relative",
407
- c ? "bg-card" : ""
408
- ), children: B })
413
+ f ? "bg-card" : ""
414
+ ), children: $ })
409
415
  ] })
410
416
  ] });
411
417
  }
412
418
  export {
413
- mt as DocumentEditor,
414
- Ge as tamanhoDeEntrada
419
+ dt as DocumentEditor,
420
+ Xe as tamanhoDeEntrada
415
421
  };
416
422
  //# sourceMappingURL=document-editor.js.map