ritext 1.0.14 → 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 +27 -28
- package/dist/chunk-2YUUKIIT.mjs +149 -0
- package/dist/chunk-7QOFJIQ3.mjs +90 -0
- package/dist/chunk-D47XME55.mjs +49 -0
- package/dist/chunk-FWCSY2DS.mjs +37 -0
- package/dist/chunk-GSHINFPO.mjs +53 -0
- package/dist/chunk-LMOTHRGQ.mjs +37 -0
- package/dist/chunk-MBF77NHS.mjs +37 -0
- package/dist/chunk-VYDH6BZE.mjs +17 -0
- package/dist/extension/bold.d.mts +8 -0
- package/dist/extension/bold.d.ts +8 -0
- package/dist/extension/bold.js +260 -0
- package/dist/extension/bold.mjs +70 -0
- 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 +8 -0
- package/dist/extension/italic.d.ts +8 -0
- package/dist/extension/italic.js +264 -0
- package/dist/extension/italic.mjs +74 -0
- package/dist/extension/strike.d.mts +8 -0
- package/dist/extension/strike.d.ts +8 -0
- package/dist/extension/strike.js +264 -0
- package/dist/extension/strike.mjs +74 -0
- package/dist/extension/subandsuperscript.d.mts +21 -0
- package/dist/extension/subandsuperscript.d.ts +21 -0
- package/dist/extension/subandsuperscript.js +452 -0
- package/dist/extension/subandsuperscript.mjs +121 -0
- package/dist/extension/subscript.d.mts +8 -0
- package/dist/extension/subscript.d.ts +8 -0
- package/dist/extension/subscript.js +264 -0
- package/dist/extension/subscript.mjs +46 -0
- package/dist/extension/superscript.d.mts +8 -0
- package/dist/extension/superscript.d.ts +8 -0
- package/dist/extension/superscript.js +264 -0
- package/dist/extension/superscript.mjs +46 -0
- package/dist/extension/underline.d.mts +8 -0
- package/dist/extension/underline.d.ts +8 -0
- package/dist/extension/underline.js +263 -0
- package/dist/extension/underline.mjs +73 -0
- package/dist/index.css +471 -5
- package/dist/index.d.mts +6 -32
- package/dist/index.d.ts +6 -32
- package/dist/index.js +26 -538
- package/dist/index.mjs +31 -549
- package/dist/tiptap-ext.type-DrneAC5G.d.mts +39 -0
- package/dist/tiptap-ext.type-DrneAC5G.d.ts +39 -0
- package/package.json +52 -26
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/extension/Bold.tsx
|
|
60
|
+
var Bold_exports = {};
|
|
61
|
+
__export(Bold_exports, {
|
|
62
|
+
Bold: () => Bold
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(Bold_exports);
|
|
65
|
+
var import_extension_bold = __toESM(require("@tiptap/extension-bold"));
|
|
66
|
+
|
|
67
|
+
// src/lib/icon/BoldIcon.tsx
|
|
68
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
+
var BoldIcon = (_a) => {
|
|
70
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
|
+
"svg",
|
|
73
|
+
__spreadProps(__spreadValues({
|
|
74
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
75
|
+
viewBox: "0 0 24 24",
|
|
76
|
+
fill: "none",
|
|
77
|
+
stroke: "currentColor",
|
|
78
|
+
strokeWidth: 2,
|
|
79
|
+
strokeLinecap: "round",
|
|
80
|
+
strokeLinejoin: "round",
|
|
81
|
+
width: size,
|
|
82
|
+
height: size,
|
|
83
|
+
className
|
|
84
|
+
}, props), {
|
|
85
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" })
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
var BoldIcon_default = BoldIcon;
|
|
90
|
+
|
|
91
|
+
// src/lib/components/ButtonComponent.tsx
|
|
92
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
93
|
+
|
|
94
|
+
// src/lib/components/_com/Tooltip.tsx
|
|
95
|
+
var import_react = require("react");
|
|
96
|
+
var import_react2 = require("@floating-ui/react");
|
|
97
|
+
var import_react3 = require("motion/react");
|
|
98
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
99
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
100
|
+
var Tooltip = ({ placement = "top", children, content, className }) => {
|
|
101
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
102
|
+
const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
|
|
103
|
+
open,
|
|
104
|
+
onOpenChange: setOpen,
|
|
105
|
+
placement,
|
|
106
|
+
middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
|
|
107
|
+
whileElementsMounted: import_react2.autoUpdate
|
|
108
|
+
});
|
|
109
|
+
const hover = (0, import_react2.useHover)(context);
|
|
110
|
+
const dismiss = (0, import_react2.useDismiss)(context);
|
|
111
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
|
|
112
|
+
const id = (0, import_react.useId)();
|
|
113
|
+
function mergeRefs(...refsToMerge) {
|
|
114
|
+
return (node) => {
|
|
115
|
+
for (const r of refsToMerge) {
|
|
116
|
+
if (!r) continue;
|
|
117
|
+
if (typeof r === "function") r(node);
|
|
118
|
+
else r.current = node;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const side = resolvedPlacement.split("-")[0];
|
|
123
|
+
const enterOffset = 6;
|
|
124
|
+
const getInitial = () => {
|
|
125
|
+
switch (side) {
|
|
126
|
+
case "top":
|
|
127
|
+
return { opacity: 0, y: enterOffset };
|
|
128
|
+
case "bottom":
|
|
129
|
+
return { opacity: 0, y: -enterOffset };
|
|
130
|
+
case "left":
|
|
131
|
+
return { opacity: 0, x: enterOffset };
|
|
132
|
+
case "right":
|
|
133
|
+
return { opacity: 0, x: -enterOffset };
|
|
134
|
+
default:
|
|
135
|
+
return { opacity: 0 };
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
|
|
140
|
+
(0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
|
|
141
|
+
onFocus: () => setOpen(true),
|
|
142
|
+
onBlur: () => setOpen(false),
|
|
143
|
+
"aria-describedby": open ? id : void 0
|
|
144
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
145
|
+
})), {
|
|
146
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
147
|
+
ref: mergeRefs(children.props.ref, refs.setReference)
|
|
148
|
+
})) : children,
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react3.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
150
|
+
import_react3.motion.div,
|
|
151
|
+
__spreadProps(__spreadValues({
|
|
152
|
+
ref: refs.setFloating
|
|
153
|
+
}, getFloatingProps({
|
|
154
|
+
role: "tooltip",
|
|
155
|
+
id,
|
|
156
|
+
style: {
|
|
157
|
+
position: strategy,
|
|
158
|
+
top: y != null ? y : 0,
|
|
159
|
+
left: x != null ? x : 0,
|
|
160
|
+
pointerEvents: "none"
|
|
161
|
+
}
|
|
162
|
+
})), {
|
|
163
|
+
initial: getInitial(),
|
|
164
|
+
animate: { opacity: 1, x: 0, y: 0, scale: 1 },
|
|
165
|
+
exit: getExit(),
|
|
166
|
+
transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
|
|
167
|
+
className: (0, import_tailwind_merge.twMerge)("bg-white border border-solid border-gray-200/50 py-1 px-3 rounded-lg text-sm shadow-lg shadow-gray-50 text-center", className),
|
|
168
|
+
children: content
|
|
169
|
+
}),
|
|
170
|
+
"tooltip"
|
|
171
|
+
) }) })
|
|
172
|
+
] });
|
|
173
|
+
};
|
|
174
|
+
var Tooltip_default = Tooltip;
|
|
175
|
+
|
|
176
|
+
// src/lib/context/editor.context.tsx
|
|
177
|
+
var import_react4 = require("react");
|
|
178
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
179
|
+
var EditorContext = (0, import_react4.createContext)({ editor: null });
|
|
180
|
+
var useEditor = () => {
|
|
181
|
+
const ctx = (0, import_react4.useContext)(EditorContext);
|
|
182
|
+
if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
|
|
183
|
+
return ctx;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/lib/components/ButtonComponent.tsx
|
|
187
|
+
var import_react5 = require("@tiptap/react");
|
|
188
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
189
|
+
var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
|
|
190
|
+
const { editor } = useEditor();
|
|
191
|
+
const editorState = (0, import_react5.useEditorState)({
|
|
192
|
+
editor,
|
|
193
|
+
selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
|
|
194
|
+
});
|
|
195
|
+
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
|
|
196
|
+
typeof tooltip === "string" ? tooltip : _tooltipContent,
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
|
|
198
|
+
_interShortcut
|
|
199
|
+
] });
|
|
200
|
+
const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
onClick: _onToggle,
|
|
204
|
+
className: (0, import_tailwind_merge2.twMerge)(
|
|
205
|
+
"py-1.5 px-2.5 rounded-md",
|
|
206
|
+
_buttonClassName,
|
|
207
|
+
(editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
|
|
208
|
+
className,
|
|
209
|
+
(editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
|
|
210
|
+
),
|
|
211
|
+
style,
|
|
212
|
+
children: icon != null ? icon : _internalIcon
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
if (tooltip === false) return btn;
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
217
|
+
Tooltip_default,
|
|
218
|
+
{
|
|
219
|
+
content: tooltipContent,
|
|
220
|
+
className: tooltipClassName,
|
|
221
|
+
placement: tooltipPlacement,
|
|
222
|
+
children: btn
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
var ButtonComponent_default = ButtonComponent;
|
|
227
|
+
|
|
228
|
+
// src/extension/Bold.tsx
|
|
229
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
230
|
+
var Bold = import_extension_bold.default.extend({
|
|
231
|
+
addOptions() {
|
|
232
|
+
var _a;
|
|
233
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
234
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
236
|
+
ButtonComponent_default,
|
|
237
|
+
{
|
|
238
|
+
className: options.className,
|
|
239
|
+
icon: options.icon,
|
|
240
|
+
style: options.style,
|
|
241
|
+
activeClassName: options.activeClassName,
|
|
242
|
+
tooltip: options.tooltip,
|
|
243
|
+
tooltipClassName: options.tooltipClassName,
|
|
244
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
245
|
+
_internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoldIcon_default, {}),
|
|
246
|
+
_extName: "bold",
|
|
247
|
+
_onToggle: () => editor.chain().focus().toggleBold().run(),
|
|
248
|
+
_interShortcut: "\u2318 + B",
|
|
249
|
+
_tooltipContent: "Bold",
|
|
250
|
+
_buttonClassName: buttonClassName
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
259
|
+
Bold
|
|
260
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonComponent_default
|
|
3
|
+
} from "../chunk-GSHINFPO.mjs";
|
|
4
|
+
import "../chunk-7QOFJIQ3.mjs";
|
|
5
|
+
import "../chunk-VYDH6BZE.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__objRest,
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "../chunk-FWCSY2DS.mjs";
|
|
11
|
+
|
|
12
|
+
// src/extension/Bold.tsx
|
|
13
|
+
import TiptapBold from "@tiptap/extension-bold";
|
|
14
|
+
|
|
15
|
+
// src/lib/icon/BoldIcon.tsx
|
|
16
|
+
import { jsx } from "react/jsx-runtime";
|
|
17
|
+
var BoldIcon = (_a) => {
|
|
18
|
+
var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
"svg",
|
|
21
|
+
__spreadProps(__spreadValues({
|
|
22
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
23
|
+
viewBox: "0 0 24 24",
|
|
24
|
+
fill: "none",
|
|
25
|
+
stroke: "currentColor",
|
|
26
|
+
strokeWidth: 2,
|
|
27
|
+
strokeLinecap: "round",
|
|
28
|
+
strokeLinejoin: "round",
|
|
29
|
+
width: size,
|
|
30
|
+
height: size,
|
|
31
|
+
className
|
|
32
|
+
}, props), {
|
|
33
|
+
children: /* @__PURE__ */ jsx("path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" })
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
var BoldIcon_default = BoldIcon;
|
|
38
|
+
|
|
39
|
+
// src/extension/Bold.tsx
|
|
40
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
41
|
+
var Bold = TiptapBold.extend({
|
|
42
|
+
addOptions() {
|
|
43
|
+
var _a;
|
|
44
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
45
|
+
component: ({ editor, options, buttonClassName }) => {
|
|
46
|
+
return /* @__PURE__ */ jsx2(
|
|
47
|
+
ButtonComponent_default,
|
|
48
|
+
{
|
|
49
|
+
className: options.className,
|
|
50
|
+
icon: options.icon,
|
|
51
|
+
style: options.style,
|
|
52
|
+
activeClassName: options.activeClassName,
|
|
53
|
+
tooltip: options.tooltip,
|
|
54
|
+
tooltipClassName: options.tooltipClassName,
|
|
55
|
+
tooltipPlacement: options.tooltipPlacement,
|
|
56
|
+
_internalIcon: /* @__PURE__ */ jsx2(BoldIcon_default, {}),
|
|
57
|
+
_extName: "bold",
|
|
58
|
+
_onToggle: () => editor.chain().focus().toggleBold().run(),
|
|
59
|
+
_interShortcut: "\u2318 + B",
|
|
60
|
+
_tooltipContent: "Bold",
|
|
61
|
+
_buttonClassName: buttonClassName
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export {
|
|
69
|
+
Bold
|
|
70
|
+
};
|
|
@@ -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
|
+
});
|
|
@@ -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 };
|