ritext 1.0.23 → 1.0.25

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.
Files changed (132) hide show
  1. package/README.md +1 -30
  2. package/dist/chunk-EN4BPI7N.mjs +1213 -0
  3. package/dist/chunk-FJQ4FZRS.mjs +98 -0
  4. package/dist/chunk-M4ORWR74.mjs +31 -0
  5. package/dist/chunk-SJFT7WNM.mjs +38 -0
  6. package/dist/chunk-W367UGID.mjs +55 -0
  7. package/dist/{chunk-FWCSY2DS.mjs → chunk-WNQUEZJF.mjs} +22 -1
  8. package/dist/{chunk-D47XME55.mjs → chunk-WXCHG3NQ.mjs} +8 -2
  9. package/dist/chunk-WZKGD3DD.mjs +231 -0
  10. package/dist/extension/backgroundcolor.d.mts +16 -0
  11. package/dist/extension/backgroundcolor.d.ts +16 -0
  12. package/dist/extension/backgroundcolor.js +668 -0
  13. package/dist/extension/backgroundcolor.mjs +107 -0
  14. package/dist/extension/base.d.mts +6 -0
  15. package/dist/extension/base.d.ts +6 -0
  16. package/dist/extension/base.js +65 -0
  17. package/dist/extension/base.mjs +22 -0
  18. package/dist/extension/blockquote.d.mts +10 -0
  19. package/dist/extension/blockquote.d.ts +10 -0
  20. package/dist/extension/blockquote.js +239 -0
  21. package/dist/extension/blockquote.mjs +46 -0
  22. package/dist/extension/bold.d.mts +7 -2
  23. package/dist/extension/bold.d.ts +7 -2
  24. package/dist/extension/bold.js +22 -45
  25. package/dist/extension/bold.mjs +13 -35
  26. package/dist/extension/bulletlist.d.mts +10 -0
  27. package/dist/extension/bulletlist.d.ts +10 -0
  28. package/dist/extension/bulletlist.js +241 -0
  29. package/dist/extension/bulletlist.mjs +46 -0
  30. package/dist/extension/clearformat.d.mts +1 -1
  31. package/dist/extension/clearformat.d.ts +1 -1
  32. package/dist/extension/clearformat.js +11 -6
  33. package/dist/extension/clearformat.mjs +8 -35
  34. package/dist/extension/color.d.mts +17 -0
  35. package/dist/extension/color.d.ts +17 -0
  36. package/dist/extension/color.js +580 -0
  37. package/dist/extension/color.mjs +12 -0
  38. package/dist/extension/emoji.d.mts +15 -0
  39. package/dist/extension/emoji.d.ts +15 -0
  40. package/dist/extension/emoji.js +421 -0
  41. package/dist/extension/emoji.mjs +158 -0
  42. package/dist/extension/font-family.d.mts +8 -11
  43. package/dist/extension/font-family.d.ts +8 -11
  44. package/dist/extension/font-family.js +11 -12
  45. package/dist/extension/font-family.mjs +10 -11
  46. package/dist/extension/font-size.d.mts +8 -11
  47. package/dist/extension/font-size.d.ts +8 -11
  48. package/dist/extension/font-size.js +10 -12
  49. package/dist/extension/font-size.mjs +9 -11
  50. package/dist/extension/heading.d.mts +10 -10
  51. package/dist/extension/heading.d.ts +10 -10
  52. package/dist/extension/heading.js +68 -80
  53. package/dist/extension/heading.mjs +40 -206
  54. package/dist/extension/history.d.mts +4 -2
  55. package/dist/extension/history.d.ts +4 -2
  56. package/dist/extension/history.js +16 -9
  57. package/dist/extension/history.mjs +16 -64
  58. package/dist/extension/horizontalrule.d.mts +10 -0
  59. package/dist/extension/horizontalrule.d.ts +10 -0
  60. package/dist/extension/horizontalrule.js +242 -0
  61. package/dist/extension/horizontalrule.mjs +42 -0
  62. package/dist/extension/image.d.mts +26 -0
  63. package/dist/extension/image.d.ts +26 -0
  64. package/dist/extension/image.js +1611 -0
  65. package/dist/extension/image.mjs +1153 -0
  66. package/dist/extension/indentoutdent.d.mts +21 -0
  67. package/dist/extension/indentoutdent.d.ts +21 -0
  68. package/dist/extension/indentoutdent.js +380 -0
  69. package/dist/extension/indentoutdent.mjs +164 -0
  70. package/dist/extension/italic.d.mts +7 -2
  71. package/dist/extension/italic.d.ts +7 -2
  72. package/dist/extension/italic.js +22 -45
  73. package/dist/extension/italic.mjs +14 -40
  74. package/dist/extension/lineheight.d.mts +15 -0
  75. package/dist/extension/lineheight.d.ts +15 -0
  76. package/dist/extension/lineheight.js +342 -0
  77. package/dist/extension/lineheight.mjs +87 -0
  78. package/dist/extension/link.d.mts +15 -0
  79. package/dist/extension/link.d.ts +15 -0
  80. package/dist/extension/link.js +588 -0
  81. package/dist/extension/link.mjs +278 -0
  82. package/dist/extension/orderedlist.d.mts +10 -0
  83. package/dist/extension/orderedlist.d.ts +10 -0
  84. package/dist/extension/orderedlist.js +241 -0
  85. package/dist/extension/orderedlist.mjs +46 -0
  86. package/dist/extension/strike.d.mts +8 -3
  87. package/dist/extension/strike.d.ts +8 -3
  88. package/dist/extension/strike.js +22 -45
  89. package/dist/extension/strike.mjs +14 -40
  90. package/dist/extension/subandsuperscript.d.mts +7 -10
  91. package/dist/extension/subandsuperscript.d.ts +7 -10
  92. package/dist/extension/subandsuperscript.js +66 -77
  93. package/dist/extension/subandsuperscript.mjs +18 -48
  94. package/dist/extension/subscript.d.mts +4 -2
  95. package/dist/extension/subscript.d.ts +4 -2
  96. package/dist/extension/subscript.js +20 -45
  97. package/dist/extension/subscript.mjs +10 -10
  98. package/dist/extension/superscript.d.mts +4 -2
  99. package/dist/extension/superscript.d.ts +4 -2
  100. package/dist/extension/superscript.js +20 -45
  101. package/dist/extension/superscript.mjs +10 -10
  102. package/dist/extension/table.d.mts +12 -0
  103. package/dist/extension/table.d.ts +12 -0
  104. package/dist/extension/table.js +585 -0
  105. package/dist/extension/table.mjs +324 -0
  106. package/dist/extension/tasklist.d.mts +10 -0
  107. package/dist/extension/tasklist.d.ts +10 -0
  108. package/dist/extension/tasklist.js +246 -0
  109. package/dist/extension/tasklist.mjs +52 -0
  110. package/dist/extension/textalign.d.mts +15 -0
  111. package/dist/extension/textalign.d.ts +15 -0
  112. package/dist/extension/textalign.js +404 -0
  113. package/dist/extension/textalign.mjs +79 -0
  114. package/dist/extension/underline.d.mts +7 -2
  115. package/dist/extension/underline.d.ts +7 -2
  116. package/dist/extension/underline.js +22 -45
  117. package/dist/extension/underline.mjs +14 -39
  118. package/dist/index.css +683 -31
  119. package/dist/index.d.mts +3 -1
  120. package/dist/index.d.ts +3 -1
  121. package/dist/index.js +306 -24
  122. package/dist/index.mjs +141 -13
  123. package/dist/tiptap-ext.type-B3TtT7-J.d.mts +43 -0
  124. package/dist/tiptap-ext.type-B3TtT7-J.d.ts +43 -0
  125. package/package.json +41 -28
  126. package/dist/chunk-2YUUKIIT.mjs +0 -149
  127. package/dist/chunk-7QOFJIQ3.mjs +0 -90
  128. package/dist/chunk-GSHINFPO.mjs +0 -53
  129. package/dist/chunk-LMOTHRGQ.mjs +0 -37
  130. package/dist/chunk-MBF77NHS.mjs +0 -37
  131. package/dist/tiptap-ext.type-DrneAC5G.d.mts +0 -39
  132. package/dist/tiptap-ext.type-DrneAC5G.d.ts +0 -39
@@ -0,0 +1,1611 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
78
+
79
+ // src/extension/Image.tsx
80
+ var Image_exports = {};
81
+ __export(Image_exports, {
82
+ Image: () => Image2
83
+ });
84
+ module.exports = __toCommonJS(Image_exports);
85
+ var import_react16 = require("react");
86
+ var import_extension_image = require("@tiptap/extension-image");
87
+ var import_react17 = require("@tiptap/react");
88
+ var import_react18 = require("@tiptap/react");
89
+
90
+ // src/lib/icons/index.tsx
91
+ var import_jsx_runtime = require("react/jsx-runtime");
92
+ var AlignLeft = (_a) => {
93
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
94
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
95
+ "svg",
96
+ __spreadProps(__spreadValues({
97
+ xmlns: "http://www.w3.org/2000/svg",
98
+ width: size,
99
+ height: size,
100
+ viewBox: "0 0 24 24",
101
+ fill: "none",
102
+ stroke: "currentColor",
103
+ strokeWidth: "2",
104
+ strokeLinecap: "round",
105
+ strokeLinejoin: "round"
106
+ }, props), {
107
+ children: [
108
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 5H3" }),
109
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15 12H3" }),
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 19H3" })
111
+ ]
112
+ })
113
+ );
114
+ };
115
+ var AlignCenter = (_a) => {
116
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
117
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
118
+ "svg",
119
+ __spreadProps(__spreadValues({
120
+ xmlns: "http://www.w3.org/2000/svg",
121
+ width: size,
122
+ height: size,
123
+ viewBox: "0 0 24 24",
124
+ fill: "none",
125
+ stroke: "currentColor",
126
+ strokeWidth: "2",
127
+ strokeLinecap: "round",
128
+ strokeLinejoin: "round"
129
+ }, props), {
130
+ children: [
131
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 5H3" }),
132
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 12H7" }),
133
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 19H5" })
134
+ ]
135
+ })
136
+ );
137
+ };
138
+ var AlignRight = (_a) => {
139
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
141
+ "svg",
142
+ __spreadProps(__spreadValues({
143
+ xmlns: "http://www.w3.org/2000/svg",
144
+ width: size,
145
+ height: size,
146
+ viewBox: "0 0 24 24",
147
+ fill: "none",
148
+ stroke: "currentColor",
149
+ strokeWidth: "2",
150
+ strokeLinecap: "round",
151
+ strokeLinejoin: "round"
152
+ }, props), {
153
+ children: [
154
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 5H3" }),
155
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12H9" }),
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 19H7" })
157
+ ]
158
+ })
159
+ );
160
+ };
161
+ var ImageUpIcon = (_a) => {
162
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
163
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
164
+ "svg",
165
+ __spreadProps(__spreadValues({
166
+ xmlns: "http://www.w3.org/2000/svg",
167
+ width: size,
168
+ height: size,
169
+ viewBox: "0 0 24 24",
170
+ fill: "none",
171
+ stroke: "currentColor",
172
+ strokeWidth: "2",
173
+ strokeLinecap: "round",
174
+ strokeLinejoin: "round"
175
+ }, props), {
176
+ children: [
177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21" }),
178
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m14 19.5 3-3 3 3" }),
179
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 22v-5.5" }),
180
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "9", cy: "9", r: "2" })
181
+ ]
182
+ })
183
+ );
184
+ };
185
+ var CloseIcon = (_a) => {
186
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
187
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
188
+ "svg",
189
+ __spreadProps(__spreadValues({
190
+ xmlns: "http://www.w3.org/2000/svg",
191
+ viewBox: "0 0 24 24",
192
+ fill: "none",
193
+ stroke: "currentColor",
194
+ strokeWidth: 2,
195
+ strokeLinecap: "round",
196
+ strokeLinejoin: "round",
197
+ width: size,
198
+ height: size,
199
+ className
200
+ }, props), {
201
+ children: [
202
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }),
203
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })
204
+ ]
205
+ })
206
+ );
207
+ };
208
+ var ImageIcon = (_a) => {
209
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
210
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
211
+ "svg",
212
+ __spreadProps(__spreadValues({
213
+ xmlns: "http://www.w3.org/2000/svg",
214
+ viewBox: "0 0 24 24",
215
+ fill: "none",
216
+ stroke: "currentColor",
217
+ strokeWidth: 2,
218
+ strokeLinecap: "round",
219
+ strokeLinejoin: "round",
220
+ width: size,
221
+ height: size,
222
+ className
223
+ }, props), {
224
+ children: [
225
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "9", cy: "9", r: "2" }),
227
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
228
+ ]
229
+ })
230
+ );
231
+ };
232
+ var FlipHorizontal = (_a) => {
233
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
234
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
235
+ "svg",
236
+ __spreadProps(__spreadValues({
237
+ xmlns: "http://www.w3.org/2000/svg",
238
+ viewBox: "0 0 24 24",
239
+ fill: "none",
240
+ stroke: "currentColor",
241
+ strokeWidth: 2,
242
+ strokeLinecap: "round",
243
+ strokeLinejoin: "round",
244
+ width: size,
245
+ height: size,
246
+ className
247
+ }, props), {
248
+ children: [
249
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3 7 5 5-5 5V7" }),
250
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m21 7-5 5 5 5V7" }),
251
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 20v2" }),
252
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 14v2" }),
253
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 8v2" }),
254
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 2v2" })
255
+ ]
256
+ })
257
+ );
258
+ };
259
+ var FlipVertical = (_a) => {
260
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
261
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
262
+ "svg",
263
+ __spreadProps(__spreadValues({
264
+ xmlns: "http://www.w3.org/2000/svg",
265
+ viewBox: "0 0 24 24",
266
+ fill: "none",
267
+ stroke: "currentColor",
268
+ strokeWidth: 2,
269
+ strokeLinecap: "round",
270
+ strokeLinejoin: "round",
271
+ width: size,
272
+ height: size,
273
+ className
274
+ }, props), {
275
+ children: [
276
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m17 3-5 5-5-5h10" }),
277
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m17 21-5-5-5 5h10" }),
278
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12H2" }),
279
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 12H8" }),
280
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 12h-2" }),
281
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M22 12h-2" })
282
+ ]
283
+ })
284
+ );
285
+ };
286
+ var TrashIcon = (_a) => {
287
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
288
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
289
+ "svg",
290
+ __spreadProps(__spreadValues({
291
+ xmlns: "http://www.w3.org/2000/svg",
292
+ viewBox: "0 0 24 24",
293
+ fill: "none",
294
+ stroke: "currentColor",
295
+ strokeWidth: 2,
296
+ strokeLinecap: "round",
297
+ strokeLinejoin: "round",
298
+ width: size,
299
+ height: size,
300
+ className
301
+ }, props), {
302
+ children: [
303
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 11v6" }),
304
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 11v6" }),
305
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
306
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 6h18" }),
307
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
308
+ ]
309
+ })
310
+ );
311
+ };
312
+
313
+ // src/lib/components/ButtonWithoutActive.tsx
314
+ var import_react4 = require("react");
315
+ var import_tailwind_merge2 = require("tailwind-merge");
316
+
317
+ // src/lib/components/_com/Tooltip.tsx
318
+ var import_react = require("react");
319
+ var import_react2 = require("@floating-ui/react");
320
+ var import_react3 = require("motion/react");
321
+ var import_tailwind_merge = require("tailwind-merge");
322
+ var import_jsx_runtime2 = require("react/jsx-runtime");
323
+ var Tooltip = ({ placement = "top", children, content, className }) => {
324
+ const [open, setOpen] = (0, import_react.useState)(false);
325
+ const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
326
+ open,
327
+ onOpenChange: setOpen,
328
+ placement,
329
+ middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
330
+ whileElementsMounted: import_react2.autoUpdate
331
+ });
332
+ const hover = (0, import_react2.useHover)(context);
333
+ const dismiss = (0, import_react2.useDismiss)(context);
334
+ const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
335
+ const id = (0, import_react.useId)();
336
+ function mergeRefs(...refsToMerge) {
337
+ return (node) => {
338
+ for (const r of refsToMerge) {
339
+ if (!r) continue;
340
+ if (typeof r === "function") r(node);
341
+ else r.current = node;
342
+ }
343
+ };
344
+ }
345
+ const side = resolvedPlacement.split("-")[0];
346
+ const enterOffset = 6;
347
+ const getInitial = () => {
348
+ switch (side) {
349
+ case "top":
350
+ return { opacity: 0, y: enterOffset };
351
+ case "bottom":
352
+ return { opacity: 0, y: -enterOffset };
353
+ case "left":
354
+ return { opacity: 0, x: enterOffset };
355
+ case "right":
356
+ return { opacity: 0, x: -enterOffset };
357
+ default:
358
+ return { opacity: 0 };
359
+ }
360
+ };
361
+ const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
362
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
363
+ (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
364
+ onFocus: () => setOpen(true),
365
+ onBlur: () => setOpen(false),
366
+ "aria-describedby": open ? id : void 0
367
+ /* eslint-disable @typescript-eslint/no-explicit-any */
368
+ })), {
369
+ /* eslint-disable @typescript-eslint/no-explicit-any */
370
+ ref: mergeRefs(children.props.ref, refs.setReference)
371
+ })) : children,
372
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react3.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
373
+ import_react3.motion.div,
374
+ __spreadProps(__spreadValues({
375
+ ref: refs.setFloating
376
+ }, getFloatingProps({
377
+ role: "tooltip",
378
+ id,
379
+ style: {
380
+ position: strategy,
381
+ top: y != null ? y : 0,
382
+ left: x != null ? x : 0,
383
+ pointerEvents: "none"
384
+ }
385
+ })), {
386
+ initial: getInitial(),
387
+ animate: { opacity: 1, x: 0, y: 0, scale: 1 },
388
+ exit: getExit(),
389
+ transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
390
+ className: (0, import_tailwind_merge.twMerge)("bg-white border border-solid border-gray-200/50 py-1 px-3 rounded-lg text-sm shadow-lg shadow-gray-50 text-center", className),
391
+ children: content
392
+ }),
393
+ "tooltip"
394
+ ) }) })
395
+ ] });
396
+ };
397
+ var Tooltip_default = Tooltip;
398
+
399
+ // src/lib/components/ButtonWithoutActive.tsx
400
+ var import_react5 = require("@tiptap/react");
401
+ var import_jsx_runtime3 = require("react/jsx-runtime");
402
+ var ButtonWithoutActive = ({ className, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _internalIcon, _tooltipContent, _interShortcut, _onToggle, _buttonClassName, _disabled = false }) => {
403
+ const shortcutText = (0, import_react4.useMemo)(() => {
404
+ if (!_interShortcut) return "";
405
+ return (0, import_react5.isMacOS)() ? _interShortcut.mac : _interShortcut.win;
406
+ }, [_interShortcut]);
407
+ const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
408
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
409
+ _interShortcut && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
410
+ " ",
411
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("br", {}),
412
+ " ",
413
+ shortcutText,
414
+ " "
415
+ ] })
416
+ ] });
417
+ const btn = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
418
+ "button",
419
+ {
420
+ onClick: _onToggle,
421
+ disabled: _disabled,
422
+ className: (0, import_tailwind_merge2.twMerge)(
423
+ "py-1.5 px-2.5 rounded-md hover:bg-gray-100",
424
+ _disabled ? "opacity-20" : "",
425
+ _buttonClassName,
426
+ className
427
+ ),
428
+ style,
429
+ children: icon != null ? icon : _internalIcon
430
+ }
431
+ );
432
+ if (tooltip === false) return btn;
433
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
434
+ Tooltip_default,
435
+ {
436
+ content: tooltipContent,
437
+ className: tooltipClassName,
438
+ placement: tooltipPlacement,
439
+ children: btn
440
+ }
441
+ );
442
+ };
443
+ var ButtonWithoutActive_default = ButtonWithoutActive;
444
+
445
+ // src/lib/components/ImageDialog.tsx
446
+ var import_react11 = require("react");
447
+
448
+ // src/lib/components/_com/Dialog.tsx
449
+ var import_react6 = require("motion/react");
450
+ var import_react_dom = require("react-dom");
451
+ var import_tailwind_merge3 = require("tailwind-merge");
452
+ var import_jsx_runtime4 = require("react/jsx-runtime");
453
+ var Dialog = ({ open, onClose, children, backdropClassName, className }) => {
454
+ const animation = {
455
+ unmount: {
456
+ opacity: 0,
457
+ y: -8,
458
+ transition: {
459
+ duration: 0.15
460
+ }
461
+ },
462
+ mount: {
463
+ opacity: 1,
464
+ y: 0,
465
+ transition: {
466
+ duration: 0.15
467
+ }
468
+ }
469
+ };
470
+ const backdropAnimation = {
471
+ unmount: {
472
+ opacity: 0,
473
+ transition: {
474
+ delay: 0.1
475
+ }
476
+ },
477
+ mount: {
478
+ opacity: 1
479
+ }
480
+ };
481
+ if (typeof window === "undefined") return null;
482
+ return (0, import_react_dom.createPortal)(
483
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.LazyMotion, { features: import_react6.domAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
484
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
485
+ import_react6.m.div,
486
+ {
487
+ className: `bg-black/55 fixed top-0 left-0 w-full h-full flex justify-center items-center z-9999999 ${backdropClassName}`,
488
+ initial: "unmount",
489
+ exit: "unmount",
490
+ animate: open ? "mount" : "unmount",
491
+ variants: backdropAnimation,
492
+ transition: { duration: 0.2 },
493
+ onClick: onClose
494
+ }
495
+ ),
496
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
497
+ import_react6.m.div,
498
+ {
499
+ className: (0, import_tailwind_merge3.twMerge)("fixed inset-0 h-max m-auto z-9999999 overflow-auto bg-white rounded-2xl", className),
500
+ initial: "unmount",
501
+ exit: "unmount",
502
+ animate: open ? "mount" : "unmount",
503
+ variants: animation,
504
+ children
505
+ }
506
+ )
507
+ ] }) }) }),
508
+ document.body
509
+ );
510
+ };
511
+ var Header = ({ title, className, titleClassName, buttonClassName, onClose }) => {
512
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_tailwind_merge3.twMerge)("flex items-center gap-4 text-strong", className), children: [
513
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { className: (0, import_tailwind_merge3.twMerge)("text-xl flex-1 font-semibold", titleClassName), children: title }),
514
+ onClose && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: (0, import_tailwind_merge3.twMerge)("hover:bg-light p-1 rounded-md transition-all", buttonClassName), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CloseIcon, { size: 20 }) })
515
+ ] });
516
+ };
517
+ var Body = ({ className, children, id }) => {
518
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: (0, import_tailwind_merge3.twMerge)("max-h-[80vh] overflow-auto [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-gray-200 [&::-webkit-scrollbar-thumb]:rounded-full", className), id, children });
519
+ };
520
+ Dialog.Header = Header;
521
+ Dialog.Body = Body;
522
+ var Dialog_default = Dialog;
523
+
524
+ // src/lib/components/_com/ImageUploader.tsx
525
+ var import_react9 = require("react");
526
+
527
+ // src/lib/components/_root/image/ImageUpload.tsx
528
+ var import_react7 = require("react");
529
+
530
+ // src/lib/components/_root/image/typings.ts
531
+ var ImageAcceptType = /* @__PURE__ */ ((ImageAcceptType2) => {
532
+ ImageAcceptType2["ALL"] = "all";
533
+ ImageAcceptType2["SVG"] = "image/svg+xml";
534
+ ImageAcceptType2["PNG"] = "image/png";
535
+ ImageAcceptType2["JPEG"] = "image/jpeg";
536
+ ImageAcceptType2["GIF"] = "image/gif";
537
+ ImageAcceptType2["BMP"] = "image/bmp";
538
+ ImageAcceptType2["WEBP"] = "image/webp";
539
+ ImageAcceptType2["TIFF"] = "image/tiff";
540
+ ImageAcceptType2["ICO"] = "image/x-icon";
541
+ ImageAcceptType2["HEIC"] = "image/heic";
542
+ ImageAcceptType2["HEIF"] = "image/heif";
543
+ return ImageAcceptType2;
544
+ })(ImageAcceptType || {});
545
+
546
+ // src/lib/components/_root/image/utils.ts
547
+ var openFileDialog = (inputRef) => {
548
+ if (inputRef.current) inputRef.current.click();
549
+ };
550
+ var getImageAccepts = (acceptType) => {
551
+ if (!acceptType || acceptType === "all" /* ALL */) {
552
+ const defaultArray = Object.values(ImageAcceptType).filter((value) => value !== "all" /* ALL */);
553
+ return defaultArray;
554
+ } else {
555
+ return acceptType;
556
+ }
557
+ };
558
+ var getImage = (file) => {
559
+ const image = new Image();
560
+ return new Promise((resolve) => {
561
+ image.addEventListener("load", () => resolve(image));
562
+ image.src = URL.createObjectURL(file);
563
+ });
564
+ };
565
+ var getBase64 = (file) => {
566
+ const reader = new FileReader();
567
+ return new Promise((resolve) => {
568
+ reader.addEventListener("load", () => resolve(String(reader.result)));
569
+ reader.readAsDataURL(file);
570
+ });
571
+ };
572
+ var isResolutionValid = (image, resolutionType, resolutionWidth, resolutionHeight) => {
573
+ if (!resolutionWidth || !resolutionHeight || !image.width || !image.height)
574
+ return true;
575
+ switch (resolutionType) {
576
+ case "absolute": {
577
+ if (image.width === resolutionWidth && image.height === resolutionHeight)
578
+ return true;
579
+ break;
580
+ }
581
+ case "ratio": {
582
+ const ratio = resolutionWidth / resolutionHeight;
583
+ if (image.width / image.height === ratio) return true;
584
+ break;
585
+ }
586
+ case "less": {
587
+ if (image.width <= resolutionWidth && image.height <= resolutionHeight)
588
+ return true;
589
+ break;
590
+ }
591
+ case "more": {
592
+ if (image.width >= resolutionWidth && image.height >= resolutionHeight)
593
+ return true;
594
+ break;
595
+ }
596
+ default:
597
+ break;
598
+ }
599
+ return false;
600
+ };
601
+ var createImage = (url) => new Promise((resolve, reject) => {
602
+ const image = new Image();
603
+ image.addEventListener("load", () => resolve(image));
604
+ image.addEventListener("error", (error) => reject(error));
605
+ image.src = url;
606
+ });
607
+ function getRadianAngle(degreeValue) {
608
+ return degreeValue * Math.PI / 180;
609
+ }
610
+ function rotateSize(width, height, rotation) {
611
+ const rotRad = getRadianAngle(rotation);
612
+ return {
613
+ width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height),
614
+ height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height)
615
+ };
616
+ }
617
+ function getCroppedImg(_0, _1) {
618
+ return __async(this, arguments, function* (imageSrc, pixelCrop, rotation = 0, flip3 = { horizontal: false, vertical: false }) {
619
+ const image = yield createImage(imageSrc);
620
+ const canvas = document.createElement("canvas");
621
+ const ctx = canvas.getContext("2d");
622
+ if (!ctx || !pixelCrop) {
623
+ return null;
624
+ }
625
+ const rotRad = getRadianAngle(rotation);
626
+ const { width: bBoxWidth, height: bBoxHeight } = rotateSize(
627
+ image.width,
628
+ image.height,
629
+ rotation
630
+ );
631
+ canvas.width = bBoxWidth;
632
+ canvas.height = bBoxHeight;
633
+ ctx.translate(bBoxWidth / 2, bBoxHeight / 2);
634
+ ctx.rotate(rotRad);
635
+ ctx.scale(flip3.horizontal ? -1 : 1, flip3.vertical ? -1 : 1);
636
+ ctx.translate(-image.width / 2, -image.height / 2);
637
+ ctx.drawImage(image, 0, 0);
638
+ const croppedCanvas = document.createElement("canvas");
639
+ const croppedCtx = croppedCanvas.getContext("2d");
640
+ if (!croppedCtx) {
641
+ return null;
642
+ }
643
+ croppedCanvas.width = pixelCrop.width;
644
+ croppedCanvas.height = pixelCrop.height;
645
+ croppedCtx.drawImage(
646
+ canvas,
647
+ pixelCrop.x,
648
+ pixelCrop.y,
649
+ pixelCrop.width,
650
+ pixelCrop.height,
651
+ 0,
652
+ 0,
653
+ pixelCrop.width,
654
+ pixelCrop.height
655
+ );
656
+ const blob = yield new Promise(
657
+ (resolve) => croppedCanvas.toBlob((b) => resolve(b), "image/png")
658
+ );
659
+ return {
660
+ file: new File([blob], `${crypto.randomUUID()}.png`, { type: "image/png" }),
661
+ dataURL: croppedCanvas.toDataURL("image/png")
662
+ };
663
+ });
664
+ }
665
+
666
+ // src/lib/components/_root/image/ImageUpload.tsx
667
+ var import_jsx_runtime5 = require("react/jsx-runtime");
668
+ var ImageUpload = ({ inputProps, acceptType, maxFileSize, resolutionWidth, resolutionHeight, resolutionType = "absolute", children, onChange, value, onError }) => {
669
+ if (Array.isArray(acceptType) && acceptType.includes("all" /* ALL */)) {
670
+ throw new Error("Invalid accept type: ImageAcceptType.All cannot be included in an array.");
671
+ }
672
+ const inputRef = (0, import_react7.useRef)(null);
673
+ const [isDragging, setIsDragging] = (0, import_react7.useState)(false);
674
+ const [errors, setErrors] = (0, import_react7.useState)({ acceptType: false, maxFileSize: false, resolution: false });
675
+ const handleChange = (files) => __async(null, null, function* () {
676
+ if (!files) return null;
677
+ const file = files[0];
678
+ if (!file) return null;
679
+ const newErrors = {
680
+ acceptType: false,
681
+ maxFileSize: false,
682
+ resolution: false
683
+ };
684
+ const uploadSize = Number((file.size / 1024).toFixed(2));
685
+ if (maxFileSize && uploadSize > maxFileSize) newErrors.maxFileSize = true;
686
+ if (!getImageAccepts(acceptType).includes(file.type)) newErrors.acceptType = true;
687
+ const image = yield getImage(file);
688
+ const checkRes = isResolutionValid(image, resolutionType, resolutionWidth, resolutionHeight);
689
+ if (!checkRes) newErrors.resolution = true;
690
+ setErrors(newErrors);
691
+ if (newErrors.acceptType || newErrors.maxFileSize || newErrors.resolution) {
692
+ onError == null ? void 0 : onError(newErrors);
693
+ return;
694
+ }
695
+ const dataUrl = yield getBase64(file);
696
+ onChange({
697
+ file,
698
+ dataURL: dataUrl
699
+ });
700
+ });
701
+ const onImageRemove = () => {
702
+ onChange(null);
703
+ };
704
+ const onInputChange = (e) => __async(null, null, function* () {
705
+ yield handleChange(e.target.files);
706
+ if (inputRef.current) inputRef.current.value = "";
707
+ });
708
+ const handleClickInput = (0, import_react7.useCallback)(() => openFileDialog(inputRef), [
709
+ inputRef
710
+ ]);
711
+ const onImageUpload = (0, import_react7.useCallback)(() => {
712
+ handleClickInput();
713
+ }, [handleClickInput]);
714
+ const handleDrag = (e) => {
715
+ e.preventDefault();
716
+ e.stopPropagation();
717
+ };
718
+ const handleDragIn = (e) => {
719
+ e.preventDefault();
720
+ e.stopPropagation();
721
+ if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
722
+ setIsDragging(true);
723
+ }
724
+ };
725
+ const handleDragOut = (e) => {
726
+ e.preventDefault();
727
+ e.stopPropagation();
728
+ setIsDragging(false);
729
+ };
730
+ const handleDrop = (e) => {
731
+ e.preventDefault();
732
+ e.stopPropagation();
733
+ setIsDragging(false);
734
+ if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
735
+ handleChange(e.dataTransfer.files);
736
+ }
737
+ };
738
+ const handleDragStart = (e) => {
739
+ e.preventDefault();
740
+ e.stopPropagation();
741
+ e.dataTransfer.clearData();
742
+ };
743
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
745
+ "input",
746
+ __spreadValues({
747
+ type: "file",
748
+ style: { display: "none" },
749
+ accept: getImageAccepts(acceptType).join(","),
750
+ multiple: false,
751
+ onChange: onInputChange,
752
+ ref: inputRef
753
+ }, inputProps)
754
+ ),
755
+ children == null ? void 0 : children({
756
+ onImageUpload,
757
+ onImageRemove,
758
+ dragProps: {
759
+ onDrop: handleDrop,
760
+ onDragEnter: handleDragIn,
761
+ onDragLeave: handleDragOut,
762
+ onDragOver: handleDrag,
763
+ onDragStart: handleDragStart
764
+ },
765
+ isDragging,
766
+ errors,
767
+ imageInfo: value
768
+ })
769
+ ] });
770
+ };
771
+ var ImageUpload_default = ImageUpload;
772
+
773
+ // src/lib/components/_com/ImageUploader.tsx
774
+ var import_react_easy_crop = __toESM(require("react-easy-crop"));
775
+ var import_react10 = require("motion/react");
776
+
777
+ // src/lib/components/_com/Loading.tsx
778
+ var import_tailwind_merge4 = require("tailwind-merge");
779
+ var import_jsx_runtime6 = require("react/jsx-runtime");
780
+ var Loading = ({ size = 25, className }) => {
781
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("svg", { className: `animate-spin ${(0, import_tailwind_merge4.twMerge)("stroke-primary", className)}`, viewBox: "0 0 256 256", style: { width: size + "px", height: size + "px" }, children: [
782
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "128", y1: "32", x2: "128", y2: "64", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
783
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "195.9", y1: "60.1", x2: "173.3", y2: "82.7", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
784
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "224", y1: "128", x2: "192", y2: "128", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
785
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "195.9", y1: "195.9", x2: "173.3", y2: "173.3", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
786
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "128", y1: "224", x2: "128", y2: "192", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
787
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "60.1", y1: "195.9", x2: "82.7", y2: "173.3", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
788
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "32", y1: "128", x2: "64", y2: "128", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" }),
789
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("line", { x1: "60.1", y1: "60.1", x2: "82.7", y2: "82.7", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" })
790
+ ] });
791
+ };
792
+ var Loading_default = Loading;
793
+
794
+ // src/lib/components/InputComponent.tsx
795
+ var import_jsx_runtime7 = require("react/jsx-runtime");
796
+ var InputComponent = (_a) => {
797
+ var _b = _a, { id, label, containerClassName = "", icon } = _b, rest = __objRest(_b, ["id", "label", "containerClassName", "icon"]);
798
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: containerClassName, children: [
799
+ label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: id, className: "block mb-1 text-gray-700 text-base font-medium", children: label }),
800
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
801
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
802
+ "input",
803
+ __spreadProps(__spreadValues({}, rest), {
804
+ className: "border border-solid border-gray-200 px-2 py-1.5 w-full rounded-md focus:outline-none"
805
+ })
806
+ ),
807
+ icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: icon })
808
+ ] })
809
+ ] });
810
+ };
811
+ var InputComponent_default = InputComponent;
812
+
813
+ // src/lib/components/CheckboxComponent.tsx
814
+ var import_tailwind_merge5 = require("tailwind-merge");
815
+ var import_jsx_runtime8 = require("react/jsx-runtime");
816
+ var CheckboxComponent = ({ id, checked, onChange, className, label, labelPlacement = "right", bottomSpace = true, customLabel, errorMessage = false, containerClassName = "" }) => {
817
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)(`flex items-start ${labelPlacement === "left" ? "gap-7" : "gap-2"} ${bottomSpace && "mb-6"}`, containerClassName), children: [
818
+ label && labelPlacement === "left" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: id, className: `select-none cursor-pointer block text-[15px] ${errorMessage ? "text-error" : "text-gray-700"}`, children: label }),
819
+ customLabel && labelPlacement === "left" && customLabel,
820
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative mt-0.5", children: [
821
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
822
+ "input",
823
+ {
824
+ type: "checkbox",
825
+ id,
826
+ className: `peer appearance-none border border-gray-300 w-4 h-4 rounded align-middle block bg-white checked:border-gray-700 checked:bg-gray-700 cursor-pointer ${className}`,
827
+ checked,
828
+ onChange: (e) => onChange(e.target.checked)
829
+ }
830
+ ),
831
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-white p-px pointer-events-none opacity-0 invisible peer-checked:opacity-100 peer-checked:visible", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-3.5 w-3.5", viewBox: "0 0 20 20", fill: "currentColor", stroke: "currentColor", strokeWidth: "1", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })
832
+ ] }),
833
+ customLabel && labelPlacement === "right" && customLabel,
834
+ label && labelPlacement === "right" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: id, className: `select-none cursor-pointer block text-[15px] ${errorMessage ? "text-error" : "text-gray-700"}`, children: label })
835
+ ] });
836
+ };
837
+ var CheckboxComponent_default = CheckboxComponent;
838
+
839
+ // src/lib/components/_com/RangeSlider.tsx
840
+ var import_react8 = require("react");
841
+ var import_tailwind_merge6 = require("tailwind-merge");
842
+ var import_jsx_runtime9 = require("react/jsx-runtime");
843
+ var RangeSlider = ({ min = 0, max = 100, step = 1, onChange, value, className = "", height = 4, trackColor = "#d7dbe0", showInput = true }) => {
844
+ const trackRef = (0, import_react8.useRef)(null);
845
+ const [trackWidth, setTrackWidth] = (0, import_react8.useState)(null);
846
+ const [inputValue, setInputValue] = (0, import_react8.useState)({ isFocus: false, value: value == null ? void 0 : value.toString() });
847
+ const percentage = (value - min) / (max - min) * 100;
848
+ const getThumbPosition = () => {
849
+ if (!trackWidth) return `${percentage}%`;
850
+ const thumbWidth = 18;
851
+ const pixelPosition = percentage / 100 * (trackWidth - thumbWidth) + thumbWidth / 2;
852
+ return `${pixelPosition / trackWidth * 100}%`;
853
+ };
854
+ const validateAndUpdateValue = () => {
855
+ let newValue = Number(inputValue.value);
856
+ if (isNaN(newValue)) {
857
+ setInputValue({ isFocus: false, value: value.toString() });
858
+ return;
859
+ }
860
+ if (newValue < min) newValue = min;
861
+ if (newValue > max) newValue = max;
862
+ if (step !== 1) {
863
+ const steps = Math.round((newValue - min) / step);
864
+ newValue = min + steps * step;
865
+ }
866
+ onChange(newValue);
867
+ setInputValue({ isFocus: false, value: newValue.toString() });
868
+ };
869
+ const handleKeyDown = (e) => {
870
+ if (e.key === "Enter") {
871
+ validateAndUpdateValue();
872
+ }
873
+ };
874
+ const handleBlur = () => {
875
+ validateAndUpdateValue();
876
+ };
877
+ const handleFocus = () => {
878
+ setInputValue({ isFocus: true, value: value.toString() });
879
+ };
880
+ (0, import_react8.useLayoutEffect)(() => {
881
+ if (trackRef.current) {
882
+ setTrackWidth(trackRef.current.clientWidth);
883
+ }
884
+ }, []);
885
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: (0, import_tailwind_merge6.twMerge)("relative flex items-center", className), children: [
886
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: trackRef, className: "relative w-full rounded-full", style: { height: `${height}px`, background: trackColor }, children: [
887
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
888
+ "input",
889
+ {
890
+ type: "range",
891
+ min,
892
+ max,
893
+ step,
894
+ value,
895
+ onChange: (e) => onChange(Number(e.target.value)),
896
+ className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10 peer"
897
+ }
898
+ ),
899
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "absolute h-full rounded-full bg-gray-700", style: { width: `${percentage}%` } }),
900
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-4.5 h-4.5 absolute top-1/2 -translate-1/2 group", style: { left: getThumbPosition() }, children: [
901
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "absolute w-full h-full bg-white rounded-full border border-solid border-gray-300 shadow-3xl z-99" }),
902
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "absolute bg-gray-200 -top-2.5 -left-2.5 -right-2.5 -bottom-2.5 rounded-full opacity-0 group-peer-active:opacity-100 z-9" })
903
+ ] })
904
+ ] }),
905
+ showInput && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
906
+ "input",
907
+ {
908
+ type: "text",
909
+ value: inputValue.isFocus ? inputValue.value : value,
910
+ onChange: (e) => setInputValue((p) => __spreadProps(__spreadValues({}, p), { value: e.target.value })),
911
+ onKeyDown: handleKeyDown,
912
+ onBlur: handleBlur,
913
+ onFocus: handleFocus,
914
+ className: "ml-4 w-12 text-center border border-gray-200 rounded px-1 py-1.5 text-sm focus:outline-none focus:border-gray-400",
915
+ "aria-label": "Range value"
916
+ }
917
+ )
918
+ ] });
919
+ };
920
+ var RangeSlider_default = RangeSlider;
921
+
922
+ // src/lib/components/_com/ImageUploader.tsx
923
+ var import_jsx_runtime10 = require("react/jsx-runtime");
924
+ var ImageUploader = ({ editor, options, onClose }) => {
925
+ const [image, setImage] = (0, import_react9.useState)(null);
926
+ const [open, setOpen] = (0, import_react9.useState)(false);
927
+ const [crop, setCrop] = (0, import_react9.useState)({ x: 0, y: 0 });
928
+ const [zoom, setZoom] = (0, import_react9.useState)(1);
929
+ const [rotation, setRotation] = (0, import_react9.useState)(0);
930
+ const [alt, setAlt] = (0, import_react9.useState)("");
931
+ const [inline, setInline] = (0, import_react9.useState)(false);
932
+ const [flip3, setFlip] = (0, import_react9.useState)({ horizontal: false, vertical: false });
933
+ const [croppedAreaPixels, setCroppedAreaPixels] = (0, import_react9.useState)(null);
934
+ const [isUploading, setUploading] = (0, import_react9.useState)(false);
935
+ const onImageChange = (image2) => __async(null, null, function* () {
936
+ setImage(image2);
937
+ });
938
+ const reset = () => {
939
+ setOpen(false);
940
+ setCrop({ x: 0, y: 0 });
941
+ setZoom(1);
942
+ setRotation(0);
943
+ setFlip({ horizontal: false, vertical: false });
944
+ setCroppedAreaPixels(null);
945
+ };
946
+ const createCroppedImage = () => __async(null, null, function* () {
947
+ if (image == null ? void 0 : image.dataURL) {
948
+ const croppedImage = yield getCroppedImg(
949
+ image == null ? void 0 : image.dataURL,
950
+ croppedAreaPixels,
951
+ rotation
952
+ );
953
+ onImageChange(croppedImage);
954
+ reset();
955
+ }
956
+ });
957
+ const onInsertImage = () => __async(null, null, function* () {
958
+ if (!(image == null ? void 0 : image.dataURL)) return;
959
+ if (options == null ? void 0 : options.upload) {
960
+ if (!image.file) return;
961
+ setUploading(true);
962
+ const url = yield options.upload(image.file);
963
+ editor == null ? void 0 : editor.chain().focus().setImageWithInline({ src: url, alt, width: 300, inline }).run();
964
+ setUploading(false);
965
+ onClose == null ? void 0 : onClose();
966
+ } else {
967
+ editor == null ? void 0 : editor.chain().focus().setImageWithInline({ src: image.dataURL, alt, width: 300, inline }).run();
968
+ onClose == null ? void 0 : onClose();
969
+ }
970
+ });
971
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "mt-3", children: [
972
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
973
+ ImageUpload_default,
974
+ {
975
+ onChange: onImageChange,
976
+ value: image,
977
+ maxFileSize: options == null ? void 0 : options.maxSize,
978
+ children: ({
979
+ isDragging,
980
+ dragProps,
981
+ onImageUpload,
982
+ errors
983
+ }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "relative", children: [
984
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `border bg-gray-50 overflow-hidden border-dashed w-full pt-7 pb-4 rounded-xl relative ${isDragging ? "border-green-600" : "border-gray-300"}`, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "text-center px-4 flex items-center justify-center w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
985
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", __spreadProps(__spreadValues({}, dragProps), { children: !(image == null ? void 0 : image.dataURL) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react9.Fragment, { children: [
986
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageIcon, { className: "mx-auto", size: 60, strokeWidth: 1.5 }),
987
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "mt-4 text-base", children: "Drag and drop an image here, or click following button to upload image." })
988
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "relative w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("img", { src: image.dataURL, alt: "Selected Image", className: "object-contain w-full h-full" }) }) })),
989
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex gap-x-2 mt-4", children: [
990
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "flex-1 cursor-pointer text-center bg-white border rounded-lg border-gray-200 py-2 text-sm px-2", onClick: onImageUpload, children: "Upload Image" }),
991
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "flex-1 rounded-lg text-center bg-white cursor-pointer border border-gray-200 py-2 text-sm px-2", onClick: () => (onImageUpload(), setOpen(true)), children: "Upload & Crop" })
992
+ ] })
993
+ ] }) }) }),
994
+ errors && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("ul", { className: "mt-2 ml-1", children: [
995
+ errors.maxFileSize && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("li", { className: "flex text-sm text-error items-center gap-1", children: [
996
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "w-1 h-1 rounded-full bg-error" }),
997
+ " ",
998
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: "File size exceeds 5MB limit." })
999
+ ] }),
1000
+ errors.acceptType && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("li", { className: "flex text-sm text-error items-center gap-1", children: [
1001
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "w-1 h-1 rounded-full bg-error" }),
1002
+ " ",
1003
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: "Only image files are allowed." })
1004
+ ] })
1005
+ ] }),
1006
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1007
+ CheckboxComponent_default,
1008
+ {
1009
+ id: "isInline",
1010
+ checked: inline,
1011
+ onChange: setInline,
1012
+ label: "Insert as inline",
1013
+ bottomSpace: false
1014
+ }
1015
+ ),
1016
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1017
+ InputComponent_default,
1018
+ {
1019
+ id: "Alt",
1020
+ placeholder: "Alt text",
1021
+ containerClassName: "mt-3",
1022
+ value: alt,
1023
+ onChange: (e) => setAlt(e.target.value)
1024
+ }
1025
+ ),
1026
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("button", { className: "bg-gray-700 py-2 px-6 rounded-lg text-white w-full mt-3 relative", onClick: onInsertImage, children: [
1027
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${isUploading && "opacity-15"}`, children: "Insert Image" }),
1028
+ isUploading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Loading_default, { className: "absolute top-1/2 left-1/2 -translate-1/2 stroke-white", size: 24 })
1029
+ ] })
1030
+ ] })
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react10.AnimatePresence, { children: open && (image == null ? void 0 : image.dataURL) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1034
+ import_react10.motion.div,
1035
+ {
1036
+ className: "fixed top-0 left-0 w-full h-full bg-black z-99999 flex flex-col",
1037
+ initial: { opacity: 0 },
1038
+ animate: { opacity: 1 },
1039
+ exit: { opacity: 0 },
1040
+ transition: { duration: 0.2 },
1041
+ children: [
1042
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "absolute top-8 right-8 bg-white z-9999999 text-black rounded-md p-1", onClick: () => (reset(), setImage(null)), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CloseIcon, {}) }),
1043
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "w-full flex-1 relative h-full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1044
+ import_react_easy_crop.default,
1045
+ {
1046
+ image: image == null ? void 0 : image.dataURL,
1047
+ aspect: (options == null ? void 0 : options.aspect) || 1,
1048
+ crop,
1049
+ zoom,
1050
+ rotation,
1051
+ onCropChange: setCrop,
1052
+ onZoomChange: setZoom,
1053
+ onRotationChange: setRotation,
1054
+ onCropComplete: (_, e) => setCroppedAreaPixels(e),
1055
+ transform: [
1056
+ `translate(${crop.x}px, ${crop.y}px)`,
1057
+ `rotateY(${flip3.horizontal ? 180 : 0}deg)`,
1058
+ `rotateX(${flip3.vertical ? 180 : 0}deg)`,
1059
+ `rotateZ(${rotation}deg)`,
1060
+ `scale(${zoom})`
1061
+ ].join(" ")
1062
+ }
1063
+ ) }),
1064
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1065
+ import_react10.motion.div,
1066
+ {
1067
+ className: "z-999 relative bg-white py-9 px-20",
1068
+ initial: { y: 16, opacity: 0 },
1069
+ animate: { y: 0, opacity: 1 },
1070
+ exit: { y: 16, opacity: 0 },
1071
+ transition: { duration: 0.22, ease: [0.22, 1, 0.36, 1] },
1072
+ children: [
1073
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex gap-x-10", children: [
1074
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex gap-x-6 flex-1 items-center", children: [
1075
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h4", { children: "ZOOM" }),
1076
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RangeSlider_default, { value: zoom, min: 1, max: 3, onChange: setZoom, step: 1e-10 }) })
1077
+ ] }),
1078
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex gap-x-6 flex-1 items-center", children: [
1079
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h4", { children: "ROTATION" }),
1080
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RangeSlider_default, { value: rotation, min: 0, max: 360, step: 1, onChange: setRotation }) })
1081
+ ] }),
1082
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "hover:bg-light px-2 py-2 rounded-lg transition-all", type: "button", onClick: () => setFlip((prev) => ({ horizontal: prev.horizontal, vertical: !prev.vertical })), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FlipVertical, {}) }),
1083
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "hover:bg-light px-2 py-2 rounded-lg transition-all", type: "button", onClick: () => setFlip((prev) => ({ horizontal: !prev.horizontal, vertical: prev.vertical })), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FlipHorizontal, {}) })
1084
+ ] }),
1085
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mt-8 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", onClick: createCroppedImage, className: "bg-gray-700 py-2 px-6 rounded-lg text-white", children: "Crop & Done" }) })
1086
+ ]
1087
+ }
1088
+ )
1089
+ ]
1090
+ }
1091
+ ) })
1092
+ ] });
1093
+ };
1094
+ var ImageUploader_default = ImageUploader;
1095
+
1096
+ // src/lib/components/ImageDialog.tsx
1097
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1098
+ var ImageDialog = ({ open, onClose, editor, options }) => {
1099
+ const [type, setType] = (0, import_react11.useState)("upload");
1100
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1101
+ Dialog_default,
1102
+ {
1103
+ open,
1104
+ onClose,
1105
+ className: "max-w-100 w-[calc(100vw-4px)]",
1106
+ children: [
1107
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1108
+ Dialog_default.Header,
1109
+ {
1110
+ title: "Add an image",
1111
+ onClose,
1112
+ className: "px-3 py-3.5",
1113
+ titleClassName: "text-lg font-medium"
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Dialog_default.Body, { className: "px-3 pb-3 pl-3 pr-3", children: [
1117
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex bg-gray-100 p-1 rounded-lg", children: [
1118
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: `flex-1 py-2 text-sm text-center px-2 rounded-lg ${type === "upload" ? "bg-white" : ""}`, onClick: () => setType("upload"), children: "Upload" }),
1119
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: `flex-1 py-2 text-sm text-center px-2 rounded-lg ${type === "url" ? "bg-white" : ""}`, onClick: () => setType("url"), children: "URL" })
1120
+ ] }),
1121
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1122
+ ImageUploader_default,
1123
+ {
1124
+ editor,
1125
+ options,
1126
+ onClose
1127
+ }
1128
+ )
1129
+ ] })
1130
+ ]
1131
+ }
1132
+ );
1133
+ };
1134
+ var ImageDialog_default = ImageDialog;
1135
+
1136
+ // src/lib/components/ImageView.tsx
1137
+ var import_react12 = require("react");
1138
+ var import_react13 = require("@tiptap/react");
1139
+ var import_react14 = require("@floating-ui/react");
1140
+ var import_react15 = require("motion/react");
1141
+ var import_state = require("@tiptap/pm/state");
1142
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1143
+ var clamp = (v, min, max) => Math.max(min, Math.min(max, v));
1144
+ var ImageView = (props) => {
1145
+ var _a, _b;
1146
+ const { node, selected, updateAttributes, deleteNode, editor, getPos } = props;
1147
+ const rootRef = (0, import_react12.useRef)(null);
1148
+ const boxRef = (0, import_react12.useRef)(null);
1149
+ const imgRef = (0, import_react12.useRef)(null);
1150
+ const floatingWrapRef = (0, import_react12.useRef)(null);
1151
+ const [resizing, setResizing] = (0, import_react12.useState)(false);
1152
+ const [dragging, setDragging] = (0, import_react12.useState)(false);
1153
+ const draggingRef = (0, import_react12.useRef)(false);
1154
+ const isInline = !!node.attrs.inline;
1155
+ const align = node.attrs.align || "left";
1156
+ const width = (_a = node.attrs.width) != null ? _a : null;
1157
+ const height = (_b = node.attrs.height) != null ? _b : null;
1158
+ const flipX = !!node.attrs.flipX;
1159
+ const flipY = !!node.attrs.flipY;
1160
+ const transform = (0, import_react12.useMemo)(() => {
1161
+ const sx = flipX ? -1 : 1;
1162
+ const sy = flipY ? -1 : 1;
1163
+ return `scale(${sx}, ${sy})`;
1164
+ }, [flipX, flipY]);
1165
+ const keepSelected = () => {
1166
+ try {
1167
+ const pos = typeof getPos === "function" ? getPos() : null;
1168
+ if (typeof pos === "number") editor.commands.setNodeSelection(pos);
1169
+ } catch (e) {
1170
+ void e;
1171
+ }
1172
+ };
1173
+ const setAlign = (a) => {
1174
+ keepSelected();
1175
+ updateAttributes({ align: a, inline: false });
1176
+ queueMicrotask(keepSelected);
1177
+ };
1178
+ const toggleFlipX = () => {
1179
+ keepSelected();
1180
+ updateAttributes({ flipX: !flipX });
1181
+ queueMicrotask(keepSelected);
1182
+ };
1183
+ const toggleFlipY = () => {
1184
+ keepSelected();
1185
+ updateAttributes({ flipY: !flipY });
1186
+ queueMicrotask(keepSelected);
1187
+ };
1188
+ const isMenuVisible = selected && !resizing && !draggingRef.current;
1189
+ const { refs, floatingStyles, context, update } = (0, import_react14.useFloating)({
1190
+ open: isMenuVisible,
1191
+ placement: "bottom",
1192
+ whileElementsMounted: import_react14.autoUpdate,
1193
+ strategy: "fixed",
1194
+ middleware: [(0, import_react14.offset)(14), (0, import_react14.flip)({ padding: 10 }), (0, import_react14.shift)({ padding: 8 })],
1195
+ onOpenChange: (open, ev) => {
1196
+ var _a2;
1197
+ if (open) return;
1198
+ const target = (_a2 = ev == null ? void 0 : ev.target) != null ? _a2 : null;
1199
+ if (!target) return;
1200
+ const view = editor.view;
1201
+ if (view.dom.contains(target)) return;
1202
+ try {
1203
+ const pos = typeof getPos === "function" ? getPos() : null;
1204
+ if (typeof pos !== "number") return;
1205
+ const docSize = view.state.doc.content.size;
1206
+ const next = Math.min(pos + 1, docSize);
1207
+ const tr = view.state.tr.setSelection(import_state.TextSelection.create(view.state.doc, next));
1208
+ view.dispatch(tr);
1209
+ } catch (e) {
1210
+ void e;
1211
+ }
1212
+ }
1213
+ });
1214
+ const setReferenceEl = (el) => {
1215
+ boxRef.current = el;
1216
+ if (el) refs.setReference(el);
1217
+ };
1218
+ const setFloatingWrapEl = (el) => {
1219
+ floatingWrapRef.current = el;
1220
+ if (el) refs.setFloating(el);
1221
+ };
1222
+ (0, import_react12.useLayoutEffect)(() => {
1223
+ if (!isMenuVisible) return;
1224
+ requestAnimationFrame(() => requestAnimationFrame(() => update()));
1225
+ }, [isMenuVisible, update]);
1226
+ const dismiss = (0, import_react14.useDismiss)(context, {
1227
+ outsidePressEvent: "pointerdown",
1228
+ outsidePress: (event) => {
1229
+ var _a2, _b2;
1230
+ const t = event.target;
1231
+ if (!t) return true;
1232
+ if ((_a2 = rootRef.current) == null ? void 0 : _a2.contains(t)) return false;
1233
+ if ((_b2 = floatingWrapRef.current) == null ? void 0 : _b2.contains(t)) return false;
1234
+ return true;
1235
+ }
1236
+ });
1237
+ const { getReferenceProps, getFloatingProps } = (0, import_react14.useInteractions)([dismiss]);
1238
+ const startResize = (corner, e) => {
1239
+ var _a2, _b2;
1240
+ e.preventDefault();
1241
+ e.stopPropagation();
1242
+ const box = boxRef.current;
1243
+ const img = imgRef.current;
1244
+ if (!box || !img) return;
1245
+ keepSelected();
1246
+ e.currentTarget.setPointerCapture(e.pointerId);
1247
+ const rect = box.getBoundingClientRect();
1248
+ const imgRect = img.getBoundingClientRect();
1249
+ const startW = (_a2 = width != null ? width : imgRect.width) != null ? _a2 : 200;
1250
+ const startH = (_b2 = height != null ? height : imgRect.height) != null ? _b2 : 200;
1251
+ const ratio = startW > 0 ? startH / startW : 1;
1252
+ const anchor = (() => {
1253
+ if (corner === "tl") return { x: rect.right, y: rect.bottom };
1254
+ if (corner === "tr") return { x: rect.left, y: rect.bottom };
1255
+ if (corner === "bl") return { x: rect.right, y: rect.top };
1256
+ return { x: rect.left, y: rect.top };
1257
+ })();
1258
+ setResizing(true);
1259
+ let raf = 0;
1260
+ let lastW = startW;
1261
+ let lastH = startH;
1262
+ const apply = (w, h) => {
1263
+ if (Math.abs(w - lastW) < 1 && Math.abs(h - lastH) < 1) return;
1264
+ lastW = w;
1265
+ lastH = h;
1266
+ updateAttributes({ width: w, height: h });
1267
+ };
1268
+ const onMove = (ev) => {
1269
+ const rawW = Math.abs(ev.clientX - anchor.x);
1270
+ const nextW = clamp(Math.round(rawW), 50, 4e3);
1271
+ const nextH = clamp(Math.round(nextW * ratio), 50, 4e3);
1272
+ if (raf) cancelAnimationFrame(raf);
1273
+ raf = requestAnimationFrame(() => apply(nextW, nextH));
1274
+ };
1275
+ const finish = () => {
1276
+ if (raf) cancelAnimationFrame(raf);
1277
+ setResizing(false);
1278
+ window.removeEventListener("pointermove", onMove);
1279
+ window.removeEventListener("pointerup", finish);
1280
+ setTimeout(keepSelected, 0);
1281
+ };
1282
+ window.addEventListener("pointermove", onMove);
1283
+ window.addEventListener("pointerup", finish, { once: true });
1284
+ };
1285
+ const applyInlineByDropContext = (dropEvent) => {
1286
+ requestAnimationFrame(() => {
1287
+ var _a2, _b2;
1288
+ const view = editor.view;
1289
+ const { state, dispatch } = view;
1290
+ const sel = state.selection;
1291
+ let imagePos = null;
1292
+ let imageNode = null;
1293
+ if (sel instanceof import_state.NodeSelection && sel.node.type.name === node.type.name) {
1294
+ imagePos = sel.from;
1295
+ imageNode = sel.node;
1296
+ } else {
1297
+ const coords = view.posAtCoords({ left: dropEvent.clientX, top: dropEvent.clientY });
1298
+ const pos = (_a2 = coords == null ? void 0 : coords.pos) != null ? _a2 : null;
1299
+ if (typeof pos === "number") {
1300
+ const maybe = state.doc.nodeAt(pos);
1301
+ if (((_b2 = maybe == null ? void 0 : maybe.type) == null ? void 0 : _b2.name) === node.type.name) {
1302
+ imagePos = pos;
1303
+ imageNode = maybe;
1304
+ }
1305
+ }
1306
+ }
1307
+ if (!imageNode || typeof imagePos !== "number") return;
1308
+ const $pos = state.doc.resolve(imagePos);
1309
+ const shouldInline = $pos.parent.isTextblock;
1310
+ const tr = state.tr.setNodeMarkup(imagePos, void 0, __spreadProps(__spreadValues({}, imageNode.attrs), {
1311
+ inline: shouldInline
1312
+ }));
1313
+ if (tr.docChanged) dispatch(tr);
1314
+ });
1315
+ };
1316
+ (0, import_react12.useEffect)(() => {
1317
+ if (!dragging) return;
1318
+ const stop = () => {
1319
+ draggingRef.current = false;
1320
+ setDragging(false);
1321
+ };
1322
+ window.addEventListener("dragend", stop, true);
1323
+ window.addEventListener("drop", stop, true);
1324
+ window.addEventListener("mouseup", stop, true);
1325
+ return () => {
1326
+ window.removeEventListener("dragend", stop, true);
1327
+ window.removeEventListener("drop", stop, true);
1328
+ window.removeEventListener("mouseup", stop, true);
1329
+ };
1330
+ }, [dragging]);
1331
+ const onDragStartCapture = (e) => {
1332
+ draggingRef.current = true;
1333
+ setDragging(true);
1334
+ try {
1335
+ const pos = typeof getPos === "function" ? getPos() : null;
1336
+ if (typeof pos !== "number") return;
1337
+ const { state, dispatch } = editor.view;
1338
+ dispatch(state.tr.setSelection(import_state.NodeSelection.create(state.doc, pos)));
1339
+ const slice = editor.view.state.selection.content();
1340
+ editor.view.dragging = { slice, move: true };
1341
+ try {
1342
+ e.dataTransfer.effectAllowed = "move";
1343
+ e.dataTransfer.dropEffect = "move";
1344
+ e.dataTransfer.setData("text/plain", " ");
1345
+ } catch (e2) {
1346
+ }
1347
+ } catch (e2) {
1348
+ void e2;
1349
+ }
1350
+ };
1351
+ const onDropCapture = (e) => {
1352
+ if (!draggingRef.current) return;
1353
+ applyInlineByDropContext(e.nativeEvent);
1354
+ };
1355
+ const onDragEnd = () => {
1356
+ draggingRef.current = false;
1357
+ setDragging(false);
1358
+ setTimeout(keepSelected, 0);
1359
+ };
1360
+ const wrapperStyle = isInline ? { display: "inline-block", verticalAlign: "baseline", maxWidth: "100%" } : { display: "block", width: "100%", textAlign: align };
1361
+ const boxStyle = {
1362
+ display: "inline-block",
1363
+ position: "relative",
1364
+ maxWidth: "100%",
1365
+ outline: selected ? "2px solid #111827" : void 0,
1366
+ outlineOffset: selected ? 2 : void 0
1367
+ };
1368
+ const imgStyle = {
1369
+ display: "block",
1370
+ maxWidth: "100%",
1371
+ width: width ? `${width}px` : void 0,
1372
+ height: height ? `${height}px` : "auto",
1373
+ transform,
1374
+ userSelect: "none",
1375
+ opacity: dragging ? 0.7 : 1
1376
+ };
1377
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1378
+ import_react13.NodeViewWrapper,
1379
+ {
1380
+ ref: rootRef,
1381
+ as: "span",
1382
+ contentEditable: false,
1383
+ draggable: true,
1384
+ onDragStartCapture,
1385
+ onDropCapture,
1386
+ onDragEnd,
1387
+ "data-node": "image",
1388
+ "data-inline": isInline ? "true" : "false",
1389
+ style: wrapperStyle,
1390
+ children: [
1391
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1392
+ "span",
1393
+ __spreadProps(__spreadValues({
1394
+ ref: setReferenceEl
1395
+ }, getReferenceProps({
1396
+ onPointerDownCapture: () => {
1397
+ keepSelected();
1398
+ if (!dragging) draggingRef.current = false;
1399
+ }
1400
+ })), {
1401
+ style: boxStyle,
1402
+ children: [
1403
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1404
+ "img",
1405
+ {
1406
+ ref: imgRef,
1407
+ src: node.attrs.src,
1408
+ alt: node.attrs.alt || "",
1409
+ title: node.attrs.title || "",
1410
+ draggable: false,
1411
+ style: imgStyle
1412
+ }
1413
+ ),
1414
+ dragging && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1415
+ "span",
1416
+ {
1417
+ style: {
1418
+ pointerEvents: "none",
1419
+ position: "absolute",
1420
+ inset: 0,
1421
+ borderRadius: 6,
1422
+ boxShadow: "0 0 0 2px rgba(17,24,39,0.4) inset"
1423
+ }
1424
+ }
1425
+ ),
1426
+ selected && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1427
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { onPointerDown: (e) => startResize("tl", e), style: { position: "absolute", top: -8, left: -8, height: 12, width: 12, background: "#111827", cursor: "nwse-resize" } }),
1428
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { onPointerDown: (e) => startResize("tr", e), style: { position: "absolute", top: -8, right: -8, height: 12, width: 12, background: "#111827", cursor: "nesw-resize" } }),
1429
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { onPointerDown: (e) => startResize("bl", e), style: { position: "absolute", bottom: -8, left: -8, height: 12, width: 12, background: "#111827", cursor: "nesw-resize" } }),
1430
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { onPointerDown: (e) => startResize("br", e), style: { position: "absolute", bottom: -8, right: -8, height: 12, width: 12, background: "#111827", cursor: "nwse-resize" } })
1431
+ ] })
1432
+ ]
1433
+ })
1434
+ ),
1435
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react15.AnimatePresence, { children: isMenuVisible && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1436
+ "div",
1437
+ __spreadProps(__spreadValues({
1438
+ ref: setFloatingWrapEl,
1439
+ style: floatingStyles
1440
+ }, getFloatingProps()), {
1441
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1442
+ import_react15.motion.div,
1443
+ {
1444
+ initial: { opacity: 0, scale: 0.98, y: -4 },
1445
+ animate: { opacity: 1, scale: 1, y: 0 },
1446
+ exit: { opacity: 0, scale: 0.98, y: -4 },
1447
+ transition: { type: "tween", duration: 0.12 },
1448
+ style: {
1449
+ display: "inline-flex",
1450
+ alignItems: "center",
1451
+ gap: 6,
1452
+ borderRadius: 12,
1453
+ border: "1px solid #e5e7eb",
1454
+ background: "#ffffff",
1455
+ padding: 6,
1456
+ boxShadow: "0 10px 20px rgba(0,0,0,0.06)"
1457
+ },
1458
+ children: [
1459
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip_default, { content: "Flip Horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: toggleFlipX, style: { borderRadius: 10, border: "1px solid #e5e7eb", background: "#fff", padding: "6px 8px", fontSize: 12, cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FlipVertical, {}) }) }),
1460
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip_default, { content: "Flip Vertical", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: toggleFlipY, style: { borderRadius: 10, border: "1px solid #e5e7eb", background: "#fff", padding: "6px 8px", fontSize: 12, cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FlipHorizontal, {}) }) }),
1461
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { width: 1, height: 16, background: "#e5e7eb", margin: "0 6px" } }),
1462
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip_default, { content: "Left", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setAlign("left"), style: { borderRadius: 10, border: "1px solid #e5e7eb", background: "#fff", padding: "6px 8px", fontSize: 12, cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AlignLeft, {}) }) }),
1463
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip_default, { content: "Center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setAlign("center"), style: { borderRadius: 10, border: "1px solid #e5e7eb", background: "#fff", padding: "6px 8px", fontSize: 12, cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AlignCenter, {}) }) }),
1464
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip_default, { content: "Right", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setAlign("right"), style: { borderRadius: 10, border: "1px solid #e5e7eb", background: "#fff", padding: "6px 8px", fontSize: 12, cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AlignRight, {}) }) }),
1465
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { width: 1, height: 16, background: "#e5e7eb", margin: "0 6px" } }),
1466
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip_default, { content: "Remove", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1467
+ "button",
1468
+ {
1469
+ type: "button",
1470
+ onClick: deleteNode,
1471
+ style: {
1472
+ borderRadius: 10,
1473
+ border: "1px solid #fecaca",
1474
+ background: "#fff",
1475
+ padding: "6px 8px",
1476
+ fontSize: 12,
1477
+ cursor: "pointer",
1478
+ color: "#dc2626"
1479
+ },
1480
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TrashIcon, {})
1481
+ }
1482
+ ) })
1483
+ ]
1484
+ }
1485
+ )
1486
+ })
1487
+ ) })
1488
+ ]
1489
+ }
1490
+ );
1491
+ };
1492
+
1493
+ // src/extension/Image.tsx
1494
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1495
+ var Image2 = import_extension_image.Image.extend({
1496
+ group: "inline",
1497
+ inline: true,
1498
+ draggable: true,
1499
+ selectable: true,
1500
+ defining: true,
1501
+ addOptions() {
1502
+ var _a;
1503
+ const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
1504
+ return __spreadProps(__spreadValues({}, parent != null ? parent : {}), {
1505
+ defaultInline: false,
1506
+ component: ({ editor, options, buttonClassName }) => {
1507
+ const Wrapper = () => {
1508
+ const [open, setOpen] = (0, import_react16.useState)(false);
1509
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react16.Fragment, { children: [
1510
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1511
+ ButtonWithoutActive_default,
1512
+ {
1513
+ className: options.className,
1514
+ icon: options.icon,
1515
+ style: options.style,
1516
+ tooltip: options.tooltip,
1517
+ tooltipClassName: options.tooltipClassName,
1518
+ tooltipPlacement: options.tooltipPlacement,
1519
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ImageUpIcon, {}),
1520
+ _onToggle: () => setOpen((p) => !p),
1521
+ _tooltipContent: "Image",
1522
+ _buttonClassName: buttonClassName
1523
+ }
1524
+ ),
1525
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1526
+ ImageDialog_default,
1527
+ {
1528
+ open,
1529
+ onClose: () => setOpen(false),
1530
+ editor,
1531
+ options: {
1532
+ upload: options.upload,
1533
+ maxSize: options.maxSize,
1534
+ defaultInline: options.defaultInline,
1535
+ enableAlt: options.enableAlt,
1536
+ aspect: options.aspect
1537
+ }
1538
+ }
1539
+ )
1540
+ ] });
1541
+ };
1542
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Wrapper, {});
1543
+ }
1544
+ });
1545
+ },
1546
+ addAttributes() {
1547
+ var _a;
1548
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
1549
+ inline: {
1550
+ default: false,
1551
+ parseHTML: (el) => el.getAttribute("data-inline") === "true",
1552
+ renderHTML: (attrs) => ({ "data-inline": attrs.inline ? "true" : "false" })
1553
+ },
1554
+ width: {
1555
+ default: null,
1556
+ parseHTML: (el) => {
1557
+ const v = el.getAttribute("data-width");
1558
+ return v ? Number(v) : null;
1559
+ },
1560
+ renderHTML: (attrs) => attrs.width ? { "data-width": String(attrs.width) } : {}
1561
+ },
1562
+ height: {
1563
+ default: null,
1564
+ parseHTML: (el) => {
1565
+ const v = el.getAttribute("data-height");
1566
+ return v ? Number(v) : null;
1567
+ },
1568
+ renderHTML: (attrs) => attrs.height ? { "data-height": String(attrs.height) } : {}
1569
+ },
1570
+ flipX: {
1571
+ default: false,
1572
+ parseHTML: (el) => el.getAttribute("data-flip-x") === "true",
1573
+ renderHTML: (attrs) => ({ "data-flip-x": attrs.flipX ? "true" : "false" })
1574
+ },
1575
+ flipY: {
1576
+ default: false,
1577
+ parseHTML: (el) => el.getAttribute("data-flip-y") === "true",
1578
+ renderHTML: (attrs) => ({ "data-flip-y": attrs.flipY ? "true" : "false" })
1579
+ },
1580
+ align: {
1581
+ default: "left",
1582
+ parseHTML: (el) => el.getAttribute("data-align") || "left",
1583
+ renderHTML: (attrs) => ({ "data-align": attrs.align || "left" })
1584
+ }
1585
+ });
1586
+ },
1587
+ addCommands() {
1588
+ var _a;
1589
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
1590
+ setImageWithInline: (options) => ({ commands }) => {
1591
+ var _a2, _b;
1592
+ const inlineAttr = (_b = (_a2 = options.inline) != null ? _a2 : this.options.defaultInline) != null ? _b : false;
1593
+ const _c = options, { inline: _inline } = _c, attrs = __objRest(_c, ["inline"]);
1594
+ return commands.insertContent({
1595
+ type: this.name,
1596
+ attrs: __spreadProps(__spreadValues({}, attrs), { inline: inlineAttr })
1597
+ });
1598
+ }
1599
+ });
1600
+ },
1601
+ addNodeView() {
1602
+ return (0, import_react18.ReactNodeViewRenderer)(ImageView);
1603
+ },
1604
+ renderHTML({ HTMLAttributes }) {
1605
+ return ["img", (0, import_react17.mergeAttributes)(HTMLAttributes)];
1606
+ }
1607
+ });
1608
+ // Annotate the CommonJS export names for ESM import in node:
1609
+ 0 && (module.exports = {
1610
+ Image
1611
+ });