ritext 1.0.15 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -8
- package/dist/chunk-2YUUKIIT.mjs +149 -0
- package/dist/{chunk-ZLCVIW2P.mjs → chunk-7QOFJIQ3.mjs} +1 -1
- package/dist/chunk-D47XME55.mjs +49 -0
- package/dist/{chunk-TQTCTY3E.mjs → chunk-FWCSY2DS.mjs} +1 -16
- package/dist/{chunk-CU67RXD7.mjs → chunk-GSHINFPO.mjs} +3 -3
- package/dist/{chunk-E4PPKAVK.mjs → chunk-LMOTHRGQ.mjs} +1 -1
- package/dist/{chunk-LO4RJXQF.mjs → chunk-MBF77NHS.mjs} +1 -1
- package/dist/chunk-VYDH6BZE.mjs +17 -0
- package/dist/extension/bold.d.mts +1 -1
- package/dist/extension/bold.d.ts +1 -1
- package/dist/extension/bold.js +1 -1
- package/dist/extension/bold.mjs +4 -3
- package/dist/extension/clearformat.d.mts +8 -0
- package/dist/extension/clearformat.d.ts +8 -0
- package/dist/extension/clearformat.js +239 -0
- package/dist/extension/clearformat.mjs +69 -0
- package/dist/extension/font-family.d.mts +23 -0
- package/dist/extension/font-family.d.ts +23 -0
- package/dist/extension/font-family.js +388 -0
- package/dist/extension/font-family.mjs +113 -0
- package/dist/extension/font-size.d.mts +23 -0
- package/dist/extension/font-size.d.ts +23 -0
- package/dist/extension/font-size.js +386 -0
- package/dist/extension/font-size.mjs +111 -0
- package/dist/extension/heading.d.mts +23 -0
- package/dist/extension/heading.d.ts +23 -0
- package/dist/extension/heading.js +593 -0
- package/dist/extension/heading.mjs +312 -0
- package/dist/extension/history.d.mts +8 -0
- package/dist/extension/history.d.ts +8 -0
- package/dist/extension/history.js +296 -0
- package/dist/extension/history.mjs +126 -0
- package/dist/extension/italic.d.mts +1 -1
- package/dist/extension/italic.d.ts +1 -1
- package/dist/extension/italic.js +1 -1
- package/dist/extension/italic.mjs +4 -3
- package/dist/extension/strike.d.mts +1 -1
- package/dist/extension/strike.d.ts +1 -1
- package/dist/extension/strike.js +1 -1
- package/dist/extension/strike.mjs +4 -3
- package/dist/extension/subandsuperscript.d.mts +1 -1
- package/dist/extension/subandsuperscript.d.ts +1 -1
- package/dist/extension/subandsuperscript.js +30 -21
- package/dist/extension/subandsuperscript.mjs +37 -159
- package/dist/extension/subscript.d.mts +1 -1
- package/dist/extension/subscript.d.ts +1 -1
- package/dist/extension/subscript.js +1 -1
- package/dist/extension/subscript.mjs +5 -4
- package/dist/extension/superscript.d.mts +1 -1
- package/dist/extension/superscript.d.ts +1 -1
- package/dist/extension/superscript.js +1 -1
- package/dist/extension/superscript.mjs +5 -4
- package/dist/extension/underline.d.mts +1 -1
- package/dist/extension/underline.d.ts +1 -1
- package/dist/extension/underline.js +1 -1
- package/dist/extension/underline.mjs +4 -3
- package/dist/index.css +375 -8
- package/dist/index.js +1 -2
- package/dist/index.mjs +3 -3
- package/dist/{tiptap-ext.type-D61hoEX5.d.mts → tiptap-ext.type-DrneAC5G.d.mts} +8 -1
- package/dist/{tiptap-ext.type-D61hoEX5.d.ts → tiptap-ext.type-DrneAC5G.d.ts} +8 -1
- package/package.json +27 -24
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonWithoutActive_default
|
|
3
|
+
} from "../chunk-D47XME55.mjs";
|
|
4
|
+
import "../chunk-7QOFJIQ3.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__objRest,
|
|
7
|
+
__spreadProps,
|
|
8
|
+
__spreadValues
|
|
9
|
+
} from "../chunk-FWCSY2DS.mjs";
|
|
10
|
+
|
|
11
|
+
// src/extension/ClearFormat.tsx
|
|
12
|
+
import { Extension } from "@tiptap/react";
|
|
13
|
+
|
|
14
|
+
// src/lib/icon/ClearIcon.tsx
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var ClearIcon = (_a) => {
|
|
17
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
|
+
"svg",
|
|
20
|
+
__spreadProps(__spreadValues({
|
|
21
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
22
|
+
width: size,
|
|
23
|
+
height: size,
|
|
24
|
+
viewBox: "0 0 24 24",
|
|
25
|
+
fill: "none",
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
strokeWidth: 2,
|
|
28
|
+
strokeLinecap: "round",
|
|
29
|
+
strokeLinejoin: "round"
|
|
30
|
+
}, props), {
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ 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" }),
|
|
33
|
+
/* @__PURE__ */ jsx("path", { d: "m5.082 11.09 8.828 8.828" })
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
var ClearIcon_default = ClearIcon;
|
|
39
|
+
|
|
40
|
+
// src/extension/ClearFormat.tsx
|
|
41
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
42
|
+
var ClearFormat = Extension.create({
|
|
43
|
+
name: "ClearFormat",
|
|
44
|
+
addOptions() {
|
|
45
|
+
var _a;
|
|
46
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
47
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
48
|
+
return /* @__PURE__ */ jsx2(
|
|
49
|
+
ButtonWithoutActive_default,
|
|
50
|
+
{
|
|
51
|
+
className: options.className,
|
|
52
|
+
icon: options.icon,
|
|
53
|
+
style: options.style,
|
|
54
|
+
tooltip: options.tooltip,
|
|
55
|
+
tooltipClassName: options.tooltipClassName,
|
|
56
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
57
|
+
_internalIcon: /* @__PURE__ */ jsx2(ClearIcon_default, {}),
|
|
58
|
+
_onToggle: () => editor.chain().focus().clearNodes().unsetAllMarks().run(),
|
|
59
|
+
_tooltipContent: "Clear Format",
|
|
60
|
+
_buttonClassName: buttonClassName
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
ClearFormat
|
|
69
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Extension, Editor } from '@tiptap/react';
|
|
3
|
+
import { FontFamilyOptions } from '@tiptap/extension-text-style';
|
|
4
|
+
import { a as ExtDropdownOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type FontFamilyListItem = string | {
|
|
8
|
+
label: string;
|
|
9
|
+
value?: string | null;
|
|
10
|
+
};
|
|
11
|
+
interface ExtFontFamilyOptions extends ExtDropdownOptions, FontFamilyOptions {
|
|
12
|
+
fontFamilyList?: FontFamilyListItem[];
|
|
13
|
+
component: (args: {
|
|
14
|
+
options: ExtFontFamilyOptions;
|
|
15
|
+
editor: Editor;
|
|
16
|
+
dropdownContainerClassName: string;
|
|
17
|
+
dropdownItemClassName: string;
|
|
18
|
+
}) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
declare const FontFamily: Extension<ExtFontFamilyOptions>;
|
|
21
|
+
declare const DEFAULT_FONT_FAMILY_LIST: FontFamilyListItem[];
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_FONT_FAMILY_LIST, FontFamily };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Extension, Editor } from '@tiptap/react';
|
|
3
|
+
import { FontFamilyOptions } from '@tiptap/extension-text-style';
|
|
4
|
+
import { a as ExtDropdownOptions } from '../tiptap-ext.type-DrneAC5G.js';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type FontFamilyListItem = string | {
|
|
8
|
+
label: string;
|
|
9
|
+
value?: string | null;
|
|
10
|
+
};
|
|
11
|
+
interface ExtFontFamilyOptions extends ExtDropdownOptions, FontFamilyOptions {
|
|
12
|
+
fontFamilyList?: FontFamilyListItem[];
|
|
13
|
+
component: (args: {
|
|
14
|
+
options: ExtFontFamilyOptions;
|
|
15
|
+
editor: Editor;
|
|
16
|
+
dropdownContainerClassName: string;
|
|
17
|
+
dropdownItemClassName: string;
|
|
18
|
+
}) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
declare const FontFamily: Extension<ExtFontFamilyOptions>;
|
|
21
|
+
declare const DEFAULT_FONT_FAMILY_LIST: FontFamilyListItem[];
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_FONT_FAMILY_LIST, FontFamily };
|
|
@@ -0,0 +1,388 @@
|
|
|
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/FontFamily.tsx
|
|
50
|
+
var FontFamily_exports = {};
|
|
51
|
+
__export(FontFamily_exports, {
|
|
52
|
+
DEFAULT_FONT_FAMILY_LIST: () => DEFAULT_FONT_FAMILY_LIST,
|
|
53
|
+
FontFamily: () => FontFamily
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(FontFamily_exports);
|
|
56
|
+
var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
57
|
+
|
|
58
|
+
// src/lib/components/DropdownComponent.tsx
|
|
59
|
+
var import_react4 = require("react");
|
|
60
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
61
|
+
|
|
62
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
63
|
+
var import_react = require("react");
|
|
64
|
+
var import_react2 = require("@floating-ui/react");
|
|
65
|
+
var import_react3 = require("motion/react");
|
|
66
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
67
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
68
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
69
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
70
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
|
|
71
|
+
open,
|
|
72
|
+
onOpenChange: setOpen,
|
|
73
|
+
placement,
|
|
74
|
+
middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
|
|
75
|
+
whileElementsMounted: import_react2.autoUpdate
|
|
76
|
+
});
|
|
77
|
+
const hover = (0, import_react2.useHover)(context);
|
|
78
|
+
const dismiss = (0, import_react2.useDismiss)(context);
|
|
79
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
|
|
80
|
+
const id = (0, import_react.useId)();
|
|
81
|
+
function mergeRefs(...refsToMerge) {
|
|
82
|
+
return (node) => {
|
|
83
|
+
for (const r of refsToMerge) {
|
|
84
|
+
if (!r) continue;
|
|
85
|
+
if (typeof r === "function") r(node);
|
|
86
|
+
else r.current = node;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const side = resolvedPlacement.split("-")[0];
|
|
91
|
+
const enterOffset = 6;
|
|
92
|
+
const getInitial = () => {
|
|
93
|
+
switch (side) {
|
|
94
|
+
case "top":
|
|
95
|
+
return { opacity: 0, y: enterOffset };
|
|
96
|
+
case "bottom":
|
|
97
|
+
return { opacity: 0, y: -enterOffset };
|
|
98
|
+
case "left":
|
|
99
|
+
return { opacity: 0, x: enterOffset };
|
|
100
|
+
case "right":
|
|
101
|
+
return { opacity: 0, x: -enterOffset };
|
|
102
|
+
default:
|
|
103
|
+
return { opacity: 0 };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
108
|
+
(0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
109
|
+
onFocus: () => setOpen(true),
|
|
110
|
+
onBlur: () => setOpen(false),
|
|
111
|
+
"aria-describedby": open ? id : void 0
|
|
112
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
113
|
+
})), {
|
|
114
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
115
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
116
|
+
})) : children,
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_react3.motion.div,
|
|
119
|
+
__spreadProps(__spreadValues({
|
|
120
|
+
ref: refs.setFloating
|
|
121
|
+
}, getFloatingProps({
|
|
122
|
+
role: "tooltip",
|
|
123
|
+
id,
|
|
124
|
+
style: {
|
|
125
|
+
position: strategy,
|
|
126
|
+
top: y != null ? y : 0,
|
|
127
|
+
left: x != null ? x : 0,
|
|
128
|
+
pointerEvents: "none"
|
|
129
|
+
}
|
|
130
|
+
})), {
|
|
131
|
+
initial: getInitial(),
|
|
132
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
133
|
+
exit: getExit(),
|
|
134
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
135
|
+
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),
|
|
136
|
+
children: content
|
|
137
|
+
}),
|
|
138
|
+
"tooltip"
|
|
139
|
+
) }) })
|
|
140
|
+
] });
|
|
141
|
+
};
|
|
142
|
+
var Tooltip_default = Tooltip;
|
|
143
|
+
|
|
144
|
+
// src/lib/components/DropdownComponent.tsx
|
|
145
|
+
var import_react5 = require("@floating-ui/react");
|
|
146
|
+
|
|
147
|
+
// src/lib/icon/ArrowIcon.tsx
|
|
148
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
149
|
+
var ArrowIcon = (_a) => {
|
|
150
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
152
|
+
"svg",
|
|
153
|
+
__spreadProps(__spreadValues({
|
|
154
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
155
|
+
viewBox: "0 0 48 48",
|
|
156
|
+
fill: "none",
|
|
157
|
+
stroke: "currentColor",
|
|
158
|
+
strokeWidth: 2,
|
|
159
|
+
strokeLinecap: "round",
|
|
160
|
+
strokeLinejoin: "round",
|
|
161
|
+
width: size,
|
|
162
|
+
height: size,
|
|
163
|
+
className
|
|
164
|
+
}, props), {
|
|
165
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { fill: "currentColor", stroke: "currentColor", strokeLinejoin: "round", strokeWidth: "4", d: "M36 19L24 31L12 19z" })
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
var ArrowIcon_default = ArrowIcon;
|
|
170
|
+
|
|
171
|
+
// src/lib/components/DropdownComponent.tsx
|
|
172
|
+
var import_react6 = require("motion/react");
|
|
173
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
174
|
+
var DropdownComponent = ({ children, className, showArrow = true, content, dropdownClassName, style, tooltip, tooltipClassName, tooltipPlacement, _tooltipContent, _internalContent, _dropdownClassName }) => {
|
|
175
|
+
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
176
|
+
const { x, y, refs, strategy, context } = (0, import_react5.useFloating)({
|
|
177
|
+
open,
|
|
178
|
+
onOpenChange: setOpen,
|
|
179
|
+
placement: "bottom",
|
|
180
|
+
middleware: [(0, import_react5.offset)(4), (0, import_react5.flip)(), (0, import_react5.shift)({ padding: 8 })],
|
|
181
|
+
whileElementsMounted: import_react5.autoUpdate
|
|
182
|
+
});
|
|
183
|
+
const click = (0, import_react5.useClick)(context);
|
|
184
|
+
const dismiss = (0, import_react5.useDismiss)(context);
|
|
185
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react5.useInteractions)([click, dismiss]);
|
|
186
|
+
const listId = (0, import_react4.useId)();
|
|
187
|
+
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: typeof tooltip === "string" ? tooltip : _tooltipContent });
|
|
188
|
+
const initialMotion = { opacity: 0, scale: 0.95 };
|
|
189
|
+
const animateMotion = { opacity: 1, scale: 1 };
|
|
190
|
+
const enhancedChildren = import_react4.Children.map(children, (child) => {
|
|
191
|
+
if (!(0, import_react4.isValidElement)(child)) return child;
|
|
192
|
+
if (!("onSelect" in child.props)) return child;
|
|
193
|
+
const prevOnSelect = child.props.onSelect;
|
|
194
|
+
const combinedOnSelect = () => {
|
|
195
|
+
prevOnSelect == null ? void 0 : prevOnSelect();
|
|
196
|
+
setOpen(false);
|
|
197
|
+
};
|
|
198
|
+
return (0, import_react4.cloneElement)(child, { onSelect: combinedOnSelect });
|
|
199
|
+
});
|
|
200
|
+
const btn = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
201
|
+
"button",
|
|
202
|
+
__spreadProps(__spreadValues({}, getReferenceProps({
|
|
203
|
+
ref: refs.setReference,
|
|
204
|
+
type: "button",
|
|
205
|
+
"aria-controls": open ? listId : void 0
|
|
206
|
+
})), {
|
|
207
|
+
className: (0, import_tailwind_merge2.twMerge)(
|
|
208
|
+
"p-1.5 rounded-md hover:bg-gray-100 items-center flex gap-x-0.5",
|
|
209
|
+
className
|
|
210
|
+
),
|
|
211
|
+
style,
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: content != null ? content : _internalContent }),
|
|
214
|
+
showArrow && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ArrowIcon_default, { size: 14, className: "text-gray-500 block" })
|
|
215
|
+
]
|
|
216
|
+
})
|
|
217
|
+
);
|
|
218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react4.Fragment, { children: [
|
|
219
|
+
tooltip === false ? btn : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
220
|
+
Tooltip_default,
|
|
221
|
+
{
|
|
222
|
+
content: tooltipContent,
|
|
223
|
+
className: tooltipClassName,
|
|
224
|
+
placement: tooltipPlacement,
|
|
225
|
+
children: btn
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react5.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react6.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
229
|
+
import_react6.motion.div,
|
|
230
|
+
__spreadProps(__spreadValues({}, getFloatingProps({
|
|
231
|
+
ref: refs.setFloating,
|
|
232
|
+
style: {
|
|
233
|
+
position: strategy,
|
|
234
|
+
top: y != null ? y : 0,
|
|
235
|
+
left: x != null ? x : 0
|
|
236
|
+
},
|
|
237
|
+
role: "listbox",
|
|
238
|
+
id: listId
|
|
239
|
+
})), {
|
|
240
|
+
initial: initialMotion,
|
|
241
|
+
animate: animateMotion,
|
|
242
|
+
exit: initialMotion,
|
|
243
|
+
className: (0, import_tailwind_merge2.twMerge)("bg-white border border-solid border-gray-200 p-2 space-y-1 rounded-lg shadow-sm shadow-gray-200/40 max-h-125 overflow-auto", _dropdownClassName, dropdownClassName),
|
|
244
|
+
children: enhancedChildren
|
|
245
|
+
})
|
|
246
|
+
) }) })
|
|
247
|
+
] });
|
|
248
|
+
};
|
|
249
|
+
var DropdownComponent_default = DropdownComponent;
|
|
250
|
+
|
|
251
|
+
// src/lib/components/DropdownItemComponent.tsx
|
|
252
|
+
var import_tailwind_merge3 = require("tailwind-merge");
|
|
253
|
+
|
|
254
|
+
// src/lib/context/editor.context.tsx
|
|
255
|
+
var import_react7 = require("react");
|
|
256
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
257
|
+
var EditorContext = (0, import_react7.createContext)({ editor: null });
|
|
258
|
+
var useEditor = () => {
|
|
259
|
+
const ctx = (0, import_react7.useContext)(EditorContext);
|
|
260
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
261
|
+
return ctx;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// src/lib/components/DropdownItemComponent.tsx
|
|
265
|
+
var import_react8 = require("@tiptap/react");
|
|
266
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
267
|
+
var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName, showKeyShortcutText = true, spClass }) => {
|
|
268
|
+
const { editor } = useEditor();
|
|
269
|
+
const editorState = (0, import_react8.useEditorState)({
|
|
270
|
+
editor,
|
|
271
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.name, item.ext ? { level: item.ext } : void 0)) || false })
|
|
272
|
+
});
|
|
273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_tailwind_merge3.twMerge)(
|
|
274
|
+
"flex items-center gap-x-2.5 transition-all duration-100 cursor-pointer select-none px-2 py-1.5 rounded-md",
|
|
275
|
+
_itemClassName,
|
|
276
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
277
|
+
itemClassName,
|
|
278
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
279
|
+
), onClick: onSelect, children: [
|
|
280
|
+
item.icon,
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: (0, import_tailwind_merge3.twMerge)("flex-1 text-base", spClass), style: item.style, children: item.text }),
|
|
282
|
+
showKeyShortcutText && item.keyBind && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "ml-6 text-gray-400", children: item.keyBind })
|
|
283
|
+
] });
|
|
284
|
+
};
|
|
285
|
+
var DropdownItemComponent_default = DropdownItemComponent;
|
|
286
|
+
|
|
287
|
+
// src/extension/FontFamily.tsx
|
|
288
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
289
|
+
var FontFamily = import_extension_text_style.FontFamily.extend({
|
|
290
|
+
addOptions() {
|
|
291
|
+
var _a, _b;
|
|
292
|
+
const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
|
|
293
|
+
return __spreadProps(__spreadValues({}, parent), {
|
|
294
|
+
types: (_b = parent == null ? void 0 : parent.types) != null ? _b : ["textStyle"],
|
|
295
|
+
fontFamilyList: DEFAULT_FONT_FAMILY_LIST,
|
|
296
|
+
component: ({ options, editor, dropdownContainerClassName, dropdownItemClassName }) => {
|
|
297
|
+
var _a2;
|
|
298
|
+
const items = (_a2 = options.fontFamilyList) != null ? _a2 : DEFAULT_FONT_FAMILY_LIST;
|
|
299
|
+
const list = items.map((it) => {
|
|
300
|
+
const label = typeof it === "string" ? it : it.label;
|
|
301
|
+
const value = typeof it === "string" ? it : it.value === void 0 ? it.label : it.value;
|
|
302
|
+
const isDefault = value == null || label.toLowerCase() === "default";
|
|
303
|
+
const fontFamilyPreview = !isDefault ? String(value) : void 0;
|
|
304
|
+
return {
|
|
305
|
+
id: crypto.randomUUID(),
|
|
306
|
+
text: label,
|
|
307
|
+
name: "fontFamily",
|
|
308
|
+
style: fontFamilyPreview ? { fontFamily: fontFamilyPreview } : void 0,
|
|
309
|
+
onClick: () => {
|
|
310
|
+
if (isDefault) {
|
|
311
|
+
editor.chain().focus().unsetFontFamily().run();
|
|
312
|
+
} else {
|
|
313
|
+
editor.chain().focus().setFontFamily(String(value)).run();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
319
|
+
DropdownComponent_default,
|
|
320
|
+
{
|
|
321
|
+
className: options.className,
|
|
322
|
+
showArrow: options.showArrow,
|
|
323
|
+
content: options.content,
|
|
324
|
+
dropdownClassName: options.dropdownClassName,
|
|
325
|
+
style: options.style,
|
|
326
|
+
tooltip: options.tooltip,
|
|
327
|
+
tooltipClassName: options.tooltipClassName,
|
|
328
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
329
|
+
_tooltipContent: "Font Family",
|
|
330
|
+
_internalContent: "Font Family",
|
|
331
|
+
_dropdownClassName: dropdownContainerClassName,
|
|
332
|
+
children: [
|
|
333
|
+
list.slice(0, 1).map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
334
|
+
DropdownItemComponent_default,
|
|
335
|
+
{
|
|
336
|
+
onSelect: item.onClick,
|
|
337
|
+
item,
|
|
338
|
+
activeClassName: options.activeClassName || "",
|
|
339
|
+
itemClassName: options.itemClassName || "",
|
|
340
|
+
_itemClassName: dropdownItemClassName
|
|
341
|
+
},
|
|
342
|
+
item.id
|
|
343
|
+
)),
|
|
344
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("hr", { className: "border-gray-200" }),
|
|
345
|
+
list.slice(1).map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
346
|
+
DropdownItemComponent_default,
|
|
347
|
+
{
|
|
348
|
+
onSelect: item.onClick,
|
|
349
|
+
item,
|
|
350
|
+
activeClassName: options.activeClassName || "",
|
|
351
|
+
itemClassName: options.itemClassName || "",
|
|
352
|
+
_itemClassName: dropdownItemClassName
|
|
353
|
+
},
|
|
354
|
+
item.id
|
|
355
|
+
))
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
},
|
|
362
|
+
addExtensions() {
|
|
363
|
+
return [import_extension_text_style.TextStyle];
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
var DEFAULT_FONT_FAMILY_LIST = [
|
|
367
|
+
{ label: "Default", value: null },
|
|
368
|
+
"Inter",
|
|
369
|
+
"Comic Sans MS, Comic Sans",
|
|
370
|
+
"serif",
|
|
371
|
+
"cursive",
|
|
372
|
+
"Arial",
|
|
373
|
+
"Arial Black",
|
|
374
|
+
"Georgia",
|
|
375
|
+
"Impact",
|
|
376
|
+
"Tahoma",
|
|
377
|
+
"Times New Roman",
|
|
378
|
+
"Verdana",
|
|
379
|
+
"Courier New",
|
|
380
|
+
"Lucida Console",
|
|
381
|
+
"Monaco",
|
|
382
|
+
"monospace"
|
|
383
|
+
];
|
|
384
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
385
|
+
0 && (module.exports = {
|
|
386
|
+
DEFAULT_FONT_FAMILY_LIST,
|
|
387
|
+
FontFamily
|
|
388
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DropdownComponent_default,
|
|
3
|
+
DropdownItemComponent_default
|
|
4
|
+
} from "../chunk-2YUUKIIT.mjs";
|
|
5
|
+
import "../chunk-7QOFJIQ3.mjs";
|
|
6
|
+
import "../chunk-VYDH6BZE.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "../chunk-FWCSY2DS.mjs";
|
|
11
|
+
|
|
12
|
+
// src/extension/FontFamily.tsx
|
|
13
|
+
import { FontFamily as TiptapFontFamily, TextStyle } from "@tiptap/extension-text-style";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var FontFamily = TiptapFontFamily.extend({
|
|
16
|
+
addOptions() {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
|
|
19
|
+
return __spreadProps(__spreadValues({}, parent), {
|
|
20
|
+
types: (_b = parent == null ? void 0 : parent.types) != null ? _b : ["textStyle"],
|
|
21
|
+
fontFamilyList: DEFAULT_FONT_FAMILY_LIST,
|
|
22
|
+
component: ({ options, editor, dropdownContainerClassName, dropdownItemClassName }) => {
|
|
23
|
+
var _a2;
|
|
24
|
+
const items = (_a2 = options.fontFamilyList) != null ? _a2 : DEFAULT_FONT_FAMILY_LIST;
|
|
25
|
+
const list = items.map((it) => {
|
|
26
|
+
const label = typeof it === "string" ? it : it.label;
|
|
27
|
+
const value = typeof it === "string" ? it : it.value === void 0 ? it.label : it.value;
|
|
28
|
+
const isDefault = value == null || label.toLowerCase() === "default";
|
|
29
|
+
const fontFamilyPreview = !isDefault ? String(value) : void 0;
|
|
30
|
+
return {
|
|
31
|
+
id: crypto.randomUUID(),
|
|
32
|
+
text: label,
|
|
33
|
+
name: "fontFamily",
|
|
34
|
+
style: fontFamilyPreview ? { fontFamily: fontFamilyPreview } : void 0,
|
|
35
|
+
onClick: () => {
|
|
36
|
+
if (isDefault) {
|
|
37
|
+
editor.chain().focus().unsetFontFamily().run();
|
|
38
|
+
} else {
|
|
39
|
+
editor.chain().focus().setFontFamily(String(value)).run();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ jsxs(
|
|
45
|
+
DropdownComponent_default,
|
|
46
|
+
{
|
|
47
|
+
className: options.className,
|
|
48
|
+
showArrow: options.showArrow,
|
|
49
|
+
content: options.content,
|
|
50
|
+
dropdownClassName: options.dropdownClassName,
|
|
51
|
+
style: options.style,
|
|
52
|
+
tooltip: options.tooltip,
|
|
53
|
+
tooltipClassName: options.tooltipClassName,
|
|
54
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
55
|
+
_tooltipContent: "Font Family",
|
|
56
|
+
_internalContent: "Font Family",
|
|
57
|
+
_dropdownClassName: dropdownContainerClassName,
|
|
58
|
+
children: [
|
|
59
|
+
list.slice(0, 1).map((item) => /* @__PURE__ */ jsx(
|
|
60
|
+
DropdownItemComponent_default,
|
|
61
|
+
{
|
|
62
|
+
onSelect: item.onClick,
|
|
63
|
+
item,
|
|
64
|
+
activeClassName: options.activeClassName || "",
|
|
65
|
+
itemClassName: options.itemClassName || "",
|
|
66
|
+
_itemClassName: dropdownItemClassName
|
|
67
|
+
},
|
|
68
|
+
item.id
|
|
69
|
+
)),
|
|
70
|
+
/* @__PURE__ */ jsx("hr", { className: "border-gray-200" }),
|
|
71
|
+
list.slice(1).map((item) => /* @__PURE__ */ jsx(
|
|
72
|
+
DropdownItemComponent_default,
|
|
73
|
+
{
|
|
74
|
+
onSelect: item.onClick,
|
|
75
|
+
item,
|
|
76
|
+
activeClassName: options.activeClassName || "",
|
|
77
|
+
itemClassName: options.itemClassName || "",
|
|
78
|
+
_itemClassName: dropdownItemClassName
|
|
79
|
+
},
|
|
80
|
+
item.id
|
|
81
|
+
))
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
addExtensions() {
|
|
89
|
+
return [TextStyle];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var DEFAULT_FONT_FAMILY_LIST = [
|
|
93
|
+
{ label: "Default", value: null },
|
|
94
|
+
"Inter",
|
|
95
|
+
"Comic Sans MS, Comic Sans",
|
|
96
|
+
"serif",
|
|
97
|
+
"cursive",
|
|
98
|
+
"Arial",
|
|
99
|
+
"Arial Black",
|
|
100
|
+
"Georgia",
|
|
101
|
+
"Impact",
|
|
102
|
+
"Tahoma",
|
|
103
|
+
"Times New Roman",
|
|
104
|
+
"Verdana",
|
|
105
|
+
"Courier New",
|
|
106
|
+
"Lucida Console",
|
|
107
|
+
"Monaco",
|
|
108
|
+
"monospace"
|
|
109
|
+
];
|
|
110
|
+
export {
|
|
111
|
+
DEFAULT_FONT_FAMILY_LIST,
|
|
112
|
+
FontFamily
|
|
113
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Extension, Editor } from '@tiptap/react';
|
|
3
|
+
import { FontSizeOptions } from '@tiptap/extension-text-style';
|
|
4
|
+
import { a as ExtDropdownOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type FontSizeListItem = string | {
|
|
8
|
+
label: string;
|
|
9
|
+
value?: string | null;
|
|
10
|
+
};
|
|
11
|
+
interface ExtFontSizeOptions extends ExtDropdownOptions, FontSizeOptions {
|
|
12
|
+
fontSizeList?: FontSizeListItem[];
|
|
13
|
+
component: (args: {
|
|
14
|
+
options: ExtFontSizeOptions;
|
|
15
|
+
editor: Editor;
|
|
16
|
+
dropdownContainerClassName: string;
|
|
17
|
+
dropdownItemClassName: string;
|
|
18
|
+
}) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
declare const FontSize: Extension<ExtFontSizeOptions>;
|
|
21
|
+
declare const DEFAULT_FONT_SIZE_LIST: FontSizeListItem[];
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_FONT_SIZE_LIST, FontSize };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Extension, Editor } from '@tiptap/react';
|
|
3
|
+
import { FontSizeOptions } from '@tiptap/extension-text-style';
|
|
4
|
+
import { a as ExtDropdownOptions } from '../tiptap-ext.type-DrneAC5G.js';
|
|
5
|
+
import '@floating-ui/react';
|
|
6
|
+
|
|
7
|
+
type FontSizeListItem = string | {
|
|
8
|
+
label: string;
|
|
9
|
+
value?: string | null;
|
|
10
|
+
};
|
|
11
|
+
interface ExtFontSizeOptions extends ExtDropdownOptions, FontSizeOptions {
|
|
12
|
+
fontSizeList?: FontSizeListItem[];
|
|
13
|
+
component: (args: {
|
|
14
|
+
options: ExtFontSizeOptions;
|
|
15
|
+
editor: Editor;
|
|
16
|
+
dropdownContainerClassName: string;
|
|
17
|
+
dropdownItemClassName: string;
|
|
18
|
+
}) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
declare const FontSize: Extension<ExtFontSizeOptions>;
|
|
21
|
+
declare const DEFAULT_FONT_SIZE_LIST: FontSizeListItem[];
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_FONT_SIZE_LIST, FontSize };
|