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.
Files changed (63) hide show
  1. package/README.md +7 -8
  2. package/dist/chunk-2YUUKIIT.mjs +149 -0
  3. package/dist/{chunk-ZLCVIW2P.mjs → chunk-7QOFJIQ3.mjs} +1 -1
  4. package/dist/chunk-D47XME55.mjs +49 -0
  5. package/dist/{chunk-TQTCTY3E.mjs → chunk-FWCSY2DS.mjs} +1 -16
  6. package/dist/{chunk-CU67RXD7.mjs → chunk-GSHINFPO.mjs} +3 -3
  7. package/dist/{chunk-E4PPKAVK.mjs → chunk-LMOTHRGQ.mjs} +1 -1
  8. package/dist/{chunk-LO4RJXQF.mjs → chunk-MBF77NHS.mjs} +1 -1
  9. package/dist/chunk-VYDH6BZE.mjs +17 -0
  10. package/dist/extension/bold.d.mts +1 -1
  11. package/dist/extension/bold.d.ts +1 -1
  12. package/dist/extension/bold.js +1 -1
  13. package/dist/extension/bold.mjs +4 -3
  14. package/dist/extension/clearformat.d.mts +8 -0
  15. package/dist/extension/clearformat.d.ts +8 -0
  16. package/dist/extension/clearformat.js +239 -0
  17. package/dist/extension/clearformat.mjs +69 -0
  18. package/dist/extension/font-family.d.mts +23 -0
  19. package/dist/extension/font-family.d.ts +23 -0
  20. package/dist/extension/font-family.js +388 -0
  21. package/dist/extension/font-family.mjs +113 -0
  22. package/dist/extension/font-size.d.mts +23 -0
  23. package/dist/extension/font-size.d.ts +23 -0
  24. package/dist/extension/font-size.js +386 -0
  25. package/dist/extension/font-size.mjs +111 -0
  26. package/dist/extension/heading.d.mts +23 -0
  27. package/dist/extension/heading.d.ts +23 -0
  28. package/dist/extension/heading.js +593 -0
  29. package/dist/extension/heading.mjs +312 -0
  30. package/dist/extension/history.d.mts +8 -0
  31. package/dist/extension/history.d.ts +8 -0
  32. package/dist/extension/history.js +296 -0
  33. package/dist/extension/history.mjs +126 -0
  34. package/dist/extension/italic.d.mts +1 -1
  35. package/dist/extension/italic.d.ts +1 -1
  36. package/dist/extension/italic.js +1 -1
  37. package/dist/extension/italic.mjs +4 -3
  38. package/dist/extension/strike.d.mts +1 -1
  39. package/dist/extension/strike.d.ts +1 -1
  40. package/dist/extension/strike.js +1 -1
  41. package/dist/extension/strike.mjs +4 -3
  42. package/dist/extension/subandsuperscript.d.mts +1 -1
  43. package/dist/extension/subandsuperscript.d.ts +1 -1
  44. package/dist/extension/subandsuperscript.js +30 -21
  45. package/dist/extension/subandsuperscript.mjs +37 -159
  46. package/dist/extension/subscript.d.mts +1 -1
  47. package/dist/extension/subscript.d.ts +1 -1
  48. package/dist/extension/subscript.js +1 -1
  49. package/dist/extension/subscript.mjs +5 -4
  50. package/dist/extension/superscript.d.mts +1 -1
  51. package/dist/extension/superscript.d.ts +1 -1
  52. package/dist/extension/superscript.js +1 -1
  53. package/dist/extension/superscript.mjs +5 -4
  54. package/dist/extension/underline.d.mts +1 -1
  55. package/dist/extension/underline.d.ts +1 -1
  56. package/dist/extension/underline.js +1 -1
  57. package/dist/extension/underline.mjs +4 -3
  58. package/dist/index.css +375 -8
  59. package/dist/index.js +1 -2
  60. package/dist/index.mjs +3 -3
  61. package/dist/{tiptap-ext.type-D61hoEX5.d.mts → tiptap-ext.type-DrneAC5G.d.mts} +8 -1
  62. package/dist/{tiptap-ext.type-D61hoEX5.d.ts → tiptap-ext.type-DrneAC5G.d.ts} +8 -1
  63. package/package.json +27 -24
@@ -0,0 +1,126 @@
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/History.tsx
12
+ import { Fragment } from "react";
13
+ import { UndoRedo } from "@tiptap/extensions";
14
+ import { useEditorState } from "@tiptap/react";
15
+
16
+ // src/lib/icon/HistoryIcon.tsx
17
+ import { jsx, jsxs } from "react/jsx-runtime";
18
+ var Redo2 = (_a) => {
19
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
20
+ return /* @__PURE__ */ jsxs(
21
+ "svg",
22
+ __spreadProps(__spreadValues({
23
+ xmlns: "http://www.w3.org/2000/svg",
24
+ viewBox: "0 0 24 24",
25
+ fill: "none",
26
+ stroke: "currentColor",
27
+ strokeWidth: 2,
28
+ strokeLinecap: "round",
29
+ strokeLinejoin: "round",
30
+ width: size,
31
+ height: size,
32
+ className
33
+ }, props), {
34
+ children: [
35
+ /* @__PURE__ */ jsx("path", { d: "m15 14 5-5-5-5" }),
36
+ /* @__PURE__ */ jsx("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" })
37
+ ]
38
+ })
39
+ );
40
+ };
41
+ var Undo2 = (_a) => {
42
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
43
+ return /* @__PURE__ */ jsxs(
44
+ "svg",
45
+ __spreadProps(__spreadValues({
46
+ xmlns: "http://www.w3.org/2000/svg",
47
+ viewBox: "0 0 24 24",
48
+ fill: "none",
49
+ stroke: "currentColor",
50
+ strokeWidth: "2",
51
+ strokeLinecap: "round",
52
+ strokeLinejoin: "round",
53
+ width: size,
54
+ height: size,
55
+ className
56
+ }, props), {
57
+ children: [
58
+ /* @__PURE__ */ jsx("path", { d: "M9 14 4 9l5-5" }),
59
+ /* @__PURE__ */ jsx("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" })
60
+ ]
61
+ })
62
+ );
63
+ };
64
+
65
+ // src/extension/History.tsx
66
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
67
+ function HistoryButtons({
68
+ editor,
69
+ options,
70
+ buttonClassName
71
+ }) {
72
+ const { canUndo, canRedo } = useEditorState({
73
+ editor,
74
+ selector: (ctx) => ({
75
+ canUndo: ctx.editor.can().chain().focus().undo().run(),
76
+ canRedo: ctx.editor.can().chain().focus().redo().run()
77
+ })
78
+ });
79
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
80
+ /* @__PURE__ */ jsx2(
81
+ ButtonWithoutActive_default,
82
+ {
83
+ className: options.className,
84
+ icon: options.icon,
85
+ style: options.style,
86
+ tooltip: options.tooltip,
87
+ tooltipClassName: options.tooltipClassName,
88
+ tooltipPlacement: options.tooltipPlacement,
89
+ _internalIcon: /* @__PURE__ */ jsx2(Undo2, {}),
90
+ _onToggle: () => editor.chain().focus().undo().run(),
91
+ _interShortcut: "\u2318 + Z",
92
+ _tooltipContent: "Undo",
93
+ _disabled: !canUndo,
94
+ _buttonClassName: buttonClassName
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsx2(
98
+ ButtonWithoutActive_default,
99
+ {
100
+ className: options.className,
101
+ icon: options.icon,
102
+ style: options.style,
103
+ tooltip: options.tooltip,
104
+ tooltipClassName: options.tooltipClassName,
105
+ tooltipPlacement: options.tooltipPlacement,
106
+ _internalIcon: /* @__PURE__ */ jsx2(Redo2, {}),
107
+ _onToggle: () => editor.chain().focus().redo().run(),
108
+ _interShortcut: "\u21E7 + \u2318 + Z",
109
+ _tooltipContent: "Redo",
110
+ _disabled: !canRedo,
111
+ _buttonClassName: buttonClassName
112
+ }
113
+ )
114
+ ] });
115
+ }
116
+ var History = UndoRedo.extend({
117
+ addOptions() {
118
+ var _a;
119
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
120
+ component: ({ editor, options, buttonClassName }) => /* @__PURE__ */ jsx2(HistoryButtons, { editor, options, buttonClassName })
121
+ });
122
+ }
123
+ });
124
+ export {
125
+ History
126
+ };
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.mjs';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.js';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.js';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -206,7 +206,7 @@ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true
206
206
  {
207
207
  onClick: _onToggle,
208
208
  className: (0, import_tailwind_merge2.twMerge)(
209
- "p-1.5 rounded-md",
209
+ "py-1.5 px-2.5 rounded-md",
210
210
  _buttonClassName,
211
211
  (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
212
212
  className,
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  ButtonComponent_default
3
- } from "../chunk-CU67RXD7.mjs";
4
- import "../chunk-ZLCVIW2P.mjs";
3
+ } from "../chunk-GSHINFPO.mjs";
4
+ import "../chunk-7QOFJIQ3.mjs";
5
+ import "../chunk-VYDH6BZE.mjs";
5
6
  import {
6
7
  __objRest,
7
8
  __spreadProps,
8
9
  __spreadValues
9
- } from "../chunk-TQTCTY3E.mjs";
10
+ } from "../chunk-FWCSY2DS.mjs";
10
11
 
11
12
  // src/extension/Italic.tsx
12
13
  import TiptapItalic from "@tiptap/extension-italic";
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.mjs';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.js';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.js';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -206,7 +206,7 @@ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true
206
206
  {
207
207
  onClick: _onToggle,
208
208
  className: (0, import_tailwind_merge2.twMerge)(
209
- "p-1.5 rounded-md",
209
+ "py-1.5 px-2.5 rounded-md",
210
210
  _buttonClassName,
211
211
  (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
212
212
  className,
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  ButtonComponent_default
3
- } from "../chunk-CU67RXD7.mjs";
4
- import "../chunk-ZLCVIW2P.mjs";
3
+ } from "../chunk-GSHINFPO.mjs";
4
+ import "../chunk-7QOFJIQ3.mjs";
5
+ import "../chunk-VYDH6BZE.mjs";
5
6
  import {
6
7
  __objRest,
7
8
  __spreadProps,
8
9
  __spreadValues
9
- } from "../chunk-TQTCTY3E.mjs";
10
+ } from "../chunk-FWCSY2DS.mjs";
10
11
 
11
12
  // src/extension/Strike.tsx
12
13
  import TiptapStrike from "@tiptap/extension-strike";
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Extension, Editor } from '@tiptap/react';
3
- import { a as ExtDropdownOptions } from '../tiptap-ext.type-D61hoEX5.mjs';
3
+ import { a as ExtDropdownOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
4
4
  import '@floating-ui/react';
5
5
 
6
6
  interface ExtSubAndSupOptions extends ExtDropdownOptions {
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Extension, Editor } from '@tiptap/react';
3
- import { a as ExtDropdownOptions } from '../tiptap-ext.type-D61hoEX5.js';
3
+ import { a as ExtDropdownOptions } from '../tiptap-ext.type-DrneAC5G.js';
4
4
  import '@floating-ui/react';
5
5
 
6
6
  interface ExtSubAndSupOptions extends ExtDropdownOptions {
@@ -300,13 +300,13 @@ var DropdownComponent = ({ children, className, showArrow = true, content, dropd
300
300
  "aria-controls": open ? listId : void 0
301
301
  })), {
302
302
  className: (0, import_tailwind_merge2.twMerge)(
303
- "p-1.5 rounded-md hover:bg-gray-100 flex gap-x-px",
303
+ "p-1.5 rounded-md hover:bg-gray-100 items-center flex gap-x-0.5",
304
304
  className
305
305
  ),
306
306
  style,
307
307
  children: [
308
308
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: content != null ? content : _internalContent }),
309
- showArrow && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ArrowIcon_default, { size: 14, className: "text-gray-500 block mt-0.5" })
309
+ showArrow && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ArrowIcon_default, { size: 14, className: "text-gray-500 block" })
310
310
  ]
311
311
  })
312
312
  );
@@ -335,7 +335,7 @@ var DropdownComponent = ({ children, className, showArrow = true, content, dropd
335
335
  initial: initialMotion,
336
336
  animate: animateMotion,
337
337
  exit: initialMotion,
338
- 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", _dropdownClassName, dropdownClassName),
338
+ 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),
339
339
  children: enhancedChildren
340
340
  })
341
341
  ) }) })
@@ -359,11 +359,11 @@ var useEditor = () => {
359
359
  // src/lib/components/DropdownItemComponent.tsx
360
360
  var import_react8 = require("@tiptap/react");
361
361
  var import_jsx_runtime8 = require("react/jsx-runtime");
362
- var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName }) => {
362
+ var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName, showKeyShortcutText = true, spClass }) => {
363
363
  const { editor } = useEditor();
364
364
  const editorState = (0, import_react8.useEditorState)({
365
365
  editor,
366
- selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.id)) || false })
366
+ selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.name, item.ext ? { level: item.ext } : void 0)) || false })
367
367
  });
368
368
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_tailwind_merge3.twMerge)(
369
369
  "flex items-center gap-x-2.5 transition-all duration-100 cursor-pointer select-none px-2 py-1.5 rounded-md",
@@ -373,8 +373,8 @@ var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _
373
373
  (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
374
374
  ), onClick: onSelect, children: [
375
375
  item.icon,
376
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "flex-1", children: item.text }),
377
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ml-6 text-gray-400", children: item.keyBind })
376
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: (0, import_tailwind_merge3.twMerge)("flex-1 text-base", spClass), style: item.style, children: item.text }),
377
+ showKeyShortcutText && item.keyBind && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ml-6 text-gray-400", children: item.keyBind })
378
378
  ] });
379
379
  };
380
380
  var DropdownItemComponent_default = DropdownItemComponent;
@@ -387,19 +387,28 @@ var SubAndSuperscript = import_react9.Extension.create({
387
387
  var _a;
388
388
  return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
389
389
  component: ({ options, editor, dropdownContainerClassName, dropdownItemClassName }) => {
390
- const list = [{
391
- icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SubIcon_default, {}),
392
- text: "Subscript",
393
- onClick: () => editor.chain().focus().toggleSubscript().run(),
394
- keyBind: "\u2318 .",
395
- id: "subscript"
396
- }, {
397
- icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SupIcon_default, {}),
398
- text: "Superscript",
399
- onClick: () => editor.chain().focus().toggleSuperscript().run(),
400
- keyBind: "\u2318 ,",
401
- id: "superscript"
402
- }];
390
+ var _a2, _b;
391
+ const list = [];
392
+ if (options.subscript !== false) {
393
+ list.push({
394
+ id: crypto.randomUUID(),
395
+ icon: (_a2 = options.subscriptIcon) != null ? _a2 : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SubIcon_default, {}),
396
+ text: typeof options.subscript === "string" ? options.subscript : "Subscript",
397
+ onClick: () => editor.chain().focus().toggleSubscript().run(),
398
+ keyBind: "\u2318 .",
399
+ name: "subscript"
400
+ });
401
+ }
402
+ if (options.superscript !== false) {
403
+ list.push({
404
+ id: crypto.randomUUID(),
405
+ icon: (_b = options.superscriptIcon) != null ? _b : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SupIcon_default, {}),
406
+ text: typeof options.superscript === "string" ? options.superscript : "Superscript",
407
+ onClick: () => editor.chain().focus().toggleSuperscript().run(),
408
+ keyBind: "\u2318 ,",
409
+ name: "superscript"
410
+ });
411
+ }
403
412
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
404
413
  DropdownComponent_default,
405
414
  {
@@ -411,7 +420,7 @@ var SubAndSuperscript = import_react9.Extension.create({
411
420
  tooltip: options.tooltip,
412
421
  tooltipClassName: options.tooltipClassName,
413
422
  tooltipPlacement: options.tooltipPlacement,
414
- _tooltipContent: "More text styles",
423
+ _tooltipContent: "Sub & Superscript",
415
424
  _internalContent: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SubAndSupIcon_default, {}),
416
425
  _dropdownClassName: dropdownContainerClassName,
417
426
  children: list.map((item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -1,18 +1,20 @@
1
+ import {
2
+ DropdownComponent_default,
3
+ DropdownItemComponent_default
4
+ } from "../chunk-2YUUKIIT.mjs";
1
5
  import {
2
6
  SubIcon_default
3
- } from "../chunk-LO4RJXQF.mjs";
7
+ } from "../chunk-MBF77NHS.mjs";
4
8
  import {
5
9
  SupIcon_default
6
- } from "../chunk-E4PPKAVK.mjs";
7
- import {
8
- Tooltip_default
9
- } from "../chunk-ZLCVIW2P.mjs";
10
+ } from "../chunk-LMOTHRGQ.mjs";
11
+ import "../chunk-7QOFJIQ3.mjs";
12
+ import "../chunk-VYDH6BZE.mjs";
10
13
  import {
11
14
  __objRest,
12
15
  __spreadProps,
13
- __spreadValues,
14
- useEditor
15
- } from "../chunk-TQTCTY3E.mjs";
16
+ __spreadValues
17
+ } from "../chunk-FWCSY2DS.mjs";
16
18
 
17
19
  // src/extension/SubAndSuperscript.tsx
18
20
  import { Extension } from "@tiptap/react";
@@ -47,161 +49,37 @@ var SubAndSupIcon = (_a) => {
47
49
  };
48
50
  var SubAndSupIcon_default = SubAndSupIcon;
49
51
 
50
- // src/lib/components/DropdownComponent.tsx
51
- import { useState, Fragment, useId, Children, isValidElement, cloneElement } from "react";
52
- import { twMerge } from "tailwind-merge";
53
- import { useFloating, offset, flip, shift, autoUpdate, useInteractions, useClick, useDismiss, FloatingPortal } from "@floating-ui/react";
54
-
55
- // src/lib/icon/ArrowIcon.tsx
56
- import { jsx as jsx2 } from "react/jsx-runtime";
57
- var ArrowIcon = (_a) => {
58
- var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
59
- return /* @__PURE__ */ jsx2(
60
- "svg",
61
- __spreadProps(__spreadValues({
62
- xmlns: "http://www.w3.org/2000/svg",
63
- viewBox: "0 0 48 48",
64
- fill: "none",
65
- stroke: "currentColor",
66
- strokeWidth: 2,
67
- strokeLinecap: "round",
68
- strokeLinejoin: "round",
69
- width: size,
70
- height: size,
71
- className
72
- }, props), {
73
- children: /* @__PURE__ */ jsx2("path", { fill: "currentColor", stroke: "currentColor", strokeLinejoin: "round", strokeWidth: "4", d: "M36 19L24 31L12 19z" })
74
- })
75
- );
76
- };
77
- var ArrowIcon_default = ArrowIcon;
78
-
79
- // src/lib/components/DropdownComponent.tsx
80
- import { AnimatePresence, motion } from "motion/react";
81
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
82
- var DropdownComponent = ({ children, className, showArrow = true, content, dropdownClassName, style, tooltip, tooltipClassName, tooltipPlacement, _tooltipContent, _internalContent, _dropdownClassName }) => {
83
- const [open, setOpen] = useState(false);
84
- const { x, y, refs, strategy, context } = useFloating({
85
- open,
86
- onOpenChange: setOpen,
87
- placement: "bottom",
88
- middleware: [offset(4), flip(), shift({ padding: 8 })],
89
- whileElementsMounted: autoUpdate
90
- });
91
- const click = useClick(context);
92
- const dismiss = useDismiss(context);
93
- const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]);
94
- const listId = useId();
95
- const tooltipContent = /* @__PURE__ */ jsx3("p", { children: typeof tooltip === "string" ? tooltip : _tooltipContent });
96
- const initialMotion = { opacity: 0, scale: 0.95 };
97
- const animateMotion = { opacity: 1, scale: 1 };
98
- const enhancedChildren = Children.map(children, (child) => {
99
- if (!isValidElement(child)) return child;
100
- if (!("onSelect" in child.props)) return child;
101
- const prevOnSelect = child.props.onSelect;
102
- const combinedOnSelect = () => {
103
- prevOnSelect == null ? void 0 : prevOnSelect();
104
- setOpen(false);
105
- };
106
- return cloneElement(child, { onSelect: combinedOnSelect });
107
- });
108
- const btn = /* @__PURE__ */ jsxs2(
109
- "button",
110
- __spreadProps(__spreadValues({}, getReferenceProps({
111
- ref: refs.setReference,
112
- type: "button",
113
- "aria-controls": open ? listId : void 0
114
- })), {
115
- className: twMerge(
116
- "p-1.5 rounded-md hover:bg-gray-100 flex gap-x-px",
117
- className
118
- ),
119
- style,
120
- children: [
121
- /* @__PURE__ */ jsx3("span", { children: content != null ? content : _internalContent }),
122
- showArrow && /* @__PURE__ */ jsx3(ArrowIcon_default, { size: 14, className: "text-gray-500 block mt-0.5" })
123
- ]
124
- })
125
- );
126
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
127
- tooltip === false ? btn : /* @__PURE__ */ jsx3(
128
- Tooltip_default,
129
- {
130
- content: tooltipContent,
131
- className: tooltipClassName,
132
- placement: tooltipPlacement,
133
- children: btn
134
- }
135
- ),
136
- /* @__PURE__ */ jsx3(FloatingPortal, { children: /* @__PURE__ */ jsx3(AnimatePresence, { children: open && /* @__PURE__ */ jsx3(
137
- motion.div,
138
- __spreadProps(__spreadValues({}, getFloatingProps({
139
- ref: refs.setFloating,
140
- style: {
141
- position: strategy,
142
- top: y != null ? y : 0,
143
- left: x != null ? x : 0
144
- },
145
- role: "listbox",
146
- id: listId
147
- })), {
148
- initial: initialMotion,
149
- animate: animateMotion,
150
- exit: initialMotion,
151
- className: twMerge("bg-white border border-solid border-gray-200 p-2 space-y-1 rounded-lg shadow-sm shadow-gray-200/40", _dropdownClassName, dropdownClassName),
152
- children: enhancedChildren
153
- })
154
- ) }) })
155
- ] });
156
- };
157
- var DropdownComponent_default = DropdownComponent;
158
-
159
- // src/lib/components/DropdownItemComponent.tsx
160
- import { twMerge as twMerge2 } from "tailwind-merge";
161
- import { useEditorState } from "@tiptap/react";
162
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
163
- var DropdownItemComponent = ({ item, onSelect, activeClassName, itemClassName, _itemClassName }) => {
164
- const { editor } = useEditor();
165
- const editorState = useEditorState({
166
- editor,
167
- selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(item.id)) || false })
168
- });
169
- return /* @__PURE__ */ jsxs3("div", { className: twMerge2(
170
- "flex items-center gap-x-2.5 transition-all duration-100 cursor-pointer select-none px-2 py-1.5 rounded-md",
171
- _itemClassName,
172
- (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
173
- itemClassName,
174
- (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
175
- ), onClick: onSelect, children: [
176
- item.icon,
177
- /* @__PURE__ */ jsx4("span", { className: "flex-1", children: item.text }),
178
- /* @__PURE__ */ jsx4("span", { className: "ml-6 text-gray-400", children: item.keyBind })
179
- ] });
180
- };
181
- var DropdownItemComponent_default = DropdownItemComponent;
182
-
183
52
  // src/extension/SubAndSuperscript.tsx
184
- import { jsx as jsx5 } from "react/jsx-runtime";
53
+ import { jsx as jsx2 } from "react/jsx-runtime";
185
54
  var SubAndSuperscript = Extension.create({
186
55
  name: "subAndSuperScript",
187
56
  addOptions() {
188
57
  var _a;
189
58
  return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
190
59
  component: ({ options, editor, dropdownContainerClassName, dropdownItemClassName }) => {
191
- const list = [{
192
- icon: /* @__PURE__ */ jsx5(SubIcon_default, {}),
193
- text: "Subscript",
194
- onClick: () => editor.chain().focus().toggleSubscript().run(),
195
- keyBind: "\u2318 .",
196
- id: "subscript"
197
- }, {
198
- icon: /* @__PURE__ */ jsx5(SupIcon_default, {}),
199
- text: "Superscript",
200
- onClick: () => editor.chain().focus().toggleSuperscript().run(),
201
- keyBind: "\u2318 ,",
202
- id: "superscript"
203
- }];
204
- return /* @__PURE__ */ jsx5(
60
+ var _a2, _b;
61
+ const list = [];
62
+ if (options.subscript !== false) {
63
+ list.push({
64
+ id: crypto.randomUUID(),
65
+ icon: (_a2 = options.subscriptIcon) != null ? _a2 : /* @__PURE__ */ jsx2(SubIcon_default, {}),
66
+ text: typeof options.subscript === "string" ? options.subscript : "Subscript",
67
+ onClick: () => editor.chain().focus().toggleSubscript().run(),
68
+ keyBind: "\u2318 .",
69
+ name: "subscript"
70
+ });
71
+ }
72
+ if (options.superscript !== false) {
73
+ list.push({
74
+ id: crypto.randomUUID(),
75
+ icon: (_b = options.superscriptIcon) != null ? _b : /* @__PURE__ */ jsx2(SupIcon_default, {}),
76
+ text: typeof options.superscript === "string" ? options.superscript : "Superscript",
77
+ onClick: () => editor.chain().focus().toggleSuperscript().run(),
78
+ keyBind: "\u2318 ,",
79
+ name: "superscript"
80
+ });
81
+ }
82
+ return /* @__PURE__ */ jsx2(
205
83
  DropdownComponent_default,
206
84
  {
207
85
  className: options.className,
@@ -212,10 +90,10 @@ var SubAndSuperscript = Extension.create({
212
90
  tooltip: options.tooltip,
213
91
  tooltipClassName: options.tooltipClassName,
214
92
  tooltipPlacement: options.tooltipPlacement,
215
- _tooltipContent: "More text styles",
216
- _internalContent: /* @__PURE__ */ jsx5(SubAndSupIcon_default, {}),
93
+ _tooltipContent: "Sub & Superscript",
94
+ _internalContent: /* @__PURE__ */ jsx2(SubAndSupIcon_default, {}),
217
95
  _dropdownClassName: dropdownContainerClassName,
218
- children: list.map((item) => /* @__PURE__ */ jsx5(
96
+ children: list.map((item) => /* @__PURE__ */ jsx2(
219
97
  DropdownItemComponent_default,
220
98
  {
221
99
  onSelect: item.onClick,
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.mjs';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.js';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.js';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -206,7 +206,7 @@ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true
206
206
  {
207
207
  onClick: _onToggle,
208
208
  className: (0, import_tailwind_merge2.twMerge)(
209
- "p-1.5 rounded-md",
209
+ "py-1.5 px-2.5 rounded-md",
210
210
  _buttonClassName,
211
211
  (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
212
212
  className,
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  ButtonComponent_default
3
- } from "../chunk-CU67RXD7.mjs";
3
+ } from "../chunk-GSHINFPO.mjs";
4
4
  import {
5
5
  SubIcon_default
6
- } from "../chunk-LO4RJXQF.mjs";
7
- import "../chunk-ZLCVIW2P.mjs";
6
+ } from "../chunk-MBF77NHS.mjs";
7
+ import "../chunk-7QOFJIQ3.mjs";
8
+ import "../chunk-VYDH6BZE.mjs";
8
9
  import {
9
10
  __spreadProps,
10
11
  __spreadValues
11
- } from "../chunk-TQTCTY3E.mjs";
12
+ } from "../chunk-FWCSY2DS.mjs";
12
13
 
13
14
  // src/extension/Subscript.tsx
14
15
  import TiptapSubscript from "@tiptap/extension-subscript";
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.mjs';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.mjs';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/react';
2
- import { E as ExtButtonOptions } from '../tiptap-ext.type-D61hoEX5.js';
2
+ import { E as ExtButtonOptions } from '../tiptap-ext.type-DrneAC5G.js';
3
3
  import 'react';
4
4
  import '@floating-ui/react';
5
5
 
@@ -206,7 +206,7 @@ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true
206
206
  {
207
207
  onClick: _onToggle,
208
208
  className: (0, import_tailwind_merge2.twMerge)(
209
- "p-1.5 rounded-md",
209
+ "py-1.5 px-2.5 rounded-md",
210
210
  _buttonClassName,
211
211
  (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200/60" : "hover:bg-gray-100",
212
212
  className,
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  ButtonComponent_default
3
- } from "../chunk-CU67RXD7.mjs";
3
+ } from "../chunk-GSHINFPO.mjs";
4
4
  import {
5
5
  SupIcon_default
6
- } from "../chunk-E4PPKAVK.mjs";
7
- import "../chunk-ZLCVIW2P.mjs";
6
+ } from "../chunk-LMOTHRGQ.mjs";
7
+ import "../chunk-7QOFJIQ3.mjs";
8
+ import "../chunk-VYDH6BZE.mjs";
8
9
  import {
9
10
  __spreadProps,
10
11
  __spreadValues
11
- } from "../chunk-TQTCTY3E.mjs";
12
+ } from "../chunk-FWCSY2DS.mjs";
12
13
 
13
14
  // src/extension/Superscript.tsx
14
15
  import TiptapSuperscript from "@tiptap/extension-superscript";