ritext 1.0.19 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +57 -0
- package/README.md +15 -41
- package/dist/chunk-EN4BPI7N.mjs +1213 -0
- package/dist/chunk-FJQ4FZRS.mjs +98 -0
- package/dist/chunk-M4ORWR74.mjs +31 -0
- package/dist/chunk-SJFT7WNM.mjs +38 -0
- package/dist/chunk-W367UGID.mjs +55 -0
- package/dist/{chunk-FWCSY2DS.mjs → chunk-WNQUEZJF.mjs} +22 -1
- package/dist/{chunk-D47XME55.mjs → chunk-WXCHG3NQ.mjs} +8 -2
- package/dist/chunk-WZKGD3DD.mjs +231 -0
- package/dist/extension/backgroundcolor.d.mts +16 -0
- package/dist/extension/backgroundcolor.d.ts +16 -0
- package/dist/extension/backgroundcolor.js +668 -0
- package/dist/extension/backgroundcolor.mjs +107 -0
- package/dist/extension/base.d.mts +6 -0
- package/dist/extension/base.d.ts +6 -0
- package/dist/extension/base.js +65 -0
- package/dist/extension/base.mjs +22 -0
- package/dist/extension/blockquote.d.mts +10 -0
- package/dist/extension/blockquote.d.ts +10 -0
- package/dist/extension/blockquote.js +239 -0
- package/dist/extension/blockquote.mjs +46 -0
- package/dist/extension/bold.d.mts +7 -2
- package/dist/extension/bold.d.ts +7 -2
- package/dist/extension/bold.js +22 -45
- package/dist/extension/bold.mjs +13 -35
- package/dist/extension/bulletlist.d.mts +10 -0
- package/dist/extension/bulletlist.d.ts +10 -0
- package/dist/extension/bulletlist.js +241 -0
- package/dist/extension/bulletlist.mjs +46 -0
- package/dist/extension/clearformat.d.mts +1 -1
- package/dist/extension/clearformat.d.ts +1 -1
- package/dist/extension/clearformat.js +11 -6
- package/dist/extension/clearformat.mjs +8 -35
- package/dist/extension/color.d.mts +17 -0
- package/dist/extension/color.d.ts +17 -0
- package/dist/extension/color.js +580 -0
- package/dist/extension/color.mjs +12 -0
- package/dist/extension/emoji.d.mts +15 -0
- package/dist/extension/emoji.d.ts +15 -0
- package/dist/extension/emoji.js +421 -0
- package/dist/extension/emoji.mjs +158 -0
- package/dist/extension/font-family.d.mts +8 -11
- package/dist/extension/font-family.d.ts +8 -11
- package/dist/extension/font-family.js +11 -12
- package/dist/extension/font-family.mjs +10 -11
- package/dist/extension/font-size.d.mts +8 -11
- package/dist/extension/font-size.d.ts +8 -11
- package/dist/extension/font-size.js +10 -12
- package/dist/extension/font-size.mjs +9 -11
- package/dist/extension/heading.d.mts +10 -10
- package/dist/extension/heading.d.ts +10 -10
- package/dist/extension/heading.js +68 -80
- package/dist/extension/heading.mjs +40 -206
- package/dist/extension/history.d.mts +4 -2
- package/dist/extension/history.d.ts +4 -2
- package/dist/extension/history.js +16 -9
- package/dist/extension/history.mjs +16 -64
- package/dist/extension/horizontalrule.d.mts +10 -0
- package/dist/extension/horizontalrule.d.ts +10 -0
- package/dist/extension/horizontalrule.js +242 -0
- package/dist/extension/horizontalrule.mjs +42 -0
- package/dist/extension/image.d.mts +26 -0
- package/dist/extension/image.d.ts +26 -0
- package/dist/extension/image.js +1611 -0
- package/dist/extension/image.mjs +1153 -0
- package/dist/extension/indentoutdent.d.mts +21 -0
- package/dist/extension/indentoutdent.d.ts +21 -0
- package/dist/extension/indentoutdent.js +380 -0
- package/dist/extension/indentoutdent.mjs +164 -0
- package/dist/extension/italic.d.mts +7 -2
- package/dist/extension/italic.d.ts +7 -2
- package/dist/extension/italic.js +22 -45
- package/dist/extension/italic.mjs +14 -40
- package/dist/extension/lineheight.d.mts +15 -0
- package/dist/extension/lineheight.d.ts +15 -0
- package/dist/extension/lineheight.js +342 -0
- package/dist/extension/lineheight.mjs +87 -0
- package/dist/extension/link.d.mts +15 -0
- package/dist/extension/link.d.ts +15 -0
- package/dist/extension/link.js +588 -0
- package/dist/extension/link.mjs +278 -0
- package/dist/extension/orderedlist.d.mts +10 -0
- package/dist/extension/orderedlist.d.ts +10 -0
- package/dist/extension/orderedlist.js +241 -0
- package/dist/extension/orderedlist.mjs +46 -0
- package/dist/extension/strike.d.mts +8 -3
- package/dist/extension/strike.d.ts +8 -3
- package/dist/extension/strike.js +22 -45
- package/dist/extension/strike.mjs +14 -40
- package/dist/extension/subandsuperscript.d.mts +7 -10
- package/dist/extension/subandsuperscript.d.ts +7 -10
- package/dist/extension/subandsuperscript.js +66 -77
- package/dist/extension/subandsuperscript.mjs +18 -48
- package/dist/extension/subscript.d.mts +4 -2
- package/dist/extension/subscript.d.ts +4 -2
- package/dist/extension/subscript.js +20 -45
- package/dist/extension/subscript.mjs +10 -10
- package/dist/extension/superscript.d.mts +4 -2
- package/dist/extension/superscript.d.ts +4 -2
- package/dist/extension/superscript.js +20 -45
- package/dist/extension/superscript.mjs +10 -10
- package/dist/extension/table.d.mts +12 -0
- package/dist/extension/table.d.ts +12 -0
- package/dist/extension/table.js +585 -0
- package/dist/extension/table.mjs +324 -0
- package/dist/extension/tasklist.d.mts +10 -0
- package/dist/extension/tasklist.d.ts +10 -0
- package/dist/extension/tasklist.js +246 -0
- package/dist/extension/tasklist.mjs +52 -0
- package/dist/extension/textalign.d.mts +15 -0
- package/dist/extension/textalign.d.ts +15 -0
- package/dist/extension/textalign.js +404 -0
- package/dist/extension/textalign.mjs +79 -0
- package/dist/extension/underline.d.mts +7 -2
- package/dist/extension/underline.d.ts +7 -2
- package/dist/extension/underline.js +22 -45
- package/dist/extension/underline.mjs +14 -39
- package/dist/index.css +683 -31
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +306 -24
- package/dist/index.mjs +141 -13
- package/dist/tiptap-ext.type-B3TtT7-J.d.mts +43 -0
- package/dist/tiptap-ext.type-B3TtT7-J.d.ts +43 -0
- package/package.json +41 -28
- package/dist/chunk-2YUUKIIT.mjs +0 -149
- package/dist/chunk-7QOFJIQ3.mjs +0 -90
- package/dist/chunk-GSHINFPO.mjs +0 -53
- package/dist/chunk-LMOTHRGQ.mjs +0 -37
- package/dist/chunk-MBF77NHS.mjs +0 -37
- package/dist/tiptap-ext.type-DrneAC5G.d.mts +0 -39
- package/dist/tiptap-ext.type-DrneAC5G.d.ts +0 -39
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckboxComponent_default,
|
|
3
|
+
InputComponent_default
|
|
4
|
+
} from "../chunk-W367UGID.mjs";
|
|
5
|
+
import {
|
|
6
|
+
DropdownComponent_default
|
|
7
|
+
} from "../chunk-FJQ4FZRS.mjs";
|
|
8
|
+
import {
|
|
9
|
+
useEditor
|
|
10
|
+
} from "../chunk-VYDH6BZE.mjs";
|
|
11
|
+
import {
|
|
12
|
+
LinkIcon
|
|
13
|
+
} from "../chunk-EN4BPI7N.mjs";
|
|
14
|
+
import {
|
|
15
|
+
__spreadProps,
|
|
16
|
+
__spreadValues
|
|
17
|
+
} from "../chunk-WNQUEZJF.mjs";
|
|
18
|
+
|
|
19
|
+
// src/extension/Link.tsx
|
|
20
|
+
import { Fragment } from "react";
|
|
21
|
+
import { mergeAttributes } from "@tiptap/react";
|
|
22
|
+
import { Link as TiptapLink } from "@tiptap/extension-link";
|
|
23
|
+
|
|
24
|
+
// src/lib/components/LinkComponent.tsx
|
|
25
|
+
import { useEffect, useState, useRef } from "react";
|
|
26
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
var LinkComponent = ({ editor, onClose, open }) => {
|
|
28
|
+
const [form, setForm] = useState({
|
|
29
|
+
text: "",
|
|
30
|
+
link: "",
|
|
31
|
+
target: "_self"
|
|
32
|
+
});
|
|
33
|
+
const textInputRef = useRef(null);
|
|
34
|
+
const linkInputRef = useRef(null);
|
|
35
|
+
const onApply = () => {
|
|
36
|
+
const { link, text, target } = form;
|
|
37
|
+
if (!link) {
|
|
38
|
+
editor.chain().extendMarkRange("link").unsetLink().run();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (editor.isActive("link")) {
|
|
42
|
+
editor.chain().extendMarkRange("link").run();
|
|
43
|
+
}
|
|
44
|
+
const { from } = editor.state.selection;
|
|
45
|
+
const insertedLength = text.length;
|
|
46
|
+
editor.chain().insertContent({
|
|
47
|
+
type: "text",
|
|
48
|
+
text,
|
|
49
|
+
marks: [
|
|
50
|
+
{
|
|
51
|
+
type: "link",
|
|
52
|
+
attrs: {
|
|
53
|
+
href: /^https?:\/\//i.test(link) ? link : `https://${link}`,
|
|
54
|
+
target
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}).setLink({ href: link }).setTextSelection({ from, to: from + insertedLength }).focus().run();
|
|
59
|
+
onClose == null ? void 0 : onClose();
|
|
60
|
+
};
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const updateForm = () => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const { from, to, empty } = editor.state.selection;
|
|
65
|
+
let text = "";
|
|
66
|
+
let link = "";
|
|
67
|
+
let target = "_self";
|
|
68
|
+
const node = editor.state.doc.nodeAt(from);
|
|
69
|
+
if (node) {
|
|
70
|
+
const linkMark = node.marks.find((mark) => mark.type.name === "link");
|
|
71
|
+
if (linkMark) {
|
|
72
|
+
link = linkMark.attrs.href || "";
|
|
73
|
+
target = linkMark.attrs.target;
|
|
74
|
+
if (empty) {
|
|
75
|
+
text = node.text || "";
|
|
76
|
+
} else {
|
|
77
|
+
text = editor.state.doc.textBetween(from, to, " ");
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
text = editor.state.doc.textBetween(from, to, " ");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!node) {
|
|
84
|
+
text = editor.state.doc.textBetween(from, to, " ");
|
|
85
|
+
}
|
|
86
|
+
setForm({ link, text, target });
|
|
87
|
+
if (open) {
|
|
88
|
+
if (text === "") {
|
|
89
|
+
(_a = textInputRef.current) == null ? void 0 : _a.focus();
|
|
90
|
+
} else {
|
|
91
|
+
(_b = linkInputRef.current) == null ? void 0 : _b.focus();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
updateForm();
|
|
96
|
+
editor.on("selectionUpdate", updateForm);
|
|
97
|
+
return () => {
|
|
98
|
+
editor.off("selectionUpdate", updateForm);
|
|
99
|
+
};
|
|
100
|
+
}, [editor, open]);
|
|
101
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
InputComponent_default,
|
|
104
|
+
{
|
|
105
|
+
id: "text",
|
|
106
|
+
label: "Text",
|
|
107
|
+
value: form.text,
|
|
108
|
+
onChange: (e) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { text: e.target.value })),
|
|
109
|
+
ref: textInputRef
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
InputComponent_default,
|
|
114
|
+
{
|
|
115
|
+
id: "link",
|
|
116
|
+
label: "Link",
|
|
117
|
+
value: form.link,
|
|
118
|
+
onChange: (e) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { link: e.target.value })),
|
|
119
|
+
placeholder: "https://yourlink.com",
|
|
120
|
+
ref: linkInputRef,
|
|
121
|
+
containerClassName: "mt-3 mb-2.5"
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
CheckboxComponent_default,
|
|
126
|
+
{
|
|
127
|
+
id: "openNewTab",
|
|
128
|
+
checked: form.target === "_blank",
|
|
129
|
+
onChange: () => setForm((prev) => __spreadProps(__spreadValues({}, prev), { target: prev.target === "_self" ? "_blank" : "_self" })),
|
|
130
|
+
label: "Open in a new tab?",
|
|
131
|
+
bottomSpace: false
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "bg-gray-800 text-white w-full py-1.5 rounded-lg mt-5", onClick: onApply, children: "Apply Now" })
|
|
135
|
+
] });
|
|
136
|
+
};
|
|
137
|
+
var LinkComponent_default = LinkComponent;
|
|
138
|
+
|
|
139
|
+
// src/lib/components/LinkMenuComponent.tsx
|
|
140
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
141
|
+
import { useFloating, autoUpdate, offset, flip, shift, useDismiss, useInteractions } from "@floating-ui/react";
|
|
142
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
143
|
+
var LinkMenuComponent = () => {
|
|
144
|
+
const { editor } = useEditor();
|
|
145
|
+
const [pop, setPop] = useState2({ open: false });
|
|
146
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
147
|
+
open: pop.open,
|
|
148
|
+
onOpenChange: (o) => setPop((s) => o ? s : { open: false }),
|
|
149
|
+
placement: "bottom-start",
|
|
150
|
+
whileElementsMounted: autoUpdate,
|
|
151
|
+
strategy: "fixed",
|
|
152
|
+
middleware: [offset(8), flip(), shift({ padding: 8 })]
|
|
153
|
+
});
|
|
154
|
+
const dismiss = useDismiss(context, { outsidePressEvent: "pointerdown" });
|
|
155
|
+
const { getFloatingProps } = useInteractions([dismiss]);
|
|
156
|
+
useEffect2(() => {
|
|
157
|
+
if (!editor) return;
|
|
158
|
+
const dom = editor.view.dom;
|
|
159
|
+
const onClick = (e) => {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
const target = e.target;
|
|
162
|
+
if (!target) return;
|
|
163
|
+
const a = target.closest("a[href]");
|
|
164
|
+
if (!a || !dom.contains(a)) return;
|
|
165
|
+
if (e.metaKey || e.ctrlKey) return;
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
refs.setReference(a);
|
|
169
|
+
const href = (_a = a.getAttribute("href")) != null ? _a : "";
|
|
170
|
+
const targetBlank = ((_b = a.getAttribute("target")) != null ? _b : "") === "_blank";
|
|
171
|
+
setPop({ open: true, href, targetBlank });
|
|
172
|
+
};
|
|
173
|
+
dom.addEventListener("click", onClick, true);
|
|
174
|
+
return () => dom.removeEventListener("click", onClick, true);
|
|
175
|
+
}, [editor, refs]);
|
|
176
|
+
const applyLink = () => {
|
|
177
|
+
if (!editor || !pop.open) return;
|
|
178
|
+
editor.chain().focus().extendMarkRange("link").setLink({ href: pop.href, target: pop.targetBlank ? "_blank" : null }).run();
|
|
179
|
+
setPop({ open: false });
|
|
180
|
+
};
|
|
181
|
+
const removeLink = () => {
|
|
182
|
+
if (!editor) return;
|
|
183
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
184
|
+
setPop({ open: false });
|
|
185
|
+
};
|
|
186
|
+
if (!editor || !pop.open) return null;
|
|
187
|
+
return /* @__PURE__ */ jsxs2("div", __spreadProps(__spreadValues({ ref: refs.setFloating, style: floatingStyles }, getFloatingProps()), { className: "z-99999999 w-66 rounded-xl border border-gray-200 bg-white p-3 shadow-lg", children: [
|
|
188
|
+
/* @__PURE__ */ jsx2(
|
|
189
|
+
InputComponent_default,
|
|
190
|
+
{
|
|
191
|
+
id: "link",
|
|
192
|
+
label: "Link",
|
|
193
|
+
value: pop.href,
|
|
194
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
195
|
+
onChange: (e) => setPop((s) => s.open ? __spreadProps(__spreadValues({}, s), { href: e.target.value }) : s),
|
|
196
|
+
placeholder: "https://yourlink.com",
|
|
197
|
+
containerClassName: "mb-2.5"
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsx2(
|
|
201
|
+
CheckboxComponent_default,
|
|
202
|
+
{
|
|
203
|
+
id: "openNewTab",
|
|
204
|
+
checked: pop.targetBlank,
|
|
205
|
+
onChange: (e) => setPop((s) => s.open ? __spreadProps(__spreadValues({}, s), { targetBlank: e }) : s),
|
|
206
|
+
label: "Open in a new tab?",
|
|
207
|
+
bottomSpace: false
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
/* @__PURE__ */ jsxs2("div", { className: "mt-3 flex gap-2", children: [
|
|
211
|
+
/* @__PURE__ */ jsx2("button", { className: "rounded-lg border bg-gray-700 text-white border-gray-700 px-3 py-1 text-sm", onMouseDown: (e) => e.stopPropagation(), onClick: applyLink, children: "Apply" }),
|
|
212
|
+
/* @__PURE__ */ jsx2("button", { className: "rounded-lg border border-gray-200 px-3 py-1 text-sm", onMouseDown: (e) => e.stopPropagation(), onClick: removeLink, children: "Unlink" }),
|
|
213
|
+
/* @__PURE__ */ jsx2("button", { className: "ml-auto rounded-lg border border-gray-200 px-3 py-1 text-sm", onMouseDown: (e) => e.stopPropagation(), onClick: () => setPop({ open: false }), children: "Cancel" })
|
|
214
|
+
] })
|
|
215
|
+
] }));
|
|
216
|
+
};
|
|
217
|
+
var LinkMenuComponent_default = LinkMenuComponent;
|
|
218
|
+
|
|
219
|
+
// src/extension/Link.tsx
|
|
220
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
221
|
+
var Links = TiptapLink.extend({
|
|
222
|
+
inclusive: false,
|
|
223
|
+
parseHTML() {
|
|
224
|
+
return [
|
|
225
|
+
{
|
|
226
|
+
tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'
|
|
227
|
+
}
|
|
228
|
+
];
|
|
229
|
+
},
|
|
230
|
+
renderHTML({ HTMLAttributes }) {
|
|
231
|
+
return [
|
|
232
|
+
"a",
|
|
233
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
234
|
+
class: "link"
|
|
235
|
+
}),
|
|
236
|
+
0
|
|
237
|
+
];
|
|
238
|
+
},
|
|
239
|
+
addOptions() {
|
|
240
|
+
var _a;
|
|
241
|
+
const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
|
|
242
|
+
return __spreadProps(__spreadValues({}, parent != null ? parent : {}), {
|
|
243
|
+
openOnClick: false,
|
|
244
|
+
showInBubbleMenu: true,
|
|
245
|
+
bubbleMenuPosition: 9,
|
|
246
|
+
component: ({ options, editor, dropdownContainerClassName }) => {
|
|
247
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
248
|
+
/* @__PURE__ */ jsx3(
|
|
249
|
+
DropdownComponent_default,
|
|
250
|
+
{
|
|
251
|
+
className: options.className,
|
|
252
|
+
showArrow: options.showArrow || false,
|
|
253
|
+
content: options.content,
|
|
254
|
+
dropdownClassName: options.dropdownClassName,
|
|
255
|
+
style: options.style,
|
|
256
|
+
tooltip: options.tooltip,
|
|
257
|
+
tooltipClassName: options.tooltipClassName,
|
|
258
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
259
|
+
_tooltipContent: "Link",
|
|
260
|
+
_internalContent: /* @__PURE__ */ jsx3(LinkIcon, {}),
|
|
261
|
+
_dropdownClassName: "w-66 " + dropdownContainerClassName,
|
|
262
|
+
children: /* @__PURE__ */ jsx3(
|
|
263
|
+
LinkComponent_default,
|
|
264
|
+
{
|
|
265
|
+
editor
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsx3(LinkMenuComponent_default, {})
|
|
271
|
+
] });
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
export {
|
|
277
|
+
Links
|
|
278
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OrderedListOptions } from '@tiptap/extension-list';
|
|
2
|
+
import { Node } from '@tiptap/react';
|
|
3
|
+
import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.mjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type ExtOrderListOptions = ExtButtonOptions<OrderedListOptions>;
|
|
8
|
+
declare const OrderedList: Node<ExtOrderListOptions>;
|
|
9
|
+
|
|
10
|
+
export { OrderedList };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OrderedListOptions } from '@tiptap/extension-list';
|
|
2
|
+
import { Node } from '@tiptap/react';
|
|
3
|
+
import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type ExtOrderListOptions = ExtButtonOptions<OrderedListOptions>;
|
|
8
|
+
declare const OrderedList: Node<ExtOrderListOptions>;
|
|
9
|
+
|
|
10
|
+
export { OrderedList };
|
|
@@ -0,0 +1,241 @@
|
|
|
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/Orderlist.tsx
|
|
50
|
+
var Orderlist_exports = {};
|
|
51
|
+
__export(Orderlist_exports, {
|
|
52
|
+
OrderedList: () => OrderedList
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(Orderlist_exports);
|
|
55
|
+
var import_extension_list = require("@tiptap/extension-list");
|
|
56
|
+
|
|
57
|
+
// src/lib/icons/index.tsx
|
|
58
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
59
|
+
var OrderListIcon = (_a) => {
|
|
60
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
62
|
+
"svg",
|
|
63
|
+
__spreadProps(__spreadValues({
|
|
64
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
+
width: size,
|
|
66
|
+
height: size,
|
|
67
|
+
viewBox: "0 0 24 24",
|
|
68
|
+
fill: "none",
|
|
69
|
+
stroke: "currentColor",
|
|
70
|
+
strokeWidth: "2",
|
|
71
|
+
strokeLinecap: "round",
|
|
72
|
+
strokeLinejoin: "round"
|
|
73
|
+
}, props), {
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M11 5h10" }),
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M11 12h10" }),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M11 19h10" }),
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 4h1v5" }),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 9h2" }),
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" })
|
|
81
|
+
]
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/lib/components/ButtonComponent.tsx
|
|
87
|
+
var import_react5 = require("react");
|
|
88
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
89
|
+
|
|
90
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
91
|
+
var import_react = require("react");
|
|
92
|
+
var import_react2 = require("@floating-ui/react");
|
|
93
|
+
var import_react3 = require("motion/react");
|
|
94
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
95
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
96
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
97
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
98
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
|
|
99
|
+
open,
|
|
100
|
+
onOpenChange: setOpen,
|
|
101
|
+
placement,
|
|
102
|
+
middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
|
|
103
|
+
whileElementsMounted: import_react2.autoUpdate
|
|
104
|
+
});
|
|
105
|
+
const hover = (0, import_react2.useHover)(context);
|
|
106
|
+
const dismiss = (0, import_react2.useDismiss)(context);
|
|
107
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
|
|
108
|
+
const id = (0, import_react.useId)();
|
|
109
|
+
function mergeRefs(...refsToMerge) {
|
|
110
|
+
return (node) => {
|
|
111
|
+
for (const r of refsToMerge) {
|
|
112
|
+
if (!r) continue;
|
|
113
|
+
if (typeof r === "function") r(node);
|
|
114
|
+
else r.current = node;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const side = resolvedPlacement.split("-")[0];
|
|
119
|
+
const enterOffset = 6;
|
|
120
|
+
const getInitial = () => {
|
|
121
|
+
switch (side) {
|
|
122
|
+
case "top":
|
|
123
|
+
return { opacity: 0, y: enterOffset };
|
|
124
|
+
case "bottom":
|
|
125
|
+
return { opacity: 0, y: -enterOffset };
|
|
126
|
+
case "left":
|
|
127
|
+
return { opacity: 0, x: enterOffset };
|
|
128
|
+
case "right":
|
|
129
|
+
return { opacity: 0, x: -enterOffset };
|
|
130
|
+
default:
|
|
131
|
+
return { opacity: 0 };
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
|
|
136
|
+
(0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
137
|
+
onFocus: () => setOpen(true),
|
|
138
|
+
onBlur: () => setOpen(false),
|
|
139
|
+
"aria-describedby": open ? id : void 0
|
|
140
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
141
|
+
})), {
|
|
142
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
143
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
144
|
+
})) : children,
|
|
145
|
+
/* @__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)(
|
|
146
|
+
import_react3.motion.div,
|
|
147
|
+
__spreadProps(__spreadValues({
|
|
148
|
+
ref: refs.setFloating
|
|
149
|
+
}, getFloatingProps({
|
|
150
|
+
role: "tooltip",
|
|
151
|
+
id,
|
|
152
|
+
style: {
|
|
153
|
+
position: strategy,
|
|
154
|
+
top: y != null ? y : 0,
|
|
155
|
+
left: x != null ? x : 0,
|
|
156
|
+
pointerEvents: "none"
|
|
157
|
+
}
|
|
158
|
+
})), {
|
|
159
|
+
initial: getInitial(),
|
|
160
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
161
|
+
exit: getExit(),
|
|
162
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
163
|
+
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),
|
|
164
|
+
children: content
|
|
165
|
+
}),
|
|
166
|
+
"tooltip"
|
|
167
|
+
) }) })
|
|
168
|
+
] });
|
|
169
|
+
};
|
|
170
|
+
var Tooltip_default = Tooltip;
|
|
171
|
+
|
|
172
|
+
// src/lib/context/editor.context.tsx
|
|
173
|
+
var import_react4 = require("react");
|
|
174
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
175
|
+
var EditorContext = (0, import_react4.createContext)({ editor: null });
|
|
176
|
+
var useEditor = () => {
|
|
177
|
+
const ctx = (0, import_react4.useContext)(EditorContext);
|
|
178
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
179
|
+
return ctx;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/lib/components/ButtonComponent.tsx
|
|
183
|
+
var import_react6 = require("@tiptap/react");
|
|
184
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
185
|
+
var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
|
|
186
|
+
const { editor } = useEditor();
|
|
187
|
+
const editorState = (0, import_react6.useEditorState)({
|
|
188
|
+
editor,
|
|
189
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
|
|
190
|
+
});
|
|
191
|
+
const shortcutText = (0, import_react5.useMemo)(() => {
|
|
192
|
+
if (!_interShortcut) return "";
|
|
193
|
+
return (0, import_react6.isMacOS)() ? _interShortcut.mac : _interShortcut.win;
|
|
194
|
+
}, [_interShortcut]);
|
|
195
|
+
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
|
|
196
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
197
|
+
shortcutText ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "opacity-70", children: shortcutText })
|
|
200
|
+
] }) : null
|
|
201
|
+
] });
|
|
202
|
+
const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { onClick: _onToggle, className: (0, import_tailwind_merge2.twMerge)("py-1.5 px-2.5 rounded-md", _buttonClassName, (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100", className, (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"), style, children: icon != null ? icon : _internalIcon });
|
|
203
|
+
if (tooltip === false) return btn;
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip_default, { content: tooltipContent, className: tooltipClassName, placement: tooltipPlacement, children: btn });
|
|
205
|
+
};
|
|
206
|
+
var ButtonComponent_default = ButtonComponent;
|
|
207
|
+
|
|
208
|
+
// src/extension/Orderlist.tsx
|
|
209
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
210
|
+
var OrderedList = import_extension_list.OrderedList.extend({
|
|
211
|
+
addOptions() {
|
|
212
|
+
var _a;
|
|
213
|
+
const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
|
|
214
|
+
return __spreadProps(__spreadValues({}, parent != null ? parent : {}), {
|
|
215
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
217
|
+
ButtonComponent_default,
|
|
218
|
+
{
|
|
219
|
+
className: options.className,
|
|
220
|
+
icon: options.icon,
|
|
221
|
+
style: options.style,
|
|
222
|
+
activeClassName: options.activeClassName,
|
|
223
|
+
tooltip: options.tooltip,
|
|
224
|
+
tooltipClassName: options.tooltipClassName,
|
|
225
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
226
|
+
_internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OrderListIcon, {}),
|
|
227
|
+
_extName: "orderedList",
|
|
228
|
+
_onToggle: () => editor.chain().focus().toggleOrderedList().run(),
|
|
229
|
+
_interShortcut: { win: "Ctrl + \u21E7 + 7", mac: "\u2318 + \u21E7 + 7" },
|
|
230
|
+
_tooltipContent: "Ordered List",
|
|
231
|
+
_buttonClassName: buttonClassName
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
239
|
+
0 && (module.exports = {
|
|
240
|
+
OrderedList
|
|
241
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonComponent_default
|
|
3
|
+
} from "../chunk-SJFT7WNM.mjs";
|
|
4
|
+
import "../chunk-VYDH6BZE.mjs";
|
|
5
|
+
import {
|
|
6
|
+
OrderListIcon
|
|
7
|
+
} from "../chunk-EN4BPI7N.mjs";
|
|
8
|
+
import {
|
|
9
|
+
__spreadProps,
|
|
10
|
+
__spreadValues
|
|
11
|
+
} from "../chunk-WNQUEZJF.mjs";
|
|
12
|
+
|
|
13
|
+
// src/extension/Orderlist.tsx
|
|
14
|
+
import { OrderedList as TiptapOrderedList } from "@tiptap/extension-list";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var OrderedList = TiptapOrderedList.extend({
|
|
17
|
+
addOptions() {
|
|
18
|
+
var _a;
|
|
19
|
+
const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
|
|
20
|
+
return __spreadProps(__spreadValues({}, parent != null ? parent : {}), {
|
|
21
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
ButtonComponent_default,
|
|
24
|
+
{
|
|
25
|
+
className: options.className,
|
|
26
|
+
icon: options.icon,
|
|
27
|
+
style: options.style,
|
|
28
|
+
activeClassName: options.activeClassName,
|
|
29
|
+
tooltip: options.tooltip,
|
|
30
|
+
tooltipClassName: options.tooltipClassName,
|
|
31
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
32
|
+
_internalIcon: /* @__PURE__ */ jsx(OrderListIcon, {}),
|
|
33
|
+
_extName: "orderedList",
|
|
34
|
+
_onToggle: () => editor.chain().focus().toggleOrderedList().run(),
|
|
35
|
+
_interShortcut: { win: "Ctrl + \u21E7 + 7", mac: "\u2318 + \u21E7 + 7" },
|
|
36
|
+
_tooltipContent: "Ordered List",
|
|
37
|
+
_buttonClassName: buttonClassName
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
OrderedList
|
|
46
|
+
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { StrikeOptions } from '@tiptap/extension-strike';
|
|
1
2
|
import { Mark } from '@tiptap/react';
|
|
2
|
-
import { E as ExtButtonOptions } from '../tiptap-ext.type-
|
|
3
|
+
import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.mjs';
|
|
3
4
|
import 'react';
|
|
4
5
|
import '@floating-ui/react';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
type ExtStrikeOptions = ExtButtonOptions<StrikeOptions & {
|
|
8
|
+
showInBubbleMenu?: boolean;
|
|
9
|
+
bubbleMenuPosition?: number;
|
|
10
|
+
}>;
|
|
11
|
+
declare const Strike: Mark<ExtStrikeOptions>;
|
|
7
12
|
|
|
8
|
-
export { Strike };
|
|
13
|
+
export { type ExtStrikeOptions, Strike };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { StrikeOptions } from '@tiptap/extension-strike';
|
|
1
2
|
import { Mark } from '@tiptap/react';
|
|
2
|
-
import { E as ExtButtonOptions } from '../tiptap-ext.type-
|
|
3
|
+
import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.js';
|
|
3
4
|
import 'react';
|
|
4
5
|
import '@floating-ui/react';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
type ExtStrikeOptions = ExtButtonOptions<StrikeOptions & {
|
|
8
|
+
showInBubbleMenu?: boolean;
|
|
9
|
+
bubbleMenuPosition?: number;
|
|
10
|
+
}>;
|
|
11
|
+
declare const Strike: Mark<ExtStrikeOptions>;
|
|
7
12
|
|
|
8
|
-
export { Strike };
|
|
13
|
+
export { type ExtStrikeOptions, Strike };
|