@collabchron/notiq 0.3.0 → 1.0.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 (282) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +230 -39
  3. package/dist/CodeActionMenuPlugin-EINOY4U4.mjs +15 -0
  4. package/dist/DynamicBlockComponent-NRQJ4WW4.mjs +161 -0
  5. package/dist/EquationComponent-CB6DFIHV.mjs +154 -0
  6. package/dist/ExcalidrawComponent-XW6646OH.mjs +528 -0
  7. package/dist/ExcalidrawPlugin-ZFHT62IF.mjs +14 -0
  8. package/dist/ExportPlugin-V2RLM63S.mjs +11 -0
  9. package/dist/FloatingLinkEditorPlugin-TRTCMSP4.mjs +12 -0
  10. package/dist/FloatingTextFormatToolbarPlugin-F2GY6LMI.mjs +30 -0
  11. package/dist/HintComponet-BRL6EAMS.mjs +217 -0
  12. package/dist/InlineImageComponent-UWIUWBHI.mjs +453 -0
  13. package/dist/MobileToolbar-BOOZAMQE.mjs +268 -0
  14. package/dist/SlashCommand-GMT5JI33.mjs +28 -0
  15. package/dist/StoryBuilderComponent-JGDBM5JU.mjs +562 -0
  16. package/{src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx → dist/TableCellActionMenuPlugin-PGK2K3VG.mjs} +667 -759
  17. package/{src/components/editor/plugins/TableHoverActionsPlugin/index.tsx → dist/TableHoverActionsPlugin-GJVE6VRW.mjs} +258 -314
  18. package/dist/TemplatePlugin-ZD3QEVTI.mjs +9 -0
  19. package/dist/ToolbarPlugin-7TOZRD2R.mjs +1547 -0
  20. package/dist/babel-JZ2EV6AX.mjs +7233 -0
  21. package/dist/background-color-XZTYLGO2.mjs +362 -0
  22. package/dist/block-format-YJCV2DIY.mjs +15 -0
  23. package/dist/chunk-2FNEAMSP.mjs +127 -0
  24. package/dist/chunk-3CPBODXA.mjs +84 -0
  25. package/dist/chunk-3G37YKTV.mjs +83 -0
  26. package/dist/chunk-3JVFG7ER.mjs +184 -0
  27. package/dist/chunk-456TN7IM.mjs +110 -0
  28. package/dist/chunk-4EXYCTGJ.mjs +27 -0
  29. package/{src/utils/getSelectedNode.ts → dist/chunk-4HBCVSE6.mjs} +26 -27
  30. package/dist/chunk-4MEDW3T6.mjs +125 -0
  31. package/dist/chunk-4VWFVWYP.mjs +36 -0
  32. package/dist/chunk-5BAKY5KN.mjs +84 -0
  33. package/dist/chunk-5QSNIVIG.mjs +333 -0
  34. package/dist/chunk-64Z3FI7T.mjs +37 -0
  35. package/{src/components/editor/nodes/Stepper/index.tsx → dist/chunk-6RNZQOH2.mjs} +214 -260
  36. package/dist/chunk-77KXU36M.mjs +64 -0
  37. package/dist/chunk-77UA6HYR.mjs +165 -0
  38. package/dist/chunk-7NZAPJ4G.mjs +102 -0
  39. package/dist/chunk-7VUMHWWL.mjs +152 -0
  40. package/dist/chunk-AMMKBSST.mjs +1256 -0
  41. package/dist/chunk-BIU7WTLX.mjs +95 -0
  42. package/dist/chunk-EGMI62PP.mjs +83 -0
  43. package/dist/chunk-EHNQD5KO.mjs +88 -0
  44. package/dist/chunk-FSM26655.mjs +37 -0
  45. package/{src/components/editor/nodes/Hint/index.tsx → dist/chunk-G53GLEAY.mjs} +158 -190
  46. package/dist/chunk-GK35L7UY.mjs +28 -0
  47. package/dist/chunk-GXYD4VZM.mjs +193 -0
  48. package/dist/chunk-GYIOYVCN.mjs +538 -0
  49. package/dist/chunk-GZPNVR7L.mjs +157 -0
  50. package/dist/chunk-JXDPPUJI.mjs +52 -0
  51. package/dist/chunk-K36V4SIW.mjs +141 -0
  52. package/dist/chunk-KJ6AJ44Q.mjs +128 -0
  53. package/dist/chunk-KJV3FAZ7.mjs +142 -0
  54. package/{src/components/editor/plugins/ImagesPlugin/index.tsx → dist/chunk-LGG4IUIA.mjs} +189 -222
  55. package/dist/chunk-LQN3CMKV.mjs +1906 -0
  56. package/dist/chunk-N3WN46VL.mjs +236 -0
  57. package/dist/chunk-PBD6LMLC.mjs +366 -0
  58. package/dist/chunk-POGRR73N.mjs +33 -0
  59. package/{src/components/editor/utils/editorFormatting.ts → dist/chunk-PZSUSXQG.mjs} +238 -282
  60. package/dist/chunk-QEIFVK5M.mjs +29 -0
  61. package/dist/chunk-QHIQKMVN.mjs +427 -0
  62. package/dist/chunk-TCYK7DM7.mjs +36 -0
  63. package/dist/chunk-TTHQCW5F.mjs +47 -0
  64. package/dist/chunk-U47ABU5Z.mjs +53 -0
  65. package/dist/chunk-WDG7J2DY.mjs +116 -0
  66. package/dist/chunk-WJRHXI2C.mjs +733 -0
  67. package/dist/chunk-XLER2DHM.mjs +357 -0
  68. package/dist/chunk-XWC4TK2N.mjs +315 -0
  69. package/dist/chunk-YHPNOWFH.mjs +15 -0
  70. package/dist/chunk-YKC3SO4Z.mjs +32 -0
  71. package/dist/chunk-YMBXLRW5.mjs +374 -0
  72. package/dist/chunk-YPHOEJ46.mjs +64 -0
  73. package/dist/chunk-YUDCJRJM.mjs +25 -0
  74. package/dist/chunk-Z4EWP7BI.mjs +65 -0
  75. package/dist/chunk-ZB5LZQKC.mjs +191 -0
  76. package/dist/chunk-ZJRKATOJ.mjs +65 -0
  77. package/dist/color-BPKOPQKN.mjs +12 -0
  78. package/dist/estree-XC56IUFX.mjs +4414 -0
  79. package/dist/font-FEZ3GKSF.mjs +13 -0
  80. package/dist/font-size-EK775WRH.mjs +15 -0
  81. package/dist/html-S3ACX7NI.mjs +2738 -0
  82. package/dist/image-2PJIAYAT.mjs +993 -0
  83. package/dist/index.d.mts +145 -0
  84. package/dist/index.d.ts +145 -0
  85. package/dist/index.js +57855 -0
  86. package/dist/index.mjs +1790 -0
  87. package/dist/insert-gif-SAIDYURE.mjs +100 -0
  88. package/dist/insert-image-U3RJN3OW.mjs +259 -0
  89. package/dist/insert-node-5P2CRJ7S.mjs +201 -0
  90. package/dist/insert-poll-HCPM7MO6.mjs +33 -0
  91. package/dist/insert-table-24XYUS2W.mjs +66 -0
  92. package/dist/markdown-SNVBOSRA.mjs +3487 -0
  93. package/dist/poll-component-2R4MDLHS.mjs +303 -0
  94. package/dist/postcss-ONF3VDIM.mjs +5051 -0
  95. package/dist/standalone-EOIALU3M.mjs +2373 -0
  96. package/dist/stepper-FSARL6X6.mjs +304 -0
  97. package/dist/styles/notiq.css +1149 -0
  98. package/dist/text-align-VLECWO4H.mjs +118 -0
  99. package/dist/text-format-BG5WOOPZ.mjs +16 -0
  100. package/dist/typescript-AMPI6OVS.mjs +13135 -0
  101. package/package.json +66 -11
  102. package/src/styles/notiq.css +1149 -0
  103. package/src/styles/tailwind-plugin.ts +134 -0
  104. package/components.json +0 -21
  105. package/eslint.config.mjs +0 -16
  106. package/next.config.ts +0 -12
  107. package/postcss.config.mjs +0 -5
  108. package/public/file.svg +0 -1
  109. package/public/globe.svg +0 -1
  110. package/public/images/icons/plus.svg +0 -10
  111. package/public/next.svg +0 -1
  112. package/public/vercel.svg +0 -1
  113. package/public/window.svg +0 -1
  114. package/src/app/actions.ts +0 -2
  115. package/src/app/api/ai/route.ts +0 -175
  116. package/src/app/api/edgestore/[...edgestore]/route.ts +0 -28
  117. package/src/app/favicon.ico +0 -0
  118. package/src/app/globals.css +0 -205
  119. package/src/app/layout.tsx +0 -38
  120. package/src/app/page.tsx +0 -12
  121. package/src/components/editor/Core.tsx +0 -220
  122. package/src/components/editor/hooks/instructions-messages.ts +0 -300
  123. package/src/components/editor/hooks/use-mobile.ts +0 -19
  124. package/src/components/editor/hooks/useReport.ts +0 -67
  125. package/src/components/editor/hooks/useResizeObservert.ts +0 -22
  126. package/src/components/editor/index.tsx +0 -39
  127. package/src/components/editor/lexical-on-change.tsx +0 -28
  128. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +0 -92
  129. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +0 -65
  130. package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +0 -105
  131. package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +0 -143
  132. package/src/components/editor/nodes/EquationNode/EquationNode.tsx +0 -170
  133. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +0 -228
  134. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +0 -137
  135. package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +0 -317
  136. package/src/components/editor/nodes/ExcalidrawNode/index.tsx +0 -204
  137. package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +0 -134
  138. package/src/components/editor/nodes/Hint/HintComponet.tsx +0 -221
  139. package/src/components/editor/nodes/ImageNode/index.tsx +0 -328
  140. package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +0 -383
  141. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +0 -94
  142. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +0 -309
  143. package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +0 -146
  144. package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +0 -79
  145. package/src/components/editor/nodes/PollNode/index.tsx +0 -204
  146. package/src/components/editor/nodes/TweetNode/index.tsx +0 -214
  147. package/src/components/editor/nodes/index.ts +0 -81
  148. package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +0 -350
  149. package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +0 -56
  150. package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +0 -70
  151. package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +0 -192
  152. package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +0 -217
  153. package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +0 -26
  154. package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +0 -21
  155. package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +0 -76
  156. package/src/components/editor/plugins/CollapsiblePlugin/index.ts +0 -228
  157. package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +0 -44
  158. package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +0 -52
  159. package/src/components/editor/plugins/EquationsPlugin/index.tsx +0 -85
  160. package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +0 -98
  161. package/src/components/editor/plugins/FigmaPlugin/index.tsx +0 -42
  162. package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +0 -445
  163. package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +0 -275
  164. package/src/components/editor/plugins/InlineImagePlugin/index.tsx +0 -351
  165. package/src/components/editor/plugins/LayoutPlugin/index.tsx +0 -238
  166. package/src/components/editor/plugins/LinkPlugin/index.tsx +0 -36
  167. package/src/components/editor/plugins/LinkWithMetaData/index.tsx +0 -271
  168. package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +0 -11
  169. package/src/components/editor/plugins/MarkdownTransformers/index.tsx +0 -304
  170. package/src/components/editor/plugins/PollPlugin/index.tsx +0 -49
  171. package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +0 -180
  172. package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +0 -253
  173. package/src/components/editor/plugins/SlashCommand/index.tsx +0 -621
  174. package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +0 -127
  175. package/src/components/editor/plugins/TabFocusPlugin/index.ts +0 -58
  176. package/src/components/editor/plugins/TableCellResizer/index.tsx +0 -438
  177. package/src/components/editor/plugins/TablePlugin/index.tsx +0 -99
  178. package/src/components/editor/plugins/ToolbarPlugin/index.tsx +0 -522
  179. package/src/components/editor/plugins/TwitterPlugin/index.ts +0 -35
  180. package/src/components/editor/plugins/YouTubeNode/index.tsx +0 -179
  181. package/src/components/editor/plugins/YouTubePlugin/index.ts +0 -41
  182. package/src/components/editor/themes/editor-theme.ts +0 -113
  183. package/src/components/editor/themes/theme.css +0 -377
  184. package/src/components/editor/utils/ai.ts +0 -291
  185. package/src/components/editor/utils/canUseDOM.ts +0 -12
  186. package/src/components/editor/utils/environment.ts +0 -50
  187. package/src/components/editor/utils/extract-data.ts +0 -166
  188. package/src/components/editor/utils/getAllLexicalChildren.ts +0 -13
  189. package/src/components/editor/utils/getDOMRangeRect.ts +0 -27
  190. package/src/components/editor/utils/getSelectedNode.ts +0 -27
  191. package/src/components/editor/utils/gif.ts +0 -29
  192. package/src/components/editor/utils/invariant.ts +0 -15
  193. package/src/components/editor/utils/setFloatingElemPosition.ts +0 -51
  194. package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +0 -40
  195. package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +0 -51
  196. package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +0 -15
  197. package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +0 -114
  198. package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +0 -6
  199. package/src/components/editor/utils/url.ts +0 -109
  200. package/src/components/editor/utils/useLayoutEffect.ts +0 -13
  201. package/src/components/providers/QueryProvider.tsx +0 -15
  202. package/src/components/providers/SharedHistoryContext.tsx +0 -28
  203. package/src/components/providers/ToolbarContext.tsx +0 -123
  204. package/src/components/providers/theme-provider.tsx +0 -11
  205. package/src/components/theme/ModeToggle.tsx +0 -40
  206. package/src/components/ui/FileInput.tsx +0 -40
  207. package/src/components/ui/Input.css +0 -32
  208. package/src/components/ui/Select.css +0 -42
  209. package/src/components/ui/Select.tsx +0 -36
  210. package/src/components/ui/TextInput.tsx +0 -48
  211. package/src/components/ui/ai/ai-button.tsx +0 -574
  212. package/src/components/ui/ai/border.tsx +0 -99
  213. package/src/components/ui/ai/placeholder-input-vanish.tsx +0 -282
  214. package/src/components/ui/button.tsx +0 -89
  215. package/src/components/ui/card.tsx +0 -76
  216. package/src/components/ui/checkbox.tsx +0 -30
  217. package/src/components/ui/command.tsx +0 -153
  218. package/src/components/ui/dialog/Dialog.css +0 -25
  219. package/src/components/ui/dialog/Dialog.tsx +0 -34
  220. package/src/components/ui/dialog.tsx +0 -122
  221. package/src/components/ui/drop-downs/background-color.tsx +0 -183
  222. package/src/components/ui/drop-downs/block-format.tsx +0 -159
  223. package/src/components/ui/drop-downs/code.tsx +0 -42
  224. package/src/components/ui/drop-downs/color.tsx +0 -177
  225. package/src/components/ui/drop-downs/font-size.tsx +0 -138
  226. package/src/components/ui/drop-downs/font.tsx +0 -155
  227. package/src/components/ui/drop-downs/index.tsx +0 -122
  228. package/src/components/ui/drop-downs/insert-node.tsx +0 -213
  229. package/src/components/ui/drop-downs/text-align.tsx +0 -123
  230. package/src/components/ui/drop-downs/text-format.tsx +0 -104
  231. package/src/components/ui/dropdown-menu.tsx +0 -201
  232. package/src/components/ui/equation/EquationEditor.css +0 -38
  233. package/src/components/ui/equation/EquationEditor.tsx +0 -56
  234. package/src/components/ui/equation/KatexEquationAlterer.css +0 -41
  235. package/src/components/ui/equation/KatexEquationAlterer.tsx +0 -83
  236. package/src/components/ui/equation/KatexRenderer.tsx +0 -66
  237. package/src/components/ui/excalidraw/ExcalidrawModal.css +0 -64
  238. package/src/components/ui/excalidraw/ExcalidrawModal.tsx +0 -234
  239. package/src/components/ui/excalidraw/Modal.css +0 -62
  240. package/src/components/ui/excalidraw/Modal.tsx +0 -110
  241. package/src/components/ui/hover-card.tsx +0 -29
  242. package/src/components/ui/image/error-image.tsx +0 -17
  243. package/src/components/ui/image/file-upload.tsx +0 -240
  244. package/src/components/ui/image/image-resizer.tsx +0 -297
  245. package/src/components/ui/image/image-toolbar.tsx +0 -264
  246. package/src/components/ui/image/index.tsx +0 -408
  247. package/src/components/ui/image/lazy-image.tsx +0 -68
  248. package/src/components/ui/image/lazy-video.tsx +0 -71
  249. package/src/components/ui/input.tsx +0 -22
  250. package/src/components/ui/models/custom-dialog.tsx +0 -320
  251. package/src/components/ui/models/insert-gif.tsx +0 -90
  252. package/src/components/ui/models/insert-image.tsx +0 -52
  253. package/src/components/ui/models/insert-poll.tsx +0 -29
  254. package/src/components/ui/models/insert-table.tsx +0 -62
  255. package/src/components/ui/models/use-model.tsx +0 -91
  256. package/src/components/ui/poll/poll-component.tsx +0 -304
  257. package/src/components/ui/popover.tsx +0 -33
  258. package/src/components/ui/progress.tsx +0 -28
  259. package/src/components/ui/scroll-area.tsx +0 -48
  260. package/src/components/ui/separator.tsx +0 -31
  261. package/src/components/ui/skeleton.tsx +0 -15
  262. package/src/components/ui/sonner.tsx +0 -31
  263. package/src/components/ui/stepper/step.tsx +0 -179
  264. package/src/components/ui/stepper/stepper.tsx +0 -89
  265. package/src/components/ui/textarea.tsx +0 -22
  266. package/src/components/ui/toggle.tsx +0 -71
  267. package/src/components/ui/tooltip.tsx +0 -32
  268. package/src/components/ui/write/text-format-floting-toolbar.tsx +0 -346
  269. package/src/lib/edgestore.ts +0 -9
  270. package/src/lib/pinecone-client.ts +0 -0
  271. package/src/lib/utils.ts +0 -6
  272. package/src/utils/docSerialization.ts +0 -77
  273. package/src/utils/emoji-list.ts +0 -16615
  274. package/src/utils/getDOMRangeRect.ts +0 -27
  275. package/src/utils/getThemeSelector.ts +0 -25
  276. package/src/utils/isMobileWidth.ts +0 -7
  277. package/src/utils/joinClasses.ts +0 -13
  278. package/src/utils/setFloatingElemPosition.ts +0 -74
  279. package/src/utils/setFloatingElemPositionForLinkEditor.ts +0 -46
  280. package/src/utils/swipe.ts +0 -127
  281. package/src/utils/url.ts +0 -38
  282. package/tsconfig.json +0 -27
@@ -1,36 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import type {JSX} from 'react';
10
-
11
- import './Select.css';
12
-
13
- import * as React from 'react';
14
-
15
- type SelectIntrinsicProps = JSX.IntrinsicElements['select'];
16
- interface SelectProps extends SelectIntrinsicProps {
17
- label: string;
18
- }
19
-
20
- export default function Select({
21
- children,
22
- label,
23
- className,
24
- ...other
25
- }: SelectProps): JSX.Element {
26
- return (
27
- <div className="Input__wrapper">
28
- <label style={{marginTop: '-1em'}} className="Input__label">
29
- {label}
30
- </label>
31
- <select {...other} className={className || 'select'}>
32
- {children}
33
- </select>
34
- </div>
35
- );
36
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import type {JSX} from 'react';
10
-
11
- import './Input.css';
12
-
13
- import * as React from 'react';
14
- import {HTMLInputTypeAttribute} from 'react';
15
-
16
- type Props = Readonly<{
17
- 'data-test-id'?: string;
18
- label: string;
19
- onChange: (val: string) => void;
20
- placeholder?: string;
21
- value: string;
22
- type?: HTMLInputTypeAttribute;
23
- }>;
24
-
25
- export default function TextInput({
26
- label,
27
- value,
28
- onChange,
29
- placeholder = '',
30
- 'data-test-id': dataTestId,
31
- type = 'text',
32
- }: Props): JSX.Element {
33
- return (
34
- <div className="Input__wrapper">
35
- <label className="Input__label">{label}</label>
36
- <input
37
- type={type}
38
- className="Input__input"
39
- placeholder={placeholder}
40
- value={value}
41
- onChange={(e) => {
42
- onChange(e.target.value);
43
- }}
44
- data-test-id={dataTestId}
45
- />
46
- </div>
47
- );
48
- }
@@ -1,574 +0,0 @@
1
- import { Loader2, RotateCcw, StarsIcon, WandSparkles } from "lucide-react";
2
- import React, { useMemo, useState } from "react";
3
- import {
4
- Popover,
5
- PopoverContent,
6
- PopoverTrigger,
7
- } from "@/components/ui/popover";
8
- import {
9
- Command,
10
- CommandEmpty,
11
- CommandGroup,
12
- CommandInput,
13
- CommandItem,
14
- CommandList,
15
- CommandSeparator,
16
- } from "@/components/ui/command";
17
- import {
18
- HoverCard,
19
- HoverCardContent,
20
- HoverCardTrigger,
21
- } from "@/components/ui/hover-card";
22
- import { HoverBorderGradient } from "./border";
23
- import { PlaceholdersAndVanishInput } from "./placeholder-input-vanish";
24
- import { motion } from "framer-motion";
25
- import {
26
- getSelectedText,
27
- insertText,
28
- insertTextUnderSelected,
29
- replaceSelectedText,
30
- } from "../../editor/utils/ai";
31
- import { LexicalEditor } from "lexical";
32
- import { useCompletion } from "@ai-sdk/react";
33
- import { toast } from "sonner";
34
- import ReactMarkdown from "react-markdown";
35
- import { ExtractData } from "../../editor/utils/extract-data";
36
- import { AIAction } from "../../editor/hooks/instructions-messages";
37
- const placeholders = [
38
- "Chat with what you are writing.",
39
- "Click on the stepper to generate tasks step by step.",
40
- "Click on autocomplete to complete sentences.",
41
- "Is your text too long? Do you want to make it shorter?"
42
- ];
43
- export default function AiButton({ editor }: { editor: LexicalEditor }) {
44
- const [actionType, setActionType] = useState<AIAction | null>(null); // track the user action
45
- const [streamedResponse, setStreamedResponse] = useState<string>("");
46
-
47
- const { completion, isLoading, complete, handleInputChange, input } =useCompletion({
48
- api: "/api/ai",
49
- onError: (err) => {
50
- toast.error(err.message);
51
- },
52
- onResponse: (response) => {
53
- setStreamedResponse("");
54
- },
55
- onFinish: (prompt,compeletion) => {
56
- if (actionType === "Steps") {
57
- setStreamedResponse(compeletion)
58
- }
59
- },
60
- });
61
- const handleAction = async (
62
- action: AIAction,
63
- payload: {
64
- prompt?: string;
65
- question?: string;
66
- context?: string;
67
- }
68
- ) => {
69
- try {
70
- await complete("", {
71
- body: {
72
- action,
73
- ...payload,
74
- },
75
- });
76
- setActionType(action);
77
- } catch (err) {
78
- toast.error("Failed to process AI action. Please try again.");
79
- }
80
- };
81
- const handleRegeneration = async () => {
82
- if (!completion) {
83
- toast.error("No content to regenerate");
84
- return;
85
- }
86
- await handleAction("GenerateAgain", { prompt: completion });
87
- };
88
-
89
- const handleAutoComplete = async () => {
90
- const selectedText = getSelectedText(editor, 30);
91
- await handleAction("autoComplete", { prompt: selectedText });
92
- };
93
- const handleImproveWriting = async () => {
94
- const selectedText = getSelectedText(editor);
95
- await handleAction("ImproveWriting", { prompt: selectedText });
96
- };
97
- const handleSimplifyLanguage = async () => {
98
- const selectedText = getSelectedText(editor);
99
- await handleAction("SimplifyLanguage", { prompt: selectedText });
100
- };
101
- const handleMakeLong = async () => {
102
- const selectedText = getSelectedText(editor);
103
- await handleAction("MakeLong", { prompt: selectedText });
104
- };
105
- const handleMakeShort = async () => {
106
- const selectedText = getSelectedText(editor);
107
- await handleAction("MakeShort", { prompt: selectedText });
108
- };
109
- const handleFixSpellingGrammar = async () => {
110
- const selectedText = getSelectedText(editor);
111
- await handleAction("FixSpellingGrammar", { prompt: selectedText });
112
- };
113
- const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
114
- e.preventDefault();
115
- if (!input) {
116
- toast.error("Please enter a question or instruction");
117
- return;
118
- }
119
- if (actionType === "Steps") {
120
- await handleAction("Steps", { prompt: input });
121
- } else {
122
- const data = ExtractData(editor);
123
- const selectedText = getSelectedText(editor, 30);
124
- if (!selectedText) {
125
- toast.error("Please select some text first");
126
- return;
127
- }
128
- await handleAction("ChatWithSelectedString", {
129
- prompt: input,
130
- context: data,
131
- });
132
- setActionType(null);
133
- }
134
- };
135
-
136
- const renderSteps = () => {
137
- if (!streamedResponse ) return null;
138
-
139
- try {
140
- const steps = JSON.parse(streamedResponse);
141
- return (
142
- <ul className="list-none space-y-2">
143
- {steps.map((step: { id: number; title: string; content: string }) => (
144
- <li key={step.id} className="rounded-md shadow-md p-1">
145
- <h3 className="font-semibold text-lg">
146
- {step.id+1}. {step.title}
147
- </h3>
148
- <p className="text-gray-600 dark:text-gray-300 mtx-2">
149
- {step.content}
150
- </p>
151
- </li>
152
- ))}
153
- </ul>
154
- );
155
- } catch (error) {
156
- return
157
-
158
- }
159
- };
160
- const Actions = useMemo(
161
- () => ({
162
- suggestion: [
163
- {
164
- icon: (
165
- <svg
166
- xmlns="http://www.w3.org/2000/svg"
167
- className="size-5 text-purple-500"
168
- viewBox="0 0 24 24"
169
- >
170
- <path
171
- fill="currentColor"
172
- d="m19 9l-1.25-2.75L15 5l2.75-1.25L19 1l1.25 2.75L23 5l-2.75 1.25Zm0 14l-1.25-2.75L15 19l2.75-1.25L19 15l1.25 2.75L23 19l-2.75 1.25ZM4.8 16L8 7h2l3.2 9h-1.9l-.7-2H7.4l-.7 2Zm3.05-3.35h2.3L9 9ZM9 18q2.5 0 4.25-1.75T15 12q0-2.5-1.75-4.25T9 6Q6.5 6 4.75 7.75T3 12q0 2.5 1.75 4.25T9 18Zm0 2q-3.35 0-5.675-2.325Q1 15.35 1 12q0-3.35 2.325-5.675Q5.65 4 9 4q3.35 0 5.675 2.325Q17 8.65 17 12q0 3.35-2.325 5.675Q12.35 20 9 20Z"
173
- ></path>
174
- </svg>
175
- ),
176
- label: "auto compeletion",
177
- HoverCard: {
178
- desc: "Improve your sentences effortlessly—just select the text you want to refine, and let AI work its magic! ✨",
179
- },
180
- onClick: handleAutoComplete,
181
- },
182
- {
183
- icon: (
184
- <svg
185
- xmlns="http://www.w3.org/2000/svg"
186
- className="size-5 text-purple-500"
187
- viewBox="0 0 24 24"
188
- >
189
- <path
190
- fill="currentColor"
191
- d="M7.5 5.6L10 7L8.6 4.5L10 2L7.5 3.4L5 2l1.4 2.5L5 7zm12 9.8L17 14l1.4 2.5L17 19l2.5-1.4L22 19l-1.4-2.5L22 14zM22 2l-2.5 1.4L17 2l1.4 2.5L17 7l2.5-1.4L22 7l-1.4-2.5zm-7.63 5.29a.996.996 0 0 0-1.41 0L1.29 18.96a.996.996 0 0 0 0 1.41l2.34 2.34c.39.39 1.02.39 1.41 0L16.7 11.05a.996.996 0 0 0 0-1.41zm-1.03 5.49l-2.12-2.12l2.44-2.44l2.12 2.12z"
192
- ></path>
193
- </svg>
194
- ),
195
- label: "Improve Writing",
196
- HoverCard: {
197
- desc: " Simply select the text you want, and let our AI refine your writing effortlessly! 📝🚀",
198
- },
199
- onClick: handleImproveWriting,
200
- },
201
-
202
- {
203
- icon: (
204
- <svg
205
- xmlns="http://www.w3.org/2000/svg"
206
- className="size-5 text-purple-500"
207
- viewBox="0 0 24 24"
208
- >
209
- <path
210
- fill="currentColor"
211
- d="m9 16.2l-3.5-3.5a.984.984 0 0 0-1.4 0a.984.984 0 0 0 0 1.4l4.19 4.19c.39.39 1.02.39 1.41 0L20.3 7.7a.984.984 0 0 0 0-1.4a.984.984 0 0 0-1.4 0z"
212
- ></path>
213
- </svg>
214
- ),
215
- label: "Fix spelling & grammar",
216
- HoverCard: {
217
- desc: "📝 Select your messy text, and let AI transform it into perfection! 🚀",
218
- },
219
- onClick: handleFixSpellingGrammar,
220
- },
221
- ],
222
- Edit: [
223
- {
224
- icon: (
225
- <svg
226
- xmlns="http://www.w3.org/2000/svg"
227
- className="h-4 flex-shrink-0 w-4 block text-green-400"
228
- viewBox="0 0 20 20"
229
- >
230
- <path
231
- fill="currentColor"
232
- d="M3.5 5a.5.5 0 0 0 0 1h13a.5.5 0 0 0 0-1zm0 3a.5.5 0 0 0 0 1h13a.5.5 0 0 0 0-1zm0 7h7.002l.416-1H3.5a.5.5 0 0 0 0 1m8.668-4l-.416 1H3.5a.5.5 0 0 1 0-1zm-.667 6.012h1.75l-.59 2.363c-.121.485.462.828.826.488l4.873-4.556c.497-.466.169-1.301-.512-1.301H16.75l.781-2.347a.5.5 0 0 0-.474-.659h-3.473a.5.5 0 0 0-.462.308l-2.083 5.01a.5.5 0 0 0 .462.694"
233
- ></path>
234
- </svg>
235
- ),
236
- label: "Make longer",
237
- HoverCard: {
238
- desc: "Enhance your text by adding more detail and context. Let AI expand your ideas! 🚀",
239
- },
240
- onClick:handleMakeLong,
241
- },
242
- {
243
- icon: (
244
- <svg
245
- xmlns="http://www.w3.org/2000/svg"
246
- className="h-4 flex-shrink-0 w-4 block text-green-400"
247
- viewBox="0 0 32 32"
248
- >
249
- <path fill="currentColor" d="M6 18h14v2H6zm0-6h20v2H6z"></path>
250
- </svg>
251
- ),
252
- label: "Make shorter",
253
- HoverCard: {
254
- desc: "Select your dummy short paragraph and let our AI expand it while preserving its original content! 🚀✨",
255
- },
256
- onClick: handleMakeShort,
257
- },
258
- {
259
- icon: (
260
- <svg
261
- xmlns="http://www.w3.org/2000/svg"
262
- className="h-4 flex-shrink-0 w-4 block text-green-400"
263
- viewBox="0 0 24 24"
264
- >
265
- <path
266
- fill="currentColor"
267
- fillRule="evenodd"
268
- d="M12.75 18.96V22h-1.5v-3.04A7 7 0 0 1 5 12v-2h1.5v2a5.5 5.5 0 0 0 11 0v-2H19v2a7 7 0 0 1-6.25 6.96M8 6a4 4 0 1 1 8 0v6a4 4 0 1 1-8 0z"
269
- ></path>
270
- </svg>
271
- ),
272
- label: "Simplify Language",
273
- HoverCard: {
274
- desc: "If you're using overly complex language and want to simplify it for easier understanding, let our AI transform your text into clear, concise, and engaging content! 😊✨",
275
- },
276
- onClick: handleSimplifyLanguage,
277
- },
278
- ],
279
- format_block: [
280
- {
281
- icon: (
282
- <svg
283
- xmlns="http://www.w3.org/2000/svg"
284
- className="size-5 text-yellow-400"
285
- viewBox="0 0 24 24"
286
- >
287
- <g fill="none">
288
- <path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path>
289
- <path
290
- fill="currentColor"
291
- d="M5.436 16.72a1.466 1.466 0 0 1 1.22 2.275a1.466 1.466 0 0 1-1.22 2.275c-.587 0-1.134-.21-1.38-.79c-.153-.361-.112-.79.297-.963a.65.65 0 0 1 .852.344a.18.18 0 0 0 .165.11c.114-.003.23-.026.23-.168c0-.1-.073-.143-.156-.155l-.051-.003a.65.65 0 0 1-.112-1.29l.112-.01c.102 0 .207-.037.207-.158c0-.141-.116-.165-.23-.168a.18.18 0 0 0-.164.11a.65.65 0 0 1-.853.345c-.409-.174-.45-.603-.297-.963c.246-.58.793-.79 1.38-.79ZM20 17.5a1.5 1.5 0 0 1 0 3H9a1.5 1.5 0 0 1 0-3zM6.08 9.945a1.552 1.552 0 0 1 .43 2.442l-.554.593h.47a.65.65 0 1 1 0 1.3H4.573a.655.655 0 0 1-.655-.654c0-.207.029-.399.177-.557L5.559 11.5c.142-.152.03-.473-.203-.415c-.087.022-.123.089-.134.165l-.004.059a.65.65 0 1 1-1.3 0c0-.692.439-1.314 1.123-1.485c.35-.088.718-.04 1.04.121ZM20 10.5a1.5 1.5 0 0 1 .144 2.993L20 13.5H9a1.5 1.5 0 0 1-.144-2.993L9 10.5zM6.15 3.39v3.24a.65.65 0 0 1-1.3 0V4.523a.65.65 0 0 1-.46-1.184l.742-.494a.655.655 0 0 1 1.018.544ZM20 3.5a1.5 1.5 0 0 1 .144 2.993L20 6.5H9a1.5 1.5 0 0 1-.144-2.993L9 3.5z"
292
- ></path>
293
- </g>
294
- </svg>
295
- ),
296
- label: "Step-by-Step Guide",
297
- HoverCard: {
298
- desc: "Need a clear roadmap to programming mastery? step-by-step guide that breaks down complex topics into simple, actionable steps. Let it light your path to coding success! 🚀💻",
299
- },
300
- onClick: () => setActionType("Steps"),
301
- },
302
- ],
303
- }),
304
- []
305
- );
306
-
307
- const response = useMemo(
308
- () => [
309
- {
310
- icon: (
311
- <svg
312
- xmlns="http://www.w3.org/2000/svg"
313
- className="text-[#8d5bc1] size-5"
314
- viewBox="0 0 16 16"
315
- >
316
- <path
317
- fill="currentColor"
318
- fillRule="evenodd"
319
- d="M0 3.2c0-1.12 0-1.68.218-2.11C.41.714.716.408 1.092.216c.428-.218.988-.218 2.11-.218h.6c1.12 0 1.68 0 2.11.218c.376.192.682.498.874.874c.218.428.218.988.218 2.11v.6c0 1.12 0 1.68-.218 2.11a2 2 0 0 1-.874.874c-.428.218-.988.218-2.11.218h-.6c-1.12 0-1.68 0-2.11-.218a2 2 0 0 1-.874-.874C0 5.482 0 4.922 0 3.8zM3.2 1h.6c.577 0 .949 0 1.23.024c.272.022.372.06.422.085c.188.096.341.249.437.437c.025.05.063.15.085.422c.023.283.024.656.024 1.23v.6c0 .577 0 .949-.024 1.23c-.022.272-.06.372-.085.422a1 1 0 0 1-.437.437c-.05.025-.15.063-.422.085c-.283.023-.656.024-1.23.024h-.6c-.577 0-.949 0-1.23-.024c-.272-.022-.372-.06-.422-.085a1 1 0 0 1-.437-.437c-.025-.05-.063-.15-.085-.422a17 17 0 0 1-.024-1.23v-.6c0-.577 0-.949.024-1.23c.022-.272.06-.372.085-.422c.096-.188.249-.341.437-.437c.05-.025.15-.063.422-.085C2.253 1 2.626 1 3.2 1M9 12.2c0-1.12 0-1.68.218-2.11c.192-.376.498-.682.874-.874c.428-.218.988-.218 2.11-.218h.6c1.12 0 1.68 0 2.11.218c.376.192.682.498.874.874c.218.428.218.988.218 2.11v.6c0 1.12 0 1.68-.218 2.11a2 2 0 0 1-.874.874c-.428.218-.988.218-2.11.218h-.6c-1.12 0-1.68 0-2.11-.218a2 2 0 0 1-.874-.874C9 14.482 9 13.922 9 12.8zm3.8-2.2c.577 0 .949 0 1.23.024c.272.022.372.06.422.085c.188.096.341.249.437.437c.025.05.063.15.085.422c.023.283.024.656.024 1.23v.6c0 .577 0 .949-.024 1.23c-.022.272-.06.372-.085.422a1 1 0 0 1-.437.437c-.05.025-.15.063-.422.085c-.283.023-.656.024-1.23.024h-.6c-.577 0-.949 0-1.23-.024c-.272-.022-.372-.06-.422-.085a1 1 0 0 1-.437-.437c-.025-.05-.063-.15-.085-.422a17 17 0 0 1-.024-1.23v-.6c0-.577 0-.949.024-1.23c.022-.272.06-.372.085-.422c.096-.188.249-.341.437-.437c.05-.025.15-.063.422-.085c.283-.023.656-.024 1.23-.024z"
320
- clipRule="evenodd"
321
- ></path>
322
- <path
323
- fill="currentColor"
324
- d="M8 2.5a.5.5 0 0 1 .5-.5h2A2.5 2.5 0 0 1 13 4.5v1.79l1.15-1.15a.5.5 0 0 1 .707.707l-2 2a.5.5 0 0 1-.707 0l-2-2a.5.5 0 0 1 .707-.707l1.15 1.15V4.5a1.5 1.5 0 0 0-1.5-1.5h-2a.5.5 0 0 1-.5-.5zM3.31 8.04a.5.5 0 0 1 .188-.038h.006a.5.5 0 0 1 .351.146l2 2a.5.5 0 0 1-.707.707l-1.15-1.15v1.79a1.5 1.5 0 0 0 1.5 1.5h2a.5.5 0 0 1 0 1h-2a2.5 2.5 0 0 1-2.5-2.5v-1.79l-1.15 1.15a.5.5 0 0 1-.707-.707l2-2a.5.5 0 0 1 .162-.109z"
325
- ></path>
326
- </svg>
327
- ),
328
- label: "rplace text",
329
- HoverCard: {
330
- desc: "Select your text and let our AI replace it with a polished, enhanced version! 🚀✨",
331
- },
332
- func: () => replaceSelectedText(completion, editor),
333
- },
334
- {
335
- icon: (
336
- <svg
337
- xmlns="http://www.w3.org/2000/svg"
338
- className="text-[#8d5bc1] size-5"
339
- viewBox="0 0 56 56"
340
- >
341
- <path
342
- fill="currentColor"
343
- d="M33.8 11.36h16.01c1.008 0 1.804-.774 1.804-1.782c0-.984-.797-1.758-1.804-1.758H33.8c-1.008 0-1.782.774-1.782 1.758c0 1.008.774 1.781 1.782 1.781M7.083 26.944c1.71 0 2.695-1.195 2.695-3.093v-4.477c0-.516.235-.82.797-.82h6.375v2.343c0 1.852 1.875 2.555 3.281 1.43l6.352-5.062c.96-.774.96-2.11 0-2.86L20.23 9.32c-1.453-1.195-3.28-.469-3.28 1.43v2.438h-6.891c-3.305 0-5.672 2.039-5.672 5.367v5.297c0 1.898.984 3.093 2.695 3.093m26.719-3.304h16.008c1.008 0 1.804-.774 1.804-1.782c0-.984-.797-1.758-1.804-1.758H33.8c-1.008 0-1.782.774-1.782 1.758c0 1.008.774 1.782 1.782 1.782M6.168 35.92h43.64a1.786 1.786 0 0 0 1.805-1.78c0-.985-.797-1.758-1.804-1.758H6.168c-1.008 0-1.781.773-1.781 1.758c0 .984.773 1.78 1.78 1.78m0 12.259h43.64c1.008 0 1.805-.774 1.805-1.758s-.797-1.781-1.804-1.781H6.168a1.766 1.766 0 0 0-1.781 1.78c0 .985.773 1.759 1.78 1.759"
344
- ></path>
345
- </svg>
346
- ),
347
- label: "insert text",
348
- HoverCard: {
349
- desc: "text will inserted immediately following your selection.",
350
- },
351
- func: () => insertText(completion, editor),
352
- },
353
- {
354
- icon: (
355
- <svg
356
- xmlns="http://www.w3.org/2000/svg"
357
- className="text-[#8d5bc1] size-5"
358
- viewBox="0 0 14 14"
359
- >
360
- <g
361
- fill="none"
362
- stroke="currentColor"
363
- strokeLinecap="round"
364
- strokeLinejoin="round"
365
- >
366
- <path d="M9.5 6.5h-9m13-3H.5m13-3H.5"></path>
367
- <rect
368
- width="4"
369
- height="13"
370
- x="5"
371
- y="5"
372
- rx=".5"
373
- transform="rotate(-90 7 11.5)"
374
- ></rect>
375
- </g>
376
- </svg>
377
- ),
378
- label: "insert below",
379
- HoverCard: {
380
- desc: "text will inserted under your selection.",
381
- },
382
- func: () => insertTextUnderSelected(completion, editor),
383
- },
384
-
385
- {
386
- icon: <RotateCcw className="text-[#8d5bc1] size-4" />,
387
- label: "try again",
388
- HoverCard: {
389
- desc: "you did not like the ai response? try it again with what do you want",
390
- },
391
- func: handleRegeneration,
392
- },
393
- ],
394
- [completion]
395
- );
396
-
397
- return (
398
- <Popover >
399
- <PopoverTrigger asChild>
400
- <button className="inline-flex px-6 max-sm:py-2 max-sm:px-[5px] h-6 animate-background-shine items-center justify-center rounded-md border border-gray-800 bg-[linear-gradient(110deg,#000103,45%,#1e2631,55%,#000103)] bg-[length:200%_100%] font-medium text-gray-400 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 focus:ring-offset-gray-50">
401
- <WandSparkles className=" size-4 text-purple-400" />
402
- </button>
403
- </PopoverTrigger>
404
- <PopoverContent className="absolute max-h-[300px] h-fit shadow-sm shadow-black dark:shadow-gray-500 p-0 w-[420px] max-sm:w-[200px] min-w-[200px] max-w-[420px] top-[10px] max-sm:left-6 -left-7 AI-format">
405
- <div className="w-full relative">
406
- <div className="flex flex-col items-start justify-between">
407
- {(completion || actionType === "Steps") && (
408
- <motion.div
409
- initial={{ opacity: 0, y: 20 }}
410
- animate={{ opacity: 1, y: 0 }}
411
- transition={{ duration: 0.5, ease: "easeOut" }}
412
- className="cursor-text w-full p-2 z-20 break-words max-h-64 h-fit overflow-y-auto"
413
- >
414
- {streamedResponse!=="" ? (
415
- renderSteps()
416
- ) : (
417
- <ReactMarkdown>
418
- {completion ||
419
- "Ask for a step-by-step guide on any programming topic. Example: 'How can I become a backend developer?'"}
420
- </ReactMarkdown>
421
- )}
422
- </motion.div>
423
- )}
424
- <div className="relative w-full">
425
- <div className=" absolute top-1/2 -translate-y-1/2 left-2">
426
- <HoverBorderGradient
427
- duration={2}
428
- clockwise={false}
429
- containerClassName="rounded-full border-0"
430
- as="button"
431
- className="dark:bg-white size-5 bg-black dark:text-white flex justify-center items-center"
432
- >
433
- {isLoading ? (
434
- <Loader2 className="size-3 dark:text-black text-white animate-spin" />
435
- ) : (
436
- <StarsIcon className="dark:text-purple-600 text-purple-300 size-3" />
437
- )}
438
- </HoverBorderGradient>
439
- </div>
440
- <PlaceholdersAndVanishInput
441
- placeholders={placeholders}
442
- onChange={handleInputChange}
443
- onSubmit={handleSubmit}
444
- disabled={isLoading}
445
- />
446
- </div>
447
- </div>
448
- <div className="w-[200px] h-[180px] z-50 rounded border mt-2 fixed">
449
- {!completion ? (
450
- <Command id="toolbar" className="w-full ">
451
- <CommandInput placeholder="Type a command" />
452
- <CommandList>
453
- <CommandEmpty>No results found.</CommandEmpty>
454
- <CommandGroup heading="Suggested">
455
- {Actions.suggestion.map((sug) => (
456
- <HoverCard key={sug.label}>
457
- <HoverCardTrigger
458
- onClick={sug.onClick}
459
- className="w-full p-0"
460
- >
461
- <CommandItem className="w-full">
462
- <div>{sug.icon}</div>
463
- <span>{sug.label}</span>
464
- </CommandItem>
465
- </HoverCardTrigger>
466
- <HoverCardContent
467
- className=" p-2"
468
- side="right"
469
- alignOffset={60}
470
- sideOffset={30}
471
- >
472
- <span className="text-sm break-words text-muted-foreground">
473
- {sug.HoverCard.desc}
474
- </span>
475
- </HoverCardContent>
476
- </HoverCard>
477
- ))}
478
- </CommandGroup>
479
-
480
- <CommandSeparator />
481
- <CommandGroup heading="format block">
482
- {Actions.format_block.map((sug) => (
483
- <HoverCard key={sug.label}>
484
- <HoverCardTrigger
485
- onClick={sug.onClick}
486
- className="w-full p-0"
487
- >
488
- <CommandItem className="w-full">
489
- <div>{sug.icon}</div>
490
- <span>{sug.label}</span>
491
- </CommandItem>
492
- </HoverCardTrigger>
493
- <HoverCardContent
494
- className=" p-2"
495
- side="right"
496
- alignOffset={60}
497
- sideOffset={30}
498
- >
499
- <span className="text-sm break-words text-muted-foreground">
500
- {sug.HoverCard.desc}
501
- </span>
502
- </HoverCardContent>
503
- </HoverCard>
504
- ))}
505
- </CommandGroup>
506
- <CommandSeparator />
507
-
508
- <CommandGroup heading="Edit">
509
- {Actions.Edit.map((sug) => (
510
- <HoverCard key={sug.label}>
511
- <HoverCardTrigger
512
- onClick={sug.onClick}
513
- className="w-full p-0"
514
- >
515
- <CommandItem className="w-full">
516
- <div>{sug.icon}</div>
517
- <span>{sug.label}</span>
518
- </CommandItem>
519
- </HoverCardTrigger>
520
- <HoverCardContent
521
- className="p-2"
522
- side="right"
523
- alignOffset={60}
524
- sideOffset={30}
525
- >
526
- <span className="text-sm text-muted-foreground">
527
- {sug.HoverCard.desc}
528
- </span>
529
- </HoverCardContent>
530
- </HoverCard>
531
- ))}
532
- </CommandGroup>
533
- </CommandList>
534
- </Command>
535
- ) : (
536
- <Command id="toolbar" className="w-full">
537
- <CommandInput placeholder="Type a command" />
538
- <CommandList>
539
- <CommandEmpty>No results found.</CommandEmpty>
540
- <CommandGroup>
541
- {response.map((sug) => (
542
- <HoverCard key={sug.label}>
543
- <HoverCardTrigger
544
- onClick={sug.func}
545
-
546
- className="w-full p-0"
547
- >
548
- <CommandItem disabled={isLoading} className="w-full">
549
- <div>{sug.icon}</div>
550
- <span>{sug.label}</span>
551
- </CommandItem>
552
- </HoverCardTrigger>
553
- <HoverCardContent
554
- className=" p-2"
555
- side="right"
556
- alignOffset={60}
557
- sideOffset={30}
558
- >
559
- <span className="text-sm break-words text-muted-foreground">
560
- {sug.HoverCard.desc}
561
- </span>
562
- </HoverCardContent>
563
- </HoverCard>
564
- ))}
565
- </CommandGroup>
566
- </CommandList>
567
- </Command>
568
- )}
569
- </div>
570
- </div>
571
- </PopoverContent>
572
- </Popover>
573
- );
574
- }