ritext 1.0.15 → 1.0.19

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 (63) hide show
  1. package/README.md +7 -8
  2. package/dist/chunk-2YUUKIIT.mjs +149 -0
  3. package/dist/{chunk-ZLCVIW2P.mjs → chunk-7QOFJIQ3.mjs} +1 -1
  4. package/dist/chunk-D47XME55.mjs +49 -0
  5. package/dist/{chunk-TQTCTY3E.mjs → chunk-FWCSY2DS.mjs} +1 -16
  6. package/dist/{chunk-CU67RXD7.mjs → chunk-GSHINFPO.mjs} +3 -3
  7. package/dist/{chunk-E4PPKAVK.mjs → chunk-LMOTHRGQ.mjs} +1 -1
  8. package/dist/{chunk-LO4RJXQF.mjs → chunk-MBF77NHS.mjs} +1 -1
  9. package/dist/chunk-VYDH6BZE.mjs +17 -0
  10. package/dist/extension/bold.d.mts +1 -1
  11. package/dist/extension/bold.d.ts +1 -1
  12. package/dist/extension/bold.js +1 -1
  13. package/dist/extension/bold.mjs +4 -3
  14. package/dist/extension/clearformat.d.mts +8 -0
  15. package/dist/extension/clearformat.d.ts +8 -0
  16. package/dist/extension/clearformat.js +239 -0
  17. package/dist/extension/clearformat.mjs +69 -0
  18. package/dist/extension/font-family.d.mts +23 -0
  19. package/dist/extension/font-family.d.ts +23 -0
  20. package/dist/extension/font-family.js +388 -0
  21. package/dist/extension/font-family.mjs +113 -0
  22. package/dist/extension/font-size.d.mts +23 -0
  23. package/dist/extension/font-size.d.ts +23 -0
  24. package/dist/extension/font-size.js +386 -0
  25. package/dist/extension/font-size.mjs +111 -0
  26. package/dist/extension/heading.d.mts +23 -0
  27. package/dist/extension/heading.d.ts +23 -0
  28. package/dist/extension/heading.js +593 -0
  29. package/dist/extension/heading.mjs +312 -0
  30. package/dist/extension/history.d.mts +8 -0
  31. package/dist/extension/history.d.ts +8 -0
  32. package/dist/extension/history.js +296 -0
  33. package/dist/extension/history.mjs +126 -0
  34. package/dist/extension/italic.d.mts +1 -1
  35. package/dist/extension/italic.d.ts +1 -1
  36. package/dist/extension/italic.js +1 -1
  37. package/dist/extension/italic.mjs +4 -3
  38. package/dist/extension/strike.d.mts +1 -1
  39. package/dist/extension/strike.d.ts +1 -1
  40. package/dist/extension/strike.js +1 -1
  41. package/dist/extension/strike.mjs +4 -3
  42. package/dist/extension/subandsuperscript.d.mts +1 -1
  43. package/dist/extension/subandsuperscript.d.ts +1 -1
  44. package/dist/extension/subandsuperscript.js +30 -21
  45. package/dist/extension/subandsuperscript.mjs +37 -159
  46. package/dist/extension/subscript.d.mts +1 -1
  47. package/dist/extension/subscript.d.ts +1 -1
  48. package/dist/extension/subscript.js +1 -1
  49. package/dist/extension/subscript.mjs +5 -4
  50. package/dist/extension/superscript.d.mts +1 -1
  51. package/dist/extension/superscript.d.ts +1 -1
  52. package/dist/extension/superscript.js +1 -1
  53. package/dist/extension/superscript.mjs +5 -4
  54. package/dist/extension/underline.d.mts +1 -1
  55. package/dist/extension/underline.d.ts +1 -1
  56. package/dist/extension/underline.js +1 -1
  57. package/dist/extension/underline.mjs +4 -3
  58. package/dist/index.css +375 -8
  59. package/dist/index.js +1 -2
  60. package/dist/index.mjs +3 -3
  61. package/dist/{tiptap-ext.type-D61hoEX5.d.mts → tiptap-ext.type-DrneAC5G.d.mts} +8 -1
  62. package/dist/{tiptap-ext.type-D61hoEX5.d.ts → tiptap-ext.type-DrneAC5G.d.ts} +8 -1
  63. package/package.json +27 -24
@@ -0,0 +1,312 @@
1
+ import {
2
+ DropdownComponent_default,
3
+ DropdownItemComponent_default
4
+ } from "../chunk-2YUUKIIT.mjs";
5
+ import "../chunk-7QOFJIQ3.mjs";
6
+ import "../chunk-VYDH6BZE.mjs";
7
+ import {
8
+ __objRest,
9
+ __spreadProps,
10
+ __spreadValues
11
+ } from "../chunk-FWCSY2DS.mjs";
12
+
13
+ // src/extension/Heading.tsx
14
+ import TiptapHeading from "@tiptap/extension-heading";
15
+ import TiptapParagraph from "@tiptap/extension-paragraph";
16
+
17
+ // src/lib/icon/HeadingIcon.tsx
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ var H1Icon = (_a) => {
20
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
21
+ return /* @__PURE__ */ jsxs(
22
+ "svg",
23
+ __spreadProps(__spreadValues({
24
+ xmlns: "http://www.w3.org/2000/svg",
25
+ width: size,
26
+ height: size,
27
+ viewBox: "0 0 24 24",
28
+ fill: "none",
29
+ stroke: "currentColor",
30
+ strokeWidth: 2,
31
+ strokeLinecap: "round",
32
+ strokeLinejoin: "round"
33
+ }, props), {
34
+ children: [
35
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
36
+ /* @__PURE__ */ jsx("path", { d: "M4 18V6" }),
37
+ /* @__PURE__ */ jsx("path", { d: "M12 18V6" }),
38
+ /* @__PURE__ */ jsx("path", { d: "m17 12 3-2v8" })
39
+ ]
40
+ })
41
+ );
42
+ };
43
+ var H2Icon = (_a) => {
44
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
45
+ return /* @__PURE__ */ jsxs(
46
+ "svg",
47
+ __spreadProps(__spreadValues({
48
+ xmlns: "http://www.w3.org/2000/svg",
49
+ width: size,
50
+ height: size,
51
+ viewBox: "0 0 24 24",
52
+ fill: "none",
53
+ stroke: "currentColor",
54
+ strokeWidth: 2,
55
+ strokeLinecap: "round",
56
+ strokeLinejoin: "round"
57
+ }, props), {
58
+ children: [
59
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
60
+ /* @__PURE__ */ jsx("path", { d: "M4 18V6" }),
61
+ /* @__PURE__ */ jsx("path", { d: "M12 18V6" }),
62
+ /* @__PURE__ */ jsx("path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" })
63
+ ]
64
+ })
65
+ );
66
+ };
67
+ var H3Icon = (_a) => {
68
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
69
+ return /* @__PURE__ */ jsxs(
70
+ "svg",
71
+ __spreadProps(__spreadValues({
72
+ xmlns: "http://www.w3.org/2000/svg",
73
+ width: size,
74
+ height: size,
75
+ viewBox: "0 0 24 24",
76
+ fill: "none",
77
+ stroke: "currentColor",
78
+ strokeWidth: 2,
79
+ strokeLinecap: "round",
80
+ strokeLinejoin: "round"
81
+ }, props), {
82
+ children: [
83
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
84
+ /* @__PURE__ */ jsx("path", { d: "M4 18V6" }),
85
+ /* @__PURE__ */ jsx("path", { d: "M12 18V6" }),
86
+ /* @__PURE__ */ jsx("path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" }),
87
+ /* @__PURE__ */ jsx("path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" })
88
+ ]
89
+ })
90
+ );
91
+ };
92
+ var H4Icon = (_a) => {
93
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
94
+ return /* @__PURE__ */ 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__ */ jsx("path", { d: "M12 18V6" }),
109
+ /* @__PURE__ */ jsx("path", { d: "M17 10v3a1 1 0 0 0 1 1h3" }),
110
+ /* @__PURE__ */ jsx("path", { d: "M21 10v8" }),
111
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
112
+ /* @__PURE__ */ jsx("path", { d: "M4 18V6" })
113
+ ]
114
+ })
115
+ );
116
+ };
117
+ var H5Icon = (_a) => {
118
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
119
+ return /* @__PURE__ */ jsxs(
120
+ "svg",
121
+ __spreadProps(__spreadValues({
122
+ xmlns: "http://www.w3.org/2000/svg",
123
+ width: size,
124
+ height: size,
125
+ viewBox: "0 0 24 24",
126
+ fill: "none",
127
+ stroke: "currentColor",
128
+ strokeWidth: 2,
129
+ strokeLinecap: "round",
130
+ strokeLinejoin: "round"
131
+ }, props), {
132
+ children: [
133
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
134
+ /* @__PURE__ */ jsx("path", { d: "M4 18V6" }),
135
+ /* @__PURE__ */ jsx("path", { d: "M12 18V6" }),
136
+ /* @__PURE__ */ jsx("path", { d: "M17 13v-3h4" }),
137
+ /* @__PURE__ */ jsx("path", { d: "M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17" })
138
+ ]
139
+ })
140
+ );
141
+ };
142
+ var H6Icon = (_a) => {
143
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
144
+ return /* @__PURE__ */ jsxs(
145
+ "svg",
146
+ __spreadProps(__spreadValues({
147
+ xmlns: "http://www.w3.org/2000/svg",
148
+ width: size,
149
+ height: size,
150
+ viewBox: "0 0 24 24",
151
+ fill: "none",
152
+ stroke: "currentColor",
153
+ strokeWidth: 2,
154
+ strokeLinecap: "round",
155
+ strokeLinejoin: "round"
156
+ }, props), {
157
+ children: [
158
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
159
+ /* @__PURE__ */ jsx("path", { d: "M4 18V6" }),
160
+ /* @__PURE__ */ jsx("path", { d: "M12 18V6" }),
161
+ /* @__PURE__ */ jsx("circle", { cx: "19", cy: "16", r: "2" }),
162
+ /* @__PURE__ */ jsx("path", { d: "M20 10c-2 2-3 3.5-3 6" })
163
+ ]
164
+ })
165
+ );
166
+ };
167
+ var Pilcrow = (_a) => {
168
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
169
+ return /* @__PURE__ */ jsxs(
170
+ "svg",
171
+ __spreadProps(__spreadValues({
172
+ xmlns: "http://www.w3.org/2000/svg",
173
+ width: size,
174
+ height: size,
175
+ viewBox: "0 0 24 24",
176
+ fill: "none",
177
+ stroke: "currentColor",
178
+ strokeWidth: 2,
179
+ strokeLinecap: "round",
180
+ strokeLinejoin: "round"
181
+ }, props), {
182
+ children: [
183
+ /* @__PURE__ */ jsx("path", { d: "M13 4v16" }),
184
+ /* @__PURE__ */ jsx("path", { d: "M17 4v16" }),
185
+ /* @__PURE__ */ jsx("path", { d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13" })
186
+ ]
187
+ })
188
+ );
189
+ };
190
+
191
+ // src/extension/Heading.tsx
192
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
193
+ var Heading = TiptapHeading.extend({
194
+ addOptions() {
195
+ var _a;
196
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
197
+ component: ({ options, editor, dropdownContainerClassName, dropdownItemClassName }) => {
198
+ const defaultIcons = {
199
+ 1: /* @__PURE__ */ jsx2(H1Icon, {}),
200
+ 2: /* @__PURE__ */ jsx2(H2Icon, {}),
201
+ 3: /* @__PURE__ */ jsx2(H3Icon, {}),
202
+ 4: /* @__PURE__ */ jsx2(H4Icon, {}),
203
+ 5: /* @__PURE__ */ jsx2(H5Icon, {}),
204
+ 6: /* @__PURE__ */ jsx2(H6Icon, {})
205
+ };
206
+ const defaultTexts = {
207
+ 1: "Heading 1",
208
+ 2: "Heading 2",
209
+ 3: "Heading 3",
210
+ 4: "Heading 4",
211
+ 5: "Heading 5",
212
+ 6: "Heading 6"
213
+ };
214
+ const defaultKeys = {
215
+ 1: "\u2318\u2325 1",
216
+ 2: "\u2318\u2325 2",
217
+ 3: "\u2318\u2325 3",
218
+ 4: "\u2318\u2325 4",
219
+ 5: "\u2318\u2325 5",
220
+ 6: "\u2318\u2325 6"
221
+ };
222
+ const list = [];
223
+ const levels = options.level;
224
+ const shouldShowAll = !Array.isArray(levels) || levels.length === 0;
225
+ if (shouldShowAll) {
226
+ for (let level = 1; level <= 6; level++) {
227
+ list.push({
228
+ id: crypto.randomUUID(),
229
+ icon: defaultIcons[level],
230
+ text: defaultTexts[level],
231
+ keyBind: defaultKeys[level],
232
+ onClick: () => editor.chain().focus().toggleHeading({ level }).run(),
233
+ name: "heading",
234
+ ext: level
235
+ });
236
+ }
237
+ } else {
238
+ levels.forEach((cfg, index) => {
239
+ var _a2, _b, _c;
240
+ const level = index + 1;
241
+ if (!(cfg == null ? void 0 : cfg.enable)) return;
242
+ list.push({
243
+ id: crypto.randomUUID(),
244
+ icon: (_a2 = cfg.icon) != null ? _a2 : defaultIcons[level],
245
+ text: (_b = cfg.text) != null ? _b : defaultTexts[level],
246
+ keyBind: (_c = cfg.keyShortcuts) != null ? _c : defaultKeys[level],
247
+ onClick: () => editor.chain().focus().toggleHeading({ level }).run(),
248
+ name: "heading",
249
+ ext: level
250
+ });
251
+ });
252
+ }
253
+ return /* @__PURE__ */ jsxs2(
254
+ DropdownComponent_default,
255
+ {
256
+ className: options.className,
257
+ showArrow: options.showArrow,
258
+ content: options.content,
259
+ dropdownClassName: options.dropdownClassName,
260
+ style: options.style,
261
+ tooltip: options.tooltip,
262
+ tooltipClassName: options.tooltipClassName,
263
+ tooltipPlacement: options.tooltipPlacement,
264
+ _tooltipContent: "Sub & Superscript",
265
+ _internalContent: "Heading",
266
+ _dropdownClassName: dropdownContainerClassName,
267
+ children: [
268
+ /* @__PURE__ */ jsx2(
269
+ DropdownItemComponent_default,
270
+ {
271
+ onSelect: () => editor.chain().setParagraph().run(),
272
+ item: {
273
+ id: crypto.randomUUID(),
274
+ icon: /* @__PURE__ */ jsx2(Pilcrow, {}),
275
+ text: "Paragraph",
276
+ keyBind: "\u2318\u2325 P",
277
+ onClick: () => editor.chain().setParagraph().run(),
278
+ name: "paragraph"
279
+ },
280
+ activeClassName: options.activeClassName || "",
281
+ itemClassName: options.itemClassName || "",
282
+ showKeyShortcutText: options.showKeyShortcutText,
283
+ _itemClassName: dropdownItemClassName
284
+ }
285
+ ),
286
+ /* @__PURE__ */ jsx2("hr", { className: "border-gray-200" }),
287
+ list.map((item) => /* @__PURE__ */ jsx2(
288
+ DropdownItemComponent_default,
289
+ {
290
+ onSelect: item.onClick,
291
+ item,
292
+ spClass: ["text-3xl", "text-2xl", "text-xl", "text-lg", "text-base", "text-sm"][(Number(item.ext) || 6) - 1],
293
+ activeClassName: options.activeClassName || "",
294
+ itemClassName: options.itemClassName || "",
295
+ showKeyShortcutText: options.showKeyShortcutText,
296
+ _itemClassName: dropdownItemClassName
297
+ },
298
+ `${item.name}${item.ext}`
299
+ ))
300
+ ]
301
+ }
302
+ );
303
+ }
304
+ });
305
+ },
306
+ addExtensions() {
307
+ return [TiptapParagraph];
308
+ }
309
+ });
310
+ export {
311
+ Heading
312
+ };
@@ -0,0 +1,8 @@
1
+ import { Extension } from '@tiptap/react';
2
+ import { b as ExtWithoutActiveOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
3
+ import 'react';
4
+ import '@floating-ui/react';
5
+
6
+ declare const History: Extension<ExtWithoutActiveOptions>;
7
+
8
+ export { History };
@@ -0,0 +1,8 @@
1
+ import { Extension } from '@tiptap/react';
2
+ import { b as ExtWithoutActiveOptions } from '../tiptap-ext.type-DrneAC5G.js';
3
+ import 'react';
4
+ import '@floating-ui/react';
5
+
6
+ declare const History: Extension<ExtWithoutActiveOptions>;
7
+
8
+ export { History };
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
35
+ var __export = (target, all) => {
36
+ for (var name in all)
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ };
39
+ var __copyProps = (to, from, except, desc) => {
40
+ if (from && typeof from === "object" || typeof from === "function") {
41
+ for (let key of __getOwnPropNames(from))
42
+ if (!__hasOwnProp.call(to, key) && key !== except)
43
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
44
+ }
45
+ return to;
46
+ };
47
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
+
49
+ // src/extension/History.tsx
50
+ var History_exports = {};
51
+ __export(History_exports, {
52
+ History: () => History
53
+ });
54
+ module.exports = __toCommonJS(History_exports);
55
+ var import_react4 = require("react");
56
+ var import_extensions = require("@tiptap/extensions");
57
+ var import_react5 = require("@tiptap/react");
58
+
59
+ // src/lib/icon/HistoryIcon.tsx
60
+ var import_jsx_runtime = require("react/jsx-runtime");
61
+ var Redo2 = (_a) => {
62
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
64
+ "svg",
65
+ __spreadProps(__spreadValues({
66
+ xmlns: "http://www.w3.org/2000/svg",
67
+ viewBox: "0 0 24 24",
68
+ fill: "none",
69
+ stroke: "currentColor",
70
+ strokeWidth: 2,
71
+ strokeLinecap: "round",
72
+ strokeLinejoin: "round",
73
+ width: size,
74
+ height: size,
75
+ className
76
+ }, props), {
77
+ children: [
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m15 14 5-5-5-5" }),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" })
80
+ ]
81
+ })
82
+ );
83
+ };
84
+ var Undo2 = (_a) => {
85
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
87
+ "svg",
88
+ __spreadProps(__spreadValues({
89
+ xmlns: "http://www.w3.org/2000/svg",
90
+ viewBox: "0 0 24 24",
91
+ fill: "none",
92
+ stroke: "currentColor",
93
+ strokeWidth: "2",
94
+ strokeLinecap: "round",
95
+ strokeLinejoin: "round",
96
+ width: size,
97
+ height: size,
98
+ className
99
+ }, props), {
100
+ children: [
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 14 4 9l5-5" }),
102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" })
103
+ ]
104
+ })
105
+ );
106
+ };
107
+
108
+ // src/lib/components/ButtonWithoutActive.tsx
109
+ var import_tailwind_merge2 = require("tailwind-merge");
110
+
111
+ // src/lib/components/_com/Tooltip.tsx
112
+ var import_react = require("react");
113
+ var import_react2 = require("@floating-ui/react");
114
+ var import_react3 = require("motion/react");
115
+ var import_tailwind_merge = require("tailwind-merge");
116
+ var import_jsx_runtime2 = require("react/jsx-runtime");
117
+ var Tooltip = ({ placement = "top", children, content, className }) => {
118
+ const [open, setOpen] = (0, import_react.useState)(false);
119
+ const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
120
+ open,
121
+ onOpenChange: setOpen,
122
+ placement,
123
+ middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
124
+ whileElementsMounted: import_react2.autoUpdate
125
+ });
126
+ const hover = (0, import_react2.useHover)(context);
127
+ const dismiss = (0, import_react2.useDismiss)(context);
128
+ const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
129
+ const id = (0, import_react.useId)();
130
+ function mergeRefs(...refsToMerge) {
131
+ return (node) => {
132
+ for (const r of refsToMerge) {
133
+ if (!r) continue;
134
+ if (typeof r === "function") r(node);
135
+ else r.current = node;
136
+ }
137
+ };
138
+ }
139
+ const side = resolvedPlacement.split("-")[0];
140
+ const enterOffset = 6;
141
+ const getInitial = () => {
142
+ switch (side) {
143
+ case "top":
144
+ return { opacity: 0, y: enterOffset };
145
+ case "bottom":
146
+ return { opacity: 0, y: -enterOffset };
147
+ case "left":
148
+ return { opacity: 0, x: enterOffset };
149
+ case "right":
150
+ return { opacity: 0, x: -enterOffset };
151
+ default:
152
+ return { opacity: 0 };
153
+ }
154
+ };
155
+ const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
156
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
157
+ (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
158
+ onFocus: () => setOpen(true),
159
+ onBlur: () => setOpen(false),
160
+ "aria-describedby": open ? id : void 0
161
+ /* eslint-disable @typescript-eslint/no-explicit-any */
162
+ })), {
163
+ /* eslint-disable @typescript-eslint/no-explicit-any */
164
+ ref: mergeRefs(children.props.ref, refs.setReference)
165
+ })) : children,
166
+ /* @__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)(
167
+ import_react3.motion.div,
168
+ __spreadProps(__spreadValues({
169
+ ref: refs.setFloating
170
+ }, getFloatingProps({
171
+ role: "tooltip",
172
+ id,
173
+ style: {
174
+ position: strategy,
175
+ top: y != null ? y : 0,
176
+ left: x != null ? x : 0,
177
+ pointerEvents: "none"
178
+ }
179
+ })), {
180
+ initial: getInitial(),
181
+ animate: { opacity: 1, x: 0, y: 0, scale: 1 },
182
+ exit: getExit(),
183
+ transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
184
+ 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),
185
+ children: content
186
+ }),
187
+ "tooltip"
188
+ ) }) })
189
+ ] });
190
+ };
191
+ var Tooltip_default = Tooltip;
192
+
193
+ // src/lib/components/ButtonWithoutActive.tsx
194
+ var import_jsx_runtime3 = require("react/jsx-runtime");
195
+ var ButtonWithoutActive = ({ className, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _internalIcon, _tooltipContent, _interShortcut, _onToggle, _buttonClassName, _disabled = false }) => {
196
+ const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
197
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
198
+ _interShortcut && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
199
+ " ",
200
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("br", {}),
201
+ " ",
202
+ _interShortcut,
203
+ " "
204
+ ] })
205
+ ] });
206
+ const btn = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
207
+ "button",
208
+ {
209
+ onClick: _onToggle,
210
+ disabled: _disabled,
211
+ className: (0, import_tailwind_merge2.twMerge)(
212
+ "py-1.5 px-2.5 rounded-md hover:bg-gray-100",
213
+ _disabled ? "opacity-20" : "",
214
+ _buttonClassName,
215
+ className
216
+ ),
217
+ style,
218
+ children: icon != null ? icon : _internalIcon
219
+ }
220
+ );
221
+ if (tooltip === false) return btn;
222
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
223
+ Tooltip_default,
224
+ {
225
+ content: tooltipContent,
226
+ className: tooltipClassName,
227
+ placement: tooltipPlacement,
228
+ children: btn
229
+ }
230
+ );
231
+ };
232
+ var ButtonWithoutActive_default = ButtonWithoutActive;
233
+
234
+ // src/extension/History.tsx
235
+ var import_jsx_runtime4 = require("react/jsx-runtime");
236
+ function HistoryButtons({
237
+ editor,
238
+ options,
239
+ buttonClassName
240
+ }) {
241
+ const { canUndo, canRedo } = (0, import_react5.useEditorState)({
242
+ editor,
243
+ selector: (ctx) => ({
244
+ canUndo: ctx.editor.can().chain().focus().undo().run(),
245
+ canRedo: ctx.editor.can().chain().focus().redo().run()
246
+ })
247
+ });
248
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.Fragment, { children: [
249
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
250
+ ButtonWithoutActive_default,
251
+ {
252
+ className: options.className,
253
+ icon: options.icon,
254
+ style: options.style,
255
+ tooltip: options.tooltip,
256
+ tooltipClassName: options.tooltipClassName,
257
+ tooltipPlacement: options.tooltipPlacement,
258
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Undo2, {}),
259
+ _onToggle: () => editor.chain().focus().undo().run(),
260
+ _interShortcut: "\u2318 + Z",
261
+ _tooltipContent: "Undo",
262
+ _disabled: !canUndo,
263
+ _buttonClassName: buttonClassName
264
+ }
265
+ ),
266
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
267
+ ButtonWithoutActive_default,
268
+ {
269
+ className: options.className,
270
+ icon: options.icon,
271
+ style: options.style,
272
+ tooltip: options.tooltip,
273
+ tooltipClassName: options.tooltipClassName,
274
+ tooltipPlacement: options.tooltipPlacement,
275
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Redo2, {}),
276
+ _onToggle: () => editor.chain().focus().redo().run(),
277
+ _interShortcut: "\u21E7 + \u2318 + Z",
278
+ _tooltipContent: "Redo",
279
+ _disabled: !canRedo,
280
+ _buttonClassName: buttonClassName
281
+ }
282
+ )
283
+ ] });
284
+ }
285
+ var History = import_extensions.UndoRedo.extend({
286
+ addOptions() {
287
+ var _a;
288
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
289
+ component: ({ editor, options, buttonClassName }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(HistoryButtons, { editor, options, buttonClassName })
290
+ });
291
+ }
292
+ });
293
+ // Annotate the CommonJS export names for ESM import in node:
294
+ 0 && (module.exports = {
295
+ History
296
+ });