ritext 1.0.13 → 1.0.15

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 (42) hide show
  1. package/README.md +28 -28
  2. package/dist/chunk-CU67RXD7.mjs +53 -0
  3. package/dist/chunk-E4PPKAVK.mjs +37 -0
  4. package/dist/chunk-LO4RJXQF.mjs +37 -0
  5. package/dist/chunk-TQTCTY3E.mjs +52 -0
  6. package/dist/chunk-ZLCVIW2P.mjs +90 -0
  7. package/dist/extension/bold.d.mts +8 -0
  8. package/dist/extension/bold.d.ts +8 -0
  9. package/dist/extension/bold.js +260 -0
  10. package/dist/extension/bold.mjs +69 -0
  11. package/dist/extension/italic.d.mts +8 -0
  12. package/dist/extension/italic.d.ts +8 -0
  13. package/dist/extension/italic.js +264 -0
  14. package/dist/extension/italic.mjs +73 -0
  15. package/dist/extension/strike.d.mts +8 -0
  16. package/dist/extension/strike.d.ts +8 -0
  17. package/dist/extension/strike.js +264 -0
  18. package/dist/extension/strike.mjs +73 -0
  19. package/dist/extension/subandsuperscript.d.mts +21 -0
  20. package/dist/extension/subandsuperscript.d.ts +21 -0
  21. package/dist/extension/subandsuperscript.js +443 -0
  22. package/dist/extension/subandsuperscript.mjs +243 -0
  23. package/dist/extension/subscript.d.mts +8 -0
  24. package/dist/extension/subscript.d.ts +8 -0
  25. package/dist/extension/subscript.js +264 -0
  26. package/dist/extension/subscript.mjs +45 -0
  27. package/dist/extension/superscript.d.mts +8 -0
  28. package/dist/extension/superscript.d.ts +8 -0
  29. package/dist/extension/superscript.js +264 -0
  30. package/dist/extension/superscript.mjs +45 -0
  31. package/dist/extension/underline.d.mts +8 -0
  32. package/dist/extension/underline.d.ts +8 -0
  33. package/dist/extension/underline.js +263 -0
  34. package/dist/extension/underline.mjs +72 -0
  35. package/dist/index.css +101 -2
  36. package/dist/index.d.mts +6 -32
  37. package/dist/index.d.ts +6 -32
  38. package/dist/index.js +26 -537
  39. package/dist/index.mjs +30 -548
  40. package/dist/tiptap-ext.type-D61hoEX5.d.mts +32 -0
  41. package/dist/tiptap-ext.type-D61hoEX5.d.ts +32 -0
  42. package/package.json +29 -6
@@ -0,0 +1,264 @@
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
+
59
+ // src/extension/Superscript.tsx
60
+ var Superscript_exports = {};
61
+ __export(Superscript_exports, {
62
+ Superscript: () => Superscript
63
+ });
64
+ module.exports = __toCommonJS(Superscript_exports);
65
+ var import_extension_superscript = __toESM(require("@tiptap/extension-superscript"));
66
+
67
+ // src/lib/icon/SupIcon.tsx
68
+ var import_jsx_runtime = require("react/jsx-runtime");
69
+ var SupIcon = (_a) => {
70
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
72
+ "svg",
73
+ __spreadProps(__spreadValues({
74
+ xmlns: "http://www.w3.org/2000/svg",
75
+ viewBox: "0 0 24 24",
76
+ fill: "none",
77
+ stroke: "currentColor",
78
+ strokeWidth: 2,
79
+ strokeLinecap: "round",
80
+ strokeLinejoin: "round",
81
+ width: size,
82
+ height: size,
83
+ className
84
+ }, props), {
85
+ children: [
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m4 19 8-8" }),
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m12 19-8-8" }),
88
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" })
89
+ ]
90
+ })
91
+ );
92
+ };
93
+ var SupIcon_default = SupIcon;
94
+
95
+ // src/lib/components/ButtonComponent.tsx
96
+ var import_tailwind_merge2 = require("tailwind-merge");
97
+
98
+ // src/lib/components/_com/Tooltip.tsx
99
+ var import_react = require("react");
100
+ var import_react2 = require("@floating-ui/react");
101
+ var import_react3 = require("motion/react");
102
+ var import_tailwind_merge = require("tailwind-merge");
103
+ var import_jsx_runtime2 = require("react/jsx-runtime");
104
+ var Tooltip = ({ placement = "top", children, content, className }) => {
105
+ const [open, setOpen] = (0, import_react.useState)(false);
106
+ const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
107
+ open,
108
+ onOpenChange: setOpen,
109
+ placement,
110
+ middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
111
+ whileElementsMounted: import_react2.autoUpdate
112
+ });
113
+ const hover = (0, import_react2.useHover)(context);
114
+ const dismiss = (0, import_react2.useDismiss)(context);
115
+ const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
116
+ const id = (0, import_react.useId)();
117
+ function mergeRefs(...refsToMerge) {
118
+ return (node) => {
119
+ for (const r of refsToMerge) {
120
+ if (!r) continue;
121
+ if (typeof r === "function") r(node);
122
+ else r.current = node;
123
+ }
124
+ };
125
+ }
126
+ const side = resolvedPlacement.split("-")[0];
127
+ const enterOffset = 6;
128
+ const getInitial = () => {
129
+ switch (side) {
130
+ case "top":
131
+ return { opacity: 0, y: enterOffset };
132
+ case "bottom":
133
+ return { opacity: 0, y: -enterOffset };
134
+ case "left":
135
+ return { opacity: 0, x: enterOffset };
136
+ case "right":
137
+ return { opacity: 0, x: -enterOffset };
138
+ default:
139
+ return { opacity: 0 };
140
+ }
141
+ };
142
+ const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
143
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
144
+ (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
145
+ onFocus: () => setOpen(true),
146
+ onBlur: () => setOpen(false),
147
+ "aria-describedby": open ? id : void 0
148
+ /* eslint-disable @typescript-eslint/no-explicit-any */
149
+ })), {
150
+ /* eslint-disable @typescript-eslint/no-explicit-any */
151
+ ref: mergeRefs(children.props.ref, refs.setReference)
152
+ })) : children,
153
+ /* @__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)(
154
+ import_react3.motion.div,
155
+ __spreadProps(__spreadValues({
156
+ ref: refs.setFloating
157
+ }, getFloatingProps({
158
+ role: "tooltip",
159
+ id,
160
+ style: {
161
+ position: strategy,
162
+ top: y != null ? y : 0,
163
+ left: x != null ? x : 0,
164
+ pointerEvents: "none"
165
+ }
166
+ })), {
167
+ initial: getInitial(),
168
+ animate: { opacity: 1, x: 0, y: 0, scale: 1 },
169
+ exit: getExit(),
170
+ transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
171
+ 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),
172
+ children: content
173
+ }),
174
+ "tooltip"
175
+ ) }) })
176
+ ] });
177
+ };
178
+ var Tooltip_default = Tooltip;
179
+
180
+ // src/lib/context/editor.context.tsx
181
+ var import_react4 = require("react");
182
+ var import_jsx_runtime3 = require("react/jsx-runtime");
183
+ var EditorContext = (0, import_react4.createContext)({ editor: null });
184
+ var useEditor = () => {
185
+ const ctx = (0, import_react4.useContext)(EditorContext);
186
+ if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
187
+ return ctx;
188
+ };
189
+
190
+ // src/lib/components/ButtonComponent.tsx
191
+ var import_react5 = require("@tiptap/react");
192
+ var import_jsx_runtime4 = require("react/jsx-runtime");
193
+ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
194
+ const { editor } = useEditor();
195
+ const editorState = (0, import_react5.useEditorState)({
196
+ editor,
197
+ selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
198
+ });
199
+ const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
200
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
201
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
202
+ _interShortcut
203
+ ] });
204
+ const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
205
+ "button",
206
+ {
207
+ onClick: _onToggle,
208
+ className: (0, import_tailwind_merge2.twMerge)(
209
+ "p-1.5 rounded-md",
210
+ _buttonClassName,
211
+ (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
212
+ className,
213
+ (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
214
+ ),
215
+ style,
216
+ children: icon != null ? icon : _internalIcon
217
+ }
218
+ );
219
+ if (tooltip === false) return btn;
220
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
221
+ Tooltip_default,
222
+ {
223
+ content: tooltipContent,
224
+ className: tooltipClassName,
225
+ placement: tooltipPlacement,
226
+ children: btn
227
+ }
228
+ );
229
+ };
230
+ var ButtonComponent_default = ButtonComponent;
231
+
232
+ // src/extension/Superscript.tsx
233
+ var import_jsx_runtime5 = require("react/jsx-runtime");
234
+ var Superscript = import_extension_superscript.default.extend({
235
+ addOptions() {
236
+ var _a;
237
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
238
+ component: ({ options, editor, buttonClassName }) => {
239
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
240
+ ButtonComponent_default,
241
+ {
242
+ className: options.className,
243
+ icon: options.icon,
244
+ style: options.style,
245
+ activeClassName: options.activeClassName,
246
+ tooltip: options.tooltip,
247
+ tooltipClassName: options.tooltipClassName,
248
+ tooltipPlacement: options.tooltipPlacement,
249
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SupIcon_default, {}),
250
+ _extName: "superscript",
251
+ _onToggle: () => editor.chain().focus().toggleSuperscript().run(),
252
+ _interShortcut: "\u2318 + ,",
253
+ _tooltipContent: "Superscript",
254
+ _buttonClassName: buttonClassName
255
+ }
256
+ );
257
+ }
258
+ });
259
+ }
260
+ });
261
+ // Annotate the CommonJS export names for ESM import in node:
262
+ 0 && (module.exports = {
263
+ Superscript
264
+ });
@@ -0,0 +1,45 @@
1
+ import {
2
+ ButtonComponent_default
3
+ } from "../chunk-CU67RXD7.mjs";
4
+ import {
5
+ SupIcon_default
6
+ } from "../chunk-E4PPKAVK.mjs";
7
+ import "../chunk-ZLCVIW2P.mjs";
8
+ import {
9
+ __spreadProps,
10
+ __spreadValues
11
+ } from "../chunk-TQTCTY3E.mjs";
12
+
13
+ // src/extension/Superscript.tsx
14
+ import TiptapSuperscript from "@tiptap/extension-superscript";
15
+ import { jsx } from "react/jsx-runtime";
16
+ var Superscript = TiptapSuperscript.extend({
17
+ addOptions() {
18
+ var _a;
19
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
20
+ component: ({ options, editor, buttonClassName }) => {
21
+ return /* @__PURE__ */ jsx(
22
+ ButtonComponent_default,
23
+ {
24
+ className: options.className,
25
+ icon: options.icon,
26
+ style: options.style,
27
+ activeClassName: options.activeClassName,
28
+ tooltip: options.tooltip,
29
+ tooltipClassName: options.tooltipClassName,
30
+ tooltipPlacement: options.tooltipPlacement,
31
+ _internalIcon: /* @__PURE__ */ jsx(SupIcon_default, {}),
32
+ _extName: "superscript",
33
+ _onToggle: () => editor.chain().focus().toggleSuperscript().run(),
34
+ _interShortcut: "\u2318 + ,",
35
+ _tooltipContent: "Superscript",
36
+ _buttonClassName: buttonClassName
37
+ }
38
+ );
39
+ }
40
+ });
41
+ }
42
+ });
43
+ export {
44
+ Superscript
45
+ };
@@ -0,0 +1,8 @@
1
+ import { Mark } from '@tiptap/react';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.mjs';
3
+ import 'react';
4
+ import '@floating-ui/react';
5
+
6
+ declare const Underline: Mark<ExtButtonOptions>;
7
+
8
+ export { Underline };
@@ -0,0 +1,8 @@
1
+ import { Mark } from '@tiptap/react';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.js';
3
+ import 'react';
4
+ import '@floating-ui/react';
5
+
6
+ declare const Underline: Mark<ExtButtonOptions>;
7
+
8
+ export { Underline };
@@ -0,0 +1,263 @@
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
+
59
+ // src/extension/Underline.tsx
60
+ var Underline_exports = {};
61
+ __export(Underline_exports, {
62
+ Underline: () => Underline
63
+ });
64
+ module.exports = __toCommonJS(Underline_exports);
65
+ var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
66
+
67
+ // src/lib/icon/UnderIcon.tsx
68
+ var import_jsx_runtime = require("react/jsx-runtime");
69
+ var UnderIcon = (_a) => {
70
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
72
+ "svg",
73
+ __spreadProps(__spreadValues({
74
+ xmlns: "http://www.w3.org/2000/svg",
75
+ viewBox: "0 0 24 24",
76
+ fill: "none",
77
+ stroke: "currentColor",
78
+ strokeWidth: 2,
79
+ strokeLinecap: "round",
80
+ strokeLinejoin: "round",
81
+ width: size,
82
+ height: size,
83
+ className
84
+ }, props), {
85
+ children: [
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
88
+ ]
89
+ })
90
+ );
91
+ };
92
+ var UnderIcon_default = UnderIcon;
93
+
94
+ // src/lib/components/ButtonComponent.tsx
95
+ var import_tailwind_merge2 = require("tailwind-merge");
96
+
97
+ // src/lib/components/_com/Tooltip.tsx
98
+ var import_react = require("react");
99
+ var import_react2 = require("@floating-ui/react");
100
+ var import_react3 = require("motion/react");
101
+ var import_tailwind_merge = require("tailwind-merge");
102
+ var import_jsx_runtime2 = require("react/jsx-runtime");
103
+ var Tooltip = ({ placement = "top", children, content, className }) => {
104
+ const [open, setOpen] = (0, import_react.useState)(false);
105
+ const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
106
+ open,
107
+ onOpenChange: setOpen,
108
+ placement,
109
+ middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
110
+ whileElementsMounted: import_react2.autoUpdate
111
+ });
112
+ const hover = (0, import_react2.useHover)(context);
113
+ const dismiss = (0, import_react2.useDismiss)(context);
114
+ const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
115
+ const id = (0, import_react.useId)();
116
+ function mergeRefs(...refsToMerge) {
117
+ return (node) => {
118
+ for (const r of refsToMerge) {
119
+ if (!r) continue;
120
+ if (typeof r === "function") r(node);
121
+ else r.current = node;
122
+ }
123
+ };
124
+ }
125
+ const side = resolvedPlacement.split("-")[0];
126
+ const enterOffset = 6;
127
+ const getInitial = () => {
128
+ switch (side) {
129
+ case "top":
130
+ return { opacity: 0, y: enterOffset };
131
+ case "bottom":
132
+ return { opacity: 0, y: -enterOffset };
133
+ case "left":
134
+ return { opacity: 0, x: enterOffset };
135
+ case "right":
136
+ return { opacity: 0, x: -enterOffset };
137
+ default:
138
+ return { opacity: 0 };
139
+ }
140
+ };
141
+ const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
142
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
143
+ (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
144
+ onFocus: () => setOpen(true),
145
+ onBlur: () => setOpen(false),
146
+ "aria-describedby": open ? id : void 0
147
+ /* eslint-disable @typescript-eslint/no-explicit-any */
148
+ })), {
149
+ /* eslint-disable @typescript-eslint/no-explicit-any */
150
+ ref: mergeRefs(children.props.ref, refs.setReference)
151
+ })) : children,
152
+ /* @__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)(
153
+ import_react3.motion.div,
154
+ __spreadProps(__spreadValues({
155
+ ref: refs.setFloating
156
+ }, getFloatingProps({
157
+ role: "tooltip",
158
+ id,
159
+ style: {
160
+ position: strategy,
161
+ top: y != null ? y : 0,
162
+ left: x != null ? x : 0,
163
+ pointerEvents: "none"
164
+ }
165
+ })), {
166
+ initial: getInitial(),
167
+ animate: { opacity: 1, x: 0, y: 0, scale: 1 },
168
+ exit: getExit(),
169
+ transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
170
+ 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),
171
+ children: content
172
+ }),
173
+ "tooltip"
174
+ ) }) })
175
+ ] });
176
+ };
177
+ var Tooltip_default = Tooltip;
178
+
179
+ // src/lib/context/editor.context.tsx
180
+ var import_react4 = require("react");
181
+ var import_jsx_runtime3 = require("react/jsx-runtime");
182
+ var EditorContext = (0, import_react4.createContext)({ editor: null });
183
+ var useEditor = () => {
184
+ const ctx = (0, import_react4.useContext)(EditorContext);
185
+ if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
186
+ return ctx;
187
+ };
188
+
189
+ // src/lib/components/ButtonComponent.tsx
190
+ var import_react5 = require("@tiptap/react");
191
+ var import_jsx_runtime4 = require("react/jsx-runtime");
192
+ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
193
+ const { editor } = useEditor();
194
+ const editorState = (0, import_react5.useEditorState)({
195
+ editor,
196
+ selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
197
+ });
198
+ const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
199
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
200
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
201
+ _interShortcut
202
+ ] });
203
+ const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
204
+ "button",
205
+ {
206
+ onClick: _onToggle,
207
+ className: (0, import_tailwind_merge2.twMerge)(
208
+ "p-1.5 rounded-md",
209
+ _buttonClassName,
210
+ (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
211
+ className,
212
+ (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
213
+ ),
214
+ style,
215
+ children: icon != null ? icon : _internalIcon
216
+ }
217
+ );
218
+ if (tooltip === false) return btn;
219
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
220
+ Tooltip_default,
221
+ {
222
+ content: tooltipContent,
223
+ className: tooltipClassName,
224
+ placement: tooltipPlacement,
225
+ children: btn
226
+ }
227
+ );
228
+ };
229
+ var ButtonComponent_default = ButtonComponent;
230
+
231
+ // src/extension/Underline.tsx
232
+ var import_jsx_runtime5 = require("react/jsx-runtime");
233
+ var Underline = import_extension_underline.default.extend({
234
+ addOptions() {
235
+ var _a;
236
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
237
+ component: ({ options, editor, buttonClassName }) => {
238
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
239
+ ButtonComponent_default,
240
+ {
241
+ className: options.className,
242
+ icon: options.icon,
243
+ style: options.style,
244
+ activeClassName: options.activeClassName,
245
+ tooltip: options.tooltip,
246
+ tooltipClassName: options.tooltipClassName,
247
+ tooltipPlacement: options.tooltipPlacement,
248
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UnderIcon_default, {}),
249
+ _extName: "underline",
250
+ _onToggle: () => editor.chain().focus().toggleUnderline().run(),
251
+ _interShortcut: "\u2318 + U",
252
+ _tooltipContent: "Underline",
253
+ _buttonClassName: buttonClassName
254
+ }
255
+ );
256
+ }
257
+ });
258
+ }
259
+ });
260
+ // Annotate the CommonJS export names for ESM import in node:
261
+ 0 && (module.exports = {
262
+ Underline
263
+ });
@@ -0,0 +1,72 @@
1
+ import {
2
+ ButtonComponent_default
3
+ } from "../chunk-CU67RXD7.mjs";
4
+ import "../chunk-ZLCVIW2P.mjs";
5
+ import {
6
+ __objRest,
7
+ __spreadProps,
8
+ __spreadValues
9
+ } from "../chunk-TQTCTY3E.mjs";
10
+
11
+ // src/extension/Underline.tsx
12
+ import TiptapUnder from "@tiptap/extension-underline";
13
+
14
+ // src/lib/icon/UnderIcon.tsx
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ var UnderIcon = (_a) => {
17
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
18
+ return /* @__PURE__ */ jsxs(
19
+ "svg",
20
+ __spreadProps(__spreadValues({
21
+ xmlns: "http://www.w3.org/2000/svg",
22
+ viewBox: "0 0 24 24",
23
+ fill: "none",
24
+ stroke: "currentColor",
25
+ strokeWidth: 2,
26
+ strokeLinecap: "round",
27
+ strokeLinejoin: "round",
28
+ width: size,
29
+ height: size,
30
+ className
31
+ }, props), {
32
+ children: [
33
+ /* @__PURE__ */ jsx("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
34
+ /* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
35
+ ]
36
+ })
37
+ );
38
+ };
39
+ var UnderIcon_default = UnderIcon;
40
+
41
+ // src/extension/Underline.tsx
42
+ import { jsx as jsx2 } from "react/jsx-runtime";
43
+ var Underline = TiptapUnder.extend({
44
+ addOptions() {
45
+ var _a;
46
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
47
+ component: ({ options, editor, buttonClassName }) => {
48
+ return /* @__PURE__ */ jsx2(
49
+ ButtonComponent_default,
50
+ {
51
+ className: options.className,
52
+ icon: options.icon,
53
+ style: options.style,
54
+ activeClassName: options.activeClassName,
55
+ tooltip: options.tooltip,
56
+ tooltipClassName: options.tooltipClassName,
57
+ tooltipPlacement: options.tooltipPlacement,
58
+ _internalIcon: /* @__PURE__ */ jsx2(UnderIcon_default, {}),
59
+ _extName: "underline",
60
+ _onToggle: () => editor.chain().focus().toggleUnderline().run(),
61
+ _interShortcut: "\u2318 + U",
62
+ _tooltipContent: "Underline",
63
+ _buttonClassName: buttonClassName
64
+ }
65
+ );
66
+ }
67
+ });
68
+ }
69
+ });
70
+ export {
71
+ Underline
72
+ };