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,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowIcon,
|
|
3
|
+
Tooltip_default
|
|
4
|
+
} from "./chunk-EN4BPI7N.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__spreadProps,
|
|
7
|
+
__spreadValues
|
|
8
|
+
} from "./chunk-WNQUEZJF.mjs";
|
|
9
|
+
|
|
10
|
+
// src/lib/components/DropdownComponent.tsx
|
|
11
|
+
import { useState, Fragment, useId, Children, isValidElement, cloneElement } from "react";
|
|
12
|
+
import { twMerge } from "tailwind-merge";
|
|
13
|
+
import { useFloating, offset, flip, shift, autoUpdate, useInteractions, useClick, useDismiss, FloatingPortal } from "@floating-ui/react";
|
|
14
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var DropdownComponent = ({ children, className, showArrow = true, content, dropdownClassName, style, tooltip, tooltipClassName, tooltipPlacement, _tooltipContent, _internalContent, _dropdownClassName }) => {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const { x, y, refs, strategy, context } = useFloating({
|
|
19
|
+
open,
|
|
20
|
+
onOpenChange: setOpen,
|
|
21
|
+
placement: "bottom",
|
|
22
|
+
middleware: [offset(4), flip(), shift({ padding: 8 })],
|
|
23
|
+
whileElementsMounted: autoUpdate
|
|
24
|
+
});
|
|
25
|
+
const click = useClick(context);
|
|
26
|
+
const dismiss = useDismiss(context);
|
|
27
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]);
|
|
28
|
+
const listId = useId();
|
|
29
|
+
const tooltipContent = /* @__PURE__ */ jsx("p", { children: typeof tooltip === "string" ? tooltip : _tooltipContent });
|
|
30
|
+
const initialMotion = { opacity: 0, scale: 0.95 };
|
|
31
|
+
const animateMotion = { opacity: 1, scale: 1 };
|
|
32
|
+
const enhancedChildren = Children.map(children, (child) => {
|
|
33
|
+
if (!isValidElement(child)) return child;
|
|
34
|
+
const prevOnSelect = child.props.onSelect;
|
|
35
|
+
const combinedOnSelect = () => {
|
|
36
|
+
prevOnSelect == null ? void 0 : prevOnSelect();
|
|
37
|
+
setOpen(false);
|
|
38
|
+
};
|
|
39
|
+
return cloneElement(child, {
|
|
40
|
+
onSelect: prevOnSelect ? combinedOnSelect : void 0,
|
|
41
|
+
open,
|
|
42
|
+
onClose: () => setOpen(false)
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
const btn = /* @__PURE__ */ jsxs(
|
|
46
|
+
"button",
|
|
47
|
+
__spreadProps(__spreadValues({}, getReferenceProps({
|
|
48
|
+
ref: refs.setReference,
|
|
49
|
+
type: "button",
|
|
50
|
+
"aria-controls": open ? listId : void 0
|
|
51
|
+
})), {
|
|
52
|
+
className: twMerge(
|
|
53
|
+
"p-1.5 rounded-md hover:bg-gray-100 items-center flex gap-x-0.5",
|
|
54
|
+
className
|
|
55
|
+
),
|
|
56
|
+
style,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx("span", { children: content != null ? content : _internalContent }),
|
|
59
|
+
showArrow && /* @__PURE__ */ jsx(ArrowIcon, { size: 14, className: "text-gray-500 block" })
|
|
60
|
+
]
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
64
|
+
tooltip === false ? btn : /* @__PURE__ */ jsx(
|
|
65
|
+
Tooltip_default,
|
|
66
|
+
{
|
|
67
|
+
content: tooltipContent,
|
|
68
|
+
className: tooltipClassName,
|
|
69
|
+
placement: tooltipPlacement,
|
|
70
|
+
children: btn
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
|
|
74
|
+
motion.div,
|
|
75
|
+
__spreadProps(__spreadValues({}, getFloatingProps({
|
|
76
|
+
ref: refs.setFloating,
|
|
77
|
+
style: {
|
|
78
|
+
position: strategy,
|
|
79
|
+
top: y != null ? y : 0,
|
|
80
|
+
left: x != null ? x : 0
|
|
81
|
+
},
|
|
82
|
+
role: "listbox",
|
|
83
|
+
id: listId
|
|
84
|
+
})), {
|
|
85
|
+
initial: initialMotion,
|
|
86
|
+
animate: animateMotion,
|
|
87
|
+
exit: initialMotion,
|
|
88
|
+
className: twMerge("bg-white border border-solid border-gray-200 p-2 space-y-1 rounded-lg shadow-sm shadow-gray-200/40 z-99999999 max-h-125 overflow-auto", _dropdownClassName, dropdownClassName),
|
|
89
|
+
children: enhancedChildren
|
|
90
|
+
})
|
|
91
|
+
) }) })
|
|
92
|
+
] });
|
|
93
|
+
};
|
|
94
|
+
var DropdownComponent_default = DropdownComponent;
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
DropdownComponent_default
|
|
98
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEditor
|
|
3
|
+
} from "./chunk-VYDH6BZE.mjs";
|
|
4
|
+
|
|
5
|
+
// src/lib/components/DropdownItemComponent.tsx
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import { useEditorState } from "@tiptap/react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName, showKeyShortcutText = true, spClass }) => {
|
|
10
|
+
const { editor } = useEditor();
|
|
11
|
+
const editorState = useEditorState({
|
|
12
|
+
editor,
|
|
13
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.name, item.ext ? { level: item.ext } : void 0)) || false })
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", { className: twMerge(
|
|
16
|
+
"flex items-center gap-x-2.5 transition-all duration-100 cursor-pointer select-none px-2 py-1.5 rounded-md",
|
|
17
|
+
_itemClassName,
|
|
18
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
19
|
+
itemClassName,
|
|
20
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
21
|
+
), onClick: onSelect, children: [
|
|
22
|
+
item.icon,
|
|
23
|
+
/* @__PURE__ */ jsx("span", { className: twMerge("flex-1 text-base", spClass), style: item.style, children: item.text }),
|
|
24
|
+
showKeyShortcutText && item.keyBind && /* @__PURE__ */ jsx("span", { className: "ml-6 text-gray-400", children: item.keyBind })
|
|
25
|
+
] });
|
|
26
|
+
};
|
|
27
|
+
var DropdownItemComponent_default = DropdownItemComponent;
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
DropdownItemComponent_default
|
|
31
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEditor
|
|
3
|
+
} from "./chunk-VYDH6BZE.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Tooltip_default
|
|
6
|
+
} from "./chunk-EN4BPI7N.mjs";
|
|
7
|
+
|
|
8
|
+
// src/lib/components/ButtonComponent.tsx
|
|
9
|
+
import { useMemo } from "react";
|
|
10
|
+
import { twMerge } from "tailwind-merge";
|
|
11
|
+
import { useEditorState, isMacOS } from "@tiptap/react";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
|
|
14
|
+
const { editor } = useEditor();
|
|
15
|
+
const editorState = useEditorState({
|
|
16
|
+
editor,
|
|
17
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
|
|
18
|
+
});
|
|
19
|
+
const shortcutText = useMemo(() => {
|
|
20
|
+
if (!_interShortcut) return "";
|
|
21
|
+
return isMacOS() ? _interShortcut.mac : _interShortcut.win;
|
|
22
|
+
}, [_interShortcut]);
|
|
23
|
+
const tooltipContent = /* @__PURE__ */ jsxs("p", { children: [
|
|
24
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
25
|
+
shortcutText ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
27
|
+
/* @__PURE__ */ jsx("span", { className: "opacity-70", children: shortcutText })
|
|
28
|
+
] }) : null
|
|
29
|
+
] });
|
|
30
|
+
const btn = /* @__PURE__ */ jsx("button", { onClick: _onToggle, className: 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 });
|
|
31
|
+
if (tooltip === false) return btn;
|
|
32
|
+
return /* @__PURE__ */ jsx(Tooltip_default, { content: tooltipContent, className: tooltipClassName, placement: tooltipPlacement, children: btn });
|
|
33
|
+
};
|
|
34
|
+
var ButtonComponent_default = ButtonComponent;
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ButtonComponent_default
|
|
38
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "./chunk-WNQUEZJF.mjs";
|
|
6
|
+
|
|
7
|
+
// src/lib/components/InputComponent.tsx
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var InputComponent = (_a) => {
|
|
10
|
+
var _b = _a, { id, label, containerClassName = "", icon } = _b, rest = __objRest(_b, ["id", "label", "containerClassName", "icon"]);
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", { className: containerClassName, children: [
|
|
12
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: id, className: "block mb-1 text-gray-700 text-base font-medium", children: label }),
|
|
13
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
"input",
|
|
16
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
17
|
+
className: "border border-solid border-gray-200 px-2 py-1.5 w-full rounded-md focus:outline-none"
|
|
18
|
+
})
|
|
19
|
+
),
|
|
20
|
+
icon && /* @__PURE__ */ jsx("span", { children: icon })
|
|
21
|
+
] })
|
|
22
|
+
] });
|
|
23
|
+
};
|
|
24
|
+
var InputComponent_default = InputComponent;
|
|
25
|
+
|
|
26
|
+
// src/lib/components/CheckboxComponent.tsx
|
|
27
|
+
import { twMerge } from "tailwind-merge";
|
|
28
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
29
|
+
var CheckboxComponent = ({ id, checked, onChange, className, label, labelPlacement = "right", bottomSpace = true, customLabel, errorMessage = false, containerClassName = "" }) => {
|
|
30
|
+
return /* @__PURE__ */ jsxs2("div", { className: twMerge(`flex items-start ${labelPlacement === "left" ? "gap-7" : "gap-2"} ${bottomSpace && "mb-6"}`, containerClassName), children: [
|
|
31
|
+
label && labelPlacement === "left" && /* @__PURE__ */ jsx2("label", { htmlFor: id, className: `select-none cursor-pointer block text-[15px] ${errorMessage ? "text-error" : "text-gray-700"}`, children: label }),
|
|
32
|
+
customLabel && labelPlacement === "left" && customLabel,
|
|
33
|
+
/* @__PURE__ */ jsxs2("div", { className: "relative mt-0.5", children: [
|
|
34
|
+
/* @__PURE__ */ jsx2(
|
|
35
|
+
"input",
|
|
36
|
+
{
|
|
37
|
+
type: "checkbox",
|
|
38
|
+
id,
|
|
39
|
+
className: `peer appearance-none border border-gray-300 w-4 h-4 rounded align-middle block bg-white checked:border-gray-700 checked:bg-gray-700 cursor-pointer ${className}`,
|
|
40
|
+
checked,
|
|
41
|
+
onChange: (e) => onChange(e.target.checked)
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsx2("span", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-white p-px pointer-events-none opacity-0 invisible peer-checked:opacity-100 peer-checked:visible", children: /* @__PURE__ */ jsx2("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-3.5 w-3.5", viewBox: "0 0 20 20", fill: "currentColor", stroke: "currentColor", strokeWidth: "1", children: /* @__PURE__ */ jsx2("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })
|
|
45
|
+
] }),
|
|
46
|
+
customLabel && labelPlacement === "right" && customLabel,
|
|
47
|
+
label && labelPlacement === "right" && /* @__PURE__ */ jsx2("label", { htmlFor: id, className: `select-none cursor-pointer block text-[15px] ${errorMessage ? "text-error" : "text-gray-700"}`, children: label })
|
|
48
|
+
] });
|
|
49
|
+
};
|
|
50
|
+
var CheckboxComponent_default = CheckboxComponent;
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
InputComponent_default,
|
|
54
|
+
CheckboxComponent_default
|
|
55
|
+
};
|
|
@@ -29,9 +29,30 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
32
52
|
|
|
33
53
|
export {
|
|
34
54
|
__spreadValues,
|
|
35
55
|
__spreadProps,
|
|
36
|
-
__objRest
|
|
56
|
+
__objRest,
|
|
57
|
+
__async
|
|
37
58
|
};
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tooltip_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EN4BPI7N.mjs";
|
|
4
4
|
|
|
5
5
|
// src/lib/components/ButtonWithoutActive.tsx
|
|
6
|
+
import { useMemo } from "react";
|
|
6
7
|
import { twMerge } from "tailwind-merge";
|
|
8
|
+
import { isMacOS } from "@tiptap/react";
|
|
7
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
var ButtonWithoutActive = ({ className, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _internalIcon, _tooltipContent, _interShortcut, _onToggle, _buttonClassName, _disabled = false }) => {
|
|
11
|
+
const shortcutText = useMemo(() => {
|
|
12
|
+
if (!_interShortcut) return "";
|
|
13
|
+
return isMacOS() ? _interShortcut.mac : _interShortcut.win;
|
|
14
|
+
}, [_interShortcut]);
|
|
9
15
|
const tooltipContent = /* @__PURE__ */ jsxs("p", { children: [
|
|
10
16
|
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
11
17
|
_interShortcut && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12
18
|
" ",
|
|
13
19
|
/* @__PURE__ */ jsx("br", {}),
|
|
14
20
|
" ",
|
|
15
|
-
|
|
21
|
+
shortcutText,
|
|
16
22
|
" "
|
|
17
23
|
] })
|
|
18
24
|
] });
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DropdownComponent_default
|
|
3
|
+
} from "./chunk-FJQ4FZRS.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useEditor
|
|
6
|
+
} from "./chunk-VYDH6BZE.mjs";
|
|
7
|
+
import {
|
|
8
|
+
BackgroundIcon,
|
|
9
|
+
ColorIcon,
|
|
10
|
+
Palette
|
|
11
|
+
} from "./chunk-EN4BPI7N.mjs";
|
|
12
|
+
import {
|
|
13
|
+
__spreadProps,
|
|
14
|
+
__spreadValues
|
|
15
|
+
} from "./chunk-WNQUEZJF.mjs";
|
|
16
|
+
|
|
17
|
+
// src/extension/Color.tsx
|
|
18
|
+
import { useEffect, useState as useState2 } from "react";
|
|
19
|
+
import { Color as TiptapColor } from "@tiptap/extension-text-style";
|
|
20
|
+
|
|
21
|
+
// src/lib/components/ColorIconComponent.tsx
|
|
22
|
+
import { useEditorState } from "@tiptap/react";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
var ColorIconComponent = ({ type = "color" }) => {
|
|
25
|
+
const { editor } = useEditor();
|
|
26
|
+
const editorState = useEditorState({
|
|
27
|
+
editor,
|
|
28
|
+
selector: ({ editor: editor2 }) => ({
|
|
29
|
+
color: type === "color" ? (editor2 == null ? void 0 : editor2.getAttributes("textStyle").color) || "#000" : (editor2 == null ? void 0 : editor2.getAttributes("textStyle").backgroundColor) || "#000"
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
return type === "color" ? /* @__PURE__ */ jsx(ColorIcon, { fill: editorState == null ? void 0 : editorState.color }) : /* @__PURE__ */ jsx(BackgroundIcon, { fill: editorState == null ? void 0 : editorState.color });
|
|
33
|
+
};
|
|
34
|
+
var ColorIconComponent_default = ColorIconComponent;
|
|
35
|
+
|
|
36
|
+
// src/lib/components/ColorComponent.tsx
|
|
37
|
+
import { useState, Fragment } from "react";
|
|
38
|
+
import { ColorPicker } from "@siamf/react-color-pick";
|
|
39
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
40
|
+
var ColorComponent = ({ onPick, onClose, items, recents }) => {
|
|
41
|
+
const [open, setOpen] = useState(false);
|
|
42
|
+
const [value, setValue] = useState("");
|
|
43
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsxs("button", { className: "flex gap-x-2 items-center", onClick: () => (onPick("#000000"), onClose == null ? void 0 : onClose()), children: [
|
|
45
|
+
/* @__PURE__ */ jsx2(Palette, { className: "text-sm" }),
|
|
46
|
+
/* @__PURE__ */ jsx2("span", { children: "Default" })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ jsx2("div", { className: "grid grid-cols-10 gap-1 mt-2", children: items.map((item) => /* @__PURE__ */ jsx2("button", { className: "w-5.5 h-5.5 p-px border border-solid border-gray-200 cursor-pointer rounded-sm", onClick: () => (onPick(item), onClose == null ? void 0 : onClose()), children: /* @__PURE__ */ jsx2("div", { style: { background: item }, className: "w-full h-full rounded-sm" }) }, item)) }),
|
|
49
|
+
/* @__PURE__ */ jsx2("h6", { className: "mt-2", children: "Recent Color" }),
|
|
50
|
+
recents.length > 0 && /* @__PURE__ */ jsx2("div", { className: "grid grid-cols-10 gap-1 mt-2", children: recents.map((c) => /* @__PURE__ */ jsx2("button", { className: "w-5.5 h-5.5 p-px border border-solid border-gray-200 cursor-pointer rounded-sm", onClick: () => (onPick(c), onClose == null ? void 0 : onClose()), children: /* @__PURE__ */ jsx2("div", { style: { background: c }, className: "w-full h-full rounded-sm" }) }, c)) }),
|
|
51
|
+
/* @__PURE__ */ jsx2("button", { onClick: () => setOpen(!open), className: "mt-2", children: "More Color" }),
|
|
52
|
+
open && /* @__PURE__ */ jsxs("div", { children: [
|
|
53
|
+
/* @__PURE__ */ jsx2(
|
|
54
|
+
ColorPicker,
|
|
55
|
+
{
|
|
56
|
+
value,
|
|
57
|
+
onChange: setValue
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsx2("button", { className: "mt-2 w-full bg-gray-800 text-white py-1.5 rounded-lg", onClick: () => (onPick(value), onClose == null ? void 0 : onClose()), children: "Set Color" })
|
|
61
|
+
] })
|
|
62
|
+
] });
|
|
63
|
+
};
|
|
64
|
+
var ColorComponent_default = ColorComponent;
|
|
65
|
+
|
|
66
|
+
// src/extension/Color.tsx
|
|
67
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
68
|
+
var RECENT_COLORS_KEY = "tiptap_recent_colors";
|
|
69
|
+
var RECENT_COLORS_LIMIT = 10;
|
|
70
|
+
var normalizeHex = (c) => {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = c == null ? void 0 : c.trim()) == null ? void 0 : _a.toUpperCase();
|
|
73
|
+
};
|
|
74
|
+
var readRecentColors = () => {
|
|
75
|
+
if (typeof window === "undefined") return [];
|
|
76
|
+
try {
|
|
77
|
+
const raw = window.localStorage.getItem(RECENT_COLORS_KEY);
|
|
78
|
+
if (!raw) return [];
|
|
79
|
+
const parsed = JSON.parse(raw);
|
|
80
|
+
if (!Array.isArray(parsed)) return [];
|
|
81
|
+
return parsed.filter((x) => typeof x === "string" && x.startsWith("#")).map(normalizeHex);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var writeRecentColors = (colors) => {
|
|
87
|
+
if (typeof window === "undefined") return;
|
|
88
|
+
window.localStorage.setItem(RECENT_COLORS_KEY, JSON.stringify(colors));
|
|
89
|
+
};
|
|
90
|
+
var pushRecentColor = (color) => {
|
|
91
|
+
const c = normalizeHex(color);
|
|
92
|
+
const prev = readRecentColors();
|
|
93
|
+
const next = [c, ...prev.filter((x) => normalizeHex(x) !== c)].slice(0, RECENT_COLORS_LIMIT);
|
|
94
|
+
writeRecentColors(next);
|
|
95
|
+
return next;
|
|
96
|
+
};
|
|
97
|
+
var Color = TiptapColor.extend({
|
|
98
|
+
addOptions() {
|
|
99
|
+
var _a;
|
|
100
|
+
const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
|
|
101
|
+
return __spreadProps(__spreadValues({}, parent), {
|
|
102
|
+
types: ["textStyle"],
|
|
103
|
+
colorLists: DEFAULT_COLOR_LIST,
|
|
104
|
+
showInBubbleMenu: true,
|
|
105
|
+
bubbleMenuPosition: 6,
|
|
106
|
+
component: ({ options, editor, dropdownContainerClassName }) => {
|
|
107
|
+
var _a2;
|
|
108
|
+
const items = (_a2 = options.colorLists) != null ? _a2 : DEFAULT_COLOR_LIST;
|
|
109
|
+
const Wrapper = () => {
|
|
110
|
+
const [recents, setRecents] = useState2([]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
setRecents(readRecentColors());
|
|
113
|
+
const onStorage = (e) => {
|
|
114
|
+
if (e.key === RECENT_COLORS_KEY) setRecents(readRecentColors());
|
|
115
|
+
};
|
|
116
|
+
window.addEventListener("storage", onStorage);
|
|
117
|
+
return () => window.removeEventListener("storage", onStorage);
|
|
118
|
+
}, []);
|
|
119
|
+
const onPick = (hex) => {
|
|
120
|
+
setRecents(pushRecentColor(hex));
|
|
121
|
+
editor.chain().focus().setColor(hex).run();
|
|
122
|
+
};
|
|
123
|
+
return /* @__PURE__ */ jsx3(
|
|
124
|
+
DropdownComponent_default,
|
|
125
|
+
{
|
|
126
|
+
className: options.className,
|
|
127
|
+
showArrow: options.showArrow,
|
|
128
|
+
content: options.content,
|
|
129
|
+
dropdownClassName: options.dropdownClassName,
|
|
130
|
+
style: options.style,
|
|
131
|
+
tooltip: options.tooltip,
|
|
132
|
+
tooltipClassName: options.tooltipClassName,
|
|
133
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
134
|
+
_tooltipContent: "Color",
|
|
135
|
+
_internalContent: /* @__PURE__ */ jsx3(ColorIconComponent_default, {}),
|
|
136
|
+
_dropdownClassName: "w-65 " + dropdownContainerClassName,
|
|
137
|
+
children: /* @__PURE__ */ jsx3(
|
|
138
|
+
ColorComponent_default,
|
|
139
|
+
{
|
|
140
|
+
onPick: (e) => onPick(e),
|
|
141
|
+
items,
|
|
142
|
+
recents
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
return /* @__PURE__ */ jsx3(Wrapper, {});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
var DEFAULT_COLOR_LIST = [
|
|
154
|
+
"#000000",
|
|
155
|
+
"#222222",
|
|
156
|
+
"#4F4F4F",
|
|
157
|
+
"#818181",
|
|
158
|
+
"#B7B7B7",
|
|
159
|
+
"#D4D4D4",
|
|
160
|
+
"#E6E6E6",
|
|
161
|
+
"#F3F3F3",
|
|
162
|
+
"#F9F9F9",
|
|
163
|
+
"#FFFFFF",
|
|
164
|
+
"#D0442D",
|
|
165
|
+
"#D86024",
|
|
166
|
+
"#DF7A18",
|
|
167
|
+
"#E2D625",
|
|
168
|
+
"#71AF1A",
|
|
169
|
+
"#58B1B6",
|
|
170
|
+
"#457DF4",
|
|
171
|
+
"#2B41E0",
|
|
172
|
+
"#5120C4",
|
|
173
|
+
"#C04897",
|
|
174
|
+
"#F4E3E3",
|
|
175
|
+
"#F9EEE3",
|
|
176
|
+
"#FBF4E0",
|
|
177
|
+
"#FBFBD8",
|
|
178
|
+
"#ECF7D9",
|
|
179
|
+
"#D9F1F2",
|
|
180
|
+
"#DAE8FF",
|
|
181
|
+
"#E4E5FF",
|
|
182
|
+
"#E8DFFB",
|
|
183
|
+
"#F2DFEB",
|
|
184
|
+
"#E9A29B",
|
|
185
|
+
"#EDB37D",
|
|
186
|
+
"#ECC676",
|
|
187
|
+
"#F8F671",
|
|
188
|
+
"#B3CE72",
|
|
189
|
+
"#8ED3C9",
|
|
190
|
+
"#7CB5FF",
|
|
191
|
+
"#919CF9",
|
|
192
|
+
"#B7A5F8",
|
|
193
|
+
"#E999C8",
|
|
194
|
+
"#E26652",
|
|
195
|
+
"#E48048",
|
|
196
|
+
"#EA9B3B",
|
|
197
|
+
"#F0E037",
|
|
198
|
+
"#8FBD35",
|
|
199
|
+
"#75C2C4",
|
|
200
|
+
"#5A8EF3",
|
|
201
|
+
"#4A60E4",
|
|
202
|
+
"#7240D0",
|
|
203
|
+
"#D86AAE",
|
|
204
|
+
"#AE392A",
|
|
205
|
+
"#AE5523",
|
|
206
|
+
"#AA701B",
|
|
207
|
+
"#AE9F1B",
|
|
208
|
+
"#4C8A16",
|
|
209
|
+
"#3D7D84",
|
|
210
|
+
"#3A50B9",
|
|
211
|
+
"#242DA0",
|
|
212
|
+
"#4729A0",
|
|
213
|
+
"#8D3475",
|
|
214
|
+
"#5C1811",
|
|
215
|
+
"#4E1A08",
|
|
216
|
+
"#4E2607",
|
|
217
|
+
"#413406",
|
|
218
|
+
"#1E3A07",
|
|
219
|
+
"#16333D",
|
|
220
|
+
"#182C7D",
|
|
221
|
+
"#0B0B5C",
|
|
222
|
+
"#19085E",
|
|
223
|
+
"#53184B"
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
export {
|
|
227
|
+
ColorIconComponent_default,
|
|
228
|
+
ColorComponent_default,
|
|
229
|
+
Color,
|
|
230
|
+
DEFAULT_COLOR_LIST
|
|
231
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/react';
|
|
2
|
+
import { BackgroundColorOptions } from '@tiptap/extension-text-style';
|
|
3
|
+
import { a as ExtDropdownOptions } from '../tiptap-ext.type-B3TtT7-J.mjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type ExtBackgroundOptions = ExtDropdownOptions<BackgroundColorOptions & {
|
|
8
|
+
colorLists?: string[];
|
|
9
|
+
showInBubbleMenu?: boolean;
|
|
10
|
+
bubbleMenuPosition?: number;
|
|
11
|
+
}, {
|
|
12
|
+
dropdownContainerClassName: string;
|
|
13
|
+
}>;
|
|
14
|
+
declare const BackgroundColor: Extension<ExtBackgroundOptions>;
|
|
15
|
+
|
|
16
|
+
export { BackgroundColor };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/react';
|
|
2
|
+
import { BackgroundColorOptions } from '@tiptap/extension-text-style';
|
|
3
|
+
import { a as ExtDropdownOptions } from '../tiptap-ext.type-B3TtT7-J.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type ExtBackgroundOptions = ExtDropdownOptions<BackgroundColorOptions & {
|
|
8
|
+
colorLists?: string[];
|
|
9
|
+
showInBubbleMenu?: boolean;
|
|
10
|
+
bubbleMenuPosition?: number;
|
|
11
|
+
}, {
|
|
12
|
+
dropdownContainerClassName: string;
|
|
13
|
+
}>;
|
|
14
|
+
declare const BackgroundColor: Extension<ExtBackgroundOptions>;
|
|
15
|
+
|
|
16
|
+
export { BackgroundColor };
|