ritext 1.0.10 → 1.0.12

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 CHANGED
@@ -11,7 +11,36 @@ Ritext is a modern WYSIWYG rich text editor built with Tailwind CSS, powered by
11
11
 
12
12
  <a href="https://www.buymeacoffee.com/siamahnaf" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
13
13
 
14
- # This is an testing phase will publish soon.
14
+ ### This is an testing phase will publish soon.
15
+
16
+ # Extension Roadmap
17
+ - [x] Starter Kit
18
+ - [x] Bold
19
+ - [x] Italic
20
+ - [x] Underline
21
+ - [x] Strike
22
+ - [ ] Subscript
23
+ - [ ] Superscript
24
+ - [ ] Format Painter
25
+ - [ ] Clear Format
26
+ - [ ] Font Family
27
+ - [ ] Heading
28
+ - [ ] Fonts Size
29
+ - [ ] Undo
30
+ - [ ] Redo
31
+ - [ ] Emoji
32
+ - [ ] Color
33
+ - [ ] Highlight
34
+ - [ ] Bullet List
35
+ - [ ] Ordered List
36
+ - [ ] Alignment
37
+ - [ ] Indent
38
+ - [ ] Outdent
39
+ - [ ] Line Height
40
+ - [ ] Task List
41
+ - [ ] Image
42
+ - [ ] Link
43
+ - [ ] Blockquote
15
44
 
16
45
  # Stay in touch
17
46
 
package/dist/index.css CHANGED
@@ -226,6 +226,12 @@
226
226
  }
227
227
  }
228
228
  @layer utilities {
229
+ .flex {
230
+ display: flex;
231
+ }
232
+ .gap-x-1\.5 {
233
+ column-gap: calc(var(--spacing) * 1.5);
234
+ }
229
235
  .rounded-lg {
230
236
  border-radius: var(--radius-lg);
231
237
  }
@@ -268,6 +274,12 @@
268
274
  font-size: var(--text-sm);
269
275
  line-height: var(--tw-leading, var(--text-sm--line-height));
270
276
  }
277
+ .italic {
278
+ font-style: italic;
279
+ }
280
+ .underline {
281
+ text-decoration-line: underline;
282
+ }
271
283
  .shadow-lg {
272
284
  --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
273
285
  box-shadow:
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
- import { Extensions, Mark } from '@tiptap/react';
3
+ import { Extensions, Editor as Editor$1, Mark } from '@tiptap/react';
4
4
  import { Placement } from '@floating-ui/react';
5
5
 
6
6
  interface Props$2 {
@@ -12,15 +12,16 @@ declare const Editor: ({ children, extensions, className }: Props$2) => react_js
12
12
 
13
13
  interface Props$1 {
14
14
  className?: string;
15
+ buttonClassName?: string;
15
16
  }
16
- declare const Toolbar: ({ className }: Props$1) => react_jsx_runtime.JSX.Element | null;
17
+ declare const Toolbar: ({ className, buttonClassName }: Props$1) => react_jsx_runtime.JSX.Element | null;
17
18
 
18
19
  interface Props {
19
20
  className?: string;
20
21
  }
21
22
  declare const Content: ({ className }: Props) => react_jsx_runtime.JSX.Element;
22
23
 
23
- type BoldOptions = {
24
+ type ExtButtonOptions = {
24
25
  className?: string;
25
26
  activeClassName?: string;
26
27
  icon?: ReactNode;
@@ -29,9 +30,18 @@ type BoldOptions = {
29
30
  tooltipClassName?: string;
30
31
  tooltipPlacement?: Placement;
31
32
  button: (args: {
32
- options: BoldOptions;
33
+ options: ExtButtonOptions;
34
+ editor: Editor$1;
35
+ buttonClassName: string;
33
36
  }) => ReactNode;
34
37
  };
35
- declare const Bold: Mark<BoldOptions, any>;
36
38
 
37
- export { Bold, Content, Editor, Toolbar };
39
+ declare const Bold: Mark<ExtButtonOptions, any>;
40
+
41
+ declare const Italic: Mark<ExtButtonOptions, any>;
42
+
43
+ declare const Underline: Mark<ExtButtonOptions, any>;
44
+
45
+ declare const Strike: Mark<ExtButtonOptions, any>;
46
+
47
+ export { Bold, Content, Editor, Italic, Strike, Toolbar, Underline };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
- import { Extensions, Mark } from '@tiptap/react';
3
+ import { Extensions, Editor as Editor$1, Mark } from '@tiptap/react';
4
4
  import { Placement } from '@floating-ui/react';
5
5
 
6
6
  interface Props$2 {
@@ -12,15 +12,16 @@ declare const Editor: ({ children, extensions, className }: Props$2) => react_js
12
12
 
13
13
  interface Props$1 {
14
14
  className?: string;
15
+ buttonClassName?: string;
15
16
  }
16
- declare const Toolbar: ({ className }: Props$1) => react_jsx_runtime.JSX.Element | null;
17
+ declare const Toolbar: ({ className, buttonClassName }: Props$1) => react_jsx_runtime.JSX.Element | null;
17
18
 
18
19
  interface Props {
19
20
  className?: string;
20
21
  }
21
22
  declare const Content: ({ className }: Props) => react_jsx_runtime.JSX.Element;
22
23
 
23
- type BoldOptions = {
24
+ type ExtButtonOptions = {
24
25
  className?: string;
25
26
  activeClassName?: string;
26
27
  icon?: ReactNode;
@@ -29,9 +30,18 @@ type BoldOptions = {
29
30
  tooltipClassName?: string;
30
31
  tooltipPlacement?: Placement;
31
32
  button: (args: {
32
- options: BoldOptions;
33
+ options: ExtButtonOptions;
34
+ editor: Editor$1;
35
+ buttonClassName: string;
33
36
  }) => ReactNode;
34
37
  };
35
- declare const Bold: Mark<BoldOptions, any>;
36
38
 
37
- export { Bold, Content, Editor, Toolbar };
39
+ declare const Bold: Mark<ExtButtonOptions, any>;
40
+
41
+ declare const Italic: Mark<ExtButtonOptions, any>;
42
+
43
+ declare const Underline: Mark<ExtButtonOptions, any>;
44
+
45
+ declare const Strike: Mark<ExtButtonOptions, any>;
46
+
47
+ export { Bold, Content, Editor, Italic, Strike, Toolbar, Underline };
package/dist/index.js CHANGED
@@ -62,7 +62,10 @@ __export(index_exports, {
62
62
  Bold: () => Bold,
63
63
  Content: () => Content_default,
64
64
  Editor: () => Editor_default,
65
- Toolbar: () => Toolbar_default
65
+ Italic: () => Italic,
66
+ Strike: () => Strike,
67
+ Toolbar: () => Toolbar_default,
68
+ Underline: () => Underline
66
69
  });
67
70
  module.exports = __toCommonJS(index_exports);
68
71
 
@@ -102,17 +105,17 @@ var Editor_default = Editor;
102
105
  var React = __toESM(require("react"));
103
106
  var import_tailwind_merge = require("tailwind-merge");
104
107
  var import_jsx_runtime3 = require("react/jsx-runtime");
105
- var Toolbar = ({ className }) => {
108
+ var Toolbar = ({ className, buttonClassName }) => {
106
109
  const { editor } = useEditor();
107
110
  if (!editor) return null;
108
111
  const entries = editor.extensionManager.extensions.map((ext) => {
109
112
  var _a, _b, _c;
110
113
  const anyExt = ext;
111
114
  const renderButton = ((_a = anyExt.options) == null ? void 0 : _a.button) || ((_c = (_b = anyExt.options) == null ? void 0 : _b.ui) == null ? void 0 : _c.button);
112
- return renderButton ? { name: anyExt.name, renderButton, options: anyExt.options } : null;
115
+ return renderButton ? { name: anyExt.name, renderButton, options: anyExt.options, buttonClassName: anyExt.buttonClassName } : null;
113
116
  }).filter(Boolean);
114
117
  if (!entries.length) return null;
115
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_tailwind_merge.twMerge)("", className), children: entries.map(({ name, renderButton, options }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(React.Fragment, { children: renderButton({ editor, options }) }, name)) });
118
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_tailwind_merge.twMerge)("flex gap-x-1.5", className), children: entries.map(({ name, renderButton, options }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(React.Fragment, { children: renderButton({ editor, options, buttonClassName: buttonClassName || "" }) }, name)) });
116
119
  };
117
120
  var Toolbar_default = Toolbar;
118
121
 
@@ -129,19 +132,10 @@ var Content_default = Content;
129
132
  // src/lib/extensions/Bold.tsx
130
133
  var import_extension_bold = __toESM(require("@tiptap/extension-bold"));
131
134
 
132
- // src/lib/components/BoldComponent.tsx
133
- var import_tailwind_merge4 = require("tailwind-merge");
134
-
135
135
  // src/lib/icon/BoldIcon.tsx
136
136
  var import_jsx_runtime5 = require("react/jsx-runtime");
137
137
  var BoldIcon = (_a) => {
138
- var _b = _a, {
139
- size = 17,
140
- className
141
- } = _b, props = __objRest(_b, [
142
- "size",
143
- "className"
144
- ]);
138
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
145
139
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
146
140
  "svg",
147
141
  __spreadProps(__spreadValues({
@@ -162,6 +156,9 @@ var BoldIcon = (_a) => {
162
156
  };
163
157
  var BoldIcon_default = BoldIcon;
164
158
 
159
+ // src/lib/components/ButtonComponent.tsx
160
+ var import_tailwind_merge4 = require("tailwind-merge");
161
+
165
162
  // src/lib/components/_com/Tooltip.tsx
166
163
  var import_react5 = require("react");
167
164
  var import_react6 = require("@floating-ui/react");
@@ -242,32 +239,33 @@ var Tooltip = ({ placement = "top", children, content, className }) => {
242
239
  };
243
240
  var Tooltip_default = Tooltip;
244
241
 
245
- // src/lib/components/BoldComponent.tsx
242
+ // src/lib/components/ButtonComponent.tsx
246
243
  var import_react8 = require("@tiptap/react");
247
244
  var import_jsx_runtime7 = require("react/jsx-runtime");
248
- var BoldComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement }) => {
245
+ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
249
246
  const { editor } = useEditor();
250
247
  const editorState = (0, import_react8.useEditorState)({
251
248
  editor,
252
- selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive("bold")) || false })
249
+ selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
253
250
  });
254
251
  const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { children: [
255
- typeof tooltip === "string" ? tooltip : "Bold",
252
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
256
253
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("br", {}),
257
- "\u2318 + B"
254
+ _interShortcut
258
255
  ] });
259
256
  const btn = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
260
257
  "button",
261
258
  {
262
- onClick: () => editor == null ? void 0 : editor.chain().focus().toggleBold().run(),
259
+ onClick: _onToggle,
263
260
  className: (0, import_tailwind_merge4.twMerge)(
264
261
  "p-1.5 rounded-md",
262
+ _buttonClassName,
265
263
  (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200" : "hover:bg-gray-100",
266
264
  className,
267
265
  (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
268
266
  ),
269
267
  style,
270
- children: icon != null ? icon : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BoldIcon_default, {})
268
+ children: icon != null ? icon : _internalIcon
271
269
  }
272
270
  );
273
271
  if (tooltip === false) return btn;
@@ -281,7 +279,7 @@ var BoldComponent = ({ className, activeClassName, icon, style, tooltip = true,
281
279
  }
282
280
  );
283
281
  };
284
- var BoldComponent_default = BoldComponent;
282
+ var ButtonComponent_default = ButtonComponent;
285
283
 
286
284
  // src/lib/extensions/Bold.tsx
287
285
  var import_jsx_runtime8 = require("react/jsx-runtime");
@@ -289,9 +287,191 @@ var Bold = import_extension_bold.default.extend({
289
287
  addOptions() {
290
288
  var _a;
291
289
  return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
292
- button: ({ options }) => {
290
+ button: ({ editor, options, buttonClassName }) => {
293
291
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
294
- BoldComponent_default,
292
+ ButtonComponent_default,
293
+ {
294
+ className: options.className,
295
+ icon: options.icon,
296
+ style: options.style,
297
+ activeClassName: options.activeClassName,
298
+ tooltip: options.tooltip,
299
+ tooltipClassName: options.tooltipClassName,
300
+ tooltipPlacement: options.tooltipPlacement,
301
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BoldIcon_default, {}),
302
+ _extName: "bold",
303
+ _onToggle: () => editor.chain().focus().toggleBold().run(),
304
+ _interShortcut: "\u2318 + B",
305
+ _tooltipContent: "Bold",
306
+ _buttonClassName: buttonClassName
307
+ }
308
+ );
309
+ }
310
+ });
311
+ }
312
+ });
313
+
314
+ // src/lib/extensions/Italic.tsx
315
+ var import_extension_italic = __toESM(require("@tiptap/extension-italic"));
316
+
317
+ // src/lib/icon/ItalicIcon.tsx
318
+ var import_jsx_runtime9 = require("react/jsx-runtime");
319
+ var ItalicIcon = (_a) => {
320
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
321
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
322
+ "svg",
323
+ __spreadProps(__spreadValues({
324
+ xmlns: "http://www.w3.org/2000/svg",
325
+ viewBox: "0 0 24 24",
326
+ fill: "none",
327
+ stroke: "currentColor",
328
+ strokeWidth: 2,
329
+ strokeLinecap: "round",
330
+ strokeLinejoin: "round",
331
+ width: size,
332
+ height: size,
333
+ className
334
+ }, props), {
335
+ children: [
336
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
337
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
338
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
339
+ ]
340
+ })
341
+ );
342
+ };
343
+ var ItalicIcon_default = ItalicIcon;
344
+
345
+ // src/lib/extensions/Italic.tsx
346
+ var import_jsx_runtime10 = require("react/jsx-runtime");
347
+ var Italic = import_extension_italic.default.extend({
348
+ addOptions() {
349
+ var _a;
350
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
351
+ button: ({ options, editor, buttonClassName }) => {
352
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
353
+ ButtonComponent_default,
354
+ {
355
+ className: options.className,
356
+ icon: options.icon,
357
+ style: options.style,
358
+ activeClassName: options.activeClassName,
359
+ tooltip: options.tooltip,
360
+ tooltipClassName: options.tooltipClassName,
361
+ tooltipPlacement: options.tooltipPlacement,
362
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ItalicIcon_default, {}),
363
+ _extName: "italic",
364
+ _onToggle: () => editor.chain().focus().toggleItalic().run(),
365
+ _interShortcut: "\u2318 + I",
366
+ _tooltipContent: "Italic",
367
+ _buttonClassName: buttonClassName
368
+ }
369
+ );
370
+ }
371
+ });
372
+ }
373
+ });
374
+
375
+ // src/lib/extensions/Underline.tsx
376
+ var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
377
+
378
+ // src/lib/icon/UnderIcon.tsx
379
+ var import_jsx_runtime11 = require("react/jsx-runtime");
380
+ var UnderIcon = (_a) => {
381
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
382
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
383
+ "svg",
384
+ __spreadProps(__spreadValues({
385
+ xmlns: "http://www.w3.org/2000/svg",
386
+ viewBox: "0 0 24 24",
387
+ fill: "none",
388
+ stroke: "currentColor",
389
+ strokeWidth: 2,
390
+ strokeLinecap: "round",
391
+ strokeLinejoin: "round",
392
+ width: size,
393
+ height: size,
394
+ className
395
+ }, props), {
396
+ children: [
397
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
398
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
399
+ ]
400
+ })
401
+ );
402
+ };
403
+ var UnderIcon_default = UnderIcon;
404
+
405
+ // src/lib/extensions/Underline.tsx
406
+ var import_jsx_runtime12 = require("react/jsx-runtime");
407
+ var Underline = import_extension_underline.default.extend({
408
+ addOptions() {
409
+ var _a;
410
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
411
+ button: ({ options, editor, buttonClassName }) => {
412
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
413
+ ButtonComponent_default,
414
+ {
415
+ className: options.className,
416
+ icon: options.icon,
417
+ style: options.style,
418
+ activeClassName: options.activeClassName,
419
+ tooltip: options.tooltip,
420
+ tooltipClassName: options.tooltipClassName,
421
+ tooltipPlacement: options.tooltipPlacement,
422
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(UnderIcon_default, {}),
423
+ _extName: "underline",
424
+ _onToggle: () => editor.chain().focus().toggleUnderline().run(),
425
+ _interShortcut: "\u2318 + U",
426
+ _tooltipContent: "Underline",
427
+ _buttonClassName: buttonClassName
428
+ }
429
+ );
430
+ }
431
+ });
432
+ }
433
+ });
434
+
435
+ // src/lib/extensions/Strike.tsx
436
+ var import_extension_strike = __toESM(require("@tiptap/extension-strike"));
437
+
438
+ // src/lib/icon/StrikeIcon.tsx
439
+ var import_jsx_runtime13 = require("react/jsx-runtime");
440
+ var StrikeIcon = (_a) => {
441
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
442
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
443
+ "svg",
444
+ __spreadProps(__spreadValues({
445
+ xmlns: "http://www.w3.org/2000/svg",
446
+ viewBox: "0 0 24 24",
447
+ fill: "none",
448
+ stroke: "currentColor",
449
+ strokeWidth: 2,
450
+ strokeLinecap: "round",
451
+ strokeLinejoin: "round",
452
+ width: size,
453
+ height: size,
454
+ className
455
+ }, props), {
456
+ children: [
457
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
458
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
459
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("line", { x1: "4", x2: "20", y1: "12", y2: "12" })
460
+ ]
461
+ })
462
+ );
463
+ };
464
+ var StrikeIcon_default = StrikeIcon;
465
+
466
+ // src/lib/extensions/Strike.tsx
467
+ var import_jsx_runtime14 = require("react/jsx-runtime");
468
+ var Strike = import_extension_strike.default.extend({
469
+ addOptions() {
470
+ var _a;
471
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
472
+ button: ({ options, editor, buttonClassName }) => {
473
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
474
+ ButtonComponent_default,
295
475
  {
296
476
  className: options.className,
297
477
  icon: options.icon,
@@ -299,7 +479,13 @@ var Bold = import_extension_bold.default.extend({
299
479
  activeClassName: options.activeClassName,
300
480
  tooltip: options.tooltip,
301
481
  tooltipClassName: options.tooltipClassName,
302
- tooltipPlacement: options.tooltipPlacement
482
+ tooltipPlacement: options.tooltipPlacement,
483
+ _internalIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(StrikeIcon_default, {}),
484
+ _extName: "strike",
485
+ _onToggle: () => editor.chain().focus().toggleStrike().run(),
486
+ _interShortcut: "\u2318 \u21E7 S",
487
+ _tooltipContent: "Strike",
488
+ _buttonClassName: buttonClassName
303
489
  }
304
490
  );
305
491
  }
@@ -311,5 +497,8 @@ var Bold = import_extension_bold.default.extend({
311
497
  Bold,
312
498
  Content,
313
499
  Editor,
314
- Toolbar
500
+ Italic,
501
+ Strike,
502
+ Toolbar,
503
+ Underline
315
504
  });
package/dist/index.mjs CHANGED
@@ -66,17 +66,17 @@ var Editor_default = Editor;
66
66
  import * as React from "react";
67
67
  import { twMerge } from "tailwind-merge";
68
68
  import { jsx as jsx3 } from "react/jsx-runtime";
69
- var Toolbar = ({ className }) => {
69
+ var Toolbar = ({ className, buttonClassName }) => {
70
70
  const { editor } = useEditor();
71
71
  if (!editor) return null;
72
72
  const entries = editor.extensionManager.extensions.map((ext) => {
73
73
  var _a, _b, _c;
74
74
  const anyExt = ext;
75
75
  const renderButton = ((_a = anyExt.options) == null ? void 0 : _a.button) || ((_c = (_b = anyExt.options) == null ? void 0 : _b.ui) == null ? void 0 : _c.button);
76
- return renderButton ? { name: anyExt.name, renderButton, options: anyExt.options } : null;
76
+ return renderButton ? { name: anyExt.name, renderButton, options: anyExt.options, buttonClassName: anyExt.buttonClassName } : null;
77
77
  }).filter(Boolean);
78
78
  if (!entries.length) return null;
79
- return /* @__PURE__ */ jsx3("div", { className: twMerge("", className), children: entries.map(({ name, renderButton, options }) => /* @__PURE__ */ jsx3(React.Fragment, { children: renderButton({ editor, options }) }, name)) });
79
+ return /* @__PURE__ */ jsx3("div", { className: twMerge("flex gap-x-1.5", className), children: entries.map(({ name, renderButton, options }) => /* @__PURE__ */ jsx3(React.Fragment, { children: renderButton({ editor, options, buttonClassName: buttonClassName || "" }) }, name)) });
80
80
  };
81
81
  var Toolbar_default = Toolbar;
82
82
 
@@ -93,19 +93,10 @@ var Content_default = Content;
93
93
  // src/lib/extensions/Bold.tsx
94
94
  import TiptapBold from "@tiptap/extension-bold";
95
95
 
96
- // src/lib/components/BoldComponent.tsx
97
- import { twMerge as twMerge4 } from "tailwind-merge";
98
-
99
96
  // src/lib/icon/BoldIcon.tsx
100
97
  import { jsx as jsx5 } from "react/jsx-runtime";
101
98
  var BoldIcon = (_a) => {
102
- var _b = _a, {
103
- size = 17,
104
- className
105
- } = _b, props = __objRest(_b, [
106
- "size",
107
- "className"
108
- ]);
99
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
109
100
  return /* @__PURE__ */ jsx5(
110
101
  "svg",
111
102
  __spreadProps(__spreadValues({
@@ -126,6 +117,9 @@ var BoldIcon = (_a) => {
126
117
  };
127
118
  var BoldIcon_default = BoldIcon;
128
119
 
120
+ // src/lib/components/ButtonComponent.tsx
121
+ import { twMerge as twMerge4 } from "tailwind-merge";
122
+
129
123
  // src/lib/components/_com/Tooltip.tsx
130
124
  import { useState, Fragment as Fragment2, cloneElement, isValidElement, useId } from "react";
131
125
  import { useFloating, offset, flip, shift, autoUpdate, useInteractions, useHover, useDismiss, FloatingPortal } from "@floating-ui/react";
@@ -206,32 +200,33 @@ var Tooltip = ({ placement = "top", children, content, className }) => {
206
200
  };
207
201
  var Tooltip_default = Tooltip;
208
202
 
209
- // src/lib/components/BoldComponent.tsx
203
+ // src/lib/components/ButtonComponent.tsx
210
204
  import { useEditorState } from "@tiptap/react";
211
205
  import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
212
- var BoldComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement }) => {
206
+ var ButtonComponent = ({ className, activeClassName, icon, style, tooltip = true, tooltipClassName, tooltipPlacement, _extName, _internalIcon, _tooltipContent, _onToggle, _interShortcut, _buttonClassName }) => {
213
207
  const { editor } = useEditor();
214
208
  const editorState = useEditorState({
215
209
  editor,
216
- selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive("bold")) || false })
210
+ selector: ({ editor: editor2 }) => ({ isActive: (editor2 == null ? void 0 : editor2.isActive(_extName)) || false })
217
211
  });
218
212
  const tooltipContent = /* @__PURE__ */ jsxs2("p", { children: [
219
- typeof tooltip === "string" ? tooltip : "Bold",
213
+ typeof tooltip === "string" ? tooltip : _tooltipContent,
220
214
  /* @__PURE__ */ jsx7("br", {}),
221
- "\u2318 + B"
215
+ _interShortcut
222
216
  ] });
223
217
  const btn = /* @__PURE__ */ jsx7(
224
218
  "button",
225
219
  {
226
- onClick: () => editor == null ? void 0 : editor.chain().focus().toggleBold().run(),
220
+ onClick: _onToggle,
227
221
  className: twMerge4(
228
222
  "p-1.5 rounded-md",
223
+ _buttonClassName,
229
224
  (editorState == null ? void 0 : editorState.isActive) ? "bg-gray-200" : "hover:bg-gray-100",
230
225
  className,
231
226
  (editorState == null ? void 0 : editorState.isActive) ? activeClassName : "hover:bg-gray-100"
232
227
  ),
233
228
  style,
234
- children: icon != null ? icon : /* @__PURE__ */ jsx7(BoldIcon_default, {})
229
+ children: icon != null ? icon : _internalIcon
235
230
  }
236
231
  );
237
232
  if (tooltip === false) return btn;
@@ -245,7 +240,7 @@ var BoldComponent = ({ className, activeClassName, icon, style, tooltip = true,
245
240
  }
246
241
  );
247
242
  };
248
- var BoldComponent_default = BoldComponent;
243
+ var ButtonComponent_default = ButtonComponent;
249
244
 
250
245
  // src/lib/extensions/Bold.tsx
251
246
  import { jsx as jsx8 } from "react/jsx-runtime";
@@ -253,9 +248,191 @@ var Bold = TiptapBold.extend({
253
248
  addOptions() {
254
249
  var _a;
255
250
  return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
256
- button: ({ options }) => {
251
+ button: ({ editor, options, buttonClassName }) => {
257
252
  return /* @__PURE__ */ jsx8(
258
- BoldComponent_default,
253
+ ButtonComponent_default,
254
+ {
255
+ className: options.className,
256
+ icon: options.icon,
257
+ style: options.style,
258
+ activeClassName: options.activeClassName,
259
+ tooltip: options.tooltip,
260
+ tooltipClassName: options.tooltipClassName,
261
+ tooltipPlacement: options.tooltipPlacement,
262
+ _internalIcon: /* @__PURE__ */ jsx8(BoldIcon_default, {}),
263
+ _extName: "bold",
264
+ _onToggle: () => editor.chain().focus().toggleBold().run(),
265
+ _interShortcut: "\u2318 + B",
266
+ _tooltipContent: "Bold",
267
+ _buttonClassName: buttonClassName
268
+ }
269
+ );
270
+ }
271
+ });
272
+ }
273
+ });
274
+
275
+ // src/lib/extensions/Italic.tsx
276
+ import TiptapItalic from "@tiptap/extension-italic";
277
+
278
+ // src/lib/icon/ItalicIcon.tsx
279
+ import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
280
+ var ItalicIcon = (_a) => {
281
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
282
+ return /* @__PURE__ */ jsxs3(
283
+ "svg",
284
+ __spreadProps(__spreadValues({
285
+ xmlns: "http://www.w3.org/2000/svg",
286
+ viewBox: "0 0 24 24",
287
+ fill: "none",
288
+ stroke: "currentColor",
289
+ strokeWidth: 2,
290
+ strokeLinecap: "round",
291
+ strokeLinejoin: "round",
292
+ width: size,
293
+ height: size,
294
+ className
295
+ }, props), {
296
+ children: [
297
+ /* @__PURE__ */ jsx9("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
298
+ /* @__PURE__ */ jsx9("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
299
+ /* @__PURE__ */ jsx9("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
300
+ ]
301
+ })
302
+ );
303
+ };
304
+ var ItalicIcon_default = ItalicIcon;
305
+
306
+ // src/lib/extensions/Italic.tsx
307
+ import { jsx as jsx10 } from "react/jsx-runtime";
308
+ var Italic = TiptapItalic.extend({
309
+ addOptions() {
310
+ var _a;
311
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
312
+ button: ({ options, editor, buttonClassName }) => {
313
+ return /* @__PURE__ */ jsx10(
314
+ ButtonComponent_default,
315
+ {
316
+ className: options.className,
317
+ icon: options.icon,
318
+ style: options.style,
319
+ activeClassName: options.activeClassName,
320
+ tooltip: options.tooltip,
321
+ tooltipClassName: options.tooltipClassName,
322
+ tooltipPlacement: options.tooltipPlacement,
323
+ _internalIcon: /* @__PURE__ */ jsx10(ItalicIcon_default, {}),
324
+ _extName: "italic",
325
+ _onToggle: () => editor.chain().focus().toggleItalic().run(),
326
+ _interShortcut: "\u2318 + I",
327
+ _tooltipContent: "Italic",
328
+ _buttonClassName: buttonClassName
329
+ }
330
+ );
331
+ }
332
+ });
333
+ }
334
+ });
335
+
336
+ // src/lib/extensions/Underline.tsx
337
+ import TiptapUnder from "@tiptap/extension-underline";
338
+
339
+ // src/lib/icon/UnderIcon.tsx
340
+ import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
341
+ var UnderIcon = (_a) => {
342
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
343
+ return /* @__PURE__ */ jsxs4(
344
+ "svg",
345
+ __spreadProps(__spreadValues({
346
+ xmlns: "http://www.w3.org/2000/svg",
347
+ viewBox: "0 0 24 24",
348
+ fill: "none",
349
+ stroke: "currentColor",
350
+ strokeWidth: 2,
351
+ strokeLinecap: "round",
352
+ strokeLinejoin: "round",
353
+ width: size,
354
+ height: size,
355
+ className
356
+ }, props), {
357
+ children: [
358
+ /* @__PURE__ */ jsx11("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
359
+ /* @__PURE__ */ jsx11("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
360
+ ]
361
+ })
362
+ );
363
+ };
364
+ var UnderIcon_default = UnderIcon;
365
+
366
+ // src/lib/extensions/Underline.tsx
367
+ import { jsx as jsx12 } from "react/jsx-runtime";
368
+ var Underline = TiptapUnder.extend({
369
+ addOptions() {
370
+ var _a;
371
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
372
+ button: ({ options, editor, buttonClassName }) => {
373
+ return /* @__PURE__ */ jsx12(
374
+ ButtonComponent_default,
375
+ {
376
+ className: options.className,
377
+ icon: options.icon,
378
+ style: options.style,
379
+ activeClassName: options.activeClassName,
380
+ tooltip: options.tooltip,
381
+ tooltipClassName: options.tooltipClassName,
382
+ tooltipPlacement: options.tooltipPlacement,
383
+ _internalIcon: /* @__PURE__ */ jsx12(UnderIcon_default, {}),
384
+ _extName: "underline",
385
+ _onToggle: () => editor.chain().focus().toggleUnderline().run(),
386
+ _interShortcut: "\u2318 + U",
387
+ _tooltipContent: "Underline",
388
+ _buttonClassName: buttonClassName
389
+ }
390
+ );
391
+ }
392
+ });
393
+ }
394
+ });
395
+
396
+ // src/lib/extensions/Strike.tsx
397
+ import TiptapStrike from "@tiptap/extension-strike";
398
+
399
+ // src/lib/icon/StrikeIcon.tsx
400
+ import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
401
+ var StrikeIcon = (_a) => {
402
+ var _b = _a, { size = 17, className } = _b, props = __objRest(_b, ["size", "className"]);
403
+ return /* @__PURE__ */ jsxs5(
404
+ "svg",
405
+ __spreadProps(__spreadValues({
406
+ xmlns: "http://www.w3.org/2000/svg",
407
+ viewBox: "0 0 24 24",
408
+ fill: "none",
409
+ stroke: "currentColor",
410
+ strokeWidth: 2,
411
+ strokeLinecap: "round",
412
+ strokeLinejoin: "round",
413
+ width: size,
414
+ height: size,
415
+ className
416
+ }, props), {
417
+ children: [
418
+ /* @__PURE__ */ jsx13("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
419
+ /* @__PURE__ */ jsx13("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
420
+ /* @__PURE__ */ jsx13("line", { x1: "4", x2: "20", y1: "12", y2: "12" })
421
+ ]
422
+ })
423
+ );
424
+ };
425
+ var StrikeIcon_default = StrikeIcon;
426
+
427
+ // src/lib/extensions/Strike.tsx
428
+ import { jsx as jsx14 } from "react/jsx-runtime";
429
+ var Strike = TiptapStrike.extend({
430
+ addOptions() {
431
+ var _a;
432
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
433
+ button: ({ options, editor, buttonClassName }) => {
434
+ return /* @__PURE__ */ jsx14(
435
+ ButtonComponent_default,
259
436
  {
260
437
  className: options.className,
261
438
  icon: options.icon,
@@ -263,7 +440,13 @@ var Bold = TiptapBold.extend({
263
440
  activeClassName: options.activeClassName,
264
441
  tooltip: options.tooltip,
265
442
  tooltipClassName: options.tooltipClassName,
266
- tooltipPlacement: options.tooltipPlacement
443
+ tooltipPlacement: options.tooltipPlacement,
444
+ _internalIcon: /* @__PURE__ */ jsx14(StrikeIcon_default, {}),
445
+ _extName: "strike",
446
+ _onToggle: () => editor.chain().focus().toggleStrike().run(),
447
+ _interShortcut: "\u2318 \u21E7 S",
448
+ _tooltipContent: "Strike",
449
+ _buttonClassName: buttonClassName
267
450
  }
268
451
  );
269
452
  }
@@ -274,5 +457,8 @@ export {
274
457
  Bold,
275
458
  Content_default as Content,
276
459
  Editor_default as Editor,
277
- Toolbar_default as Toolbar
460
+ Italic,
461
+ Strike,
462
+ Toolbar_default as Toolbar,
463
+ Underline
278
464
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ritext",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Ritext is a modern WYSIWYG rich text editor built with Tailwind CSS, powered by Tiptap. It offers a customizable UI and functional layer that lets you design your own editor controls and toolbars with clean, composable React components—no heavy UI, no extra dependencies beyond Tiptap.",
5
5
  "homepage": "https://ritext.vercel.app/",
6
6
  "main": "dist/index.js",
@@ -63,7 +63,9 @@
63
63
  "@tiptap/extension-document": "^3.7.2",
64
64
  "@tiptap/extension-italic": "^3.7.2",
65
65
  "@tiptap/extension-paragraph": "^3.7.2",
66
+ "@tiptap/extension-strike": "^3.10.1",
66
67
  "@tiptap/extension-text": "^3.7.2",
68
+ "@tiptap/extension-underline": "^3.10.1",
67
69
  "@tiptap/pm": "^3.7.2",
68
70
  "@tiptap/react": "^3.7.2",
69
71
  "@tiptap/starter-kit": "^3.7.2",