ritext 1.0.14 → 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.
- package/README.md +28 -28
- package/dist/chunk-CU67RXD7.mjs +53 -0
- package/dist/chunk-E4PPKAVK.mjs +37 -0
- package/dist/chunk-LO4RJXQF.mjs +37 -0
- package/dist/chunk-TQTCTY3E.mjs +52 -0
- package/dist/chunk-ZLCVIW2P.mjs +90 -0
- package/dist/extension/bold.d.mts +8 -0
- package/dist/extension/bold.d.ts +8 -0
- package/dist/extension/bold.js +260 -0
- package/dist/extension/bold.mjs +69 -0
- package/dist/extension/italic.d.mts +8 -0
- package/dist/extension/italic.d.ts +8 -0
- package/dist/extension/italic.js +264 -0
- package/dist/extension/italic.mjs +73 -0
- package/dist/extension/strike.d.mts +8 -0
- package/dist/extension/strike.d.ts +8 -0
- package/dist/extension/strike.js +264 -0
- package/dist/extension/strike.mjs +73 -0
- package/dist/extension/subandsuperscript.d.mts +21 -0
- package/dist/extension/subandsuperscript.d.ts +21 -0
- package/dist/extension/subandsuperscript.js +443 -0
- package/dist/extension/subandsuperscript.mjs +243 -0
- package/dist/extension/subscript.d.mts +8 -0
- package/dist/extension/subscript.d.ts +8 -0
- package/dist/extension/subscript.js +264 -0
- package/dist/extension/subscript.mjs +45 -0
- package/dist/extension/superscript.d.mts +8 -0
- package/dist/extension/superscript.d.ts +8 -0
- package/dist/extension/superscript.js +264 -0
- package/dist/extension/superscript.mjs +45 -0
- package/dist/extension/underline.d.mts +8 -0
- package/dist/extension/underline.d.ts +8 -0
- package/dist/extension/underline.js +263 -0
- package/dist/extension/underline.mjs +72 -0
- package/dist/index.css +101 -2
- package/dist/index.d.mts +6 -32
- package/dist/index.d.ts +6 -32
- package/dist/index.js +26 -537
- package/dist/index.mjs +30 -548
- package/dist/tiptap-ext.type-D61hoEX5.d.mts +32 -0
- package/dist/tiptap-ext.type-D61hoEX5.d.ts +32 -0
- 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/Italic.tsx
|
|
60
|
+
var Italic_exports = {};
|
|
61
|
+
__export(Italic_exports, {
|
|
62
|
+
Italic: () => Italic
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(Italic_exports);
|
|
65
|
+
var import_extension_italic = __toESM(require("@tiptap/extension-italic"));
|
|
66
|
+
|
|
67
|
+
// src/lib/icon/ItalicIcon.tsx
|
|
68
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
+
var ItalicIcon = (_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)("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
var ItalicIcon_default = ItalicIcon;
|
|
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/Italic.tsx
|
|
233
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
234
|
+
var Italic = import_extension_italic.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)(ItalicIcon_default, {}),
|
|
250
|
+
_extName: "italic",
|
|
251
|
+
_onToggle: () => editor.chain().focus().toggleItalic().run(),
|
|
252
|
+
_interShortcut: "\u2318 + I",
|
|
253
|
+
_tooltipContent: "Italic",
|
|
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
|
+
Italic
|
|
264
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
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/Italic.tsx
|
|
12
|
+
import TiptapItalic from "@tiptap/extension-italic";
|
|
13
|
+
|
|
14
|
+
// src/lib/icon/ItalicIcon.tsx
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var ItalicIcon = (_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("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
|
|
34
|
+
/* @__PURE__ */ jsx("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
|
|
35
|
+
/* @__PURE__ */ jsx("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
|
|
36
|
+
]
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
var ItalicIcon_default = ItalicIcon;
|
|
41
|
+
|
|
42
|
+
// src/extension/Italic.tsx
|
|
43
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
44
|
+
var Italic = TiptapItalic.extend({
|
|
45
|
+
addOptions() {
|
|
46
|
+
var _a;
|
|
47
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
48
|
+
component: ({ options, editor, buttonClassName }) => {
|
|
49
|
+
return /* @__PURE__ */ jsx2(
|
|
50
|
+
ButtonComponent_default,
|
|
51
|
+
{
|
|
52
|
+
className: options.className,
|
|
53
|
+
icon: options.icon,
|
|
54
|
+
style: options.style,
|
|
55
|
+
activeClassName: options.activeClassName,
|
|
56
|
+
tooltip: options.tooltip,
|
|
57
|
+
tooltipClassName: options.tooltipClassName,
|
|
58
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
59
|
+
_internalIcon: /* @__PURE__ */ jsx2(ItalicIcon_default, {}),
|
|
60
|
+
_extName: "italic",
|
|
61
|
+
_onToggle: () => editor.chain().focus().toggleItalic().run(),
|
|
62
|
+
_interShortcut: "\u2318 + I",
|
|
63
|
+
_tooltipContent: "Italic",
|
|
64
|
+
_buttonClassName: buttonClassName
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
export {
|
|
72
|
+
Italic
|
|
73
|
+
};
|
|
@@ -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/Strike.tsx
|
|
60
|
+
var Strike_exports = {};
|
|
61
|
+
__export(Strike_exports, {
|
|
62
|
+
Strike: () => Strike
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(Strike_exports);
|
|
65
|
+
var import_extension_strike = __toESM(require("@tiptap/extension-strike"));
|
|
66
|
+
|
|
67
|
+
// src/lib/icon/StrikeIcon.tsx
|
|
68
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
+
var StrikeIcon = (_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: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "4", x2: "20", y1: "12", y2: "12" })
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
var StrikeIcon_default = StrikeIcon;
|
|
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/Strike.tsx
|
|
233
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
234
|
+
var Strike = import_extension_strike.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)(StrikeIcon_default, {}),
|
|
250
|
+
_extName: "strike",
|
|
251
|
+
_onToggle: () => editor.chain().focus().toggleStrike().run(),
|
|
252
|
+
_interShortcut: "\u2318 \u21E7 S",
|
|
253
|
+
_tooltipContent: "Strike",
|
|
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
|
+
Strike
|
|
264
|
+
});
|