ritext 1.0.15 → 1.0.18
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 +7 -8
- package/dist/chunk-2YUUKIIT.mjs +149 -0
- package/dist/{chunk-ZLCVIW2P.mjs → chunk-7QOFJIQ3.mjs} +1 -1
- package/dist/chunk-D47XME55.mjs +49 -0
- package/dist/{chunk-TQTCTY3E.mjs → chunk-FWCSY2DS.mjs} +1 -16
- package/dist/{chunk-CU67RXD7.mjs → chunk-GSHINFPO.mjs} +3 -3
- package/dist/{chunk-E4PPKAVK.mjs → chunk-LMOTHRGQ.mjs} +1 -1
- package/dist/{chunk-LO4RJXQF.mjs → chunk-MBF77NHS.mjs} +1 -1
- package/dist/chunk-VYDH6BZE.mjs +17 -0
- package/dist/extension/bold.d.mts +1 -1
- package/dist/extension/bold.d.ts +1 -1
- package/dist/extension/bold.js +1 -1
- package/dist/extension/bold.mjs +4 -3
- package/dist/extension/clearformat.d.mts +8 -0
- package/dist/extension/clearformat.d.ts +8 -0
- package/dist/extension/clearformat.js +239 -0
- package/dist/extension/clearformat.mjs +69 -0
- package/dist/extension/font-family.d.mts +23 -0
- package/dist/extension/font-family.d.ts +23 -0
- package/dist/extension/font-family.js +388 -0
- package/dist/extension/font-family.mjs +113 -0
- package/dist/extension/font-size.d.mts +23 -0
- package/dist/extension/font-size.d.ts +23 -0
- package/dist/extension/font-size.js +386 -0
- package/dist/extension/font-size.mjs +111 -0
- package/dist/extension/heading.d.mts +23 -0
- package/dist/extension/heading.d.ts +23 -0
- package/dist/extension/heading.js +593 -0
- package/dist/extension/heading.mjs +312 -0
- package/dist/extension/history.d.mts +8 -0
- package/dist/extension/history.d.ts +8 -0
- package/dist/extension/history.js +296 -0
- package/dist/extension/history.mjs +126 -0
- package/dist/extension/italic.d.mts +1 -1
- package/dist/extension/italic.d.ts +1 -1
- package/dist/extension/italic.js +1 -1
- package/dist/extension/italic.mjs +4 -3
- package/dist/extension/strike.d.mts +1 -1
- package/dist/extension/strike.d.ts +1 -1
- package/dist/extension/strike.js +1 -1
- package/dist/extension/strike.mjs +4 -3
- package/dist/extension/subandsuperscript.d.mts +1 -1
- package/dist/extension/subandsuperscript.d.ts +1 -1
- package/dist/extension/subandsuperscript.js +30 -21
- package/dist/extension/subandsuperscript.mjs +37 -159
- package/dist/extension/subscript.d.mts +1 -1
- package/dist/extension/subscript.d.ts +1 -1
- package/dist/extension/subscript.js +1 -1
- package/dist/extension/subscript.mjs +5 -4
- package/dist/extension/superscript.d.mts +1 -1
- package/dist/extension/superscript.d.ts +1 -1
- package/dist/extension/superscript.js +1 -1
- package/dist/extension/superscript.mjs +5 -4
- package/dist/extension/underline.d.mts +1 -1
- package/dist/extension/underline.d.ts +1 -1
- package/dist/extension/underline.js +1 -1
- package/dist/extension/underline.mjs +4 -3
- package/dist/index.css +375 -8
- package/dist/index.js +1 -2
- package/dist/index.mjs +3 -3
- package/dist/{tiptap-ext.type-D61hoEX5.d.mts → tiptap-ext.type-DrneAC5G.d.mts} +8 -1
- package/dist/{tiptap-ext.type-D61hoEX5.d.ts → tiptap-ext.type-DrneAC5G.d.ts} +8 -1
- package/package.json +27 -24
|
@@ -0,0 +1,593 @@
|
|
|
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/Heading.tsx
|
|
60
|
+
var Heading_exports = {};
|
|
61
|
+
__export(Heading_exports, {
|
|
62
|
+
Heading: () => Heading
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(Heading_exports);
|
|
65
|
+
var import_extension_heading = __toESM(require("@tiptap/extension-heading"));
|
|
66
|
+
var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"));
|
|
67
|
+
|
|
68
|
+
// src/lib/icon/HeadingIcon.tsx
|
|
69
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
70
|
+
var H1Icon = (_a) => {
|
|
71
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
73
|
+
"svg",
|
|
74
|
+
__spreadProps(__spreadValues({
|
|
75
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
76
|
+
width: size,
|
|
77
|
+
height: size,
|
|
78
|
+
viewBox: "0 0 24 24",
|
|
79
|
+
fill: "none",
|
|
80
|
+
stroke: "currentColor",
|
|
81
|
+
strokeWidth: 2,
|
|
82
|
+
strokeLinecap: "round",
|
|
83
|
+
strokeLinejoin: "round"
|
|
84
|
+
}, props), {
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12h8" }),
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 18V6" }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 18V6" }),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m17 12 3-2v8" })
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
var H2Icon = (_a) => {
|
|
95
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
97
|
+
"svg",
|
|
98
|
+
__spreadProps(__spreadValues({
|
|
99
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
100
|
+
width: size,
|
|
101
|
+
height: size,
|
|
102
|
+
viewBox: "0 0 24 24",
|
|
103
|
+
fill: "none",
|
|
104
|
+
stroke: "currentColor",
|
|
105
|
+
strokeWidth: 2,
|
|
106
|
+
strokeLinecap: "round",
|
|
107
|
+
strokeLinejoin: "round"
|
|
108
|
+
}, props), {
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12h8" }),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 18V6" }),
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 18V6" }),
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" })
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
var H3Icon = (_a) => {
|
|
119
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
121
|
+
"svg",
|
|
122
|
+
__spreadProps(__spreadValues({
|
|
123
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
124
|
+
width: size,
|
|
125
|
+
height: size,
|
|
126
|
+
viewBox: "0 0 24 24",
|
|
127
|
+
fill: "none",
|
|
128
|
+
stroke: "currentColor",
|
|
129
|
+
strokeWidth: 2,
|
|
130
|
+
strokeLinecap: "round",
|
|
131
|
+
strokeLinejoin: "round"
|
|
132
|
+
}, props), {
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12h8" }),
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 18V6" }),
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 18V6" }),
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" }),
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" })
|
|
139
|
+
]
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
var H4Icon = (_a) => {
|
|
144
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
146
|
+
"svg",
|
|
147
|
+
__spreadProps(__spreadValues({
|
|
148
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
149
|
+
width: size,
|
|
150
|
+
height: size,
|
|
151
|
+
viewBox: "0 0 24 24",
|
|
152
|
+
fill: "none",
|
|
153
|
+
stroke: "currentColor",
|
|
154
|
+
strokeWidth: 2,
|
|
155
|
+
strokeLinecap: "round",
|
|
156
|
+
strokeLinejoin: "round"
|
|
157
|
+
}, props), {
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 18V6" }),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 10v3a1 1 0 0 0 1 1h3" }),
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 10v8" }),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12h8" }),
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 18V6" })
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
var H5Icon = (_a) => {
|
|
169
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
171
|
+
"svg",
|
|
172
|
+
__spreadProps(__spreadValues({
|
|
173
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
174
|
+
width: size,
|
|
175
|
+
height: size,
|
|
176
|
+
viewBox: "0 0 24 24",
|
|
177
|
+
fill: "none",
|
|
178
|
+
stroke: "currentColor",
|
|
179
|
+
strokeWidth: 2,
|
|
180
|
+
strokeLinecap: "round",
|
|
181
|
+
strokeLinejoin: "round"
|
|
182
|
+
}, props), {
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12h8" }),
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 18V6" }),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 18V6" }),
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 13v-3h4" }),
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.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" })
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
var H6Icon = (_a) => {
|
|
194
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
196
|
+
"svg",
|
|
197
|
+
__spreadProps(__spreadValues({
|
|
198
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
199
|
+
width: size,
|
|
200
|
+
height: size,
|
|
201
|
+
viewBox: "0 0 24 24",
|
|
202
|
+
fill: "none",
|
|
203
|
+
stroke: "currentColor",
|
|
204
|
+
strokeWidth: 2,
|
|
205
|
+
strokeLinecap: "round",
|
|
206
|
+
strokeLinejoin: "round"
|
|
207
|
+
}, props), {
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 12h8" }),
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 18V6" }),
|
|
211
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 18V6" }),
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "19", cy: "16", r: "2" }),
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 10c-2 2-3 3.5-3 6" })
|
|
214
|
+
]
|
|
215
|
+
})
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
var Pilcrow = (_a) => {
|
|
219
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
221
|
+
"svg",
|
|
222
|
+
__spreadProps(__spreadValues({
|
|
223
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
224
|
+
width: size,
|
|
225
|
+
height: size,
|
|
226
|
+
viewBox: "0 0 24 24",
|
|
227
|
+
fill: "none",
|
|
228
|
+
stroke: "currentColor",
|
|
229
|
+
strokeWidth: 2,
|
|
230
|
+
strokeLinecap: "round",
|
|
231
|
+
strokeLinejoin: "round"
|
|
232
|
+
}, props), {
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 4v16" }),
|
|
235
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 4v16" }),
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13" })
|
|
237
|
+
]
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/lib/components/DropdownComponent.tsx
|
|
243
|
+
var import_react4 = require("react");
|
|
244
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
245
|
+
|
|
246
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
247
|
+
var import_react = require("react");
|
|
248
|
+
var import_react2 = require("@floating-ui/react");
|
|
249
|
+
var import_react3 = require("motion/react");
|
|
250
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
251
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
252
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
253
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
254
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
|
|
255
|
+
open,
|
|
256
|
+
onOpenChange: setOpen,
|
|
257
|
+
placement,
|
|
258
|
+
middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
|
|
259
|
+
whileElementsMounted: import_react2.autoUpdate
|
|
260
|
+
});
|
|
261
|
+
const hover = (0, import_react2.useHover)(context);
|
|
262
|
+
const dismiss = (0, import_react2.useDismiss)(context);
|
|
263
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
|
|
264
|
+
const id = (0, import_react.useId)();
|
|
265
|
+
function mergeRefs(...refsToMerge) {
|
|
266
|
+
return (node) => {
|
|
267
|
+
for (const r of refsToMerge) {
|
|
268
|
+
if (!r) continue;
|
|
269
|
+
if (typeof r === "function") r(node);
|
|
270
|
+
else r.current = node;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const side = resolvedPlacement.split("-")[0];
|
|
275
|
+
const enterOffset = 6;
|
|
276
|
+
const getInitial = () => {
|
|
277
|
+
switch (side) {
|
|
278
|
+
case "top":
|
|
279
|
+
return { opacity: 0, y: enterOffset };
|
|
280
|
+
case "bottom":
|
|
281
|
+
return { opacity: 0, y: -enterOffset };
|
|
282
|
+
case "left":
|
|
283
|
+
return { opacity: 0, x: enterOffset };
|
|
284
|
+
case "right":
|
|
285
|
+
return { opacity: 0, x: -enterOffset };
|
|
286
|
+
default:
|
|
287
|
+
return { opacity: 0 };
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
|
|
292
|
+
(0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
293
|
+
onFocus: () => setOpen(true),
|
|
294
|
+
onBlur: () => setOpen(false),
|
|
295
|
+
"aria-describedby": open ? id : void 0
|
|
296
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
297
|
+
})), {
|
|
298
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
299
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
300
|
+
})) : children,
|
|
301
|
+
/* @__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)(
|
|
302
|
+
import_react3.motion.div,
|
|
303
|
+
__spreadProps(__spreadValues({
|
|
304
|
+
ref: refs.setFloating
|
|
305
|
+
}, getFloatingProps({
|
|
306
|
+
role: "tooltip",
|
|
307
|
+
id,
|
|
308
|
+
style: {
|
|
309
|
+
position: strategy,
|
|
310
|
+
top: y != null ? y : 0,
|
|
311
|
+
left: x != null ? x : 0,
|
|
312
|
+
pointerEvents: "none"
|
|
313
|
+
}
|
|
314
|
+
})), {
|
|
315
|
+
initial: getInitial(),
|
|
316
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
317
|
+
exit: getExit(),
|
|
318
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
319
|
+
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),
|
|
320
|
+
children: content
|
|
321
|
+
}),
|
|
322
|
+
"tooltip"
|
|
323
|
+
) }) })
|
|
324
|
+
] });
|
|
325
|
+
};
|
|
326
|
+
var Tooltip_default = Tooltip;
|
|
327
|
+
|
|
328
|
+
// src/lib/components/DropdownComponent.tsx
|
|
329
|
+
var import_react5 = require("@floating-ui/react");
|
|
330
|
+
|
|
331
|
+
// src/lib/icon/ArrowIcon.tsx
|
|
332
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
333
|
+
var ArrowIcon = (_a) => {
|
|
334
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
336
|
+
"svg",
|
|
337
|
+
__spreadProps(__spreadValues({
|
|
338
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
339
|
+
viewBox: "0 0 48 48",
|
|
340
|
+
fill: "none",
|
|
341
|
+
stroke: "currentColor",
|
|
342
|
+
strokeWidth: 2,
|
|
343
|
+
strokeLinecap: "round",
|
|
344
|
+
strokeLinejoin: "round",
|
|
345
|
+
width: size,
|
|
346
|
+
height: size,
|
|
347
|
+
className
|
|
348
|
+
}, props), {
|
|
349
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { fill: "currentColor", stroke: "currentColor", strokeLinejoin: "round", strokeWidth: "4", d: "M36 19L24 31L12 19z" })
|
|
350
|
+
})
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
var ArrowIcon_default = ArrowIcon;
|
|
354
|
+
|
|
355
|
+
// src/lib/components/DropdownComponent.tsx
|
|
356
|
+
var import_react6 = require("motion/react");
|
|
357
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
358
|
+
var DropdownComponent = ({ children, className, showArrow = true, content, dropdownClassName, style, tooltip, tooltipClassName, tooltipPlacement, _tooltipContent, _internalContent, _dropdownClassName }) => {
|
|
359
|
+
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
360
|
+
const { x, y, refs, strategy, context } = (0, import_react5.useFloating)({
|
|
361
|
+
open,
|
|
362
|
+
onOpenChange: setOpen,
|
|
363
|
+
placement: "bottom",
|
|
364
|
+
middleware: [(0, import_react5.offset)(4), (0, import_react5.flip)(), (0, import_react5.shift)({ padding: 8 })],
|
|
365
|
+
whileElementsMounted: import_react5.autoUpdate
|
|
366
|
+
});
|
|
367
|
+
const click = (0, import_react5.useClick)(context);
|
|
368
|
+
const dismiss = (0, import_react5.useDismiss)(context);
|
|
369
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react5.useInteractions)([click, dismiss]);
|
|
370
|
+
const listId = (0, import_react4.useId)();
|
|
371
|
+
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: typeof tooltip === "string" ? tooltip : _tooltipContent });
|
|
372
|
+
const initialMotion = { opacity: 0, scale: 0.95 };
|
|
373
|
+
const animateMotion = { opacity: 1, scale: 1 };
|
|
374
|
+
const enhancedChildren = import_react4.Children.map(children, (child) => {
|
|
375
|
+
if (!(0, import_react4.isValidElement)(child)) return child;
|
|
376
|
+
if (!("onSelect" in child.props)) return child;
|
|
377
|
+
const prevOnSelect = child.props.onSelect;
|
|
378
|
+
const combinedOnSelect = () => {
|
|
379
|
+
prevOnSelect == null ? void 0 : prevOnSelect();
|
|
380
|
+
setOpen(false);
|
|
381
|
+
};
|
|
382
|
+
return (0, import_react4.cloneElement)(child, { onSelect: combinedOnSelect });
|
|
383
|
+
});
|
|
384
|
+
const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
385
|
+
"button",
|
|
386
|
+
__spreadProps(__spreadValues({}, getReferenceProps({
|
|
387
|
+
ref: refs.setReference,
|
|
388
|
+
type: "button",
|
|
389
|
+
"aria-controls": open ? listId : void 0
|
|
390
|
+
})), {
|
|
391
|
+
className: (0, import_tailwind_merge2.twMerge)(
|
|
392
|
+
"p-1.5 rounded-md hover:bg-gray-100 items-center flex gap-x-0.5",
|
|
393
|
+
className
|
|
394
|
+
),
|
|
395
|
+
style,
|
|
396
|
+
children: [
|
|
397
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: content != null ? content : _internalContent }),
|
|
398
|
+
showArrow && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ArrowIcon_default, { size: 14, className: "text-gray-500 block" })
|
|
399
|
+
]
|
|
400
|
+
})
|
|
401
|
+
);
|
|
402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.Fragment, { children: [
|
|
403
|
+
tooltip === false ? btn : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
404
|
+
Tooltip_default,
|
|
405
|
+
{
|
|
406
|
+
content: tooltipContent,
|
|
407
|
+
className: tooltipClassName,
|
|
408
|
+
placement: tooltipPlacement,
|
|
409
|
+
children: btn
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
413
|
+
import_react6.motion.div,
|
|
414
|
+
__spreadProps(__spreadValues({}, getFloatingProps({
|
|
415
|
+
ref: refs.setFloating,
|
|
416
|
+
style: {
|
|
417
|
+
position: strategy,
|
|
418
|
+
top: y != null ? y : 0,
|
|
419
|
+
left: x != null ? x : 0
|
|
420
|
+
},
|
|
421
|
+
role: "listbox",
|
|
422
|
+
id: listId
|
|
423
|
+
})), {
|
|
424
|
+
initial: initialMotion,
|
|
425
|
+
animate: animateMotion,
|
|
426
|
+
exit: initialMotion,
|
|
427
|
+
className: (0, import_tailwind_merge2.twMerge)("bg-white border border-solid border-gray-200 p-2 space-y-1 rounded-lg shadow-sm shadow-gray-200/40 max-h-125 overflow-auto", _dropdownClassName, dropdownClassName),
|
|
428
|
+
children: enhancedChildren
|
|
429
|
+
})
|
|
430
|
+
) }) })
|
|
431
|
+
] });
|
|
432
|
+
};
|
|
433
|
+
var DropdownComponent_default = DropdownComponent;
|
|
434
|
+
|
|
435
|
+
// src/lib/components/DropdownItemComponent.tsx
|
|
436
|
+
var import_tailwind_merge3 = require("tailwind-merge");
|
|
437
|
+
|
|
438
|
+
// src/lib/context/editor.context.tsx
|
|
439
|
+
var import_react7 = require("react");
|
|
440
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
441
|
+
var EditorContext = (0, import_react7.createContext)({ editor: null });
|
|
442
|
+
var useEditor = () => {
|
|
443
|
+
const ctx = (0, import_react7.useContext)(EditorContext);
|
|
444
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
445
|
+
return ctx;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/lib/components/DropdownItemComponent.tsx
|
|
449
|
+
var import_react8 = require("@tiptap/react");
|
|
450
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
451
|
+
var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName, showKeyShortcutText = true, spClass }) => {
|
|
452
|
+
const { editor } = useEditor();
|
|
453
|
+
const editorState = (0, import_react8.useEditorState)({
|
|
454
|
+
editor,
|
|
455
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.name, item.ext ? { level: item.ext } : void 0)) || false })
|
|
456
|
+
});
|
|
457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_tailwind_merge3.twMerge)(
|
|
458
|
+
"flex items-center gap-x-2.5 transition-all duration-100 cursor-pointer select-none px-2 py-1.5 rounded-md",
|
|
459
|
+
_itemClassName,
|
|
460
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
461
|
+
itemClassName,
|
|
462
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
463
|
+
), onClick: onSelect, children: [
|
|
464
|
+
item.icon,
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: (0, import_tailwind_merge3.twMerge)("flex-1 text-base", spClass), style: item.style, children: item.text }),
|
|
466
|
+
showKeyShortcutText && item.keyBind && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ml-6 text-gray-400", children: item.keyBind })
|
|
467
|
+
] });
|
|
468
|
+
};
|
|
469
|
+
var DropdownItemComponent_default = DropdownItemComponent;
|
|
470
|
+
|
|
471
|
+
// src/extension/Heading.tsx
|
|
472
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
473
|
+
var Heading = import_extension_heading.default.extend({
|
|
474
|
+
addOptions() {
|
|
475
|
+
var _a;
|
|
476
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
477
|
+
component: ({ options, editor, dropdownContainerClassName, dropdownItemClassName }) => {
|
|
478
|
+
const defaultIcons = {
|
|
479
|
+
1: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(H1Icon, {}),
|
|
480
|
+
2: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(H2Icon, {}),
|
|
481
|
+
3: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(H3Icon, {}),
|
|
482
|
+
4: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(H4Icon, {}),
|
|
483
|
+
5: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(H5Icon, {}),
|
|
484
|
+
6: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(H6Icon, {})
|
|
485
|
+
};
|
|
486
|
+
const defaultTexts = {
|
|
487
|
+
1: "Heading 1",
|
|
488
|
+
2: "Heading 2",
|
|
489
|
+
3: "Heading 3",
|
|
490
|
+
4: "Heading 4",
|
|
491
|
+
5: "Heading 5",
|
|
492
|
+
6: "Heading 6"
|
|
493
|
+
};
|
|
494
|
+
const defaultKeys = {
|
|
495
|
+
1: "\u2318\u2325 1",
|
|
496
|
+
2: "\u2318\u2325 2",
|
|
497
|
+
3: "\u2318\u2325 3",
|
|
498
|
+
4: "\u2318\u2325 4",
|
|
499
|
+
5: "\u2318\u2325 5",
|
|
500
|
+
6: "\u2318\u2325 6"
|
|
501
|
+
};
|
|
502
|
+
const list = [];
|
|
503
|
+
const levels = options.level;
|
|
504
|
+
const shouldShowAll = !Array.isArray(levels) || levels.length === 0;
|
|
505
|
+
if (shouldShowAll) {
|
|
506
|
+
for (let level = 1; level <= 6; level++) {
|
|
507
|
+
list.push({
|
|
508
|
+
id: crypto.randomUUID(),
|
|
509
|
+
icon: defaultIcons[level],
|
|
510
|
+
text: defaultTexts[level],
|
|
511
|
+
keyBind: defaultKeys[level],
|
|
512
|
+
onClick: () => editor.chain().focus().toggleHeading({ level }).run(),
|
|
513
|
+
name: "heading",
|
|
514
|
+
ext: level
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
levels.forEach((cfg, index) => {
|
|
519
|
+
var _a2, _b, _c;
|
|
520
|
+
const level = index + 1;
|
|
521
|
+
if (!(cfg == null ? void 0 : cfg.enable)) return;
|
|
522
|
+
list.push({
|
|
523
|
+
id: crypto.randomUUID(),
|
|
524
|
+
icon: (_a2 = cfg.icon) != null ? _a2 : defaultIcons[level],
|
|
525
|
+
text: (_b = cfg.text) != null ? _b : defaultTexts[level],
|
|
526
|
+
keyBind: (_c = cfg.keyShortcuts) != null ? _c : defaultKeys[level],
|
|
527
|
+
onClick: () => editor.chain().focus().toggleHeading({ level }).run(),
|
|
528
|
+
name: "heading",
|
|
529
|
+
ext: level
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
534
|
+
DropdownComponent_default,
|
|
535
|
+
{
|
|
536
|
+
className: options.className,
|
|
537
|
+
showArrow: options.showArrow,
|
|
538
|
+
content: options.content,
|
|
539
|
+
dropdownClassName: options.dropdownClassName,
|
|
540
|
+
style: options.style,
|
|
541
|
+
tooltip: options.tooltip,
|
|
542
|
+
tooltipClassName: options.tooltipClassName,
|
|
543
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
544
|
+
_tooltipContent: "Sub & Superscript",
|
|
545
|
+
_internalContent: "Heading",
|
|
546
|
+
_dropdownClassName: dropdownContainerClassName,
|
|
547
|
+
children: [
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
549
|
+
DropdownItemComponent_default,
|
|
550
|
+
{
|
|
551
|
+
onSelect: () => editor.chain().setParagraph().run(),
|
|
552
|
+
item: {
|
|
553
|
+
id: crypto.randomUUID(),
|
|
554
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Pilcrow, {}),
|
|
555
|
+
text: "Paragraph",
|
|
556
|
+
keyBind: "\u2318\u2325 P",
|
|
557
|
+
onClick: () => editor.chain().setParagraph().run(),
|
|
558
|
+
name: "paragraph"
|
|
559
|
+
},
|
|
560
|
+
activeClassName: options.activeClassName || "",
|
|
561
|
+
itemClassName: options.itemClassName || "",
|
|
562
|
+
showKeyShortcutText: options.showKeyShortcutText,
|
|
563
|
+
_itemClassName: dropdownItemClassName
|
|
564
|
+
}
|
|
565
|
+
),
|
|
566
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("hr", { className: "border-gray-200" }),
|
|
567
|
+
list.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
568
|
+
DropdownItemComponent_default,
|
|
569
|
+
{
|
|
570
|
+
onSelect: item.onClick,
|
|
571
|
+
item,
|
|
572
|
+
spClass: ["text-3xl", "text-2xl", "text-xl", "text-lg", "text-base", "text-sm"][(Number(item.ext) || 6) - 1],
|
|
573
|
+
activeClassName: options.activeClassName || "",
|
|
574
|
+
itemClassName: options.itemClassName || "",
|
|
575
|
+
showKeyShortcutText: options.showKeyShortcutText,
|
|
576
|
+
_itemClassName: dropdownItemClassName
|
|
577
|
+
},
|
|
578
|
+
`${item.name}${item.ext}`
|
|
579
|
+
))
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
},
|
|
586
|
+
addExtensions() {
|
|
587
|
+
return [import_extension_paragraph.default];
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
591
|
+
0 && (module.exports = {
|
|
592
|
+
Heading
|
|
593
|
+
});
|