ritext 1.0.15 → 1.0.19
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
package/README.md
CHANGED
|
@@ -22,14 +22,12 @@ Ritext is a modern WYSIWYG rich text editor built with Tailwind CSS, powered by
|
|
|
22
22
|
☑ Subscript
|
|
23
23
|
☑ Superscript
|
|
24
24
|
☑ SubAndSuperScript
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
☐ Redo
|
|
32
|
-
☐ Emoji
|
|
25
|
+
☑ Clear Format
|
|
26
|
+
☑ Heading
|
|
27
|
+
☑ Font Family
|
|
28
|
+
☑ Fonts Size
|
|
29
|
+
☑ Undo
|
|
30
|
+
☑ Redo
|
|
33
31
|
☐ Color
|
|
34
32
|
☐ Highlight
|
|
35
33
|
☐ Bullet List
|
|
@@ -42,6 +40,7 @@ Ritext is a modern WYSIWYG rich text editor built with Tailwind CSS, powered by
|
|
|
42
40
|
☐ Image
|
|
43
41
|
☐ Link
|
|
44
42
|
☐ Blockquote
|
|
43
|
+
☐ Format Painter
|
|
45
44
|
|
|
46
45
|
# Stay in touch
|
|
47
46
|
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Tooltip_default
|
|
3
|
+
} from "./chunk-7QOFJIQ3.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useEditor
|
|
6
|
+
} from "./chunk-VYDH6BZE.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__objRest,
|
|
9
|
+
__spreadProps,
|
|
10
|
+
__spreadValues
|
|
11
|
+
} from "./chunk-FWCSY2DS.mjs";
|
|
12
|
+
|
|
13
|
+
// src/lib/components/DropdownComponent.tsx
|
|
14
|
+
import { useState, Fragment, useId, Children, isValidElement, cloneElement } from "react";
|
|
15
|
+
import { twMerge } from "tailwind-merge";
|
|
16
|
+
import { useFloating, offset, flip, shift, autoUpdate, useInteractions, useClick, useDismiss, FloatingPortal } from "@floating-ui/react";
|
|
17
|
+
|
|
18
|
+
// src/lib/icon/ArrowIcon.tsx
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
var ArrowIcon = (_a) => {
|
|
21
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
"svg",
|
|
24
|
+
__spreadProps(__spreadValues({
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
26
|
+
viewBox: "0 0 48 48",
|
|
27
|
+
fill: "none",
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
strokeWidth: 2,
|
|
30
|
+
strokeLinecap: "round",
|
|
31
|
+
strokeLinejoin: "round",
|
|
32
|
+
width: size,
|
|
33
|
+
height: size,
|
|
34
|
+
className
|
|
35
|
+
}, props), {
|
|
36
|
+
children: /* @__PURE__ */ jsx("path", { fill: "currentColor", stroke: "currentColor", strokeLinejoin: "round", strokeWidth: "4", d: "M36 19L24 31L12 19z" })
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
var ArrowIcon_default = ArrowIcon;
|
|
41
|
+
|
|
42
|
+
// src/lib/components/DropdownComponent.tsx
|
|
43
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
44
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
45
|
+
var DropdownComponent = ({ children, className, showArrow = true, content, dropdownClassName, style, tooltip, tooltipClassName, tooltipPlacement, _tooltipContent, _internalContent, _dropdownClassName }) => {
|
|
46
|
+
const [open, setOpen] = useState(false);
|
|
47
|
+
const { x, y, refs, strategy, context } = useFloating({
|
|
48
|
+
open,
|
|
49
|
+
onOpenChange: setOpen,
|
|
50
|
+
placement: "bottom",
|
|
51
|
+
middleware: [offset(4), flip(), shift({ padding: 8 })],
|
|
52
|
+
whileElementsMounted: autoUpdate
|
|
53
|
+
});
|
|
54
|
+
const click = useClick(context);
|
|
55
|
+
const dismiss = useDismiss(context);
|
|
56
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]);
|
|
57
|
+
const listId = useId();
|
|
58
|
+
const tooltipContent = /* @__PURE__ */ jsx2("p", { children: typeof tooltip === "string" ? tooltip : _tooltipContent });
|
|
59
|
+
const initialMotion = { opacity: 0, scale: 0.95 };
|
|
60
|
+
const animateMotion = { opacity: 1, scale: 1 };
|
|
61
|
+
const enhancedChildren = Children.map(children, (child) => {
|
|
62
|
+
if (!isValidElement(child)) return child;
|
|
63
|
+
if (!("onSelect" in child.props)) return child;
|
|
64
|
+
const prevOnSelect = child.props.onSelect;
|
|
65
|
+
const combinedOnSelect = () => {
|
|
66
|
+
prevOnSelect == null ? void 0 : prevOnSelect();
|
|
67
|
+
setOpen(false);
|
|
68
|
+
};
|
|
69
|
+
return cloneElement(child, { onSelect: combinedOnSelect });
|
|
70
|
+
});
|
|
71
|
+
const btn = /* @__PURE__ */ jsxs(
|
|
72
|
+
"button",
|
|
73
|
+
__spreadProps(__spreadValues({}, getReferenceProps({
|
|
74
|
+
ref: refs.setReference,
|
|
75
|
+
type: "button",
|
|
76
|
+
"aria-controls": open ? listId : void 0
|
|
77
|
+
})), {
|
|
78
|
+
className: twMerge(
|
|
79
|
+
"p-1.5 rounded-md hover:bg-gray-100 items-center flex gap-x-0.5",
|
|
80
|
+
className
|
|
81
|
+
),
|
|
82
|
+
style,
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsx2("span", { children: content != null ? content : _internalContent }),
|
|
85
|
+
showArrow && /* @__PURE__ */ jsx2(ArrowIcon_default, { size: 14, className: "text-gray-500 block" })
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
90
|
+
tooltip === false ? btn : /* @__PURE__ */ jsx2(
|
|
91
|
+
Tooltip_default,
|
|
92
|
+
{
|
|
93
|
+
content: tooltipContent,
|
|
94
|
+
className: tooltipClassName,
|
|
95
|
+
placement: tooltipPlacement,
|
|
96
|
+
children: btn
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx2(FloatingPortal, { children: /* @__PURE__ */ jsx2(AnimatePresence, { children: open && /* @__PURE__ */ jsx2(
|
|
100
|
+
motion.div,
|
|
101
|
+
__spreadProps(__spreadValues({}, getFloatingProps({
|
|
102
|
+
ref: refs.setFloating,
|
|
103
|
+
style: {
|
|
104
|
+
position: strategy,
|
|
105
|
+
top: y != null ? y : 0,
|
|
106
|
+
left: x != null ? x : 0
|
|
107
|
+
},
|
|
108
|
+
role: "listbox",
|
|
109
|
+
id: listId
|
|
110
|
+
})), {
|
|
111
|
+
initial: initialMotion,
|
|
112
|
+
animate: animateMotion,
|
|
113
|
+
exit: initialMotion,
|
|
114
|
+
className: 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),
|
|
115
|
+
children: enhancedChildren
|
|
116
|
+
})
|
|
117
|
+
) }) })
|
|
118
|
+
] });
|
|
119
|
+
};
|
|
120
|
+
var DropdownComponent_default = DropdownComponent;
|
|
121
|
+
|
|
122
|
+
// src/lib/components/DropdownItemComponent.tsx
|
|
123
|
+
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
124
|
+
import { useEditorState } from "@tiptap/react";
|
|
125
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
126
|
+
var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName, showKeyShortcutText = true, spClass }) => {
|
|
127
|
+
const { editor } = useEditor();
|
|
128
|
+
const editorState = useEditorState({
|
|
129
|
+
editor,
|
|
130
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.name, item.ext ? { level: item.ext } : void 0)) || false })
|
|
131
|
+
});
|
|
132
|
+
return /* @__PURE__ */ jsxs2("div", { className: twMerge2(
|
|
133
|
+
"flex items-center gap-x-2.5 transition-all duration-100 cursor-pointer select-none px-2 py-1.5 rounded-md",
|
|
134
|
+
_itemClassName,
|
|
135
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
136
|
+
itemClassName,
|
|
137
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
138
|
+
), onClick: onSelect, children: [
|
|
139
|
+
item.icon,
|
|
140
|
+
/* @__PURE__ */ jsx3("span", { className: twMerge2("flex-1 text-base", spClass), style: item.style, children: item.text }),
|
|
141
|
+
showKeyShortcutText && item.keyBind && /* @__PURE__ */ jsx3("span", { className: "ml-6 text-gray-400", children: item.keyBind })
|
|
142
|
+
] });
|
|
143
|
+
};
|
|
144
|
+
var DropdownItemComponent_default = DropdownItemComponent;
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
DropdownComponent_default,
|
|
148
|
+
DropdownItemComponent_default
|
|
149
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Tooltip_default
|
|
3
|
+
} from "./chunk-7QOFJIQ3.mjs";
|
|
4
|
+
|
|
5
|
+
// src/lib/components/ButtonWithoutActive.tsx
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var ButtonWithoutActive = ({ className, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _internalIcon, _tooltipContent, _interShortcut, _onToggle, _buttonClassName, _disabled = false }) => {
|
|
9
|
+
const tooltipContent = /* @__PURE__ */ jsxs("p", { children: [
|
|
10
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
11
|
+
_interShortcut && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12
|
+
" ",
|
|
13
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
14
|
+
" ",
|
|
15
|
+
_interShortcut,
|
|
16
|
+
" "
|
|
17
|
+
] })
|
|
18
|
+
] });
|
|
19
|
+
const btn = /* @__PURE__ */ jsx(
|
|
20
|
+
"button",
|
|
21
|
+
{
|
|
22
|
+
onClick: _onToggle,
|
|
23
|
+
disabled: _disabled,
|
|
24
|
+
className: twMerge(
|
|
25
|
+
"py-1.5 px-2.5 rounded-md hover:bg-gray-100",
|
|
26
|
+
_disabled ? "opacity-20" : "",
|
|
27
|
+
_buttonClassName,
|
|
28
|
+
className
|
|
29
|
+
),
|
|
30
|
+
style,
|
|
31
|
+
children: icon != null ? icon : _internalIcon
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
if (tooltip === false) return btn;
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
Tooltip_default,
|
|
37
|
+
{
|
|
38
|
+
content: tooltipContent,
|
|
39
|
+
className: tooltipClassName,
|
|
40
|
+
placement: tooltipPlacement,
|
|
41
|
+
children: btn
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
var ButtonWithoutActive_default = ButtonWithoutActive;
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
ButtonWithoutActive_default
|
|
49
|
+
};
|
|
@@ -30,23 +30,8 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
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
33
|
export {
|
|
47
34
|
__spreadValues,
|
|
48
35
|
__spreadProps,
|
|
49
|
-
__objRest
|
|
50
|
-
useEditor,
|
|
51
|
-
EditorProvider
|
|
36
|
+
__objRest
|
|
52
37
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tooltip_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7QOFJIQ3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useEditor
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VYDH6BZE.mjs";
|
|
7
7
|
|
|
8
8
|
// src/lib/components/ButtonComponent.tsx
|
|
9
9
|
import { twMerge } from "tailwind-merge";
|
|
@@ -25,7 +25,7 @@ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true
|
|
|
25
25
|
{
|
|
26
26
|
onClick: _onToggle,
|
|
27
27
|
className: twMerge(
|
|
28
|
-
"
|
|
28
|
+
"py-1.5 px-2.5 rounded-md",
|
|
29
29
|
_buttonClassName,
|
|
30
30
|
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
31
31
|
className,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/lib/context/editor.context.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var EditorContext = createContext({ editor: null });
|
|
5
|
+
var useEditor = () => {
|
|
6
|
+
const ctx = useContext(EditorContext);
|
|
7
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
8
|
+
return ctx;
|
|
9
|
+
};
|
|
10
|
+
var EditorProvider = ({ children, value }) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, { value, children });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
useEditor,
|
|
16
|
+
EditorProvider
|
|
17
|
+
};
|
package/dist/extension/bold.d.ts
CHANGED
package/dist/extension/bold.js
CHANGED
|
@@ -202,7 +202,7 @@ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true
|
|
|
202
202
|
{
|
|
203
203
|
onClick: _onToggle,
|
|
204
204
|
className: (0, import_tailwind_merge2.twMerge)(
|
|
205
|
-
"
|
|
205
|
+
"py-1.5 px-2.5 rounded-md",
|
|
206
206
|
_buttonClassName,
|
|
207
207
|
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
208
208
|
className,
|
package/dist/extension/bold.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ButtonComponent_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-GSHINFPO.mjs";
|
|
4
|
+
import "../chunk-7QOFJIQ3.mjs";
|
|
5
|
+
import "../chunk-VYDH6BZE.mjs";
|
|
5
6
|
import {
|
|
6
7
|
__objRest,
|
|
7
8
|
__spreadProps,
|
|
8
9
|
__spreadValues
|
|
9
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-FWCSY2DS.mjs";
|
|
10
11
|
|
|
11
12
|
// src/extension/Bold.tsx
|
|
12
13
|
import TiptapBold from "@tiptap/extension-bold";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/react';
|
|
2
|
+
import { b as ExtWithoutActiveOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@floating-ui/react';
|
|
5
|
+
|
|
6
|
+
declare const ClearFormat: Extension<ExtWithoutActiveOptions, any>;
|
|
7
|
+
|
|
8
|
+
export { ClearFormat };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/react';
|
|
2
|
+
import { b as ExtWithoutActiveOptions } from '../tiptap-ext.type-DrneAC5G.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@floating-ui/react';
|
|
5
|
+
|
|
6
|
+
declare const ClearFormat: Extension<ExtWithoutActiveOptions, any>;
|
|
7
|
+
|
|
8
|
+
export { ClearFormat };
|
|
@@ -0,0 +1,239 @@
|
|
|
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/ClearFormat.tsx
|
|
50
|
+
var ClearFormat_exports = {};
|
|
51
|
+
__export(ClearFormat_exports, {
|
|
52
|
+
ClearFormat: () => ClearFormat
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(ClearFormat_exports);
|
|
55
|
+
var import_react4 = require("@tiptap/react");
|
|
56
|
+
|
|
57
|
+
// src/lib/icon/ClearIcon.tsx
|
|
58
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
59
|
+
var ClearIcon = (_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: "M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21" }),
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m5.082 11.09 8.828 8.828" })
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
var ClearIcon_default = ClearIcon;
|
|
82
|
+
|
|
83
|
+
// src/lib/components/ButtonWithoutActive.tsx
|
|
84
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
85
|
+
|
|
86
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
87
|
+
var import_react = require("react");
|
|
88
|
+
var import_react2 = require("@floating-ui/react");
|
|
89
|
+
var import_react3 = require("motion/react");
|
|
90
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
91
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
92
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
93
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
94
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
|
|
95
|
+
open,
|
|
96
|
+
onOpenChange: setOpen,
|
|
97
|
+
placement,
|
|
98
|
+
middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
|
|
99
|
+
whileElementsMounted: import_react2.autoUpdate
|
|
100
|
+
});
|
|
101
|
+
const hover = (0, import_react2.useHover)(context);
|
|
102
|
+
const dismiss = (0, import_react2.useDismiss)(context);
|
|
103
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
|
|
104
|
+
const id = (0, import_react.useId)();
|
|
105
|
+
function mergeRefs(...refsToMerge) {
|
|
106
|
+
return (node) => {
|
|
107
|
+
for (const r of refsToMerge) {
|
|
108
|
+
if (!r) continue;
|
|
109
|
+
if (typeof r === "function") r(node);
|
|
110
|
+
else r.current = node;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const side = resolvedPlacement.split("-")[0];
|
|
115
|
+
const enterOffset = 6;
|
|
116
|
+
const getInitial = () => {
|
|
117
|
+
switch (side) {
|
|
118
|
+
case "top":
|
|
119
|
+
return { opacity: 0, y: enterOffset };
|
|
120
|
+
case "bottom":
|
|
121
|
+
return { opacity: 0, y: -enterOffset };
|
|
122
|
+
case "left":
|
|
123
|
+
return { opacity: 0, x: enterOffset };
|
|
124
|
+
case "right":
|
|
125
|
+
return { opacity: 0, x: -enterOffset };
|
|
126
|
+
default:
|
|
127
|
+
return { opacity: 0 };
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
|
|
132
|
+
(0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
133
|
+
onFocus: () => setOpen(true),
|
|
134
|
+
onBlur: () => setOpen(false),
|
|
135
|
+
"aria-describedby": open ? id : void 0
|
|
136
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
137
|
+
})), {
|
|
138
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
139
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
140
|
+
})) : children,
|
|
141
|
+
/* @__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)(
|
|
142
|
+
import_react3.motion.div,
|
|
143
|
+
__spreadProps(__spreadValues({
|
|
144
|
+
ref: refs.setFloating
|
|
145
|
+
}, getFloatingProps({
|
|
146
|
+
role: "tooltip",
|
|
147
|
+
id,
|
|
148
|
+
style: {
|
|
149
|
+
position: strategy,
|
|
150
|
+
top: y != null ? y : 0,
|
|
151
|
+
left: x != null ? x : 0,
|
|
152
|
+
pointerEvents: "none"
|
|
153
|
+
}
|
|
154
|
+
})), {
|
|
155
|
+
initial: getInitial(),
|
|
156
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
157
|
+
exit: getExit(),
|
|
158
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
159
|
+
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),
|
|
160
|
+
children: content
|
|
161
|
+
}),
|
|
162
|
+
"tooltip"
|
|
163
|
+
) }) })
|
|
164
|
+
] });
|
|
165
|
+
};
|
|
166
|
+
var Tooltip_default = Tooltip;
|
|
167
|
+
|
|
168
|
+
// src/lib/components/ButtonWithoutActive.tsx
|
|
169
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
170
|
+
var ButtonWithoutActive = ({ className, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _internalIcon, _tooltipContent, _interShortcut, _onToggle, _buttonClassName, _disabled = false }) => {
|
|
171
|
+
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
172
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
173
|
+
_interShortcut && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
174
|
+
" ",
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("br", {}),
|
|
176
|
+
" ",
|
|
177
|
+
_interShortcut,
|
|
178
|
+
" "
|
|
179
|
+
] })
|
|
180
|
+
] });
|
|
181
|
+
const btn = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
182
|
+
"button",
|
|
183
|
+
{
|
|
184
|
+
onClick: _onToggle,
|
|
185
|
+
disabled: _disabled,
|
|
186
|
+
className: (0, import_tailwind_merge2.twMerge)(
|
|
187
|
+
"py-1.5 px-2.5 rounded-md hover:bg-gray-100",
|
|
188
|
+
_disabled ? "opacity-20" : "",
|
|
189
|
+
_buttonClassName,
|
|
190
|
+
className
|
|
191
|
+
),
|
|
192
|
+
style,
|
|
193
|
+
children: icon != null ? icon : _internalIcon
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
if (tooltip === false) return btn;
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
198
|
+
Tooltip_default,
|
|
199
|
+
{
|
|
200
|
+
content: tooltipContent,
|
|
201
|
+
className: tooltipClassName,
|
|
202
|
+
placement: tooltipPlacement,
|
|
203
|
+
children: btn
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
var ButtonWithoutActive_default = ButtonWithoutActive;
|
|
208
|
+
|
|
209
|
+
// src/extension/ClearFormat.tsx
|
|
210
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
211
|
+
var ClearFormat = import_react4.Extension.create({
|
|
212
|
+
name: "ClearFormat",
|
|
213
|
+
addOptions() {
|
|
214
|
+
var _a;
|
|
215
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
216
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
218
|
+
ButtonWithoutActive_default,
|
|
219
|
+
{
|
|
220
|
+
className: options.className,
|
|
221
|
+
icon: options.icon,
|
|
222
|
+
style: options.style,
|
|
223
|
+
tooltip: options.tooltip,
|
|
224
|
+
tooltipClassName: options.tooltipClassName,
|
|
225
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
226
|
+
_internalIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ClearIcon_default, {}),
|
|
227
|
+
_onToggle: () => editor.chain().focus().clearNodes().unsetAllMarks().run(),
|
|
228
|
+
_tooltipContent: "Clear Format",
|
|
229
|
+
_buttonClassName: buttonClassName
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
237
|
+
0 && (module.exports = {
|
|
238
|
+
ClearFormat
|
|
239
|
+
});
|