ritext 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/README.md
CHANGED
|
@@ -14,34 +14,34 @@ Ritext is a modern WYSIWYG rich text editor built with Tailwind CSS, powered by
|
|
|
14
14
|
### This is an testing phase will publish soon.
|
|
15
15
|
|
|
16
16
|
# Extension Roadmap
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
☑ Starter Kit
|
|
18
|
+
☑ Bold
|
|
19
|
+
☑ Italic
|
|
20
|
+
☑ Underline
|
|
21
|
+
☑ Strike
|
|
22
|
+
☑ Subscript
|
|
23
|
+
☑ Superscript
|
|
24
|
+
☑ SubAndSuperScript
|
|
25
|
+
☐ Format Painter
|
|
26
|
+
☐ Clear Format
|
|
27
|
+
☐ Font Family
|
|
28
|
+
☐ Heading
|
|
29
|
+
☐ Fonts Size
|
|
30
|
+
☐ Undo
|
|
31
|
+
☐ Redo
|
|
32
|
+
☐ Emoji
|
|
33
|
+
☐ Color
|
|
34
|
+
☐ Highlight
|
|
35
|
+
☐ Bullet List
|
|
36
|
+
☐ Ordered List
|
|
37
|
+
☐ Alignment
|
|
38
|
+
☐ Indent
|
|
39
|
+
☐ Outdent
|
|
40
|
+
☐ Line Height
|
|
41
|
+
☐ Task List
|
|
42
|
+
☐ Image
|
|
43
|
+
☐ Link
|
|
44
|
+
☐ Blockquote
|
|
45
45
|
|
|
46
46
|
# Stay in touch
|
|
47
47
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Tooltip_default
|
|
3
|
+
} from "./chunk-ZLCVIW2P.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useEditor
|
|
6
|
+
} from "./chunk-TQTCTY3E.mjs";
|
|
7
|
+
|
|
8
|
+
// src/lib/components/ButtonComponent.tsx
|
|
9
|
+
import { twMerge } from "tailwind-merge";
|
|
10
|
+
import { useEditorState } from "@tiptap/react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
|
|
13
|
+
const { editor } = useEditor();
|
|
14
|
+
const editorState = useEditorState({
|
|
15
|
+
editor,
|
|
16
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
|
|
17
|
+
});
|
|
18
|
+
const tooltipContent = /* @__PURE__ */ jsxs("p", { children: [
|
|
19
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
20
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
21
|
+
_interShortcut
|
|
22
|
+
] });
|
|
23
|
+
const btn = /* @__PURE__ */ jsx(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
onClick: _onToggle,
|
|
27
|
+
className: twMerge(
|
|
28
|
+
"p-1.5 rounded-md",
|
|
29
|
+
_buttonClassName,
|
|
30
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
31
|
+
className,
|
|
32
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
33
|
+
),
|
|
34
|
+
style,
|
|
35
|
+
children: icon != null ? icon : _internalIcon
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
if (tooltip === false) return btn;
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
Tooltip_default,
|
|
41
|
+
{
|
|
42
|
+
content: tooltipContent,
|
|
43
|
+
className: tooltipClassName,
|
|
44
|
+
placement: tooltipPlacement,
|
|
45
|
+
children: btn
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
var ButtonComponent_default = ButtonComponent;
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
ButtonComponent_default
|
|
53
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "./chunk-TQTCTY3E.mjs";
|
|
6
|
+
|
|
7
|
+
// src/lib/icon/SupIcon.tsx
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var SupIcon = (_a) => {
|
|
10
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
11
|
+
return /* @__PURE__ */ jsxs(
|
|
12
|
+
"svg",
|
|
13
|
+
__spreadProps(__spreadValues({
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeWidth: 2,
|
|
19
|
+
strokeLinecap: "round",
|
|
20
|
+
strokeLinejoin: "round",
|
|
21
|
+
width: size,
|
|
22
|
+
height: size,
|
|
23
|
+
className
|
|
24
|
+
}, props), {
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsx("path", { d: "m4 19 8-8" }),
|
|
27
|
+
/* @__PURE__ */ jsx("path", { d: "m12 19-8-8" }),
|
|
28
|
+
/* @__PURE__ */ jsx("path", { d: "M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" })
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
var SupIcon_default = SupIcon;
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
SupIcon_default
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "./chunk-TQTCTY3E.mjs";
|
|
6
|
+
|
|
7
|
+
// src/lib/icon/SubIcon.tsx
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var SubIcon = (_a) => {
|
|
10
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
11
|
+
return /* @__PURE__ */ jsxs(
|
|
12
|
+
"svg",
|
|
13
|
+
__spreadProps(__spreadValues({
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeWidth: 2,
|
|
19
|
+
strokeLinecap: "round",
|
|
20
|
+
strokeLinejoin: "round",
|
|
21
|
+
width: size,
|
|
22
|
+
height: size,
|
|
23
|
+
className
|
|
24
|
+
}, props), {
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsx("path", { d: "m4 5 8 8" }),
|
|
27
|
+
/* @__PURE__ */ jsx("path", { d: "m12 5-8 8" }),
|
|
28
|
+
/* @__PURE__ */ jsx("path", { d: "M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" })
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
var SubIcon_default = SubIcon;
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
SubIcon_default
|
|
37
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/lib/context/editor.context.tsx
|
|
34
|
+
import { createContext, useContext } from "react";
|
|
35
|
+
import { jsx } from "react/jsx-runtime";
|
|
36
|
+
var EditorContext = createContext({ editor: null });
|
|
37
|
+
var useEditor = () => {
|
|
38
|
+
const ctx = useContext(EditorContext);
|
|
39
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
40
|
+
return ctx;
|
|
41
|
+
};
|
|
42
|
+
var EditorProvider = ({ children, value }) => {
|
|
43
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, { value, children });
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
__spreadValues,
|
|
48
|
+
__spreadProps,
|
|
49
|
+
__objRest,
|
|
50
|
+
useEditor,
|
|
51
|
+
EditorProvider
|
|
52
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-TQTCTY3E.mjs";
|
|
5
|
+
|
|
6
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
7
|
+
import { useState, Fragment, cloneElement, isValidElement, useId } from "react";
|
|
8
|
+
import { useFloating, offset, flip, shift, autoUpdate, useInteractions, useHover, useDismiss, FloatingPortal } from "@floating-ui/react";
|
|
9
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
10
|
+
import { twMerge } from "tailwind-merge";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = useFloating({
|
|
15
|
+
open,
|
|
16
|
+
onOpenChange: setOpen,
|
|
17
|
+
placement,
|
|
18
|
+
middleware: [offset(8), flip(), shift({ padding: 8 })],
|
|
19
|
+
whileElementsMounted: autoUpdate
|
|
20
|
+
});
|
|
21
|
+
const hover = useHover(context);
|
|
22
|
+
const dismiss = useDismiss(context);
|
|
23
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([hover, dismiss]);
|
|
24
|
+
const id = useId();
|
|
25
|
+
function mergeRefs(...refsToMerge) {
|
|
26
|
+
return (node) => {
|
|
27
|
+
for (const r of refsToMerge) {
|
|
28
|
+
if (!r) continue;
|
|
29
|
+
if (typeof r === "function") r(node);
|
|
30
|
+
else r.current = node;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const side = resolvedPlacement.split("-")[0];
|
|
35
|
+
const enterOffset = 6;
|
|
36
|
+
const getInitial = () => {
|
|
37
|
+
switch (side) {
|
|
38
|
+
case "top":
|
|
39
|
+
return { opacity: 0, y: enterOffset };
|
|
40
|
+
case "bottom":
|
|
41
|
+
return { opacity: 0, y: -enterOffset };
|
|
42
|
+
case "left":
|
|
43
|
+
return { opacity: 0, x: enterOffset };
|
|
44
|
+
case "right":
|
|
45
|
+
return { opacity: 0, x: -enterOffset };
|
|
46
|
+
default:
|
|
47
|
+
return { opacity: 0 };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
51
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52
|
+
isValidElement(children) ? cloneElement(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
53
|
+
onFocus: () => setOpen(true),
|
|
54
|
+
onBlur: () => setOpen(false),
|
|
55
|
+
"aria-describedby": open ? id : void 0
|
|
56
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
57
|
+
})), {
|
|
58
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
59
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
60
|
+
})) : children,
|
|
61
|
+
/* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
|
|
62
|
+
motion.div,
|
|
63
|
+
__spreadProps(__spreadValues({
|
|
64
|
+
ref: refs.setFloating
|
|
65
|
+
}, getFloatingProps({
|
|
66
|
+
role: "tooltip",
|
|
67
|
+
id,
|
|
68
|
+
style: {
|
|
69
|
+
position: strategy,
|
|
70
|
+
top: y != null ? y : 0,
|
|
71
|
+
left: x != null ? x : 0,
|
|
72
|
+
pointerEvents: "none"
|
|
73
|
+
}
|
|
74
|
+
})), {
|
|
75
|
+
initial: getInitial(),
|
|
76
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
77
|
+
exit: getExit(),
|
|
78
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
79
|
+
className: 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),
|
|
80
|
+
children: content
|
|
81
|
+
}),
|
|
82
|
+
"tooltip"
|
|
83
|
+
) }) })
|
|
84
|
+
] });
|
|
85
|
+
};
|
|
86
|
+
var Tooltip_default = Tooltip;
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
Tooltip_default
|
|
90
|
+
};
|
|
@@ -0,0 +1,260 @@
|
|
|
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/Bold.tsx
|
|
60
|
+
var Bold_exports = {};
|
|
61
|
+
__export(Bold_exports, {
|
|
62
|
+
Bold: () => Bold
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(Bold_exports);
|
|
65
|
+
var import_extension_bold = __toESM(require("@tiptap/extension-bold"));
|
|
66
|
+
|
|
67
|
+
// src/lib/icon/BoldIcon.tsx
|
|
68
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
+
var BoldIcon = (_a) => {
|
|
70
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
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: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" })
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
var BoldIcon_default = BoldIcon;
|
|
90
|
+
|
|
91
|
+
// src/lib/components/ButtonComponent.tsx
|
|
92
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
93
|
+
|
|
94
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
95
|
+
var import_react = require("react");
|
|
96
|
+
var import_react2 = require("@floating-ui/react");
|
|
97
|
+
var import_react3 = require("motion/react");
|
|
98
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
99
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
100
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
101
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
102
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
|
|
103
|
+
open,
|
|
104
|
+
onOpenChange: setOpen,
|
|
105
|
+
placement,
|
|
106
|
+
middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
|
|
107
|
+
whileElementsMounted: import_react2.autoUpdate
|
|
108
|
+
});
|
|
109
|
+
const hover = (0, import_react2.useHover)(context);
|
|
110
|
+
const dismiss = (0, import_react2.useDismiss)(context);
|
|
111
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
|
|
112
|
+
const id = (0, import_react.useId)();
|
|
113
|
+
function mergeRefs(...refsToMerge) {
|
|
114
|
+
return (node) => {
|
|
115
|
+
for (const r of refsToMerge) {
|
|
116
|
+
if (!r) continue;
|
|
117
|
+
if (typeof r === "function") r(node);
|
|
118
|
+
else r.current = node;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const side = resolvedPlacement.split("-")[0];
|
|
123
|
+
const enterOffset = 6;
|
|
124
|
+
const getInitial = () => {
|
|
125
|
+
switch (side) {
|
|
126
|
+
case "top":
|
|
127
|
+
return { opacity: 0, y: enterOffset };
|
|
128
|
+
case "bottom":
|
|
129
|
+
return { opacity: 0, y: -enterOffset };
|
|
130
|
+
case "left":
|
|
131
|
+
return { opacity: 0, x: enterOffset };
|
|
132
|
+
case "right":
|
|
133
|
+
return { opacity: 0, x: -enterOffset };
|
|
134
|
+
default:
|
|
135
|
+
return { opacity: 0 };
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
|
|
140
|
+
(0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
141
|
+
onFocus: () => setOpen(true),
|
|
142
|
+
onBlur: () => setOpen(false),
|
|
143
|
+
"aria-describedby": open ? id : void 0
|
|
144
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
145
|
+
})), {
|
|
146
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
147
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
148
|
+
})) : children,
|
|
149
|
+
/* @__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)(
|
|
150
|
+
import_react3.motion.div,
|
|
151
|
+
__spreadProps(__spreadValues({
|
|
152
|
+
ref: refs.setFloating
|
|
153
|
+
}, getFloatingProps({
|
|
154
|
+
role: "tooltip",
|
|
155
|
+
id,
|
|
156
|
+
style: {
|
|
157
|
+
position: strategy,
|
|
158
|
+
top: y != null ? y : 0,
|
|
159
|
+
left: x != null ? x : 0,
|
|
160
|
+
pointerEvents: "none"
|
|
161
|
+
}
|
|
162
|
+
})), {
|
|
163
|
+
initial: getInitial(),
|
|
164
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
165
|
+
exit: getExit(),
|
|
166
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
167
|
+
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),
|
|
168
|
+
children: content
|
|
169
|
+
}),
|
|
170
|
+
"tooltip"
|
|
171
|
+
) }) })
|
|
172
|
+
] });
|
|
173
|
+
};
|
|
174
|
+
var Tooltip_default = Tooltip;
|
|
175
|
+
|
|
176
|
+
// src/lib/context/editor.context.tsx
|
|
177
|
+
var import_react4 = require("react");
|
|
178
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
179
|
+
var EditorContext = (0, import_react4.createContext)({ editor: null });
|
|
180
|
+
var useEditor = () => {
|
|
181
|
+
const ctx = (0, import_react4.useContext)(EditorContext);
|
|
182
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
183
|
+
return ctx;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/lib/components/ButtonComponent.tsx
|
|
187
|
+
var import_react5 = require("@tiptap/react");
|
|
188
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
189
|
+
var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
|
|
190
|
+
const { editor } = useEditor();
|
|
191
|
+
const editorState = (0, import_react5.useEditorState)({
|
|
192
|
+
editor,
|
|
193
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
|
|
194
|
+
});
|
|
195
|
+
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
|
|
196
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
|
|
198
|
+
_interShortcut
|
|
199
|
+
] });
|
|
200
|
+
const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
onClick: _onToggle,
|
|
204
|
+
className: (0, import_tailwind_merge2.twMerge)(
|
|
205
|
+
"p-1.5 rounded-md",
|
|
206
|
+
_buttonClassName,
|
|
207
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
208
|
+
className,
|
|
209
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
210
|
+
),
|
|
211
|
+
style,
|
|
212
|
+
children: icon != null ? icon : _internalIcon
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
if (tooltip === false) return btn;
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
217
|
+
Tooltip_default,
|
|
218
|
+
{
|
|
219
|
+
content: tooltipContent,
|
|
220
|
+
className: tooltipClassName,
|
|
221
|
+
placement: tooltipPlacement,
|
|
222
|
+
children: btn
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
var ButtonComponent_default = ButtonComponent;
|
|
227
|
+
|
|
228
|
+
// src/extension/Bold.tsx
|
|
229
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
230
|
+
var Bold = import_extension_bold.default.extend({
|
|
231
|
+
addOptions() {
|
|
232
|
+
var _a;
|
|
233
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
234
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
236
|
+
ButtonComponent_default,
|
|
237
|
+
{
|
|
238
|
+
className: options.className,
|
|
239
|
+
icon: options.icon,
|
|
240
|
+
style: options.style,
|
|
241
|
+
activeClassName: options.activeClassName,
|
|
242
|
+
tooltip: options.tooltip,
|
|
243
|
+
tooltipClassName: options.tooltipClassName,
|
|
244
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
245
|
+
_internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoldIcon_default, {}),
|
|
246
|
+
_extName: "bold",
|
|
247
|
+
_onToggle: () => editor.chain().focus().toggleBold().run(),
|
|
248
|
+
_interShortcut: "\u2318 + B",
|
|
249
|
+
_tooltipContent: "Bold",
|
|
250
|
+
_buttonClassName: buttonClassName
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
259
|
+
Bold
|
|
260
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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/Bold.tsx
|
|
12
|
+
import TiptapBold from "@tiptap/extension-bold";
|
|
13
|
+
|
|
14
|
+
// src/lib/icon/BoldIcon.tsx
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var BoldIcon = (_a) => {
|
|
17
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
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: /* @__PURE__ */ jsx("path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" })
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
var BoldIcon_default = BoldIcon;
|
|
37
|
+
|
|
38
|
+
// src/extension/Bold.tsx
|
|
39
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
40
|
+
var Bold = TiptapBold.extend({
|
|
41
|
+
addOptions() {
|
|
42
|
+
var _a;
|
|
43
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
44
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
45
|
+
return /* @__PURE__ */ jsx2(
|
|
46
|
+
ButtonComponent_default,
|
|
47
|
+
{
|
|
48
|
+
className: options.className,
|
|
49
|
+
icon: options.icon,
|
|
50
|
+
style: options.style,
|
|
51
|
+
activeClassName: options.activeClassName,
|
|
52
|
+
tooltip: options.tooltip,
|
|
53
|
+
tooltipClassName: options.tooltipClassName,
|
|
54
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
55
|
+
_internalIcon: /* @__PURE__ */ jsx2(BoldIcon_default, {}),
|
|
56
|
+
_extName: "bold",
|
|
57
|
+
_onToggle: () => editor.chain().focus().toggleBold().run(),
|
|
58
|
+
_interShortcut: "\u2318 + B",
|
|
59
|
+
_tooltipContent: "Bold",
|
|
60
|
+
_buttonClassName: buttonClassName
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
Bold
|
|
69
|
+
};
|