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.
Files changed (133) hide show
  1. package/LICENSE +57 -0
  2. package/README.md +15 -41
  3. package/dist/chunk-EN4BPI7N.mjs +1213 -0
  4. package/dist/chunk-FJQ4FZRS.mjs +98 -0
  5. package/dist/chunk-M4ORWR74.mjs +31 -0
  6. package/dist/chunk-SJFT7WNM.mjs +38 -0
  7. package/dist/chunk-W367UGID.mjs +55 -0
  8. package/dist/{chunk-FWCSY2DS.mjs → chunk-WNQUEZJF.mjs} +22 -1
  9. package/dist/{chunk-D47XME55.mjs → chunk-WXCHG3NQ.mjs} +8 -2
  10. package/dist/chunk-WZKGD3DD.mjs +231 -0
  11. package/dist/extension/backgroundcolor.d.mts +16 -0
  12. package/dist/extension/backgroundcolor.d.ts +16 -0
  13. package/dist/extension/backgroundcolor.js +668 -0
  14. package/dist/extension/backgroundcolor.mjs +107 -0
  15. package/dist/extension/base.d.mts +6 -0
  16. package/dist/extension/base.d.ts +6 -0
  17. package/dist/extension/base.js +65 -0
  18. package/dist/extension/base.mjs +22 -0
  19. package/dist/extension/blockquote.d.mts +10 -0
  20. package/dist/extension/blockquote.d.ts +10 -0
  21. package/dist/extension/blockquote.js +239 -0
  22. package/dist/extension/blockquote.mjs +46 -0
  23. package/dist/extension/bold.d.mts +7 -2
  24. package/dist/extension/bold.d.ts +7 -2
  25. package/dist/extension/bold.js +22 -45
  26. package/dist/extension/bold.mjs +13 -35
  27. package/dist/extension/bulletlist.d.mts +10 -0
  28. package/dist/extension/bulletlist.d.ts +10 -0
  29. package/dist/extension/bulletlist.js +241 -0
  30. package/dist/extension/bulletlist.mjs +46 -0
  31. package/dist/extension/clearformat.d.mts +1 -1
  32. package/dist/extension/clearformat.d.ts +1 -1
  33. package/dist/extension/clearformat.js +11 -6
  34. package/dist/extension/clearformat.mjs +8 -35
  35. package/dist/extension/color.d.mts +17 -0
  36. package/dist/extension/color.d.ts +17 -0
  37. package/dist/extension/color.js +580 -0
  38. package/dist/extension/color.mjs +12 -0
  39. package/dist/extension/emoji.d.mts +15 -0
  40. package/dist/extension/emoji.d.ts +15 -0
  41. package/dist/extension/emoji.js +421 -0
  42. package/dist/extension/emoji.mjs +158 -0
  43. package/dist/extension/font-family.d.mts +8 -11
  44. package/dist/extension/font-family.d.ts +8 -11
  45. package/dist/extension/font-family.js +11 -12
  46. package/dist/extension/font-family.mjs +10 -11
  47. package/dist/extension/font-size.d.mts +8 -11
  48. package/dist/extension/font-size.d.ts +8 -11
  49. package/dist/extension/font-size.js +10 -12
  50. package/dist/extension/font-size.mjs +9 -11
  51. package/dist/extension/heading.d.mts +10 -10
  52. package/dist/extension/heading.d.ts +10 -10
  53. package/dist/extension/heading.js +68 -80
  54. package/dist/extension/heading.mjs +40 -206
  55. package/dist/extension/history.d.mts +4 -2
  56. package/dist/extension/history.d.ts +4 -2
  57. package/dist/extension/history.js +16 -9
  58. package/dist/extension/history.mjs +16 -64
  59. package/dist/extension/horizontalrule.d.mts +10 -0
  60. package/dist/extension/horizontalrule.d.ts +10 -0
  61. package/dist/extension/horizontalrule.js +242 -0
  62. package/dist/extension/horizontalrule.mjs +42 -0
  63. package/dist/extension/image.d.mts +26 -0
  64. package/dist/extension/image.d.ts +26 -0
  65. package/dist/extension/image.js +1611 -0
  66. package/dist/extension/image.mjs +1153 -0
  67. package/dist/extension/indentoutdent.d.mts +21 -0
  68. package/dist/extension/indentoutdent.d.ts +21 -0
  69. package/dist/extension/indentoutdent.js +380 -0
  70. package/dist/extension/indentoutdent.mjs +164 -0
  71. package/dist/extension/italic.d.mts +7 -2
  72. package/dist/extension/italic.d.ts +7 -2
  73. package/dist/extension/italic.js +22 -45
  74. package/dist/extension/italic.mjs +14 -40
  75. package/dist/extension/lineheight.d.mts +15 -0
  76. package/dist/extension/lineheight.d.ts +15 -0
  77. package/dist/extension/lineheight.js +342 -0
  78. package/dist/extension/lineheight.mjs +87 -0
  79. package/dist/extension/link.d.mts +15 -0
  80. package/dist/extension/link.d.ts +15 -0
  81. package/dist/extension/link.js +588 -0
  82. package/dist/extension/link.mjs +278 -0
  83. package/dist/extension/orderedlist.d.mts +10 -0
  84. package/dist/extension/orderedlist.d.ts +10 -0
  85. package/dist/extension/orderedlist.js +241 -0
  86. package/dist/extension/orderedlist.mjs +46 -0
  87. package/dist/extension/strike.d.mts +8 -3
  88. package/dist/extension/strike.d.ts +8 -3
  89. package/dist/extension/strike.js +22 -45
  90. package/dist/extension/strike.mjs +14 -40
  91. package/dist/extension/subandsuperscript.d.mts +7 -10
  92. package/dist/extension/subandsuperscript.d.ts +7 -10
  93. package/dist/extension/subandsuperscript.js +66 -77
  94. package/dist/extension/subandsuperscript.mjs +18 -48
  95. package/dist/extension/subscript.d.mts +4 -2
  96. package/dist/extension/subscript.d.ts +4 -2
  97. package/dist/extension/subscript.js +20 -45
  98. package/dist/extension/subscript.mjs +10 -10
  99. package/dist/extension/superscript.d.mts +4 -2
  100. package/dist/extension/superscript.d.ts +4 -2
  101. package/dist/extension/superscript.js +20 -45
  102. package/dist/extension/superscript.mjs +10 -10
  103. package/dist/extension/table.d.mts +12 -0
  104. package/dist/extension/table.d.ts +12 -0
  105. package/dist/extension/table.js +585 -0
  106. package/dist/extension/table.mjs +324 -0
  107. package/dist/extension/tasklist.d.mts +10 -0
  108. package/dist/extension/tasklist.d.ts +10 -0
  109. package/dist/extension/tasklist.js +246 -0
  110. package/dist/extension/tasklist.mjs +52 -0
  111. package/dist/extension/textalign.d.mts +15 -0
  112. package/dist/extension/textalign.d.ts +15 -0
  113. package/dist/extension/textalign.js +404 -0
  114. package/dist/extension/textalign.mjs +79 -0
  115. package/dist/extension/underline.d.mts +7 -2
  116. package/dist/extension/underline.d.ts +7 -2
  117. package/dist/extension/underline.js +22 -45
  118. package/dist/extension/underline.mjs +14 -39
  119. package/dist/index.css +683 -31
  120. package/dist/index.d.mts +3 -1
  121. package/dist/index.d.ts +3 -1
  122. package/dist/index.js +306 -24
  123. package/dist/index.mjs +141 -13
  124. package/dist/tiptap-ext.type-B3TtT7-J.d.mts +43 -0
  125. package/dist/tiptap-ext.type-B3TtT7-J.d.ts +43 -0
  126. package/package.json +41 -28
  127. package/dist/chunk-2YUUKIIT.mjs +0 -149
  128. package/dist/chunk-7QOFJIQ3.mjs +0 -90
  129. package/dist/chunk-GSHINFPO.mjs +0 -53
  130. package/dist/chunk-LMOTHRGQ.mjs +0 -37
  131. package/dist/chunk-MBF77NHS.mjs +0 -37
  132. package/dist/tiptap-ext.type-DrneAC5G.d.mts +0 -39
  133. package/dist/tiptap-ext.type-DrneAC5G.d.ts +0 -39
@@ -0,0 +1,21 @@
1
+ import { Extension } from '@tiptap/react';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.mjs';
3
+ import 'react';
4
+ import '@floating-ui/react';
5
+
6
+ type ExtIndentOptions = ExtButtonOptions<{
7
+ indentSize?: number;
8
+ maxIndent?: number;
9
+ types?: string[];
10
+ }>;
11
+ declare module "@tiptap/react" {
12
+ interface Commands<ReturnType> {
13
+ indentOutdent: {
14
+ indent: () => ReturnType;
15
+ outdent: () => ReturnType;
16
+ };
17
+ }
18
+ }
19
+ declare const IndentOutdent: Extension<ExtIndentOptions, any>;
20
+
21
+ export { IndentOutdent };
@@ -0,0 +1,21 @@
1
+ import { Extension } from '@tiptap/react';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.js';
3
+ import 'react';
4
+ import '@floating-ui/react';
5
+
6
+ type ExtIndentOptions = ExtButtonOptions<{
7
+ indentSize?: number;
8
+ maxIndent?: number;
9
+ types?: string[];
10
+ }>;
11
+ declare module "@tiptap/react" {
12
+ interface Commands<ReturnType> {
13
+ indentOutdent: {
14
+ indent: () => ReturnType;
15
+ outdent: () => ReturnType;
16
+ };
17
+ }
18
+ }
19
+ declare const IndentOutdent: Extension<ExtIndentOptions, any>;
20
+
21
+ export { IndentOutdent };
@@ -0,0 +1,380 @@
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/IndentOutdent.tsx
50
+ var IndentOutdent_exports = {};
51
+ __export(IndentOutdent_exports, {
52
+ IndentOutdent: () => IndentOutdent
53
+ });
54
+ module.exports = __toCommonJS(IndentOutdent_exports);
55
+ var import_react7 = require("react");
56
+ var import_react8 = require("@tiptap/react");
57
+
58
+ // src/lib/icons/index.tsx
59
+ var import_jsx_runtime = require("react/jsx-runtime");
60
+ var IndentIcon = (_a) => {
61
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
63
+ "svg",
64
+ __spreadProps(__spreadValues({
65
+ xmlns: "http://www.w3.org/2000/svg",
66
+ width: size,
67
+ height: size,
68
+ viewBox: "0 0 24 24",
69
+ fill: "none",
70
+ stroke: "currentColor",
71
+ strokeWidth: "2",
72
+ strokeLinecap: "round",
73
+ strokeLinejoin: "round"
74
+ }, props), {
75
+ children: [
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 5H11" }),
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12H11" }),
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 19H11" }),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3 8 4 4-4 4" })
80
+ ]
81
+ })
82
+ );
83
+ };
84
+ var OutdentIcon = (_a) => {
85
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
87
+ "svg",
88
+ __spreadProps(__spreadValues({
89
+ xmlns: "http://www.w3.org/2000/svg",
90
+ width: size,
91
+ height: size,
92
+ viewBox: "0 0 24 24",
93
+ fill: "none",
94
+ stroke: "currentColor",
95
+ strokeWidth: "2",
96
+ strokeLinecap: "round",
97
+ strokeLinejoin: "round"
98
+ }, props), {
99
+ children: [
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 5H11" }),
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12H11" }),
102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 19H11" }),
103
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m7 8-4 4 4 4" })
104
+ ]
105
+ })
106
+ );
107
+ };
108
+
109
+ // src/lib/components/ButtonComponent.tsx
110
+ var import_react5 = require("react");
111
+ var import_tailwind_merge2 = require("tailwind-merge");
112
+
113
+ // src/lib/components/_com/Tooltip.tsx
114
+ var import_react = require("react");
115
+ var import_react2 = require("@floating-ui/react");
116
+ var import_react3 = require("motion/react");
117
+ var import_tailwind_merge = require("tailwind-merge");
118
+ var import_jsx_runtime2 = require("react/jsx-runtime");
119
+ var Tooltip = ({ placement = "top", children, content, className }) => {
120
+ const [open, setOpen] = (0, import_react.useState)(false);
121
+ const { x, y, refs, strategy, context, placement: resolvedPlacement } = (0, import_react2.useFloating)({
122
+ open,
123
+ onOpenChange: setOpen,
124
+ placement,
125
+ middleware: [(0, import_react2.offset)(8), (0, import_react2.flip)(), (0, import_react2.shift)({ padding: 8 })],
126
+ whileElementsMounted: import_react2.autoUpdate
127
+ });
128
+ const hover = (0, import_react2.useHover)(context);
129
+ const dismiss = (0, import_react2.useDismiss)(context);
130
+ const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([hover, dismiss]);
131
+ const id = (0, import_react.useId)();
132
+ function mergeRefs(...refsToMerge) {
133
+ return (node) => {
134
+ for (const r of refsToMerge) {
135
+ if (!r) continue;
136
+ if (typeof r === "function") r(node);
137
+ else r.current = node;
138
+ }
139
+ };
140
+ }
141
+ const side = resolvedPlacement.split("-")[0];
142
+ const enterOffset = 6;
143
+ const getInitial = () => {
144
+ switch (side) {
145
+ case "top":
146
+ return { opacity: 0, y: enterOffset };
147
+ case "bottom":
148
+ return { opacity: 0, y: -enterOffset };
149
+ case "left":
150
+ return { opacity: 0, x: enterOffset };
151
+ case "right":
152
+ return { opacity: 0, x: -enterOffset };
153
+ default:
154
+ return { opacity: 0 };
155
+ }
156
+ };
157
+ const getExit = () => __spreadProps(__spreadValues({}, getInitial()), { opacity: 0 });
158
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Fragment, { children: [
159
+ (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, __spreadProps(__spreadValues({}, getReferenceProps({
160
+ onFocus: () => setOpen(true),
161
+ onBlur: () => setOpen(false),
162
+ "aria-describedby": open ? id : void 0
163
+ /* eslint-disable @typescript-eslint/no-explicit-any */
164
+ })), {
165
+ /* eslint-disable @typescript-eslint/no-explicit-any */
166
+ ref: mergeRefs(children.props.ref, refs.setReference)
167
+ })) : children,
168
+ /* @__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)(
169
+ import_react3.motion.div,
170
+ __spreadProps(__spreadValues({
171
+ ref: refs.setFloating
172
+ }, getFloatingProps({
173
+ role: "tooltip",
174
+ id,
175
+ style: {
176
+ position: strategy,
177
+ top: y != null ? y : 0,
178
+ left: x != null ? x : 0,
179
+ pointerEvents: "none"
180
+ }
181
+ })), {
182
+ initial: getInitial(),
183
+ animate: { opacity: 1, x: 0, y: 0, scale: 1 },
184
+ exit: getExit(),
185
+ transition: { type: "spring", stiffness: 420, damping: 30, mass: 0.6 },
186
+ 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),
187
+ children: content
188
+ }),
189
+ "tooltip"
190
+ ) }) })
191
+ ] });
192
+ };
193
+ var Tooltip_default = Tooltip;
194
+
195
+ // src/lib/context/editor.context.tsx
196
+ var import_react4 = require("react");
197
+ var import_jsx_runtime3 = require("react/jsx-runtime");
198
+ var EditorContext = (0, import_react4.createContext)({ editor: null });
199
+ var useEditor = () => {
200
+ const ctx = (0, import_react4.useContext)(EditorContext);
201
+ if (!ctx) throw new Error("<Toolbar/> & <Content/> component must be used inside <Editor>...</Editor/>");
202
+ return ctx;
203
+ };
204
+
205
+ // src/lib/components/ButtonComponent.tsx
206
+ var import_react6 = require("@tiptap/react");
207
+ var import_jsx_runtime4 = require("react/jsx-runtime");
208
+ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
209
+ const { editor } = useEditor();
210
+ const editorState = (0, import_react6.useEditorState)({
211
+ editor,
212
+ selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
213
+ });
214
+ const shortcutText = (0, import_react5.useMemo)(() => {
215
+ if (!_interShortcut) return "";
216
+ return (0, import_react6.isMacOS)() ? _interShortcut.mac : _interShortcut.win;
217
+ }, [_interShortcut]);
218
+ const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
219
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
220
+ shortcutText ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
221
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
222
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "opacity-70", children: shortcutText })
223
+ ] }) : null
224
+ ] });
225
+ const btn = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { onClick: _onToggle, className: (0, import_tailwind_merge2.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 });
226
+ if (tooltip === false) return btn;
227
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip_default, { content: tooltipContent, className: tooltipClassName, placement: tooltipPlacement, children: btn });
228
+ };
229
+ var ButtonComponent_default = ButtonComponent;
230
+
231
+ // src/extension/IndentOutdent.tsx
232
+ var import_jsx_runtime5 = require("react/jsx-runtime");
233
+ var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
234
+ var toInt = (v) => {
235
+ const n = typeof v === "number" ? v : Number(v);
236
+ return Number.isFinite(n) ? Math.trunc(n) : 0;
237
+ };
238
+ var IndentOutdent = import_react8.Extension.create({
239
+ name: "indentOutdent",
240
+ addOptions() {
241
+ var _a;
242
+ const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
243
+ return __spreadProps(__spreadValues({}, parent), {
244
+ indentSize: 1,
245
+ maxIndent: 7,
246
+ types: ["paragraph", "heading", "blockquote"],
247
+ component: ({ options, editor, buttonClassName }) => {
248
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react7.Fragment, { children: [
249
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
250
+ ButtonComponent_default,
251
+ {
252
+ className: options.className,
253
+ icon: options.icon,
254
+ style: options.style,
255
+ activeClassName: options.activeClassName,
256
+ tooltip: options.tooltip,
257
+ tooltipClassName: options.tooltipClassName,
258
+ tooltipPlacement: options.tooltipPlacement,
259
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IndentIcon, {}),
260
+ _extName: "indent",
261
+ _onToggle: () => editor.chain().focus().indent().run(),
262
+ _interShortcut: { win: "\u21E5", mac: "\u21E5" },
263
+ _tooltipContent: "Indent",
264
+ _buttonClassName: buttonClassName
265
+ }
266
+ ),
267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
268
+ ButtonComponent_default,
269
+ {
270
+ className: options.className,
271
+ icon: options.icon,
272
+ style: options.style,
273
+ activeClassName: options.activeClassName,
274
+ tooltip: options.tooltip,
275
+ tooltipClassName: options.tooltipClassName,
276
+ tooltipPlacement: options.tooltipPlacement,
277
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutdentIcon, {}),
278
+ _extName: "outdent",
279
+ _onToggle: () => editor.chain().focus().outdent().run(),
280
+ _interShortcut: { win: "\u21E7 + \u21E5", mac: "\u21E7 + \u21E5" },
281
+ _tooltipContent: "Outdent",
282
+ _buttonClassName: buttonClassName
283
+ }
284
+ )
285
+ ] });
286
+ }
287
+ });
288
+ },
289
+ addGlobalAttributes() {
290
+ var _a;
291
+ return [
292
+ {
293
+ types: (_a = this.options.types) != null ? _a : [],
294
+ attributes: {
295
+ indent: {
296
+ default: null,
297
+ parseHTML: (element) => {
298
+ const raw = element.getAttribute("data-indent");
299
+ const n = toInt(raw);
300
+ return n > 0 ? n : null;
301
+ },
302
+ renderHTML: (attributes) => {
303
+ const n = toInt(attributes.indent);
304
+ if (!n || n <= 0) return {};
305
+ return { "data-indent": String(n) };
306
+ }
307
+ }
308
+ }
309
+ }
310
+ ];
311
+ },
312
+ addCommands() {
313
+ const getTargets = (state) => {
314
+ var _a, _b;
315
+ const allowed = new Set((_a = this.options.types) != null ? _a : []);
316
+ const targets = [];
317
+ state.doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
318
+ var _a2;
319
+ if (!((_a2 = node == null ? void 0 : node.type) == null ? void 0 : _a2.name)) return;
320
+ if (!allowed.has(node.type.name)) return;
321
+ targets.push({ pos, node });
322
+ });
323
+ const $from = state.selection.$from;
324
+ for (let d = $from.depth; d > 0; d--) {
325
+ const node = $from.node(d);
326
+ if (((_b = node == null ? void 0 : node.type) == null ? void 0 : _b.name) && allowed.has(node.type.name)) {
327
+ targets.unshift({ pos: $from.before(d), node });
328
+ break;
329
+ }
330
+ }
331
+ const seen = /* @__PURE__ */ new Set();
332
+ return targets.filter((t) => seen.has(t.pos) ? false : (seen.add(t.pos), true));
333
+ };
334
+ const applyDelta = (delta) => {
335
+ const step = Math.max(1, toInt(this.options.indentSize));
336
+ const maxIndent = Math.max(1, toInt(this.options.maxIndent));
337
+ return ({ state, dispatch }) => {
338
+ var _a;
339
+ const targets = getTargets(state);
340
+ if (!targets.length) return false;
341
+ const tr = state.tr;
342
+ let changed = false;
343
+ for (const { pos, node } of targets) {
344
+ const current = toInt((_a = node.attrs) == null ? void 0 : _a.indent);
345
+ const next = clamp(current + delta * step, 0, maxIndent);
346
+ if (next === current) continue;
347
+ const attrs = __spreadValues({}, node.attrs);
348
+ if (next <= 0) {
349
+ delete attrs.indent;
350
+ } else {
351
+ attrs.indent = next;
352
+ }
353
+ tr.setNodeMarkup(pos, void 0, attrs, node.marks);
354
+ changed = true;
355
+ }
356
+ if (!changed) return false;
357
+ if (dispatch) dispatch(tr);
358
+ return true;
359
+ };
360
+ };
361
+ return {
362
+ indent: () => applyDelta(1),
363
+ outdent: () => applyDelta(-1)
364
+ };
365
+ },
366
+ addKeyboardShortcuts() {
367
+ return {
368
+ Tab: () => {
369
+ return this.editor.commands.indent();
370
+ },
371
+ "Shift-Tab": () => {
372
+ return this.editor.commands.outdent();
373
+ }
374
+ };
375
+ }
376
+ });
377
+ // Annotate the CommonJS export names for ESM import in node:
378
+ 0 && (module.exports = {
379
+ IndentOutdent
380
+ });
@@ -0,0 +1,164 @@
1
+ import {
2
+ ButtonComponent_default
3
+ } from "../chunk-SJFT7WNM.mjs";
4
+ import "../chunk-VYDH6BZE.mjs";
5
+ import {
6
+ IndentIcon,
7
+ OutdentIcon
8
+ } from "../chunk-EN4BPI7N.mjs";
9
+ import {
10
+ __spreadProps,
11
+ __spreadValues
12
+ } from "../chunk-WNQUEZJF.mjs";
13
+
14
+ // src/extension/IndentOutdent.tsx
15
+ import { Fragment } from "react";
16
+ import { Extension } from "@tiptap/react";
17
+ import { jsx, jsxs } from "react/jsx-runtime";
18
+ var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
19
+ var toInt = (v) => {
20
+ const n = typeof v === "number" ? v : Number(v);
21
+ return Number.isFinite(n) ? Math.trunc(n) : 0;
22
+ };
23
+ var IndentOutdent = Extension.create({
24
+ name: "indentOutdent",
25
+ addOptions() {
26
+ var _a;
27
+ const parent = (_a = this.parent) == null ? void 0 : _a.call(this);
28
+ return __spreadProps(__spreadValues({}, parent), {
29
+ indentSize: 1,
30
+ maxIndent: 7,
31
+ types: ["paragraph", "heading", "blockquote"],
32
+ component: ({ options, editor, buttonClassName }) => {
33
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
34
+ /* @__PURE__ */ jsx(
35
+ ButtonComponent_default,
36
+ {
37
+ className: options.className,
38
+ icon: options.icon,
39
+ style: options.style,
40
+ activeClassName: options.activeClassName,
41
+ tooltip: options.tooltip,
42
+ tooltipClassName: options.tooltipClassName,
43
+ tooltipPlacement: options.tooltipPlacement,
44
+ _internalIcon: /* @__PURE__ */ jsx(IndentIcon, {}),
45
+ _extName: "indent",
46
+ _onToggle: () => editor.chain().focus().indent().run(),
47
+ _interShortcut: { win: "\u21E5", mac: "\u21E5" },
48
+ _tooltipContent: "Indent",
49
+ _buttonClassName: buttonClassName
50
+ }
51
+ ),
52
+ /* @__PURE__ */ jsx(
53
+ ButtonComponent_default,
54
+ {
55
+ className: options.className,
56
+ icon: options.icon,
57
+ style: options.style,
58
+ activeClassName: options.activeClassName,
59
+ tooltip: options.tooltip,
60
+ tooltipClassName: options.tooltipClassName,
61
+ tooltipPlacement: options.tooltipPlacement,
62
+ _internalIcon: /* @__PURE__ */ jsx(OutdentIcon, {}),
63
+ _extName: "outdent",
64
+ _onToggle: () => editor.chain().focus().outdent().run(),
65
+ _interShortcut: { win: "\u21E7 + \u21E5", mac: "\u21E7 + \u21E5" },
66
+ _tooltipContent: "Outdent",
67
+ _buttonClassName: buttonClassName
68
+ }
69
+ )
70
+ ] });
71
+ }
72
+ });
73
+ },
74
+ addGlobalAttributes() {
75
+ var _a;
76
+ return [
77
+ {
78
+ types: (_a = this.options.types) != null ? _a : [],
79
+ attributes: {
80
+ indent: {
81
+ default: null,
82
+ parseHTML: (element) => {
83
+ const raw = element.getAttribute("data-indent");
84
+ const n = toInt(raw);
85
+ return n > 0 ? n : null;
86
+ },
87
+ renderHTML: (attributes) => {
88
+ const n = toInt(attributes.indent);
89
+ if (!n || n <= 0) return {};
90
+ return { "data-indent": String(n) };
91
+ }
92
+ }
93
+ }
94
+ }
95
+ ];
96
+ },
97
+ addCommands() {
98
+ const getTargets = (state) => {
99
+ var _a, _b;
100
+ const allowed = new Set((_a = this.options.types) != null ? _a : []);
101
+ const targets = [];
102
+ state.doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
103
+ var _a2;
104
+ if (!((_a2 = node == null ? void 0 : node.type) == null ? void 0 : _a2.name)) return;
105
+ if (!allowed.has(node.type.name)) return;
106
+ targets.push({ pos, node });
107
+ });
108
+ const $from = state.selection.$from;
109
+ for (let d = $from.depth; d > 0; d--) {
110
+ const node = $from.node(d);
111
+ if (((_b = node == null ? void 0 : node.type) == null ? void 0 : _b.name) && allowed.has(node.type.name)) {
112
+ targets.unshift({ pos: $from.before(d), node });
113
+ break;
114
+ }
115
+ }
116
+ const seen = /* @__PURE__ */ new Set();
117
+ return targets.filter((t) => seen.has(t.pos) ? false : (seen.add(t.pos), true));
118
+ };
119
+ const applyDelta = (delta) => {
120
+ const step = Math.max(1, toInt(this.options.indentSize));
121
+ const maxIndent = Math.max(1, toInt(this.options.maxIndent));
122
+ return ({ state, dispatch }) => {
123
+ var _a;
124
+ const targets = getTargets(state);
125
+ if (!targets.length) return false;
126
+ const tr = state.tr;
127
+ let changed = false;
128
+ for (const { pos, node } of targets) {
129
+ const current = toInt((_a = node.attrs) == null ? void 0 : _a.indent);
130
+ const next = clamp(current + delta * step, 0, maxIndent);
131
+ if (next === current) continue;
132
+ const attrs = __spreadValues({}, node.attrs);
133
+ if (next <= 0) {
134
+ delete attrs.indent;
135
+ } else {
136
+ attrs.indent = next;
137
+ }
138
+ tr.setNodeMarkup(pos, void 0, attrs, node.marks);
139
+ changed = true;
140
+ }
141
+ if (!changed) return false;
142
+ if (dispatch) dispatch(tr);
143
+ return true;
144
+ };
145
+ };
146
+ return {
147
+ indent: () => applyDelta(1),
148
+ outdent: () => applyDelta(-1)
149
+ };
150
+ },
151
+ addKeyboardShortcuts() {
152
+ return {
153
+ Tab: () => {
154
+ return this.editor.commands.indent();
155
+ },
156
+ "Shift-Tab": () => {
157
+ return this.editor.commands.outdent();
158
+ }
159
+ };
160
+ }
161
+ });
162
+ export {
163
+ IndentOutdent
164
+ };
@@ -1,8 +1,13 @@
1
+ import { ItalicOptions } from '@tiptap/extension-italic';
1
2
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
3
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.mjs';
3
4
  import 'react';
4
5
  import '@floating-ui/react';
5
6
 
6
- declare const Italic: Mark<ExtButtonOptions>;
7
+ type ExtItalicOptions = ExtButtonOptions<ItalicOptions & {
8
+ showInBubbleMenu?: boolean;
9
+ bubbleMenuPosition?: number;
10
+ }>;
11
+ declare const Italic: Mark<ExtItalicOptions>;
7
12
 
8
13
  export { Italic };
@@ -1,8 +1,13 @@
1
+ import { ItalicOptions } from '@tiptap/extension-italic';
1
2
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.js';
3
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-B3TtT7-J.js';
3
4
  import 'react';
4
5
  import '@floating-ui/react';
5
6
 
6
- declare const Italic: Mark<ExtButtonOptions>;
7
+ type ExtItalicOptions = ExtButtonOptions<ItalicOptions & {
8
+ showInBubbleMenu?: boolean;
9
+ bubbleMenuPosition?: number;
10
+ }>;
11
+ declare const Italic: Mark<ExtItalicOptions>;
7
12
 
8
13
  export { Italic };