@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,621 +0,0 @@
1
- import { $createCodeNode } from "@lexical/code";
2
- import {
3
- INSERT_CHECK_LIST_COMMAND,
4
- INSERT_ORDERED_LIST_COMMAND,
5
- INSERT_UNORDERED_LIST_COMMAND,
6
- } from "@lexical/list";
7
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
8
- import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/react/LexicalHorizontalRuleNode";
9
- import {
10
- LexicalTypeaheadMenuPlugin,
11
- MenuOption,
12
- useBasicTypeaheadTriggerMatch,
13
- } from "@lexical/react/LexicalTypeaheadMenuPlugin";
14
- import { $createHeadingNode, $createQuoteNode } from "@lexical/rich-text";
15
- import { $setBlocksType } from "@lexical/selection";
16
- import { INSERT_TABLE_COMMAND } from "@lexical/table";
17
- import {
18
- $createParagraphNode,
19
- $getSelection,
20
- $isRangeSelection,
21
- createEditor,
22
- LexicalEditor,
23
- TextNode,
24
- } from "lexical";
25
- import { useCallback, useMemo, useState } from "react";
26
- import * as React from "react";
27
- import * as ReactDOM from "react-dom";
28
- import {
29
- Code2,
30
- Columns2,
31
- Columns3,
32
- Columns4,
33
- ImageIcon,
34
- ImagePlayIcon,
35
- ListCheck,
36
- OctagonX,
37
- Pilcrow,
38
- QuoteIcon,
39
- SquarePenIcon,
40
- StepForward,
41
- Twitter,
42
- Youtube,
43
- Figma,
44
- Heading1,
45
- Heading2,
46
- Heading3,
47
- Minus,
48
- List,
49
- ListOrdered,
50
- Table,
51
- SigmaIcon,
52
- } from "lucide-react";
53
-
54
- import { INSERT_COLLAPSIBLE_COMMAND } from "../CollapsiblePlugin";
55
- import { cn } from "@/lib/utils";
56
- import { INSERT_LAYOUT_COMMAND } from "../LayoutPlugin";
57
- import { INSERT_POLL_COMMAND } from "../PollPlugin";
58
- import { INSERT_HINT_COMMAND } from "../../nodes/Hint";
59
- import useModal from "@/components/ui/models/use-model";
60
- import {
61
- Command,
62
- CommandItem,
63
- CommandList,
64
- CommandInput,
65
- CommandEmpty,
66
- CommandShortcut,
67
- } from "@/components/ui/command";
68
- import { SHORTCUTS } from "../ShortcutsPlugin/shortcuts";
69
- import { Skeleton } from "@/components/ui/skeleton";
70
- import { ImagePayload } from "../../nodes/ImageNode";
71
- import { INSERT_IMAGE_COMMAND } from "../ImagesPlugin";
72
- import { AutoEmbedDialog, FigmaEmbedConfig, TwitterEmbedConfig, YoutubeEmbedConfig } from "../AutoEmbedPlugin";
73
- import { initialEditorState, INSERT_STEPPER_COMMAND } from "../../nodes/Stepper";
74
- import { InsertInlineImageDialog } from "../InlineImagePlugin";
75
- import { InsertEquationDialog } from "../EquationsPlugin";
76
- const InsertGif = React.lazy(() => import("@/components/ui/models/insert-gif"));
77
- const InsertImageDialog = React.lazy(() =>
78
- import("@/components/ui/models/insert-image").then((module) => ({
79
- default: module.InsertImageDialog,
80
- }))
81
- );
82
- class ComponentPickerOption extends MenuOption {
83
- // What shows up in the editor
84
- title: string;
85
- // Icon for display
86
- icon?: React.JSX.Element;
87
- // For extra searching.
88
- keywords: Array<string>;
89
- // TBD
90
- keyboardShortcut?: string;
91
- // What happens when you select this option?
92
- onSelect: (queryString: string) => void;
93
- desc?: string;
94
- constructor(
95
- title: string,
96
- options: {
97
- icon?: React.JSX.Element;
98
- keywords?: Array<string>;
99
- keyboardShortcut?: string;
100
- onSelect: (queryString: string) => void;
101
- desc?: string;
102
- }
103
- ) {
104
- super(title);
105
- this.title = title;
106
- this.keywords = options.keywords || [];
107
- this.icon = options.icon;
108
- this.keyboardShortcut = options.keyboardShortcut;
109
- this.onSelect = options.onSelect.bind(this);
110
- this.desc = options.desc; // Add this line
111
- }
112
- }
113
-
114
- function getDynamicOptions(editor: LexicalEditor, queryString: string) {
115
- const options: Array<ComponentPickerOption> = [];
116
-
117
- if (queryString == null) {
118
- return options;
119
- }
120
-
121
- const tableMatch = queryString.match(/^([1-9]\d?)(?:x([1-9]\d?)?)?$/);
122
-
123
- if (tableMatch !== null) {
124
- const rows = tableMatch[1];
125
- const colOptions = tableMatch[2]
126
- ? [tableMatch[2]]
127
- : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(String);
128
-
129
- options.push(
130
- ...colOptions.map(
131
- (columns) =>
132
- new ComponentPickerOption(`${rows}x${columns} Table`, {
133
- icon: <i className="icon table" />,
134
- keywords: ["table"],
135
- onSelect: () =>
136
- editor.dispatchCommand(INSERT_TABLE_COMMAND, { columns, rows }),
137
- })
138
- )
139
- );
140
- }
141
-
142
- return options;
143
- }
144
-
145
- function getBaseOptions(
146
- editor: LexicalEditor,
147
- showModal: (
148
- title?: string | null,
149
- description?: string | null,
150
- getContent?: (onClose: () => void) => React.JSX.Element,
151
- isDilog?: boolean
152
- ) => void
153
- ) {
154
- return [
155
- new ComponentPickerOption("Paragraph", {
156
- icon: <Pilcrow className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
157
- keywords: ["normal", "paragraph", "p", "text"],
158
- onSelect: () =>
159
- editor.update(() => {
160
- const selection = $getSelection();
161
- if ($isRangeSelection(selection)) {
162
- $setBlocksType(selection, () => $createParagraphNode());
163
- }
164
- }),
165
- desc: "Just start writing with plain text",
166
- }),
167
- ...([1, 2, 3] as const).map(
168
- (n) =>
169
- new ComponentPickerOption(`Heading ${n}`, {
170
- icon:
171
- n === 1 ? (
172
- <Heading1 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />
173
- ) : n === 2 ? (
174
- <Heading2 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />
175
- ) : (
176
- <Heading3 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />
177
- ),
178
- keywords: ["heading", "header", `h${n}`],
179
- keyboardShortcut:
180
- n === 1
181
- ? SHORTCUTS.HEADING1
182
- : n === 2
183
- ? SHORTCUTS.HEADING2
184
- : SHORTCUTS.HEADING3,
185
- onSelect: () =>
186
- editor.update(() => {
187
- const selection = $getSelection();
188
- if ($isRangeSelection(selection)) {
189
- $setBlocksType(selection, () => $createHeadingNode(`h${n}`));
190
- }
191
- }),
192
- desc: `${n == 1
193
- ? "Big section heading"
194
- : n == 2
195
- ? "Meduim section heading."
196
- : "Small section heading"
197
- }`,
198
- })
199
- ),
200
- new ComponentPickerOption("Table", {
201
- icon: <Table className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
202
- keywords: ["table", "grid", "spreadsheet", "rows", "columns"],
203
- desc: "Add simple table content to your blog.",
204
- onSelect: () =>
205
- editor.dispatchCommand(INSERT_TABLE_COMMAND, {
206
- rows: "4",
207
- columns: "4",
208
- }),
209
- }),
210
- new ComponentPickerOption("Hint", {
211
- icon: <OctagonX className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
212
- keywords: [
213
- "Hint",
214
- "note",
215
- "info",
216
- "alert",
217
- "alert",
218
- "success",
219
- "warning",
220
- "error",
221
- ],
222
- desc: "Add a hint to your content.",
223
- onSelect: () => editor.dispatchCommand(INSERT_HINT_COMMAND, "hint"),
224
- }),
225
- new ComponentPickerOption("Numbered List", {
226
- icon: <ListOrdered className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
227
- keywords: ["numbered list", "ordered list", "ol"],
228
- desc: "Create list with number",
229
- keyboardShortcut: SHORTCUTS.NUMBERED_LIST,
230
-
231
- onSelect: () =>
232
- editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined),
233
- }),
234
- new ComponentPickerOption("Bulleted List", {
235
- icon: <List className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
236
- keywords: ["bulleted list", "unordered list", "ul"],
237
- desc: "Create list with Bulleted",
238
- keyboardShortcut: SHORTCUTS.BULLET_LIST,
239
-
240
- onSelect: () =>
241
- editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined),
242
- }),
243
- new ComponentPickerOption("Check List", {
244
- icon: <ListCheck className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
245
- keywords: ["check list", "todo list"],
246
- desc: "Track tasks with to-do list.",
247
- keyboardShortcut: SHORTCUTS.CHECK_LIST,
248
-
249
- onSelect: () =>
250
- editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined),
251
- }),
252
- new ComponentPickerOption("Quote", {
253
- icon: <QuoteIcon className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
254
- keywords: ["block quote"],
255
- desc: "Capture Quote",
256
- keyboardShortcut: SHORTCUTS.QUOTE,
257
-
258
- onSelect: () =>
259
- editor.update(() => {
260
- const selection = $getSelection();
261
- if ($isRangeSelection(selection)) {
262
- $setBlocksType(selection, () => $createQuoteNode());
263
- }
264
- }),
265
- }),
266
- new ComponentPickerOption("Pool", {
267
- icon: <SquarePenIcon className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
268
- keywords: ["pool", "vote", "survey"],
269
- desc: "Add pool to take people votes.",
270
- onSelect: () =>
271
- editor.dispatchCommand(INSERT_POLL_COMMAND, "type the Question"),
272
- }),
273
- new ComponentPickerOption("Code", {
274
- icon: <Code2 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
275
- keywords: ["javascript", "python", "js", "codeblock"],
276
- desc: "Add block of code.",
277
- keyboardShortcut: SHORTCUTS.CODE_BLOCK,
278
-
279
- onSelect: () =>
280
- editor.update(() => {
281
- const selection = $getSelection();
282
- if ($isRangeSelection(selection)) {
283
- if (selection.isCollapsed()) {
284
- $setBlocksType(selection, () => $createCodeNode());
285
- } else {
286
- const textContent = selection.getTextContent();
287
- const codeNode = $createCodeNode();
288
- selection.insertNodes([codeNode]);
289
- selection.insertRawText(textContent);
290
- }
291
- }
292
- }),
293
- }),
294
- new ComponentPickerOption("Divider", {
295
- icon: <Minus className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
296
- keywords: ["horizontal rule", "divider", "hr"],
297
- desc: "Visually divide blocks",
298
-
299
- onSelect: () =>
300
- editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined),
301
- }),
302
- new ComponentPickerOption("Youtube", {
303
- icon: <Youtube className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
304
- keywords: ["Youtube", "youtube", "video"],
305
- desc: "Embedded YouTube videos ",
306
-
307
- onSelect: () => {
308
- showModal(
309
- "Youtube",
310
- "Insert a URL to embed a live preview. Works with YouTube",
311
- (onClose) => (
312
- <AutoEmbedDialog
313
- embedConfig={YoutubeEmbedConfig}
314
- onClose={onClose}
315
- />
316
- ),
317
- true
318
- );
319
- },
320
- }),
321
- new ComponentPickerOption("Figma", {
322
- icon: <Figma className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
323
- keywords: ["figma", "figma.com", "ui"],
324
- desc: "Embedded Figma File ",
325
-
326
- onSelect: () => {
327
- showModal(
328
- "Figma",
329
- "Insert a URL to embed a live preview. Works with Figma",
330
- (onClose) => (
331
- <AutoEmbedDialog
332
- embedConfig={FigmaEmbedConfig}
333
- onClose={onClose}
334
- />
335
- ),
336
- true
337
- );
338
- },
339
- }),
340
- new ComponentPickerOption("Twitter", {
341
- icon: <Twitter className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
342
- keywords: ["Twitter", "tweet", "x", "twitter"],
343
- desc: "Embedded Tweets ",
344
-
345
- onSelect: () => {
346
- showModal(
347
- "Twitter tweet",
348
- "Insert a URL to embed a live preview. Works with Twitter",
349
- (onClose) => (
350
- <AutoEmbedDialog
351
- embedConfig={TwitterEmbedConfig}
352
- onClose={onClose}
353
- />
354
- ),
355
- true
356
- );
357
- },
358
- }),
359
- new ComponentPickerOption("Image", {
360
- icon: <ImageIcon className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
361
- keywords: ["image", "photo", "picture", "file", "img"],
362
- desc: "Upload or embed with a link",
363
-
364
- onSelect: () =>
365
- showModal(
366
- "Insert Image",
367
- "Please select an image to upload.",
368
- (onClose) => (
369
- <React.Suspense
370
- fallback={<Skeleton className="mx-2 w-[350px] h-[350px]" />}
371
- >
372
- <InsertImageDialog activeEditor={editor} onClose={onClose} />
373
- </React.Suspense>
374
- ),
375
- true
376
- ),
377
- }),
378
-
379
- new ComponentPickerOption("Inline Image", {
380
- icon: <ImageIcon className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
381
- keywords: ["image", "photo", "picture", "file", "img"],
382
- desc: "Upload or embed with a link",
383
-
384
- onSelect: () =>
385
- showModal(
386
- "Insert Image",
387
- "Please select an image to upload.",
388
- (onClose) => (
389
- <React.Suspense
390
- fallback={<Skeleton className="mx-2 w-[350px] h-[350px]" />}
391
- >
392
- <InsertInlineImageDialog
393
- activeEditor={editor}
394
- onClose={onClose}
395
- />
396
- </React.Suspense>
397
- ),
398
- true
399
- ),
400
- }),
401
-
402
- new ComponentPickerOption('Equation', {
403
- icon: <SigmaIcon className="w-4 h-4" />,
404
- keywords: ['equation', 'latex', 'math'],
405
- onSelect: () =>
406
- showModal(
407
- 'Insert Equation',
408
- 'Insert mathematical equations using LaTeX syntax.',
409
- (onClose) => (
410
- <React.Suspense
411
- fallback={<Skeleton className="mx-2 w-[350px] h-[350px]" />}
412
- >
413
-
414
- <InsertEquationDialog
415
- activeEditor={editor}
416
- onClose={onClose}
417
- />
418
- </React.Suspense>
419
- ),
420
- true
421
- ),
422
- }),
423
-
424
- new ComponentPickerOption("Poll", {
425
- icon: <SquarePenIcon className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
426
- keywords: ["collapse", "collapsible", "toggle"],
427
- desc: "make poll to take people votes.",
428
- onSelect: () =>
429
- editor.dispatchCommand(INSERT_POLL_COMMAND, "type the Question"),
430
- }),
431
- new ComponentPickerOption("Collapsible", {
432
- icon: <StepForward className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
433
- keywords: ["collapse", "collapsible", "toggle"],
434
- desc: "Toggles can hide and show content inside.",
435
- onSelect: () =>
436
- editor.dispatchCommand(INSERT_COLLAPSIBLE_COMMAND, undefined),
437
- }),
438
- new ComponentPickerOption("2 columns", {
439
- icon: <Columns2 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
440
- keywords: ["columns", "flex", "row", "layout", "grid"],
441
- desc: "Dvide your content into 2 container.",
442
- onSelect: () => editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr"),
443
- }),
444
- new ComponentPickerOption("3 columns", {
445
- icon: <Columns3 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
446
- keywords: ["3columns", "3", "flex", "row", "layout", "grid"],
447
- desc: "Dvide your content into 3 container.",
448
- onSelect: () =>
449
- editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr 1fr"),
450
- }),
451
- new ComponentPickerOption("Stepper", {
452
- icon: <svg className="w-9 h-9 max-sm:h-5 max-sm:w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g fill="none" fillRule="evenodd"><path d="m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.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.003-.011l.018-.43l-.003-.012l-.01-.01z"></path><path fill="currentColor" d="M5 6a3 3 0 0 1 6 0v2a3 3 0 0 1-6 0zm3-1a1 1 0 0 0-1 1v2a1 1 0 0 0 2 0V6a1 1 0 0 0-1-1m9.707-.707a1 1 0 0 0-1.414 0L13.465 7.12a1 1 0 0 0 1.414 1.415L16 7.414V20a1 1 0 1 0 2 0V7.414l1.121 1.122a1 1 0 1 0 1.415-1.415zM5 15a3 3 0 0 1 5.995-.176l.005.186c0 .408-.039.799-.107 1.171c-.264 1.433-.964 2.58-1.57 3.352c-.307.39-.598.694-.815.904c-.124.12-.25.238-.385.345a1 1 0 0 1-1.34-1.479L7.118 19l.224-.228A7 7 0 0 0 7.971 18A3 3 0 0 1 5 15m3-1a1 1 0 1 0 0 2a1 1 0 0 0 0-2"></path></g></svg>,
453
- keywords: ["stpper", "step", "lines", "routes", "docs", "number"],
454
- desc: "Stepper with descriptions for each step.",
455
- onSelect: () => {
456
-
457
- const newEditor = createEditor();
458
- const parsedEditorState = newEditor.parseEditorState(
459
- JSON.stringify(initialEditorState)
460
- );
461
- newEditor.setEditorState(parsedEditorState);
462
- const newStep = {
463
- id: 0,
464
- title: `New step 0`,
465
- content: newEditor,
466
- };
467
- editor.dispatchCommand(INSERT_STEPPER_COMMAND, [newStep])
468
-
469
- }
470
- }),
471
- new ComponentPickerOption("Gifs", {
472
- icon: <ImagePlayIcon className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
473
- keywords: ["gif", "gifs", "videos", "short video"],
474
- desc: "Insert a GIF video",
475
- onSelect: () => {
476
- showModal(
477
- "Insert GIF",
478
- "Please select a GIF to upload.",
479
- (onClose) => (
480
- <React.Suspense
481
- fallback={<Skeleton className="mx-2 w-[400px] h-[400px]" />}
482
- >
483
- <InsertGif
484
- insertGifOnClick={(payload: ImagePayload) => {
485
- editor.dispatchCommand(INSERT_IMAGE_COMMAND, payload);
486
- }}
487
- onClose={onClose}
488
- />
489
- </React.Suspense>
490
- ),
491
- true
492
- );
493
- },
494
- }),
495
-
496
- new ComponentPickerOption("4 columns", {
497
- icon: <Columns4 className="w-9 h-9 max-sm:h-5 max-sm:w-5" />,
498
- keywords: ["4columns", "4", "flex", "row", "layout", "grid"],
499
- desc: "Dvide your content into 4 container.",
500
- onSelect: () =>
501
- editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr 1fr 1fr"),
502
- }),
503
- ];
504
- }
505
-
506
- export default function SlashCommand(): React.JSX.Element {
507
- const [editor] = useLexicalComposerContext();
508
- const [Modal, showModal] = useModal();
509
- const [queryString, setQueryString] = useState<string | null>(null);
510
-
511
- const checkForTriggerMatch = useBasicTypeaheadTriggerMatch("/", {
512
- minLength: 0,
513
- });
514
-
515
- const options = useMemo(() => {
516
- const baseOptions = getBaseOptions(editor, showModal);
517
-
518
- if (!queryString) {
519
- return baseOptions;
520
- }
521
-
522
- const regex = new RegExp(queryString, "i");
523
-
524
- return [
525
- ...getDynamicOptions(editor, queryString),
526
- ...baseOptions.filter(
527
- (option) =>
528
- regex.test(option.title) ||
529
- option.keywords.some((keyword) => regex.test(keyword))
530
- ),
531
- ];
532
- }, [editor, queryString]);
533
-
534
- const onSelectOption = useCallback(
535
- (
536
- selectedOption: ComponentPickerOption,
537
- nodeToRemove: TextNode | null,
538
- closeMenu: () => void,
539
- matchingString: string
540
- ) => {
541
- editor.update(() => {
542
- nodeToRemove?.remove();
543
- selectedOption.onSelect(matchingString);
544
- closeMenu();
545
- });
546
- },
547
- [editor, showModal]
548
- );
549
-
550
- return (
551
- <>
552
- <LexicalTypeaheadMenuPlugin<ComponentPickerOption>
553
- onQueryChange={setQueryString}
554
- onSelectOption={onSelectOption}
555
- triggerFn={checkForTriggerMatch}
556
- options={options}
557
- menuRenderFn={(
558
- anchorElementRef,
559
- { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }
560
- ) =>
561
- anchorElementRef.current && options.length
562
- ? ReactDOM.createPortal(
563
- <div
564
- id={"toolbar"}
565
- className={`
566
- overflow-x-hidden z-[100] relative max-w-[300px] max-sm:w-[200px] w-[300px] max-h-[300px] h-fit border rounded-sm bg-background shadow-sm shadow-muted-foreground/20
567
-
568
- `}
569
- >
570
- <Command>
571
- <CommandInput placeholder="Type a command" />
572
- <CommandList>
573
- <CommandEmpty>No results found.</CommandEmpty>
574
-
575
- {options.map((option, i: number) => (
576
- <CommandItem
577
- ref={option.ref as React.Ref<HTMLDivElement>}
578
- className={cn(
579
- selectedIndex == i &&
580
- "dark:bg-gray-300/10 bg-gray-400/60",
581
- "gap-x-2 h-full items-start hover:bg-transparent border-0 bg-transparent transition-colors cursor-pointer rounded-sm relative"
582
- )}
583
- onSelect={() => {
584
- setHighlightedIndex(i);
585
- selectOptionAndCleanUp(option);
586
- }}
587
- onMouseEnter={() => {
588
- setHighlightedIndex(i);
589
- }}
590
- key={option.key}
591
- >
592
- <div className="p-4 h-full bg-gray-400/60 dark:bg-gray-300/10 rounded-sm">
593
- {option.icon}
594
- </div>
595
- <div className="flex flex-row justify-between items-center">
596
- <div className="flex justify-center items-start flex-col">
597
- <div>{option.title}</div>
598
- <span className="text-sm text-muted-foreground break-words">
599
- {option.desc}
600
- </span>
601
- </div>
602
- {option.keyboardShortcut && (
603
- <CommandShortcut className=" absolute top-1 right-2">
604
- {option.keyboardShortcut}
605
- </CommandShortcut>
606
- )}
607
- </div>
608
- </CommandItem>
609
- ))}
610
- </CommandList>
611
- </Command>
612
- </div>,
613
- anchorElementRef.current
614
- )
615
- : null
616
- }
617
- />
618
- {Modal}
619
- </>
620
- );
621
- }