notra-editor 0.2.0 → 0.4.0

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 (221) hide show
  1. package/README.md +4 -8
  2. package/dist/components/blockquote-button/blockquote-button.cjs +91 -0
  3. package/dist/components/blockquote-button/blockquote-button.cjs.map +1 -0
  4. package/dist/components/blockquote-button/blockquote-button.d.cts +9 -0
  5. package/dist/components/blockquote-button/blockquote-button.d.ts +9 -0
  6. package/dist/components/blockquote-button/blockquote-button.mjs +67 -0
  7. package/dist/components/blockquote-button/blockquote-button.mjs.map +1 -0
  8. package/dist/components/code-block-button/code-block-button.cjs +91 -0
  9. package/dist/components/code-block-button/code-block-button.cjs.map +1 -0
  10. package/dist/components/code-block-button/code-block-button.d.cts +9 -0
  11. package/dist/components/code-block-button/code-block-button.d.ts +9 -0
  12. package/dist/components/code-block-button/code-block-button.mjs +67 -0
  13. package/dist/components/code-block-button/code-block-button.mjs.map +1 -0
  14. package/dist/components/code-block-view.cjs +39 -0
  15. package/dist/components/code-block-view.cjs.map +1 -0
  16. package/dist/components/code-block-view.d.cts +12 -0
  17. package/dist/components/code-block-view.d.ts +12 -0
  18. package/dist/components/code-block-view.mjs +17 -0
  19. package/dist/components/code-block-view.mjs.map +1 -0
  20. package/dist/components/copy-button.cjs +49 -0
  21. package/dist/components/copy-button.cjs.map +1 -0
  22. package/dist/components/copy-button.d.cts +9 -0
  23. package/dist/components/copy-button.d.ts +9 -0
  24. package/dist/components/copy-button.mjs +25 -0
  25. package/dist/components/copy-button.mjs.map +1 -0
  26. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.cjs +67 -0
  27. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.cjs.map +1 -0
  28. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.cts +17 -0
  29. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.ts +17 -0
  30. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.mjs +51 -0
  31. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.mjs.map +1 -0
  32. package/dist/components/heading-dropdown-menu/heading-menu-item.cjs +56 -0
  33. package/dist/components/heading-dropdown-menu/heading-menu-item.cjs.map +1 -0
  34. package/dist/components/heading-dropdown-menu/heading-menu-item.d.cts +12 -0
  35. package/dist/components/heading-dropdown-menu/heading-menu-item.d.ts +12 -0
  36. package/dist/components/heading-dropdown-menu/heading-menu-item.mjs +32 -0
  37. package/dist/components/heading-dropdown-menu/heading-menu-item.mjs.map +1 -0
  38. package/dist/components/heading-dropdown-menu/use-heading.cjs +109 -0
  39. package/dist/components/heading-dropdown-menu/use-heading.cjs.map +1 -0
  40. package/dist/components/heading-dropdown-menu/use-heading.d.cts +19 -0
  41. package/dist/components/heading-dropdown-menu/use-heading.d.ts +19 -0
  42. package/dist/components/heading-dropdown-menu/use-heading.mjs +83 -0
  43. package/dist/components/heading-dropdown-menu/use-heading.mjs.map +1 -0
  44. package/dist/components/link-popover/link-popover.cjs +148 -0
  45. package/dist/components/link-popover/link-popover.cjs.map +1 -0
  46. package/dist/components/link-popover/link-popover.d.cts +9 -0
  47. package/dist/components/link-popover/link-popover.d.ts +9 -0
  48. package/dist/components/link-popover/link-popover.mjs +129 -0
  49. package/dist/components/link-popover/link-popover.mjs.map +1 -0
  50. package/dist/components/link-popover/use-link-popover.cjs +71 -0
  51. package/dist/components/link-popover/use-link-popover.cjs.map +1 -0
  52. package/dist/components/link-popover/use-link-popover.d.cts +17 -0
  53. package/dist/components/link-popover/use-link-popover.d.ts +17 -0
  54. package/dist/components/link-popover/use-link-popover.mjs +47 -0
  55. package/dist/components/link-popover/use-link-popover.mjs.map +1 -0
  56. package/dist/components/list-dropdown-menu/list-dropdown-menu.cjs +73 -0
  57. package/dist/components/list-dropdown-menu/list-dropdown-menu.cjs.map +1 -0
  58. package/dist/components/list-dropdown-menu/list-dropdown-menu.d.cts +17 -0
  59. package/dist/components/list-dropdown-menu/list-dropdown-menu.d.ts +17 -0
  60. package/dist/components/list-dropdown-menu/list-dropdown-menu.mjs +57 -0
  61. package/dist/components/list-dropdown-menu/list-dropdown-menu.mjs.map +1 -0
  62. package/dist/components/list-dropdown-menu/list-menu-item.cjs +56 -0
  63. package/dist/components/list-dropdown-menu/list-menu-item.cjs.map +1 -0
  64. package/dist/components/list-dropdown-menu/list-menu-item.d.cts +12 -0
  65. package/dist/components/list-dropdown-menu/list-menu-item.d.ts +12 -0
  66. package/dist/components/list-dropdown-menu/list-menu-item.mjs +32 -0
  67. package/dist/components/list-dropdown-menu/list-menu-item.mjs.map +1 -0
  68. package/dist/components/list-dropdown-menu/use-list.cjs +111 -0
  69. package/dist/components/list-dropdown-menu/use-list.cjs.map +1 -0
  70. package/dist/components/list-dropdown-menu/use-list.d.cts +19 -0
  71. package/dist/components/list-dropdown-menu/use-list.d.ts +19 -0
  72. package/dist/components/list-dropdown-menu/use-list.mjs +85 -0
  73. package/dist/components/list-dropdown-menu/use-list.mjs.map +1 -0
  74. package/dist/components/mark-button/mark-button.cjs +72 -0
  75. package/dist/components/mark-button/mark-button.cjs.map +1 -0
  76. package/dist/components/mark-button/mark-button.d.cts +12 -0
  77. package/dist/components/mark-button/mark-button.d.ts +12 -0
  78. package/dist/components/mark-button/mark-button.mjs +48 -0
  79. package/dist/components/mark-button/mark-button.mjs.map +1 -0
  80. package/dist/components/mark-button/use-mark.cjs +71 -0
  81. package/dist/components/mark-button/use-mark.cjs.map +1 -0
  82. package/dist/components/mark-button/use-mark.d.cts +17 -0
  83. package/dist/components/mark-button/use-mark.d.ts +17 -0
  84. package/dist/components/mark-button/use-mark.mjs +47 -0
  85. package/dist/components/mark-button/use-mark.mjs.map +1 -0
  86. package/dist/components/toolbar/toolbar.cjs +77 -0
  87. package/dist/components/toolbar/toolbar.cjs.map +1 -0
  88. package/dist/components/toolbar/toolbar.d.cts +14 -0
  89. package/dist/components/toolbar/toolbar.d.ts +14 -0
  90. package/dist/components/toolbar/toolbar.mjs +51 -0
  91. package/dist/components/toolbar/toolbar.mjs.map +1 -0
  92. package/dist/components/ui/button.cjs +82 -0
  93. package/dist/components/ui/button.cjs.map +1 -0
  94. package/dist/components/ui/button.d.cts +14 -0
  95. package/dist/components/ui/button.d.ts +14 -0
  96. package/dist/components/ui/button.mjs +57 -0
  97. package/dist/components/ui/button.mjs.map +1 -0
  98. package/dist/components/ui/dropdown-menu.cjs +290 -0
  99. package/dist/components/ui/dropdown-menu.cjs.map +1 -0
  100. package/dist/components/ui/dropdown-menu.d.cts +32 -0
  101. package/dist/components/ui/dropdown-menu.d.ts +32 -0
  102. package/dist/components/ui/dropdown-menu.mjs +252 -0
  103. package/dist/components/ui/dropdown-menu.mjs.map +1 -0
  104. package/dist/components/ui/input.cjs +44 -0
  105. package/dist/components/ui/input.cjs.map +1 -0
  106. package/dist/components/ui/input.d.cts +6 -0
  107. package/dist/components/ui/input.d.ts +6 -0
  108. package/dist/components/ui/input.mjs +20 -0
  109. package/dist/components/ui/input.mjs.map +1 -0
  110. package/dist/components/ui/popover.cjs +72 -0
  111. package/dist/components/ui/popover.cjs.map +1 -0
  112. package/dist/components/ui/popover.d.cts +10 -0
  113. package/dist/components/ui/popover.d.ts +10 -0
  114. package/dist/components/ui/popover.mjs +45 -0
  115. package/dist/components/ui/popover.mjs.map +1 -0
  116. package/dist/components/ui/separator.cjs +51 -0
  117. package/dist/components/ui/separator.cjs.map +1 -0
  118. package/dist/components/ui/separator.d.cts +7 -0
  119. package/dist/components/ui/separator.d.ts +7 -0
  120. package/dist/components/ui/separator.mjs +27 -0
  121. package/dist/components/ui/separator.mjs.map +1 -0
  122. package/dist/components/ui/spacer.cjs +32 -0
  123. package/dist/components/ui/spacer.cjs.map +1 -0
  124. package/dist/components/ui/spacer.d.cts +5 -0
  125. package/dist/components/ui/spacer.d.ts +5 -0
  126. package/dist/components/ui/spacer.mjs +8 -0
  127. package/dist/components/ui/spacer.mjs.map +1 -0
  128. package/dist/components/undo-redo-button/undo-redo-button.cjs +63 -0
  129. package/dist/components/undo-redo-button/undo-redo-button.cjs.map +1 -0
  130. package/dist/components/undo-redo-button/undo-redo-button.d.cts +12 -0
  131. package/dist/components/undo-redo-button/undo-redo-button.d.ts +12 -0
  132. package/dist/components/undo-redo-button/undo-redo-button.mjs +39 -0
  133. package/dist/components/undo-redo-button/undo-redo-button.mjs.map +1 -0
  134. package/dist/components/undo-redo-button/use-undo-redo.cjs +68 -0
  135. package/dist/components/undo-redo-button/use-undo-redo.cjs.map +1 -0
  136. package/dist/components/undo-redo-button/use-undo-redo.d.cts +17 -0
  137. package/dist/components/undo-redo-button/use-undo-redo.d.ts +17 -0
  138. package/dist/components/undo-redo-button/use-undo-redo.mjs +44 -0
  139. package/dist/components/undo-redo-button/use-undo-redo.mjs.map +1 -0
  140. package/dist/extensions/code-block.cjs +46 -0
  141. package/dist/extensions/code-block.cjs.map +1 -0
  142. package/dist/extensions/code-block.d.cts +6 -0
  143. package/dist/extensions/code-block.d.ts +6 -0
  144. package/dist/extensions/code-block.mjs +12 -0
  145. package/dist/extensions/code-block.mjs.map +1 -0
  146. package/dist/extensions/editor.cjs +53 -0
  147. package/dist/extensions/editor.cjs.map +1 -0
  148. package/dist/extensions/editor.d.cts +9 -0
  149. package/dist/extensions/editor.d.ts +9 -0
  150. package/dist/extensions/editor.mjs +19 -0
  151. package/dist/extensions/editor.mjs.map +1 -0
  152. package/dist/extensions/index.cjs +32 -0
  153. package/dist/extensions/index.cjs.map +1 -0
  154. package/dist/extensions/index.d.cts +7 -0
  155. package/dist/extensions/index.d.ts +7 -0
  156. package/dist/extensions/index.mjs +7 -0
  157. package/dist/extensions/index.mjs.map +1 -0
  158. package/dist/extensions/shared.cjs +64 -0
  159. package/dist/extensions/shared.cjs.map +1 -0
  160. package/dist/extensions/shared.d.cts +8 -0
  161. package/dist/extensions/shared.d.ts +8 -0
  162. package/dist/extensions/shared.mjs +29 -0
  163. package/dist/extensions/shared.mjs.map +1 -0
  164. package/dist/hooks/use-copy-to-clipboard.cjs +50 -0
  165. package/dist/hooks/use-copy-to-clipboard.cjs.map +1 -0
  166. package/dist/hooks/use-copy-to-clipboard.d.cts +10 -0
  167. package/dist/hooks/use-copy-to-clipboard.d.ts +10 -0
  168. package/dist/hooks/use-copy-to-clipboard.mjs +26 -0
  169. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
  170. package/dist/hooks/use-markdown-editor.cjs +80 -0
  171. package/dist/hooks/use-markdown-editor.cjs.map +1 -0
  172. package/dist/hooks/use-markdown-editor.d.cts +13 -0
  173. package/dist/hooks/use-markdown-editor.d.ts +13 -0
  174. package/dist/hooks/use-markdown-editor.mjs +56 -0
  175. package/dist/hooks/use-markdown-editor.mjs.map +1 -0
  176. package/dist/icons/redo-icon.cjs +54 -0
  177. package/dist/icons/redo-icon.cjs.map +1 -0
  178. package/dist/icons/redo-icon.d.cts +7 -0
  179. package/dist/icons/redo-icon.d.ts +7 -0
  180. package/dist/icons/redo-icon.mjs +30 -0
  181. package/dist/icons/redo-icon.mjs.map +1 -0
  182. package/dist/icons/undo-icon.cjs +54 -0
  183. package/dist/icons/undo-icon.cjs.map +1 -0
  184. package/dist/icons/undo-icon.d.cts +7 -0
  185. package/dist/icons/undo-icon.d.ts +7 -0
  186. package/dist/icons/undo-icon.mjs +30 -0
  187. package/dist/icons/undo-icon.mjs.map +1 -0
  188. package/dist/index.cjs +25 -2127
  189. package/dist/index.cjs.map +1 -1
  190. package/dist/index.d.cts +22 -110
  191. package/dist/index.d.ts +22 -110
  192. package/dist/index.mjs +16 -2098
  193. package/dist/index.mjs.map +1 -1
  194. package/dist/lib/utils.cjs +33 -0
  195. package/dist/lib/utils.cjs.map +1 -0
  196. package/dist/lib/utils.d.cts +5 -0
  197. package/dist/lib/utils.d.ts +5 -0
  198. package/dist/lib/utils.mjs +9 -0
  199. package/dist/lib/utils.mjs.map +1 -0
  200. package/dist/notra-editor.cjs +88 -0
  201. package/dist/notra-editor.cjs.map +1 -0
  202. package/dist/notra-editor.d.cts +17 -0
  203. package/dist/notra-editor.d.ts +17 -0
  204. package/dist/notra-editor.mjs +68 -0
  205. package/dist/notra-editor.mjs.map +1 -0
  206. package/dist/notra-reader.cjs +47 -0
  207. package/dist/notra-reader.cjs.map +1 -0
  208. package/dist/notra-reader.d.cts +11 -0
  209. package/dist/notra-reader.d.ts +11 -0
  210. package/dist/notra-reader.mjs +23 -0
  211. package/dist/notra-reader.mjs.map +1 -0
  212. package/dist/styles/globals.css +1170 -0
  213. package/dist/themes/default/editor.css +2 -116
  214. package/dist/themes/default/reader.css +2 -0
  215. package/dist/utils/markdown-to-json.cjs +50 -0
  216. package/dist/utils/markdown-to-json.cjs.map +1 -0
  217. package/dist/utils/markdown-to-json.d.cts +7 -0
  218. package/dist/utils/markdown-to-json.d.ts +7 -0
  219. package/dist/utils/markdown-to-json.mjs +26 -0
  220. package/dist/utils/markdown-to-json.mjs.map +1 -0
  221. package/package.json +18 -5
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,2146 +15,46 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
19
  var index_exports = {};
32
20
  __export(index_exports, {
33
- BlockquoteButton: () => BlockquoteButton,
34
- Button: () => Button,
35
- CodeBlockButton: () => CodeBlockButton,
36
- DropdownMenu: () => DropdownMenu,
37
- HeadingDropdownMenu: () => HeadingDropdownMenu,
38
- LinkPopover: () => LinkPopover,
39
- ListDropdownMenu: () => ListDropdownMenu,
40
- MarkButton: () => MarkButton,
41
- NotraEditor: () => NotraEditor,
42
- NotraReader: () => NotraReader,
43
- Popover: () => Popover,
44
- Spacer: () => Spacer,
45
- Toolbar: () => Toolbar,
46
- ToolbarGroup: () => ToolbarGroup,
47
- ToolbarSeparator: () => ToolbarSeparator,
48
- UndoRedoButton: () => UndoRedoButton
21
+ BlockquoteButton: () => import_blockquote_button.BlockquoteButton,
22
+ CodeBlockButton: () => import_code_block_button.CodeBlockButton,
23
+ HeadingDropdownMenu: () => import_heading_dropdown_menu.HeadingDropdownMenu,
24
+ LinkPopover: () => import_link_popover.LinkPopover,
25
+ ListDropdownMenu: () => import_list_dropdown_menu.ListDropdownMenu,
26
+ MarkButton: () => import_mark_button.MarkButton,
27
+ NotraEditor: () => import_notra_editor.NotraEditor,
28
+ NotraReader: () => import_notra_reader.NotraReader,
29
+ Spacer: () => import_spacer.Spacer,
30
+ Toolbar: () => import_toolbar.Toolbar,
31
+ ToolbarGroup: () => import_toolbar.ToolbarGroup,
32
+ ToolbarSeparator: () => import_toolbar.ToolbarSeparator,
33
+ UndoRedoButton: () => import_undo_redo_button.UndoRedoButton
49
34
  });
50
35
  module.exports = __toCommonJS(index_exports);
51
-
52
- // src/notra-editor.tsx
53
- var import_react44 = require("@tiptap/react");
54
-
55
- // src/components/blockquote-button/blockquote-button.tsx
56
- var import_react3 = require("react");
57
-
58
- // src/icons/blockquote-icon.tsx
59
- var import_react = require("react");
60
- var import_jsx_runtime = require("react/jsx-runtime");
61
- var BlockquoteIcon = (0, import_react.memo)(({ className, ...props }) => {
62
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
63
- "svg",
64
- {
65
- className,
66
- fill: "currentColor",
67
- height: "24",
68
- viewBox: "0 0 24 24",
69
- width: "24",
70
- xmlns: "http://www.w3.org/2000/svg",
71
- ...props,
72
- children: [
73
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
- "path",
75
- {
76
- clipRule: "evenodd",
77
- d: "M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",
78
- fill: "currentColor",
79
- fillRule: "evenodd"
80
- }
81
- ),
82
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
- "path",
84
- {
85
- clipRule: "evenodd",
86
- d: "M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",
87
- fill: "currentColor",
88
- fillRule: "evenodd"
89
- }
90
- ),
91
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
- "path",
93
- {
94
- clipRule: "evenodd",
95
- d: "M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",
96
- fill: "currentColor",
97
- fillRule: "evenodd"
98
- }
99
- ),
100
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
- "path",
102
- {
103
- clipRule: "evenodd",
104
- d: "M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",
105
- fill: "currentColor",
106
- fillRule: "evenodd"
107
- }
108
- )
109
- ]
110
- }
111
- );
112
- });
113
- BlockquoteIcon.displayName = "BlockquoteIcon";
114
-
115
- // src/components/button/button.tsx
116
- var import_react2 = require("react");
117
- var import_jsx_runtime2 = require("react/jsx-runtime");
118
- var Button = (0, import_react2.forwardRef)(
119
- ({
120
- children,
121
- className,
122
- variant = "ghost",
123
- size = "default",
124
- active,
125
- ...props
126
- }, ref) => {
127
- const classNames = ["tiptap-button", className].filter(Boolean).join(" ");
128
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
129
- "button",
130
- {
131
- ref,
132
- className: classNames,
133
- "data-active-state": active ? "on" : void 0,
134
- "data-size": size !== "default" ? size : void 0,
135
- "data-style": variant !== "default" ? variant : void 0,
136
- ...props,
137
- children
138
- }
139
- );
140
- }
141
- );
142
- Button.displayName = "Button";
143
-
144
- // src/components/blockquote-button/blockquote-button.tsx
145
- var import_jsx_runtime3 = require("react/jsx-runtime");
146
- function canToggleBlockquote(editor) {
147
- if (!editor || !editor.isEditable) return false;
148
- return editor.can().toggleWrap("blockquote") || editor.can().clearNodes();
149
- }
150
- var BlockquoteButton = (0, import_react3.forwardRef)(({ editor, onClick, ...buttonProps }, ref) => {
151
- const [isActive, setIsActive] = (0, import_react3.useState)(false);
152
- const [canToggle, setCanToggle] = (0, import_react3.useState)(false);
153
- (0, import_react3.useEffect)(() => {
154
- if (!editor) return;
155
- const update = () => {
156
- setIsActive(editor.isActive("blockquote"));
157
- setCanToggle(canToggleBlockquote(editor));
158
- };
159
- update();
160
- editor.on("selectionUpdate", update);
161
- editor.on("transaction", update);
162
- return () => {
163
- editor.off("selectionUpdate", update);
164
- editor.off("transaction", update);
165
- };
166
- }, [editor]);
167
- const handleClick = (0, import_react3.useCallback)(
168
- (event) => {
169
- onClick?.(event);
170
- if (event.defaultPrevented) return;
171
- if (!editor) return;
172
- if (editor.isActive("blockquote")) {
173
- editor.chain().focus().lift("blockquote").run();
174
- } else {
175
- editor.chain().focus().clearNodes().wrapIn("blockquote").run();
176
- }
177
- },
178
- [editor, onClick]
179
- );
180
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
181
- Button,
182
- {
183
- ref,
184
- "aria-label": "Blockquote",
185
- "aria-pressed": isActive,
186
- "data-active-state": isActive ? "on" : "off",
187
- disabled: !canToggle,
188
- tabIndex: -1,
189
- type: "button",
190
- variant: "ghost",
191
- onClick: handleClick,
192
- ...buttonProps,
193
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(BlockquoteIcon, { className: "tiptap-button-icon" })
194
- }
195
- );
196
- });
197
- BlockquoteButton.displayName = "BlockquoteButton";
198
-
199
- // src/components/code-block-button/code-block-button.tsx
200
- var import_react5 = require("react");
201
-
202
- // src/icons/code-block-icon.tsx
203
- var import_react4 = require("react");
204
- var import_jsx_runtime4 = require("react/jsx-runtime");
205
- var CodeBlockIcon = (0, import_react4.memo)(({ className, ...props }) => {
206
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
207
- "svg",
208
- {
209
- className,
210
- fill: "currentColor",
211
- height: "24",
212
- viewBox: "0 0 24 24",
213
- width: "24",
214
- xmlns: "http://www.w3.org/2000/svg",
215
- ...props,
216
- children: [
217
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
218
- "path",
219
- {
220
- clipRule: "evenodd",
221
- d: "M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",
222
- fill: "currentColor",
223
- fillRule: "evenodd"
224
- }
225
- ),
226
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
227
- "path",
228
- {
229
- clipRule: "evenodd",
230
- d: "M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",
231
- fill: "currentColor",
232
- fillRule: "evenodd"
233
- }
234
- ),
235
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
236
- "path",
237
- {
238
- clipRule: "evenodd",
239
- d: "M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",
240
- fill: "currentColor",
241
- fillRule: "evenodd"
242
- }
243
- )
244
- ]
245
- }
246
- );
247
- });
248
- CodeBlockIcon.displayName = "CodeBlockIcon";
249
-
250
- // src/components/code-block-button/code-block-button.tsx
251
- var import_jsx_runtime5 = require("react/jsx-runtime");
252
- function canToggleCodeBlock(editor) {
253
- if (!editor || !editor.isEditable) return false;
254
- return editor.can().toggleNode("codeBlock", "paragraph") || editor.can().clearNodes();
255
- }
256
- var CodeBlockButton = (0, import_react5.forwardRef)(({ editor, onClick, ...buttonProps }, ref) => {
257
- const [isActive, setIsActive] = (0, import_react5.useState)(false);
258
- const [canToggle, setCanToggle] = (0, import_react5.useState)(false);
259
- (0, import_react5.useEffect)(() => {
260
- if (!editor) return;
261
- const update = () => {
262
- setIsActive(editor.isActive("codeBlock"));
263
- setCanToggle(canToggleCodeBlock(editor));
264
- };
265
- update();
266
- editor.on("selectionUpdate", update);
267
- editor.on("transaction", update);
268
- return () => {
269
- editor.off("selectionUpdate", update);
270
- editor.off("transaction", update);
271
- };
272
- }, [editor]);
273
- const handleClick = (0, import_react5.useCallback)(
274
- (event) => {
275
- onClick?.(event);
276
- if (event.defaultPrevented) return;
277
- if (!editor) return;
278
- if (editor.isActive("codeBlock")) {
279
- editor.chain().focus().setNode("paragraph").run();
280
- } else {
281
- editor.chain().focus().clearNodes().toggleNode("codeBlock", "paragraph").run();
282
- }
283
- },
284
- [editor, onClick]
285
- );
286
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
287
- Button,
288
- {
289
- ref,
290
- "aria-label": "Code Block",
291
- "aria-pressed": isActive,
292
- "data-active-state": isActive ? "on" : "off",
293
- disabled: !canToggle,
294
- tabIndex: -1,
295
- type: "button",
296
- variant: "ghost",
297
- onClick: handleClick,
298
- ...buttonProps,
299
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CodeBlockIcon, { className: "tiptap-button-icon" })
300
- }
301
- );
302
- });
303
- CodeBlockButton.displayName = "CodeBlockButton";
304
-
305
- // src/components/heading-dropdown-menu/heading-dropdown-menu.tsx
306
- var import_react16 = require("react");
307
-
308
- // src/components/heading-dropdown-menu/heading-button.tsx
309
- var import_react13 = require("react");
310
-
311
- // src/components/heading-dropdown-menu/use-heading.ts
312
- var import_react11 = require("react");
313
-
314
- // src/icons/heading-1-icon.tsx
315
- var import_react6 = require("react");
316
- var import_jsx_runtime6 = require("react/jsx-runtime");
317
- var Heading1Icon = (0, import_react6.memo)(({ className, ...props }) => {
318
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
319
- "svg",
320
- {
321
- className,
322
- fill: "currentColor",
323
- height: "24",
324
- viewBox: "0 0 24 24",
325
- width: "24",
326
- xmlns: "http://www.w3.org/2000/svg",
327
- ...props,
328
- children: [
329
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
330
- "path",
331
- {
332
- d: "M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",
333
- fill: "currentColor"
334
- }
335
- ),
336
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
337
- "path",
338
- {
339
- d: "M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",
340
- fill: "currentColor"
341
- }
342
- )
343
- ]
344
- }
345
- );
346
- });
347
- Heading1Icon.displayName = "Heading1Icon";
348
-
349
- // src/icons/heading-2-icon.tsx
350
- var import_react7 = require("react");
351
- var import_jsx_runtime7 = require("react/jsx-runtime");
352
- var Heading2Icon = (0, import_react7.memo)(({ className, ...props }) => {
353
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
354
- "svg",
355
- {
356
- className,
357
- fill: "currentColor",
358
- height: "24",
359
- viewBox: "0 0 24 24",
360
- width: "24",
361
- xmlns: "http://www.w3.org/2000/svg",
362
- ...props,
363
- children: [
364
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
365
- "path",
366
- {
367
- d: "M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",
368
- fill: "currentColor"
369
- }
370
- ),
371
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
372
- "path",
373
- {
374
- d: "M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",
375
- fill: "currentColor"
376
- }
377
- )
378
- ]
379
- }
380
- );
381
- });
382
- Heading2Icon.displayName = "Heading2Icon";
383
-
384
- // src/icons/heading-3-icon.tsx
385
- var import_react8 = require("react");
386
- var import_jsx_runtime8 = require("react/jsx-runtime");
387
- var Heading3Icon = (0, import_react8.memo)(({ className, ...props }) => {
388
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
389
- "svg",
390
- {
391
- className,
392
- fill: "currentColor",
393
- height: "24",
394
- viewBox: "0 0 24 24",
395
- width: "24",
396
- xmlns: "http://www.w3.org/2000/svg",
397
- ...props,
398
- children: [
399
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
400
- "path",
401
- {
402
- d: "M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",
403
- fill: "currentColor"
404
- }
405
- ),
406
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
407
- "path",
408
- {
409
- clipRule: "evenodd",
410
- d: "M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",
411
- fill: "currentColor",
412
- fillRule: "evenodd"
413
- }
414
- ),
415
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
416
- "path",
417
- {
418
- clipRule: "evenodd",
419
- d: "M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",
420
- fill: "currentColor",
421
- fillRule: "evenodd"
422
- }
423
- )
424
- ]
425
- }
426
- );
427
- });
428
- Heading3Icon.displayName = "Heading3Icon";
429
-
430
- // src/icons/heading-4-icon.tsx
431
- var import_react9 = require("react");
432
- var import_jsx_runtime9 = require("react/jsx-runtime");
433
- var Heading4Icon = (0, import_react9.memo)(({ className, ...props }) => {
434
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
435
- "svg",
436
- {
437
- className,
438
- fill: "currentColor",
439
- height: "24",
440
- viewBox: "0 0 24 24",
441
- width: "24",
442
- xmlns: "http://www.w3.org/2000/svg",
443
- ...props,
444
- children: [
445
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
446
- "path",
447
- {
448
- d: "M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",
449
- fill: "currentColor"
450
- }
451
- ),
452
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
453
- "path",
454
- {
455
- d: "M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",
456
- fill: "currentColor"
457
- }
458
- )
459
- ]
460
- }
461
- );
462
- });
463
- Heading4Icon.displayName = "Heading4Icon";
464
-
465
- // src/icons/heading-icon.tsx
466
- var import_react10 = require("react");
467
- var import_jsx_runtime10 = require("react/jsx-runtime");
468
- var HeadingIcon = (0, import_react10.memo)(({ className, ...props }) => {
469
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
470
- "svg",
471
- {
472
- className,
473
- fill: "currentColor",
474
- height: "24",
475
- viewBox: "0 0 24 24",
476
- width: "24",
477
- xmlns: "http://www.w3.org/2000/svg",
478
- ...props,
479
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
480
- "path",
481
- {
482
- d: "M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",
483
- fill: "currentColor"
484
- }
485
- )
486
- }
487
- );
488
- });
489
- HeadingIcon.displayName = "HeadingIcon";
490
-
491
- // src/components/heading-dropdown-menu/use-heading.ts
492
- var headingIcons = {
493
- 1: Heading1Icon,
494
- 2: Heading2Icon,
495
- 3: Heading3Icon,
496
- 4: Heading4Icon
497
- };
498
- var headingLabels = {
499
- 1: "Heading 1",
500
- 2: "Heading 2",
501
- 3: "Heading 3",
502
- 4: "Heading 4"
503
- };
504
- function canToggleHeading(editor, level) {
505
- if (!editor || !editor.isEditable) return false;
506
- return editor.can().setNode("heading", { level }) || editor.can().clearNodes();
507
- }
508
- function useHeading({
509
- editor,
510
- level
511
- }) {
512
- const [isActive, setIsActive] = (0, import_react11.useState)(false);
513
- const [canToggle, setCanToggle] = (0, import_react11.useState)(false);
514
- (0, import_react11.useEffect)(() => {
515
- if (!editor) return;
516
- const handleUpdate = () => {
517
- setIsActive(editor.isActive("heading", { level }));
518
- setCanToggle(canToggleHeading(editor, level));
519
- };
520
- handleUpdate();
521
- editor.on("selectionUpdate", handleUpdate);
522
- editor.on("transaction", handleUpdate);
523
- return () => {
524
- editor.off("selectionUpdate", handleUpdate);
525
- editor.off("transaction", handleUpdate);
526
- };
527
- }, [editor, level]);
528
- const handleToggle = (0, import_react11.useCallback)(() => {
529
- if (!editor || !editor.isEditable) return false;
530
- if (editor.isActive("heading", { level })) {
531
- return editor.chain().focus().setNode("paragraph").run();
532
- }
533
- return editor.chain().focus().clearNodes().setNode("heading", { level }).run();
534
- }, [editor, level]);
535
- return {
536
- isActive,
537
- canToggle,
538
- handleToggle,
539
- label: headingLabels[level],
540
- Icon: headingIcons[level]
541
- };
542
- }
543
- function useActiveHeadingLevel(editor, levels) {
544
- const [activeLevel, setActiveLevel] = (0, import_react11.useState)(null);
545
- (0, import_react11.useEffect)(() => {
546
- if (!editor) return;
547
- const handleUpdate = () => {
548
- const found = levels.find(
549
- (level) => editor.isActive("heading", { level })
550
- );
551
- setActiveLevel(found ?? null);
552
- };
553
- handleUpdate();
554
- editor.on("selectionUpdate", handleUpdate);
555
- editor.on("transaction", handleUpdate);
556
- return () => {
557
- editor.off("selectionUpdate", handleUpdate);
558
- editor.off("transaction", handleUpdate);
559
- };
560
- }, [editor, levels]);
561
- return activeLevel;
562
- }
563
- function getHeadingTriggerIcon(activeLevel) {
564
- if (activeLevel === null) return HeadingIcon;
565
- return headingIcons[activeLevel];
566
- }
567
-
568
- // src/icons/check-icon.tsx
569
- var import_react12 = require("react");
570
- var import_jsx_runtime11 = require("react/jsx-runtime");
571
- var CheckIcon = (0, import_react12.memo)(({ className, ...props }) => {
572
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
573
- "svg",
574
- {
575
- className,
576
- fill: "currentColor",
577
- height: "24",
578
- viewBox: "0 0 24 24",
579
- width: "24",
580
- xmlns: "http://www.w3.org/2000/svg",
581
- ...props,
582
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
583
- "path",
584
- {
585
- clipRule: "evenodd",
586
- d: "M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z",
587
- fill: "currentColor",
588
- fillRule: "evenodd"
589
- }
590
- )
591
- }
592
- );
593
- });
594
- CheckIcon.displayName = "CheckIcon";
595
-
596
- // src/components/heading-dropdown-menu/heading-button.tsx
597
- var import_jsx_runtime12 = require("react/jsx-runtime");
598
- var HeadingButton = (0, import_react13.forwardRef)(
599
- ({ editor, level, onClick, ...buttonProps }, ref) => {
600
- const { isActive, canToggle, handleToggle, label, Icon } = useHeading({
601
- editor,
602
- level
603
- });
604
- const handleClick = (0, import_react13.useCallback)(
605
- (event) => {
606
- onClick?.(event);
607
- if (event.defaultPrevented) return;
608
- handleToggle();
609
- },
610
- [handleToggle, onClick]
611
- );
612
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
613
- Button,
614
- {
615
- ref,
616
- "aria-label": label,
617
- "aria-pressed": isActive,
618
- "data-active-state": isActive ? "on" : "off",
619
- disabled: !canToggle,
620
- role: "menuitem",
621
- tabIndex: -1,
622
- type: "button",
623
- variant: "ghost",
624
- onClick: handleClick,
625
- ...buttonProps,
626
- children: [
627
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { className: "tiptap-button-icon" }),
628
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "tiptap-button-text", children: label }),
629
- isActive && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CheckIcon, {})
630
- ]
631
- }
632
- );
633
- }
634
- );
635
- HeadingButton.displayName = "HeadingButton";
636
-
637
- // src/icons/chevron-down-icon.tsx
638
- var import_react14 = require("react");
639
- var import_jsx_runtime13 = require("react/jsx-runtime");
640
- var ChevronDownIcon = (0, import_react14.memo)(({ className, ...props }) => {
641
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
642
- "svg",
643
- {
644
- className,
645
- fill: "currentColor",
646
- height: "24",
647
- viewBox: "0 0 24 24",
648
- width: "24",
649
- xmlns: "http://www.w3.org/2000/svg",
650
- ...props,
651
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
652
- "path",
653
- {
654
- clipRule: "evenodd",
655
- d: "M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",
656
- fill: "currentColor",
657
- fillRule: "evenodd"
658
- }
659
- )
660
- }
661
- );
662
- });
663
- ChevronDownIcon.displayName = "ChevronDownIcon";
664
-
665
- // src/components/ui-primitive/dropdown-menu.tsx
666
- var import_react15 = require("react");
667
- var import_react_dom = require("react-dom");
668
- var import_jsx_runtime14 = require("react/jsx-runtime");
669
- function DropdownMenu({
670
- trigger,
671
- children,
672
- open: controlledOpen,
673
- onOpenChange
674
- }) {
675
- const isControlled = controlledOpen !== void 0;
676
- const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react15.useState)(false);
677
- const open = isControlled ? controlledOpen : uncontrolledOpen;
678
- const triggerRef = (0, import_react15.useRef)(null);
679
- const contentRef = (0, import_react15.useRef)(null);
680
- const [position, setPosition] = (0, import_react15.useState)({ top: 0, left: 0 });
681
- const setOpen = (value) => {
682
- if (!isControlled) {
683
- setUncontrolledOpen(value);
684
- }
685
- onOpenChange?.(value);
686
- };
687
- (0, import_react15.useEffect)(() => {
688
- if (!open || !triggerRef.current) return;
689
- const updatePosition = () => {
690
- if (!triggerRef.current) return;
691
- const rect = triggerRef.current.getBoundingClientRect();
692
- setPosition({
693
- top: rect.bottom + 4,
694
- left: rect.left + rect.width / 2
695
- });
696
- };
697
- updatePosition();
698
- window.addEventListener("scroll", updatePosition, true);
699
- window.addEventListener("resize", updatePosition);
700
- return () => {
701
- window.removeEventListener("scroll", updatePosition, true);
702
- window.removeEventListener("resize", updatePosition);
703
- };
704
- }, [open]);
705
- (0, import_react15.useEffect)(() => {
706
- if (!open) return;
707
- const handleMouseDown = (event) => {
708
- const target = event.target;
709
- if (triggerRef.current?.contains(target) || contentRef.current?.contains(target)) {
710
- return;
711
- }
712
- setOpen(false);
713
- };
714
- document.addEventListener("mousedown", handleMouseDown);
715
- return () => document.removeEventListener("mousedown", handleMouseDown);
716
- }, [open]);
717
- (0, import_react15.useEffect)(() => {
718
- if (!open) return;
719
- const handleKeyDown = (event) => {
720
- if (event.key === "Escape") {
721
- setOpen(false);
722
- }
723
- };
724
- document.addEventListener("keydown", handleKeyDown);
725
- return () => document.removeEventListener("keydown", handleKeyDown);
726
- }, [open]);
727
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
728
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: triggerRef, onClick: () => setOpen(!open), children: trigger }),
729
- open && (0, import_react_dom.createPortal)(
730
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "notra-editor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
731
- "div",
732
- {
733
- ref: contentRef,
734
- className: "tiptap-dropdown-menu-content",
735
- "data-state": "open",
736
- role: "menu",
737
- style: {
738
- position: "fixed",
739
- top: position.top,
740
- left: position.left
741
- },
742
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
743
- "div",
744
- {
745
- className: "tiptap-dropdown-menu-group",
746
- onClick: () => setOpen(false),
747
- children
748
- }
749
- )
750
- }
751
- ) }),
752
- document.body
753
- )
754
- ] });
755
- }
756
-
757
- // src/components/heading-dropdown-menu/heading-dropdown-menu.tsx
758
- var import_jsx_runtime15 = require("react/jsx-runtime");
759
- var HeadingDropdownMenu = (0, import_react16.forwardRef)(({ editor, levels = [1, 2, 3, 4], ...buttonProps }, ref) => {
760
- const activeLevel = useActiveHeadingLevel(editor, levels);
761
- const TriggerIcon = getHeadingTriggerIcon(activeLevel);
762
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
763
- DropdownMenu,
764
- {
765
- trigger: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
766
- Button,
767
- {
768
- ref,
769
- "aria-label": "Heading",
770
- "data-active-state": activeLevel !== null ? "on" : "off",
771
- tabIndex: -1,
772
- type: "button",
773
- variant: "ghost",
774
- ...buttonProps,
775
- children: [
776
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TriggerIcon, { className: "tiptap-button-icon" }),
777
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDownIcon, { className: "tiptap-button-dropdown-arrows" })
778
- ]
779
- }
780
- ),
781
- children: levels.map((level) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(HeadingButton, { editor, level }, level))
782
- }
783
- );
784
- });
785
- HeadingDropdownMenu.displayName = "HeadingDropdownMenu";
786
-
787
- // src/components/link-popover/link-popover.tsx
788
- var import_react25 = require("react");
789
-
790
- // src/components/link-popover/use-link-popover.ts
791
- var import_react17 = require("react");
792
- function useLinkPopover({ editor }) {
793
- const [url, setUrl] = (0, import_react17.useState)("");
794
- const [isActive, setIsActive] = (0, import_react17.useState)(false);
795
- const [canSet, setCanSet] = (0, import_react17.useState)(false);
796
- (0, import_react17.useEffect)(() => {
797
- if (!editor) return;
798
- const handleUpdate = () => {
799
- const active = editor.isActive("link");
800
- setIsActive(active);
801
- setCanSet(editor.isEditable);
802
- if (active) {
803
- setUrl(editor.getAttributes("link").href ?? "");
804
- }
805
- };
806
- handleUpdate();
807
- editor.on("selectionUpdate", handleUpdate);
808
- editor.on("transaction", handleUpdate);
809
- return () => {
810
- editor.off("selectionUpdate", handleUpdate);
811
- editor.off("transaction", handleUpdate);
812
- };
813
- }, [editor]);
814
- const setLink = (0, import_react17.useCallback)(() => {
815
- if (!editor) return;
816
- if (!url) {
817
- editor.chain().focus().extendMarkRange("link").unsetLink().run();
818
- return;
819
- }
820
- editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
821
- }, [editor, url]);
822
- const removeLink = (0, import_react17.useCallback)(() => {
823
- if (!editor) return;
824
- editor.chain().focus().extendMarkRange("link").unsetLink().run();
825
- setUrl("");
826
- }, [editor]);
827
- const openLink = (0, import_react17.useCallback)(() => {
828
- if (!url) return;
829
- const sanitized = /^https?:\/\//i.test(url) ? url : `https://${url}`;
830
- window.open(sanitized, "_blank", "noopener,noreferrer");
831
- }, [url]);
832
- return { url, setUrl, isActive, canSet, setLink, removeLink, openLink };
833
- }
834
-
835
- // src/icons/corner-down-left-icon.tsx
836
- var import_react18 = require("react");
837
- var import_jsx_runtime16 = require("react/jsx-runtime");
838
- var CornerDownLeftIcon = (0, import_react18.memo)(({ className, ...props }) => {
839
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
840
- "svg",
841
- {
842
- className,
843
- fill: "currentColor",
844
- height: "24",
845
- viewBox: "0 0 24 24",
846
- width: "24",
847
- xmlns: "http://www.w3.org/2000/svg",
848
- ...props,
849
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
850
- "path",
851
- {
852
- clipRule: "evenodd",
853
- d: "M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",
854
- fill: "currentColor",
855
- fillRule: "evenodd"
856
- }
857
- )
858
- }
859
- );
860
- });
861
- CornerDownLeftIcon.displayName = "CornerDownLeftIcon";
862
-
863
- // src/icons/external-link-icon.tsx
864
- var import_react19 = require("react");
865
- var import_jsx_runtime17 = require("react/jsx-runtime");
866
- var ExternalLinkIcon = (0, import_react19.memo)(({ className, ...props }) => {
867
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
868
- "svg",
869
- {
870
- className,
871
- fill: "currentColor",
872
- height: "24",
873
- viewBox: "0 0 24 24",
874
- width: "24",
875
- xmlns: "http://www.w3.org/2000/svg",
876
- ...props,
877
- children: [
878
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
879
- "path",
880
- {
881
- d: "M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",
882
- fill: "currentColor"
883
- }
884
- ),
885
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
886
- "path",
887
- {
888
- d: "M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",
889
- fill: "currentColor"
890
- }
891
- )
892
- ]
893
- }
894
- );
895
- });
896
- ExternalLinkIcon.displayName = "ExternalLinkIcon";
897
-
898
- // src/icons/link-icon.tsx
899
- var import_react20 = require("react");
900
- var import_jsx_runtime18 = require("react/jsx-runtime");
901
- var LinkIcon = (0, import_react20.memo)(({ className, ...props }) => {
902
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
903
- "svg",
904
- {
905
- className,
906
- fill: "currentColor",
907
- height: "24",
908
- viewBox: "0 0 24 24",
909
- width: "24",
910
- xmlns: "http://www.w3.org/2000/svg",
911
- ...props,
912
- children: [
913
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
914
- "path",
915
- {
916
- d: "M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",
917
- fill: "currentColor"
918
- }
919
- ),
920
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
921
- "path",
922
- {
923
- d: "M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",
924
- fill: "currentColor"
925
- }
926
- )
927
- ]
928
- }
929
- );
930
- });
931
- LinkIcon.displayName = "LinkIcon";
932
-
933
- // src/icons/trash-icon.tsx
934
- var import_react21 = require("react");
935
- var import_jsx_runtime19 = require("react/jsx-runtime");
936
- var TrashIcon = (0, import_react21.memo)(({ className, ...props }) => {
937
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
938
- "svg",
939
- {
940
- className,
941
- fill: "currentColor",
942
- height: "24",
943
- viewBox: "0 0 24 24",
944
- width: "24",
945
- xmlns: "http://www.w3.org/2000/svg",
946
- ...props,
947
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
948
- "path",
949
- {
950
- clipRule: "evenodd",
951
- d: "M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",
952
- fill: "currentColor",
953
- fillRule: "evenodd"
954
- }
955
- )
956
- }
957
- );
958
- });
959
- TrashIcon.displayName = "TrashIcon";
960
-
961
- // src/components/toolbar/toolbar.tsx
962
- var import_react22 = require("react");
963
- var import_jsx_runtime20 = require("react/jsx-runtime");
964
- var Toolbar = (0, import_react22.forwardRef)(
965
- ({ children, className, variant = "fixed", ...props }, ref) => {
966
- const classNames = ["tiptap-toolbar", className].filter(Boolean).join(" ");
967
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
968
- "div",
969
- {
970
- ref,
971
- "aria-label": "toolbar",
972
- className: classNames,
973
- "data-variant": variant,
974
- role: "toolbar",
975
- ...props,
976
- children
977
- }
978
- );
979
- }
980
- );
981
- Toolbar.displayName = "Toolbar";
982
- function ToolbarGroup({
983
- children,
984
- className,
985
- ...props
986
- }) {
987
- const classNames = ["tiptap-toolbar-group", className].filter(Boolean).join(" ");
988
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: classNames, role: "group", ...props, children });
989
- }
990
- function ToolbarSeparator({
991
- orientation = "vertical",
992
- className,
993
- ...props
994
- }) {
995
- const classNames = ["tiptap-separator", className].filter(Boolean).join(" ");
996
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
997
- "div",
998
- {
999
- "aria-orientation": orientation === "vertical" ? orientation : void 0,
1000
- className: classNames,
1001
- "data-orientation": orientation,
1002
- role: "separator",
1003
- ...props
1004
- }
1005
- );
1006
- }
1007
-
1008
- // src/components/ui-primitive/card.tsx
1009
- var import_react23 = require("react");
1010
- var import_jsx_runtime21 = require("react/jsx-runtime");
1011
- var Card = (0, import_react23.forwardRef)(
1012
- ({ className, style, ...props }, ref) => {
1013
- const classNames = ["tiptap-card", className].filter(Boolean).join(" ");
1014
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref, className: classNames, style, ...props });
1015
- }
1016
- );
1017
- Card.displayName = "Card";
1018
- var CardBody = (0, import_react23.forwardRef)(
1019
- ({ className, style, ...props }, ref) => {
1020
- const classNames = ["tiptap-card-body", className].filter(Boolean).join(" ");
1021
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ref, className: classNames, style, ...props });
1022
- }
1023
- );
1024
- CardBody.displayName = "CardBody";
1025
- var CardItemGroup = (0, import_react23.forwardRef)(
1026
- ({ className, orientation = "vertical", style, ...props }, ref) => {
1027
- const classNames = ["tiptap-card-item-group", className].filter(Boolean).join(" ");
1028
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1029
- "div",
1030
- {
1031
- ref,
1032
- className: classNames,
1033
- "data-orientation": orientation,
1034
- style,
1035
- ...props
1036
- }
1037
- );
1038
- }
1039
- );
1040
- CardItemGroup.displayName = "CardItemGroup";
1041
-
1042
- // src/components/ui-primitive/input.tsx
1043
- var import_jsx_runtime22 = require("react/jsx-runtime");
1044
- function Input({ className, ...props }) {
1045
- const classNames = ["tiptap-input", className].filter(Boolean).join(" ");
1046
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { className: classNames, ...props });
1047
- }
1048
-
1049
- // src/components/ui-primitive/popover.tsx
1050
- var import_react24 = require("react");
1051
- var import_react_dom2 = require("react-dom");
1052
- var import_jsx_runtime23 = require("react/jsx-runtime");
1053
- function Popover({
1054
- trigger,
1055
- children,
1056
- open,
1057
- onOpenChange
1058
- }) {
1059
- const triggerRef = (0, import_react24.useRef)(null);
1060
- const contentRef = (0, import_react24.useRef)(null);
1061
- const [position, setPosition] = (0, import_react24.useState)({ top: 0, left: 0 });
1062
- (0, import_react24.useEffect)(() => {
1063
- if (!open || !triggerRef.current) return;
1064
- const updatePosition = () => {
1065
- if (!triggerRef.current) return;
1066
- const rect = triggerRef.current.getBoundingClientRect();
1067
- setPosition({
1068
- top: rect.bottom + 4,
1069
- left: rect.left + rect.width / 2
1070
- });
1071
- };
1072
- updatePosition();
1073
- window.addEventListener("scroll", updatePosition, true);
1074
- window.addEventListener("resize", updatePosition);
1075
- return () => {
1076
- window.removeEventListener("scroll", updatePosition, true);
1077
- window.removeEventListener("resize", updatePosition);
1078
- };
1079
- }, [open]);
1080
- (0, import_react24.useEffect)(() => {
1081
- if (!open) return;
1082
- const handleMouseDown = (event) => {
1083
- const target = event.target;
1084
- if (triggerRef.current?.contains(target) || contentRef.current?.contains(target)) {
1085
- return;
1086
- }
1087
- onOpenChange(false);
1088
- };
1089
- document.addEventListener("mousedown", handleMouseDown);
1090
- return () => document.removeEventListener("mousedown", handleMouseDown);
1091
- }, [open, onOpenChange]);
1092
- (0, import_react24.useEffect)(() => {
1093
- if (!open) return;
1094
- const handleKeyDown = (event) => {
1095
- if (event.key === "Escape") {
1096
- onOpenChange(false);
1097
- }
1098
- };
1099
- document.addEventListener("keydown", handleKeyDown);
1100
- return () => document.removeEventListener("keydown", handleKeyDown);
1101
- }, [open, onOpenChange]);
1102
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
1103
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ref: triggerRef, children: trigger }),
1104
- open && (0, import_react_dom2.createPortal)(
1105
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "notra-editor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1106
- "div",
1107
- {
1108
- ref: contentRef,
1109
- className: "tiptap-popover-content",
1110
- "data-state": "open",
1111
- style: {
1112
- position: "fixed",
1113
- top: position.top,
1114
- left: position.left
1115
- },
1116
- children
1117
- }
1118
- ) }),
1119
- document.body
1120
- )
1121
- ] });
1122
- }
1123
-
1124
- // src/components/link-popover/link-popover.tsx
1125
- var import_jsx_runtime24 = require("react/jsx-runtime");
1126
- var LinkPopover = (0, import_react25.forwardRef)(
1127
- ({ editor, ...buttonProps }, ref) => {
1128
- const [isOpen, setIsOpen] = (0, import_react25.useState)(false);
1129
- const { url, setUrl, isActive, canSet, setLink, removeLink, openLink } = useLinkPopover({ editor });
1130
- (0, import_react25.useEffect)(() => {
1131
- if (isActive) {
1132
- setIsOpen(true);
1133
- }
1134
- }, [isActive]);
1135
- const handleSetLink = (0, import_react25.useCallback)(() => {
1136
- setLink();
1137
- setIsOpen(false);
1138
- }, [setLink]);
1139
- const handleRemoveLink = (0, import_react25.useCallback)(() => {
1140
- removeLink();
1141
- setIsOpen(false);
1142
- }, [removeLink]);
1143
- const handleKeyDown = (0, import_react25.useCallback)(
1144
- (event) => {
1145
- if (event.key === "Enter") {
1146
- event.preventDefault();
1147
- handleSetLink();
1148
- }
1149
- },
1150
- [handleSetLink]
1151
- );
1152
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1153
- Popover,
1154
- {
1155
- open: isOpen,
1156
- trigger: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1157
- Button,
1158
- {
1159
- ref,
1160
- "aria-label": "Link",
1161
- "aria-pressed": isActive,
1162
- "data-active-state": isActive ? "on" : "off",
1163
- disabled: !canSet,
1164
- tabIndex: -1,
1165
- type: "button",
1166
- variant: "ghost",
1167
- onClick: () => setIsOpen((prev) => !prev),
1168
- ...buttonProps,
1169
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(LinkIcon, { className: "tiptap-button-icon" })
1170
- }
1171
- ),
1172
- onOpenChange: setIsOpen,
1173
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(CardItemGroup, { orientation: "horizontal", children: [
1174
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1175
- Input,
1176
- {
1177
- autoFocus: true,
1178
- className: "tiptap-link-input",
1179
- placeholder: "Paste a link...",
1180
- type: "url",
1181
- value: url,
1182
- onChange: (e) => setUrl(e.target.value),
1183
- onKeyDown: handleKeyDown
1184
- }
1185
- ),
1186
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1187
- Button,
1188
- {
1189
- "aria-label": "Apply link",
1190
- disabled: !url && !isActive,
1191
- tabIndex: -1,
1192
- type: "button",
1193
- variant: "ghost",
1194
- onClick: handleSetLink,
1195
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CornerDownLeftIcon, { className: "tiptap-button-icon" })
1196
- }
1197
- ),
1198
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ToolbarSeparator, {}),
1199
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1200
- Button,
1201
- {
1202
- "aria-label": "Open link in new window",
1203
- tabIndex: -1,
1204
- type: "button",
1205
- variant: "ghost",
1206
- onClick: openLink,
1207
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ExternalLinkIcon, { className: "tiptap-button-icon" })
1208
- }
1209
- ),
1210
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1211
- Button,
1212
- {
1213
- "aria-label": "Remove link",
1214
- tabIndex: -1,
1215
- type: "button",
1216
- variant: "ghost",
1217
- onClick: handleRemoveLink,
1218
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TrashIcon, { className: "tiptap-button-icon" })
1219
- }
1220
- )
1221
- ] }) }) })
1222
- }
1223
- );
1224
- }
1225
- );
1226
- LinkPopover.displayName = "LinkPopover";
1227
-
1228
- // src/components/list-dropdown-menu/list-dropdown-menu.tsx
1229
- var import_react31 = require("react");
1230
-
1231
- // src/components/list-dropdown-menu/list-button.tsx
1232
- var import_react30 = require("react");
1233
-
1234
- // src/components/list-dropdown-menu/use-list.ts
1235
- var import_react29 = require("react");
1236
-
1237
- // src/icons/bullet-list-icon.tsx
1238
- var import_react26 = require("react");
1239
- var import_jsx_runtime25 = require("react/jsx-runtime");
1240
- var BulletListIcon = (0, import_react26.memo)(({ className, ...props }) => {
1241
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
1242
- "svg",
1243
- {
1244
- className,
1245
- fill: "currentColor",
1246
- height: "24",
1247
- viewBox: "0 0 24 24",
1248
- width: "24",
1249
- xmlns: "http://www.w3.org/2000/svg",
1250
- ...props,
1251
- children: [
1252
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1253
- "path",
1254
- {
1255
- clipRule: "evenodd",
1256
- d: "M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",
1257
- fill: "currentColor",
1258
- fillRule: "evenodd"
1259
- }
1260
- ),
1261
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1262
- "path",
1263
- {
1264
- clipRule: "evenodd",
1265
- d: "M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",
1266
- fill: "currentColor",
1267
- fillRule: "evenodd"
1268
- }
1269
- ),
1270
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1271
- "path",
1272
- {
1273
- clipRule: "evenodd",
1274
- d: "M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",
1275
- fill: "currentColor",
1276
- fillRule: "evenodd"
1277
- }
1278
- ),
1279
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1280
- "path",
1281
- {
1282
- clipRule: "evenodd",
1283
- d: "M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",
1284
- fill: "currentColor",
1285
- fillRule: "evenodd"
1286
- }
1287
- ),
1288
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1289
- "path",
1290
- {
1291
- clipRule: "evenodd",
1292
- d: "M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",
1293
- fill: "currentColor",
1294
- fillRule: "evenodd"
1295
- }
1296
- ),
1297
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1298
- "path",
1299
- {
1300
- clipRule: "evenodd",
1301
- d: "M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",
1302
- fill: "currentColor",
1303
- fillRule: "evenodd"
1304
- }
1305
- )
1306
- ]
1307
- }
1308
- );
1309
- });
1310
- BulletListIcon.displayName = "BulletListIcon";
1311
-
1312
- // src/icons/ordered-list-icon.tsx
1313
- var import_react27 = require("react");
1314
- var import_jsx_runtime26 = require("react/jsx-runtime");
1315
- var OrderedListIcon = (0, import_react27.memo)(({ className, ...props }) => {
1316
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
1317
- "svg",
1318
- {
1319
- className,
1320
- fill: "currentColor",
1321
- height: "24",
1322
- viewBox: "0 0 24 24",
1323
- width: "24",
1324
- xmlns: "http://www.w3.org/2000/svg",
1325
- ...props,
1326
- children: [
1327
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1328
- "path",
1329
- {
1330
- clipRule: "evenodd",
1331
- d: "M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",
1332
- fill: "currentColor",
1333
- fillRule: "evenodd"
1334
- }
1335
- ),
1336
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1337
- "path",
1338
- {
1339
- clipRule: "evenodd",
1340
- d: "M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",
1341
- fill: "currentColor",
1342
- fillRule: "evenodd"
1343
- }
1344
- ),
1345
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1346
- "path",
1347
- {
1348
- clipRule: "evenodd",
1349
- d: "M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",
1350
- fill: "currentColor",
1351
- fillRule: "evenodd"
1352
- }
1353
- ),
1354
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1355
- "path",
1356
- {
1357
- clipRule: "evenodd",
1358
- d: "M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",
1359
- fill: "currentColor",
1360
- fillRule: "evenodd"
1361
- }
1362
- ),
1363
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1364
- "path",
1365
- {
1366
- clipRule: "evenodd",
1367
- d: "M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",
1368
- fill: "currentColor",
1369
- fillRule: "evenodd"
1370
- }
1371
- ),
1372
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1373
- "path",
1374
- {
1375
- clipRule: "evenodd",
1376
- d: "M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",
1377
- fill: "currentColor",
1378
- fillRule: "evenodd"
1379
- }
1380
- )
1381
- ]
1382
- }
1383
- );
1384
- });
1385
- OrderedListIcon.displayName = "OrderedListIcon";
1386
-
1387
- // src/icons/task-list-icon.tsx
1388
- var import_react28 = require("react");
1389
- var import_jsx_runtime27 = require("react/jsx-runtime");
1390
- var TaskListIcon = (0, import_react28.memo)(({ className, ...props }) => {
1391
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
1392
- "svg",
1393
- {
1394
- className,
1395
- fill: "currentColor",
1396
- height: "24",
1397
- viewBox: "0 0 24 24",
1398
- width: "24",
1399
- xmlns: "http://www.w3.org/2000/svg",
1400
- ...props,
1401
- children: [
1402
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1403
- "path",
1404
- {
1405
- clipRule: "evenodd",
1406
- d: "M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",
1407
- fill: "currentColor",
1408
- fillRule: "evenodd"
1409
- }
1410
- ),
1411
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1412
- "path",
1413
- {
1414
- clipRule: "evenodd",
1415
- d: "M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",
1416
- fill: "currentColor",
1417
- fillRule: "evenodd"
1418
- }
1419
- ),
1420
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1421
- "path",
1422
- {
1423
- clipRule: "evenodd",
1424
- d: "M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",
1425
- fill: "currentColor",
1426
- fillRule: "evenodd"
1427
- }
1428
- ),
1429
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1430
- "path",
1431
- {
1432
- clipRule: "evenodd",
1433
- d: "M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",
1434
- fill: "currentColor",
1435
- fillRule: "evenodd"
1436
- }
1437
- ),
1438
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1439
- "path",
1440
- {
1441
- clipRule: "evenodd",
1442
- d: "M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",
1443
- fill: "currentColor",
1444
- fillRule: "evenodd"
1445
- }
1446
- )
1447
- ]
1448
- }
1449
- );
1450
- });
1451
- TaskListIcon.displayName = "TaskListIcon";
1452
-
1453
- // src/components/list-dropdown-menu/use-list.ts
1454
- var listIcons = {
1455
- bulletList: BulletListIcon,
1456
- orderedList: OrderedListIcon,
1457
- taskList: TaskListIcon
1458
- };
1459
- var listLabels = {
1460
- bulletList: "Bullet List",
1461
- orderedList: "Ordered List",
1462
- taskList: "Task List"
1463
- };
1464
- var listItemTypes = {
1465
- bulletList: "listItem",
1466
- orderedList: "listItem",
1467
- taskList: "taskItem"
1468
- };
1469
- function canToggleList(editor) {
1470
- if (!editor || !editor.isEditable) return false;
1471
- return editor.can().toggleList("bulletList", "listItem") || editor.can().clearNodes();
1472
- }
1473
- function useList({
1474
- editor,
1475
- type
1476
- }) {
1477
- const [isActive, setIsActive] = (0, import_react29.useState)(false);
1478
- const [canToggle, setCanToggle] = (0, import_react29.useState)(false);
1479
- (0, import_react29.useEffect)(() => {
1480
- if (!editor) return;
1481
- const handleUpdate = () => {
1482
- setIsActive(editor.isActive(type));
1483
- setCanToggle(canToggleList(editor));
1484
- };
1485
- handleUpdate();
1486
- editor.on("selectionUpdate", handleUpdate);
1487
- editor.on("transaction", handleUpdate);
1488
- return () => {
1489
- editor.off("selectionUpdate", handleUpdate);
1490
- editor.off("transaction", handleUpdate);
1491
- };
1492
- }, [editor, type]);
1493
- const handleToggle = (0, import_react29.useCallback)(() => {
1494
- if (!editor || !editor.isEditable) return false;
1495
- const itemType = listItemTypes[type];
1496
- if (editor.isActive(type)) {
1497
- return editor.chain().focus().clearNodes().run();
1498
- }
1499
- return editor.chain().focus().clearNodes().toggleList(type, itemType).run();
1500
- }, [editor, type]);
1501
- return {
1502
- isActive,
1503
- canToggle,
1504
- handleToggle,
1505
- label: listLabels[type],
1506
- Icon: listIcons[type]
1507
- };
1508
- }
1509
- function useActiveListType(editor, types) {
1510
- const [activeType, setActiveType] = (0, import_react29.useState)(null);
1511
- (0, import_react29.useEffect)(() => {
1512
- if (!editor) return;
1513
- const handleUpdate = () => {
1514
- const found = types.find((type) => editor.isActive(type));
1515
- setActiveType(found ?? null);
1516
- };
1517
- handleUpdate();
1518
- editor.on("selectionUpdate", handleUpdate);
1519
- editor.on("transaction", handleUpdate);
1520
- return () => {
1521
- editor.off("selectionUpdate", handleUpdate);
1522
- editor.off("transaction", handleUpdate);
1523
- };
1524
- }, [editor, types]);
1525
- return activeType;
1526
- }
1527
- function getListTriggerIcon(activeType) {
1528
- if (activeType === null) return BulletListIcon;
1529
- return listIcons[activeType];
1530
- }
1531
-
1532
- // src/components/list-dropdown-menu/list-button.tsx
1533
- var import_jsx_runtime28 = require("react/jsx-runtime");
1534
- var ListButton = (0, import_react30.forwardRef)(
1535
- ({ editor, listType, onClick, ...buttonProps }, ref) => {
1536
- const { isActive, canToggle, handleToggle, label, Icon } = useList({
1537
- editor,
1538
- type: listType
1539
- });
1540
- const handleClick = (0, import_react30.useCallback)(
1541
- (event) => {
1542
- onClick?.(event);
1543
- if (event.defaultPrevented) return;
1544
- handleToggle();
1545
- },
1546
- [handleToggle, onClick]
1547
- );
1548
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
1549
- Button,
1550
- {
1551
- ref,
1552
- "aria-label": label,
1553
- "aria-pressed": isActive,
1554
- "data-active-state": isActive ? "on" : "off",
1555
- disabled: !canToggle,
1556
- role: "menuitem",
1557
- tabIndex: -1,
1558
- type: "button",
1559
- variant: "ghost",
1560
- onClick: handleClick,
1561
- ...buttonProps,
1562
- children: [
1563
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { className: "tiptap-button-icon" }),
1564
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "tiptap-button-text", children: label }),
1565
- isActive && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CheckIcon, {})
1566
- ]
1567
- }
1568
- );
1569
- }
1570
- );
1571
- ListButton.displayName = "ListButton";
1572
-
1573
- // src/components/list-dropdown-menu/list-dropdown-menu.tsx
1574
- var import_jsx_runtime29 = require("react/jsx-runtime");
1575
- var ListDropdownMenu = (0, import_react31.forwardRef)(
1576
- ({
1577
- editor,
1578
- types = ["bulletList", "orderedList", "taskList"],
1579
- ...buttonProps
1580
- }, ref) => {
1581
- const activeType = useActiveListType(editor, types);
1582
- const TriggerIcon = getListTriggerIcon(activeType);
1583
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1584
- DropdownMenu,
1585
- {
1586
- trigger: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
1587
- Button,
1588
- {
1589
- ref,
1590
- "aria-label": "List",
1591
- "data-active-state": activeType !== null ? "on" : "off",
1592
- tabIndex: -1,
1593
- type: "button",
1594
- variant: "ghost",
1595
- ...buttonProps,
1596
- children: [
1597
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TriggerIcon, { className: "tiptap-button-icon" }),
1598
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronDownIcon, { className: "tiptap-button-dropdown-arrows" })
1599
- ]
1600
- }
1601
- ),
1602
- children: types.map((type) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ListButton, { editor, listType: type }, type))
1603
- }
1604
- );
1605
- }
1606
- );
1607
- ListDropdownMenu.displayName = "ListDropdownMenu";
1608
-
1609
- // src/components/mark-button/mark-button.tsx
1610
- var import_react37 = require("react");
1611
-
1612
- // src/components/mark-button/use-mark.ts
1613
- var import_react36 = require("react");
1614
-
1615
- // src/icons/bold-icon.tsx
1616
- var import_react32 = require("react");
1617
- var import_jsx_runtime30 = require("react/jsx-runtime");
1618
- var BoldIcon = (0, import_react32.memo)(({ className, ...props }) => {
1619
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1620
- "svg",
1621
- {
1622
- className,
1623
- fill: "currentColor",
1624
- height: "24",
1625
- viewBox: "0 0 24 24",
1626
- width: "24",
1627
- xmlns: "http://www.w3.org/2000/svg",
1628
- ...props,
1629
- children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1630
- "path",
1631
- {
1632
- clipRule: "evenodd",
1633
- d: "M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",
1634
- fill: "currentColor",
1635
- fillRule: "evenodd"
1636
- }
1637
- )
1638
- }
1639
- );
1640
- });
1641
- BoldIcon.displayName = "BoldIcon";
1642
-
1643
- // src/icons/code-icon.tsx
1644
- var import_react33 = require("react");
1645
- var import_jsx_runtime31 = require("react/jsx-runtime");
1646
- var CodeIcon = (0, import_react33.memo)(({ className, ...props }) => {
1647
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
1648
- "svg",
1649
- {
1650
- className,
1651
- fill: "currentColor",
1652
- height: "24",
1653
- viewBox: "0 0 24 24",
1654
- width: "24",
1655
- xmlns: "http://www.w3.org/2000/svg",
1656
- ...props,
1657
- children: [
1658
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1659
- "path",
1660
- {
1661
- d: "M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",
1662
- fill: "currentColor"
1663
- }
1664
- ),
1665
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1666
- "path",
1667
- {
1668
- d: "M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",
1669
- fill: "currentColor"
1670
- }
1671
- ),
1672
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
1673
- "path",
1674
- {
1675
- d: "M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",
1676
- fill: "currentColor"
1677
- }
1678
- )
1679
- ]
1680
- }
1681
- );
1682
- });
1683
- CodeIcon.displayName = "CodeIcon";
1684
-
1685
- // src/icons/italic-icon.tsx
1686
- var import_react34 = require("react");
1687
- var import_jsx_runtime32 = require("react/jsx-runtime");
1688
- var ItalicIcon = (0, import_react34.memo)(({ className, ...props }) => {
1689
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1690
- "svg",
1691
- {
1692
- className,
1693
- fill: "currentColor",
1694
- height: "24",
1695
- viewBox: "0 0 24 24",
1696
- width: "24",
1697
- xmlns: "http://www.w3.org/2000/svg",
1698
- ...props,
1699
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
1700
- "path",
1701
- {
1702
- d: "M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",
1703
- fill: "currentColor"
1704
- }
1705
- )
1706
- }
1707
- );
1708
- });
1709
- ItalicIcon.displayName = "ItalicIcon";
1710
-
1711
- // src/icons/strikethrough-icon.tsx
1712
- var import_react35 = require("react");
1713
- var import_jsx_runtime33 = require("react/jsx-runtime");
1714
- var StrikethroughIcon = (0, import_react35.memo)(({ className, ...props }) => {
1715
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
1716
- "svg",
1717
- {
1718
- className,
1719
- fill: "currentColor",
1720
- height: "24",
1721
- viewBox: "0 0 24 24",
1722
- width: "24",
1723
- xmlns: "http://www.w3.org/2000/svg",
1724
- ...props,
1725
- children: [
1726
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1727
- "path",
1728
- {
1729
- d: "M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",
1730
- fill: "currentColor"
1731
- }
1732
- ),
1733
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1734
- "path",
1735
- {
1736
- d: "M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",
1737
- fill: "currentColor"
1738
- }
1739
- )
1740
- ]
1741
- }
1742
- );
1743
- });
1744
- StrikethroughIcon.displayName = "StrikethroughIcon";
1745
-
1746
- // src/components/mark-button/use-mark.ts
1747
- var markLabels = {
1748
- bold: "Bold",
1749
- italic: "Italic",
1750
- strike: "Strikethrough",
1751
- code: "Code"
1752
- };
1753
- var markIcons = {
1754
- bold: BoldIcon,
1755
- italic: ItalicIcon,
1756
- strike: StrikethroughIcon,
1757
- code: CodeIcon
1758
- };
1759
- function useMark({ editor, type }) {
1760
- const [isActive, setIsActive] = (0, import_react36.useState)(false);
1761
- const [canToggle, setCanToggle] = (0, import_react36.useState)(false);
1762
- (0, import_react36.useEffect)(() => {
1763
- if (!editor) return;
1764
- const handleUpdate = () => {
1765
- setIsActive(editor.isActive(type));
1766
- setCanToggle(editor.isEditable && editor.can().toggleMark(type));
1767
- };
1768
- handleUpdate();
1769
- editor.on("selectionUpdate", handleUpdate);
1770
- editor.on("transaction", handleUpdate);
1771
- return () => {
1772
- editor.off("selectionUpdate", handleUpdate);
1773
- editor.off("transaction", handleUpdate);
1774
- };
1775
- }, [editor, type]);
1776
- const handleToggle = (0, import_react36.useCallback)(() => {
1777
- if (!editor || !editor.isEditable) return false;
1778
- return editor.chain().focus().toggleMark(type).run();
1779
- }, [editor, type]);
1780
- return {
1781
- isActive,
1782
- canToggle,
1783
- handleToggle,
1784
- label: markLabels[type],
1785
- Icon: markIcons[type]
1786
- };
1787
- }
1788
-
1789
- // src/components/mark-button/mark-button.tsx
1790
- var import_jsx_runtime34 = require("react/jsx-runtime");
1791
- var MarkButton = (0, import_react37.forwardRef)(
1792
- ({ editor, type, onClick, ...buttonProps }, ref) => {
1793
- const { isActive, canToggle, handleToggle, label, Icon } = useMark({
1794
- editor,
1795
- type
1796
- });
1797
- const handleClick = (0, import_react37.useCallback)(
1798
- (event) => {
1799
- onClick?.(event);
1800
- if (event.defaultPrevented) return;
1801
- handleToggle();
1802
- },
1803
- [handleToggle, onClick]
1804
- );
1805
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1806
- Button,
1807
- {
1808
- ref,
1809
- "aria-label": label,
1810
- "aria-pressed": isActive,
1811
- "data-active-state": isActive ? "on" : "off",
1812
- disabled: !canToggle,
1813
- tabIndex: -1,
1814
- type: "button",
1815
- variant: "ghost",
1816
- onClick: handleClick,
1817
- ...buttonProps,
1818
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Icon, { className: "tiptap-button-icon" })
1819
- }
1820
- );
1821
- }
1822
- );
1823
- MarkButton.displayName = "MarkButton";
1824
-
1825
- // src/components/ui-primitive/spacer.tsx
1826
- var import_jsx_runtime35 = require("react/jsx-runtime");
1827
- function Spacer() {
1828
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { style: { flex: 1 } });
1829
- }
1830
-
1831
- // src/components/undo-redo-button/undo-redo-button.tsx
1832
- var import_react41 = require("react");
1833
-
1834
- // src/components/undo-redo-button/use-undo-redo.ts
1835
- var import_react40 = require("react");
1836
-
1837
- // src/icons/redo-icon.tsx
1838
- var import_react38 = require("react");
1839
- var import_jsx_runtime36 = require("react/jsx-runtime");
1840
- var RedoIcon = (0, import_react38.memo)(({ className, ...props }) => {
1841
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1842
- "svg",
1843
- {
1844
- className,
1845
- fill: "currentColor",
1846
- height: "24",
1847
- viewBox: "0 0 24 24",
1848
- width: "24",
1849
- xmlns: "http://www.w3.org/2000/svg",
1850
- ...props,
1851
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
1852
- "path",
1853
- {
1854
- clipRule: "evenodd",
1855
- d: "M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",
1856
- fill: "currentColor",
1857
- fillRule: "evenodd"
1858
- }
1859
- )
1860
- }
1861
- );
1862
- });
1863
- RedoIcon.displayName = "RedoIcon";
1864
-
1865
- // src/icons/undo-icon.tsx
1866
- var import_react39 = require("react");
1867
- var import_jsx_runtime37 = require("react/jsx-runtime");
1868
- var UndoIcon = (0, import_react39.memo)(({ className, ...props }) => {
1869
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1870
- "svg",
1871
- {
1872
- className,
1873
- fill: "currentColor",
1874
- height: "24",
1875
- viewBox: "0 0 24 24",
1876
- width: "24",
1877
- xmlns: "http://www.w3.org/2000/svg",
1878
- ...props,
1879
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
1880
- "path",
1881
- {
1882
- clipRule: "evenodd",
1883
- d: "M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",
1884
- fill: "currentColor",
1885
- fillRule: "evenodd"
1886
- }
1887
- )
1888
- }
1889
- );
1890
- });
1891
- UndoIcon.displayName = "UndoIcon";
1892
-
1893
- // src/components/undo-redo-button/use-undo-redo.ts
1894
- var actionLabels = {
1895
- undo: "Undo",
1896
- redo: "Redo"
1897
- };
1898
- var actionIcons = {
1899
- undo: UndoIcon,
1900
- redo: RedoIcon
1901
- };
1902
- function canExecuteAction(editor, action) {
1903
- if (!editor || !editor.isEditable) return false;
1904
- return action === "undo" ? editor.can().undo() : editor.can().redo();
1905
- }
1906
- function useUndoRedo({ editor, action }) {
1907
- const [canExecute, setCanExecute] = (0, import_react40.useState)(false);
1908
- (0, import_react40.useEffect)(() => {
1909
- if (!editor) return;
1910
- const handleUpdate = () => {
1911
- setCanExecute(canExecuteAction(editor, action));
1912
- };
1913
- handleUpdate();
1914
- editor.on("transaction", handleUpdate);
1915
- return () => {
1916
- editor.off("transaction", handleUpdate);
1917
- };
1918
- }, [editor, action]);
1919
- const handleAction = (0, import_react40.useCallback)(() => {
1920
- if (!editor || !editor.isEditable) return false;
1921
- if (!canExecuteAction(editor, action)) return false;
1922
- const chain = editor.chain().focus();
1923
- return action === "undo" ? chain.undo().run() : chain.redo().run();
1924
- }, [editor, action]);
1925
- return {
1926
- canExecute,
1927
- handleAction,
1928
- label: actionLabels[action],
1929
- Icon: actionIcons[action]
1930
- };
1931
- }
1932
-
1933
- // src/components/undo-redo-button/undo-redo-button.tsx
1934
- var import_jsx_runtime38 = require("react/jsx-runtime");
1935
- var UndoRedoButton = (0, import_react41.forwardRef)(({ editor, action, onClick, ...buttonProps }, ref) => {
1936
- const { canExecute, handleAction, label, Icon } = useUndoRedo({
1937
- editor,
1938
- action
1939
- });
1940
- const handleClick = (0, import_react41.useCallback)(
1941
- (event) => {
1942
- onClick?.(event);
1943
- if (event.defaultPrevented) return;
1944
- handleAction();
1945
- },
1946
- [handleAction, onClick]
1947
- );
1948
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1949
- Button,
1950
- {
1951
- ref,
1952
- "aria-label": label,
1953
- disabled: !canExecute,
1954
- tabIndex: -1,
1955
- type: "button",
1956
- variant: "ghost",
1957
- onClick: handleClick,
1958
- ...buttonProps,
1959
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Icon, { className: "tiptap-button-icon" })
1960
- }
1961
- );
1962
- });
1963
- UndoRedoButton.displayName = "UndoRedoButton";
1964
-
1965
- // src/hooks/use-markdown-editor.ts
1966
- var import_state = require("@tiptap/pm/state");
1967
- var import_react42 = require("@tiptap/react");
1968
- var import_react43 = require("react");
1969
-
1970
- // src/extensions/shared.ts
1971
- var import_extension_list = require("@tiptap/extension-list");
1972
- var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
1973
- var starterKitBaseConfig = {
1974
- heading: { levels: [1, 2, 3, 4, 5, 6] },
1975
- link: {
1976
- openOnClick: false,
1977
- autolink: true
1978
- },
1979
- // Disable StarterKit's built-in list handling; use @tiptap/extension-list instead
1980
- bulletList: false,
1981
- orderedList: false,
1982
- listItem: false,
1983
- listKeymap: false
1984
- };
1985
- var sharedExtensions = [
1986
- import_starter_kit.default.configure({
1987
- ...starterKitBaseConfig,
1988
- dropcursor: false,
1989
- gapcursor: false,
1990
- undoRedo: false,
1991
- trailingNode: false
1992
- }),
1993
- import_extension_list.ListKit
1994
- ];
1995
-
1996
- // src/extensions/editor.ts
1997
- var import_extension_list2 = require("@tiptap/extension-list");
1998
- var import_starter_kit2 = __toESM(require("@tiptap/starter-kit"), 1);
1999
- var import_tiptap_markdown = require("tiptap-markdown");
2000
- var editorExtensions = [
2001
- import_starter_kit2.default.configure(starterKitBaseConfig),
2002
- import_extension_list2.ListKit,
2003
- import_tiptap_markdown.Markdown.configure({
2004
- html: false,
2005
- transformPastedText: true,
2006
- transformCopiedText: true
2007
- })
2008
- ];
2009
-
2010
- // src/hooks/use-markdown-editor.ts
2011
- function getMarkdown(storage) {
2012
- return storage.markdown.getMarkdown();
2013
- }
2014
- function useMarkdownEditor({
2015
- value,
2016
- onChange,
2017
- editable = true
2018
- }) {
2019
- const externalValue = (0, import_react43.useRef)(value);
2020
- const onChangeRef = (0, import_react43.useRef)(onChange);
2021
- onChangeRef.current = onChange;
2022
- const editor = (0, import_react42.useEditor)({
2023
- extensions: editorExtensions,
2024
- editable,
2025
- content: value,
2026
- onUpdate({ editor: editor2 }) {
2027
- const md = getMarkdown(
2028
- editor2.storage
2029
- );
2030
- externalValue.current = md;
2031
- onChangeRef.current(md);
2032
- },
2033
- onCreate({ editor: editor2 }) {
2034
- setTimeout(() => {
2035
- if (editor2.isDestroyed) return;
2036
- const { state } = editor2;
2037
- const freshState = import_state.EditorState.create({
2038
- doc: state.doc,
2039
- selection: state.selection,
2040
- plugins: state.plugins
2041
- });
2042
- editor2.view.updateState(freshState);
2043
- editor2.view.dispatch(editor2.view.state.tr);
2044
- }, 0);
2045
- }
2046
- });
2047
- (0, import_react43.useEffect)(() => {
2048
- if (!editor) return;
2049
- if (value === externalValue.current) return;
2050
- externalValue.current = value;
2051
- editor.commands.setContent(value);
2052
- }, [value, editor]);
2053
- (0, import_react43.useEffect)(() => {
2054
- if (!editor) return;
2055
- editor.setEditable(editable);
2056
- }, [editable, editor]);
2057
- return { editor };
2058
- }
2059
-
2060
- // src/notra-editor.tsx
2061
- var import_jsx_runtime39 = require("react/jsx-runtime");
2062
- function NotraEditor({
2063
- value,
2064
- onChange,
2065
- placeholder,
2066
- readOnly = false,
2067
- className
2068
- }) {
2069
- const { editor } = useMarkdownEditor({
2070
- value,
2071
- onChange,
2072
- placeholder,
2073
- editable: !readOnly
2074
- });
2075
- const classNames = ["notra", "notra-editor", className].filter(Boolean).join(" ");
2076
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: classNames, children: [
2077
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Toolbar, { variant: "fixed", children: [
2078
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Spacer, {}),
2079
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(ToolbarGroup, { children: [
2080
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UndoRedoButton, { action: "undo", editor }),
2081
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UndoRedoButton, { action: "redo", editor })
2082
- ] }),
2083
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ToolbarSeparator, {}),
2084
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(ToolbarGroup, { children: [
2085
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(HeadingDropdownMenu, { editor, levels: [1, 2, 3, 4] }),
2086
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
2087
- ListDropdownMenu,
2088
- {
2089
- editor,
2090
- types: ["bulletList", "orderedList", "taskList"]
2091
- }
2092
- ),
2093
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BlockquoteButton, { editor }),
2094
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CodeBlockButton, { editor })
2095
- ] }),
2096
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ToolbarSeparator, {}),
2097
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(ToolbarGroup, { children: [
2098
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MarkButton, { editor, type: "bold" }),
2099
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MarkButton, { editor, type: "italic" }),
2100
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MarkButton, { editor, type: "strike" }),
2101
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(MarkButton, { editor, type: "code" }),
2102
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(LinkPopover, { editor })
2103
- ] }),
2104
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Spacer, {})
2105
- ] }),
2106
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react44.EditorContent, { className: "notra-editor-content", editor })
2107
- ] });
2108
- }
2109
-
2110
- // src/notra-reader.tsx
2111
- var import_react45 = require("@tiptap/static-renderer/pm/react");
2112
-
2113
- // src/utils/markdown-to-json.ts
2114
- var import_core = require("@tiptap/core");
2115
- var import_tiptap_markdown2 = require("tiptap-markdown");
2116
- var parserExtensions = [
2117
- ...sharedExtensions,
2118
- import_tiptap_markdown2.Markdown.configure({ html: false })
2119
- ];
2120
- var parserEditor = null;
2121
- function getParserEditor() {
2122
- if (!parserEditor) {
2123
- parserEditor = new import_core.Editor({
2124
- extensions: parserExtensions,
2125
- content: ""
2126
- });
2127
- }
2128
- return parserEditor;
2129
- }
2130
- function markdownToJSON(markdown) {
2131
- const editor = getParserEditor();
2132
- editor.commands.setContent(markdown);
2133
- return editor.getJSON();
2134
- }
2135
-
2136
- // src/notra-reader.tsx
2137
- var import_jsx_runtime40 = require("react/jsx-runtime");
2138
- function NotraReader({ content, className }) {
2139
- const json = markdownToJSON(content);
2140
- const rendered = (0, import_react45.renderToReactElement)({
2141
- extensions: sharedExtensions,
2142
- content: json
2143
- });
2144
- const classNames = ["notra", "notra-reader", className].filter(Boolean).join(" ");
2145
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: classNames, children: rendered });
2146
- }
36
+ var import_globals = require("./styles/globals.css");
37
+ var import_notra_editor = require("./notra-editor");
38
+ var import_notra_reader = require("./notra-reader");
39
+ var import_toolbar = require("./components/toolbar/toolbar");
40
+ var import_undo_redo_button = require("./components/undo-redo-button/undo-redo-button");
41
+ var import_spacer = require("./components/ui/spacer");
42
+ var import_mark_button = require("./components/mark-button/mark-button");
43
+ var import_heading_dropdown_menu = require("./components/heading-dropdown-menu/heading-dropdown-menu");
44
+ var import_list_dropdown_menu = require("./components/list-dropdown-menu/list-dropdown-menu");
45
+ var import_blockquote_button = require("./components/blockquote-button/blockquote-button");
46
+ var import_code_block_button = require("./components/code-block-button/code-block-button");
47
+ var import_link_popover = require("./components/link-popover/link-popover");
2147
48
  // Annotate the CommonJS export names for ESM import in node:
2148
49
  0 && (module.exports = {
2149
50
  BlockquoteButton,
2150
- Button,
2151
51
  CodeBlockButton,
2152
- DropdownMenu,
2153
52
  HeadingDropdownMenu,
2154
53
  LinkPopover,
2155
54
  ListDropdownMenu,
2156
55
  MarkButton,
2157
56
  NotraEditor,
2158
57
  NotraReader,
2159
- Popover,
2160
58
  Spacer,
2161
59
  Toolbar,
2162
60
  ToolbarGroup,