@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
@@ -0,0 +1,538 @@
1
+ import {
2
+ Command,
3
+ CommandEmpty,
4
+ CommandInput,
5
+ CommandItem,
6
+ CommandList,
7
+ CommandShortcut
8
+ } from "./chunk-KJ6AJ44Q.mjs";
9
+ import {
10
+ INSERT_DYNAMIC_BLOCK_COMMAND,
11
+ INSERT_STORY_BUILDER_COMMAND,
12
+ InsertEquationDialog,
13
+ InsertInlineImageDialog,
14
+ createDefaultDynamicBlock
15
+ } from "./chunk-WJRHXI2C.mjs";
16
+ import {
17
+ INSERT_POLL_COMMAND
18
+ } from "./chunk-U47ABU5Z.mjs";
19
+ import {
20
+ AutoEmbedDialog,
21
+ FigmaEmbedConfig,
22
+ INSERT_COLLAPSIBLE_COMMAND,
23
+ INSERT_LAYOUT_COMMAND,
24
+ TwitterEmbedConfig,
25
+ YoutubeEmbedConfig
26
+ } from "./chunk-AMMKBSST.mjs";
27
+ import {
28
+ useModal
29
+ } from "./chunk-5QSNIVIG.mjs";
30
+ import {
31
+ INSERT_IMAGE_COMMAND
32
+ } from "./chunk-LGG4IUIA.mjs";
33
+ import {
34
+ INSERT_STEPPER_COMMAND,
35
+ initialEditorState
36
+ } from "./chunk-6RNZQOH2.mjs";
37
+ import {
38
+ SHORTCUTS
39
+ } from "./chunk-ZB5LZQKC.mjs";
40
+ import {
41
+ Skeleton
42
+ } from "./chunk-QEIFVK5M.mjs";
43
+ import {
44
+ INSERT_HINT_COMMAND
45
+ } from "./chunk-G53GLEAY.mjs";
46
+ import {
47
+ cn
48
+ } from "./chunk-YHPNOWFH.mjs";
49
+ import {
50
+ init_react_shim
51
+ } from "./chunk-77KXU36M.mjs";
52
+
53
+ // src/components/editor/plugins/SlashCommand/index.tsx
54
+ init_react_shim();
55
+ import { $createCodeNode } from "@lexical/code";
56
+ import {
57
+ INSERT_CHECK_LIST_COMMAND,
58
+ INSERT_ORDERED_LIST_COMMAND,
59
+ INSERT_UNORDERED_LIST_COMMAND
60
+ } from "@lexical/list";
61
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
62
+ import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/react/LexicalHorizontalRuleNode";
63
+ import {
64
+ LexicalTypeaheadMenuPlugin,
65
+ MenuOption,
66
+ useBasicTypeaheadTriggerMatch
67
+ } from "@lexical/react/LexicalTypeaheadMenuPlugin";
68
+ import { $createHeadingNode, $createQuoteNode } from "@lexical/rich-text";
69
+ import { $setBlocksType } from "@lexical/selection";
70
+ import { INSERT_TABLE_COMMAND } from "@lexical/table";
71
+ import {
72
+ $createParagraphNode,
73
+ $getSelection,
74
+ $isRangeSelection,
75
+ createEditor
76
+ } from "lexical";
77
+ import { useCallback, useMemo, useState } from "react";
78
+ import * as React from "react";
79
+ import * as ReactDOM from "react-dom";
80
+ import {
81
+ Code2,
82
+ Columns2,
83
+ Columns3,
84
+ Columns4,
85
+ ImageIcon,
86
+ ImagePlayIcon,
87
+ ListCheck,
88
+ OctagonX,
89
+ Pilcrow,
90
+ QuoteIcon,
91
+ SquarePenIcon,
92
+ StepForward,
93
+ Twitter,
94
+ Youtube,
95
+ Figma,
96
+ Heading1,
97
+ Heading2,
98
+ Heading3,
99
+ Minus,
100
+ List,
101
+ ListOrdered,
102
+ Table,
103
+ SigmaIcon,
104
+ GitBranch,
105
+ Zap
106
+ } from "lucide-react";
107
+ var InsertGif = React.lazy(() => import("./insert-gif-SAIDYURE.mjs"));
108
+ var InsertImageDialog = React.lazy(
109
+ () => import("./insert-image-U3RJN3OW.mjs").then((module) => ({
110
+ default: module.InsertImageDialog
111
+ }))
112
+ );
113
+ var ComponentPickerOption = class extends MenuOption {
114
+ constructor(title, options) {
115
+ super(title);
116
+ this.title = title;
117
+ this.keywords = options.keywords || [];
118
+ this.icon = options.icon;
119
+ this.keyboardShortcut = options.keyboardShortcut;
120
+ this.onSelect = options.onSelect.bind(this);
121
+ this.desc = options.desc;
122
+ }
123
+ };
124
+ function getDynamicOptions(editor, queryString) {
125
+ const options = [];
126
+ if (queryString == null) {
127
+ return options;
128
+ }
129
+ const tableMatch = queryString.match(/^([1-9]\d?)(?:x([1-9]\d?)?)?$/);
130
+ if (tableMatch !== null) {
131
+ const rows = tableMatch[1];
132
+ const colOptions = tableMatch[2] ? [tableMatch[2]] : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(String);
133
+ options.push(
134
+ ...colOptions.map(
135
+ (columns) => new ComponentPickerOption(`${rows}x${columns} Table`, {
136
+ icon: /* @__PURE__ */ React.createElement("i", { className: "icon table" }),
137
+ keywords: ["table"],
138
+ onSelect: () => editor.dispatchCommand(INSERT_TABLE_COMMAND, { columns, rows })
139
+ })
140
+ )
141
+ );
142
+ }
143
+ return options;
144
+ }
145
+ function getBaseOptions(editor, showModal) {
146
+ return [
147
+ new ComponentPickerOption("Paragraph", {
148
+ icon: /* @__PURE__ */ React.createElement(Pilcrow, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
149
+ keywords: ["normal", "paragraph", "p", "text"],
150
+ onSelect: () => editor.update(() => {
151
+ const selection = $getSelection();
152
+ if ($isRangeSelection(selection)) {
153
+ $setBlocksType(selection, () => $createParagraphNode());
154
+ }
155
+ }),
156
+ desc: "Just start writing with plain text"
157
+ }),
158
+ ...[1, 2, 3].map(
159
+ (n) => new ComponentPickerOption(`Heading ${n}`, {
160
+ icon: n === 1 ? /* @__PURE__ */ React.createElement(Heading1, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }) : n === 2 ? /* @__PURE__ */ React.createElement(Heading2, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }) : /* @__PURE__ */ React.createElement(Heading3, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
161
+ keywords: ["heading", "header", `h${n}`],
162
+ keyboardShortcut: n === 1 ? SHORTCUTS.HEADING1 : n === 2 ? SHORTCUTS.HEADING2 : SHORTCUTS.HEADING3,
163
+ onSelect: () => editor.update(() => {
164
+ const selection = $getSelection();
165
+ if ($isRangeSelection(selection)) {
166
+ $setBlocksType(selection, () => $createHeadingNode(`h${n}`));
167
+ }
168
+ }),
169
+ desc: `${n == 1 ? "Big section heading" : n == 2 ? "Meduim section heading." : "Small section heading"}`
170
+ })
171
+ ),
172
+ new ComponentPickerOption("Table", {
173
+ icon: /* @__PURE__ */ React.createElement(Table, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
174
+ keywords: ["table", "grid", "spreadsheet", "rows", "columns"],
175
+ desc: "Add simple table content to your blog.",
176
+ onSelect: () => editor.dispatchCommand(INSERT_TABLE_COMMAND, {
177
+ rows: "4",
178
+ columns: "4"
179
+ })
180
+ }),
181
+ new ComponentPickerOption("Hint", {
182
+ icon: /* @__PURE__ */ React.createElement(OctagonX, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
183
+ keywords: [
184
+ "Hint",
185
+ "note",
186
+ "info",
187
+ "alert",
188
+ "alert",
189
+ "success",
190
+ "warning",
191
+ "error"
192
+ ],
193
+ desc: "Add a hint to your content.",
194
+ onSelect: () => editor.dispatchCommand(INSERT_HINT_COMMAND, "hint")
195
+ }),
196
+ new ComponentPickerOption("Numbered List", {
197
+ icon: /* @__PURE__ */ React.createElement(ListOrdered, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
198
+ keywords: ["numbered list", "ordered list", "ol"],
199
+ desc: "Create list with number",
200
+ keyboardShortcut: SHORTCUTS.NUMBERED_LIST,
201
+ onSelect: () => editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0)
202
+ }),
203
+ new ComponentPickerOption("Bulleted List", {
204
+ icon: /* @__PURE__ */ React.createElement(List, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
205
+ keywords: ["bulleted list", "unordered list", "ul"],
206
+ desc: "Create list with Bulleted",
207
+ keyboardShortcut: SHORTCUTS.BULLET_LIST,
208
+ onSelect: () => editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0)
209
+ }),
210
+ new ComponentPickerOption("Check List", {
211
+ icon: /* @__PURE__ */ React.createElement(ListCheck, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
212
+ keywords: ["check list", "todo list"],
213
+ desc: "Track tasks with to-do list.",
214
+ keyboardShortcut: SHORTCUTS.CHECK_LIST,
215
+ onSelect: () => editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, void 0)
216
+ }),
217
+ new ComponentPickerOption("Quote", {
218
+ icon: /* @__PURE__ */ React.createElement(QuoteIcon, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
219
+ keywords: ["block quote"],
220
+ desc: "Capture Quote",
221
+ keyboardShortcut: SHORTCUTS.QUOTE,
222
+ onSelect: () => editor.update(() => {
223
+ const selection = $getSelection();
224
+ if ($isRangeSelection(selection)) {
225
+ $setBlocksType(selection, () => $createQuoteNode());
226
+ }
227
+ })
228
+ }),
229
+ new ComponentPickerOption("Poll", {
230
+ icon: /* @__PURE__ */ React.createElement(SquarePenIcon, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
231
+ keywords: ["poll", "vote", "survey"],
232
+ desc: "Add poll to take people votes.",
233
+ onSelect: () => editor.dispatchCommand(INSERT_POLL_COMMAND, "Type the Question")
234
+ }),
235
+ new ComponentPickerOption("Code", {
236
+ icon: /* @__PURE__ */ React.createElement(Code2, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
237
+ keywords: ["javascript", "python", "js", "codeblock"],
238
+ desc: "Add block of code.",
239
+ keyboardShortcut: SHORTCUTS.CODE_BLOCK,
240
+ onSelect: () => editor.update(() => {
241
+ const selection = $getSelection();
242
+ if ($isRangeSelection(selection)) {
243
+ if (selection.isCollapsed()) {
244
+ $setBlocksType(selection, () => $createCodeNode());
245
+ } else {
246
+ const textContent = selection.getTextContent();
247
+ const codeNode = $createCodeNode();
248
+ selection.insertNodes([codeNode]);
249
+ selection.insertRawText(textContent);
250
+ }
251
+ }
252
+ })
253
+ }),
254
+ new ComponentPickerOption("Divider", {
255
+ icon: /* @__PURE__ */ React.createElement(Minus, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
256
+ keywords: ["horizontal rule", "divider", "hr"],
257
+ desc: "Visually divide blocks",
258
+ onSelect: () => editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0)
259
+ }),
260
+ new ComponentPickerOption("Youtube", {
261
+ icon: /* @__PURE__ */ React.createElement(Youtube, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
262
+ keywords: ["Youtube", "youtube", "video"],
263
+ desc: "Embedded YouTube videos ",
264
+ onSelect: () => {
265
+ showModal(
266
+ "Youtube",
267
+ "Insert a URL to embed a live preview. Works with YouTube",
268
+ (onClose) => /* @__PURE__ */ React.createElement(
269
+ AutoEmbedDialog,
270
+ {
271
+ embedConfig: YoutubeEmbedConfig,
272
+ onClose
273
+ }
274
+ ),
275
+ true
276
+ );
277
+ }
278
+ }),
279
+ new ComponentPickerOption("Figma", {
280
+ icon: /* @__PURE__ */ React.createElement(Figma, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
281
+ keywords: ["figma", "figma.com", "ui"],
282
+ desc: "Embedded Figma File ",
283
+ onSelect: () => {
284
+ showModal(
285
+ "Figma",
286
+ "Insert a URL to embed a live preview. Works with Figma",
287
+ (onClose) => /* @__PURE__ */ React.createElement(
288
+ AutoEmbedDialog,
289
+ {
290
+ embedConfig: FigmaEmbedConfig,
291
+ onClose
292
+ }
293
+ ),
294
+ true
295
+ );
296
+ }
297
+ }),
298
+ new ComponentPickerOption("Twitter", {
299
+ icon: /* @__PURE__ */ React.createElement(Twitter, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
300
+ keywords: ["Twitter", "tweet", "x", "twitter"],
301
+ desc: "Embedded Tweets ",
302
+ onSelect: () => {
303
+ showModal(
304
+ "Twitter tweet",
305
+ "Insert a URL to embed a live preview. Works with Twitter",
306
+ (onClose) => /* @__PURE__ */ React.createElement(
307
+ AutoEmbedDialog,
308
+ {
309
+ embedConfig: TwitterEmbedConfig,
310
+ onClose
311
+ }
312
+ ),
313
+ true
314
+ );
315
+ }
316
+ }),
317
+ new ComponentPickerOption("Image", {
318
+ icon: /* @__PURE__ */ React.createElement(ImageIcon, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
319
+ keywords: ["image", "photo", "picture", "file", "img"],
320
+ desc: "Upload or embed with a link",
321
+ onSelect: () => showModal(
322
+ "Insert Image",
323
+ "Please select an image to upload.",
324
+ (onClose) => /* @__PURE__ */ React.createElement(
325
+ React.Suspense,
326
+ {
327
+ fallback: /* @__PURE__ */ React.createElement(Skeleton, { className: "mx-2 w-[350px] h-[350px]" })
328
+ },
329
+ /* @__PURE__ */ React.createElement(InsertImageDialog, { activeEditor: editor, onClose })
330
+ ),
331
+ true
332
+ )
333
+ }),
334
+ new ComponentPickerOption("Inline Image", {
335
+ icon: /* @__PURE__ */ React.createElement(ImageIcon, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
336
+ keywords: ["image", "photo", "picture", "file", "img"],
337
+ desc: "Upload or embed with a link",
338
+ onSelect: () => showModal(
339
+ "Insert Image",
340
+ "Please select an image to upload.",
341
+ (onClose) => /* @__PURE__ */ React.createElement(
342
+ React.Suspense,
343
+ {
344
+ fallback: /* @__PURE__ */ React.createElement(Skeleton, { className: "mx-2 w-[350px] h-[350px]" })
345
+ },
346
+ /* @__PURE__ */ React.createElement(
347
+ InsertInlineImageDialog,
348
+ {
349
+ activeEditor: editor,
350
+ onClose
351
+ }
352
+ )
353
+ ),
354
+ true
355
+ )
356
+ }),
357
+ new ComponentPickerOption("Equation", {
358
+ icon: /* @__PURE__ */ React.createElement(SigmaIcon, { className: "w-4 h-4" }),
359
+ keywords: ["equation", "latex", "math"],
360
+ onSelect: () => showModal(
361
+ "Insert Equation",
362
+ "Insert mathematical equations using LaTeX syntax.",
363
+ (onClose) => /* @__PURE__ */ React.createElement(
364
+ React.Suspense,
365
+ {
366
+ fallback: /* @__PURE__ */ React.createElement(Skeleton, { className: "mx-2 w-[350px] h-[350px]" })
367
+ },
368
+ /* @__PURE__ */ React.createElement(
369
+ InsertEquationDialog,
370
+ {
371
+ activeEditor: editor,
372
+ onClose
373
+ }
374
+ )
375
+ ),
376
+ true
377
+ )
378
+ }),
379
+ new ComponentPickerOption("Collapsible", {
380
+ icon: /* @__PURE__ */ React.createElement(StepForward, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
381
+ keywords: ["collapse", "collapsible", "toggle"],
382
+ desc: "Toggles can hide and show content inside.",
383
+ onSelect: () => editor.dispatchCommand(INSERT_COLLAPSIBLE_COMMAND, void 0)
384
+ }),
385
+ new ComponentPickerOption("2 columns", {
386
+ icon: /* @__PURE__ */ React.createElement(Columns2, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
387
+ keywords: ["columns", "flex", "row", "layout", "grid"],
388
+ desc: "Dvide your content into 2 container.",
389
+ onSelect: () => editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr")
390
+ }),
391
+ new ComponentPickerOption("3 columns", {
392
+ icon: /* @__PURE__ */ React.createElement(Columns3, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
393
+ keywords: ["3columns", "3", "flex", "row", "layout", "grid"],
394
+ desc: "Dvide your content into 3 container.",
395
+ onSelect: () => editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr 1fr")
396
+ }),
397
+ new ComponentPickerOption("Stepper", {
398
+ icon: /* @__PURE__ */ React.createElement("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" }, /* @__PURE__ */ React.createElement("g", { fill: "none", fillRule: "evenodd" }, /* @__PURE__ */ React.createElement("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" }), /* @__PURE__ */ React.createElement("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" }))),
399
+ keywords: ["stpper", "step", "lines", "routes", "docs", "number"],
400
+ desc: "Stepper with descriptions for each step.",
401
+ onSelect: () => {
402
+ const newEditor = createEditor();
403
+ const parsedEditorState = newEditor.parseEditorState(
404
+ JSON.stringify(initialEditorState)
405
+ );
406
+ newEditor.setEditorState(parsedEditorState);
407
+ const newStep = {
408
+ id: 0,
409
+ title: `New step 0`,
410
+ content: newEditor
411
+ };
412
+ editor.dispatchCommand(INSERT_STEPPER_COMMAND, [newStep]);
413
+ }
414
+ }),
415
+ new ComponentPickerOption("Gifs", {
416
+ icon: /* @__PURE__ */ React.createElement(ImagePlayIcon, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
417
+ keywords: ["gif", "gifs", "videos", "short video"],
418
+ desc: "Insert a GIF video",
419
+ onSelect: () => {
420
+ showModal(
421
+ "Insert GIF",
422
+ "Please select a GIF to upload.",
423
+ (onClose) => /* @__PURE__ */ React.createElement(
424
+ React.Suspense,
425
+ {
426
+ fallback: /* @__PURE__ */ React.createElement(Skeleton, { className: "mx-2 w-[400px] h-[400px]" })
427
+ },
428
+ /* @__PURE__ */ React.createElement(
429
+ InsertGif,
430
+ {
431
+ insertGifOnClick: (payload) => {
432
+ editor.dispatchCommand(INSERT_IMAGE_COMMAND, payload);
433
+ },
434
+ onClose
435
+ }
436
+ )
437
+ ),
438
+ true
439
+ );
440
+ }
441
+ }),
442
+ new ComponentPickerOption("Interactive Story", {
443
+ icon: /* @__PURE__ */ React.createElement(GitBranch, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
444
+ keywords: ["story", "interactive", "branching", "narrative", "choose", "adventure"],
445
+ desc: "Create branching narratives with reader choices",
446
+ onSelect: () => editor.dispatchCommand(INSERT_STORY_BUILDER_COMMAND, {
447
+ nodes: [],
448
+ currentNodeId: "",
449
+ title: "Interactive Story"
450
+ })
451
+ }),
452
+ new ComponentPickerOption("Dynamic Block", {
453
+ icon: /* @__PURE__ */ React.createElement(Zap, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
454
+ keywords: ["dynamic", "interactive", "content", "block", "trigger", "animation", "responsive"],
455
+ desc: "Create interactive content that responds to user actions",
456
+ onSelect: () => editor.dispatchCommand(INSERT_DYNAMIC_BLOCK_COMMAND, createDefaultDynamicBlock())
457
+ }),
458
+ new ComponentPickerOption("4 columns", {
459
+ icon: /* @__PURE__ */ React.createElement(Columns4, { className: "w-9 h-9 max-sm:h-5 max-sm:w-5" }),
460
+ keywords: ["4columns", "4", "flex", "row", "layout", "grid"],
461
+ desc: "Dvide your content into 4 container.",
462
+ onSelect: () => editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr 1fr 1fr")
463
+ })
464
+ ];
465
+ }
466
+ function SlashCommand() {
467
+ const [editor] = useLexicalComposerContext();
468
+ const [Modal, showModal] = useModal();
469
+ const [queryString, setQueryString] = useState(null);
470
+ const checkForTriggerMatch = useBasicTypeaheadTriggerMatch("/", {
471
+ minLength: 0
472
+ });
473
+ const options = useMemo(() => {
474
+ const baseOptions = getBaseOptions(editor, showModal);
475
+ if (!queryString) {
476
+ return baseOptions;
477
+ }
478
+ const regex = new RegExp(queryString, "i");
479
+ return [
480
+ ...getDynamicOptions(editor, queryString),
481
+ ...baseOptions.filter(
482
+ (option) => regex.test(option.title) || option.keywords.some((keyword) => regex.test(keyword))
483
+ )
484
+ ];
485
+ }, [editor, queryString]);
486
+ const onSelectOption = useCallback(
487
+ (selectedOption, nodeToRemove, closeMenu, matchingString) => {
488
+ editor.update(() => {
489
+ nodeToRemove == null ? void 0 : nodeToRemove.remove();
490
+ selectedOption.onSelect(matchingString);
491
+ closeMenu();
492
+ });
493
+ },
494
+ [editor, showModal]
495
+ );
496
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
497
+ LexicalTypeaheadMenuPlugin,
498
+ {
499
+ onQueryChange: setQueryString,
500
+ onSelectOption,
501
+ triggerFn: checkForTriggerMatch,
502
+ options,
503
+ menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => anchorElementRef.current && options.length ? ReactDOM.createPortal(
504
+ /* @__PURE__ */ React.createElement(
505
+ "div",
506
+ {
507
+ id: "toolbar",
508
+ className: "overflow-x-hidden z-[100] relative max-w-[300px] max-sm:w-[200px] w-[300px] max-h-[300px] h-fit border rounded-sm bg-white/80 dark:bg-[#020b19]/95 shadow-sm shadow-muted-foreground/20"
509
+ },
510
+ /* @__PURE__ */ React.createElement(Command, null, /* @__PURE__ */ React.createElement(CommandInput, { placeholder: "Type a command" }), /* @__PURE__ */ React.createElement(CommandList, null, /* @__PURE__ */ React.createElement(CommandEmpty, null, "No results found."), options.map((option, i) => /* @__PURE__ */ React.createElement(
511
+ CommandItem,
512
+ {
513
+ ref: option.ref,
514
+ className: cn(
515
+ selectedIndex === i ? "bg-gray-200 dark:bg-gray-700" : "hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer rounded-sm gap-x-2 relative h-full border-0 transition-colors items-start"
516
+ ),
517
+ onSelect: () => {
518
+ setHighlightedIndex(i);
519
+ selectOptionAndCleanUp(option);
520
+ },
521
+ onMouseEnter: () => {
522
+ setHighlightedIndex(i);
523
+ },
524
+ key: option.key
525
+ },
526
+ /* @__PURE__ */ React.createElement("div", { className: "p-4 h-full bg-gray-400/60 dark:bg-gray-300/10 rounded-sm" }, option.icon),
527
+ /* @__PURE__ */ React.createElement("div", { className: "flex flex-row justify-between items-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex justify-center items-start flex-col" }, /* @__PURE__ */ React.createElement("div", null, option.title), /* @__PURE__ */ React.createElement("span", { className: "text-sm text-muted-foreground break-words" }, option.desc)), option.keyboardShortcut && /* @__PURE__ */ React.createElement(CommandShortcut, { className: "absolute top-1 right-2" }, option.keyboardShortcut))
528
+ ))))
529
+ ),
530
+ anchorElementRef.current
531
+ ) : null
532
+ }
533
+ ), Modal);
534
+ }
535
+
536
+ export {
537
+ SlashCommand
538
+ };
@@ -0,0 +1,157 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues,
4
+ init_react_shim
5
+ } from "./chunk-77KXU36M.mjs";
6
+
7
+ // src/components/editor/nodes/PollNode/index.tsx
8
+ init_react_shim();
9
+ import {
10
+ DecoratorNode
11
+ } from "lexical";
12
+ import * as React from "react";
13
+ import { Suspense } from "react";
14
+ var PollComponent = React.lazy(
15
+ () => import("./poll-component-2R4MDLHS.mjs")
16
+ );
17
+ function createUID() {
18
+ return Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 5);
19
+ }
20
+ function createPollOption(text = "") {
21
+ return {
22
+ text,
23
+ uid: createUID(),
24
+ votes: []
25
+ };
26
+ }
27
+ function cloneOption(option, text, votes) {
28
+ return {
29
+ text,
30
+ uid: option.uid,
31
+ votes: votes || Array.from(option.votes)
32
+ };
33
+ }
34
+ function $convertPollElement(domNode) {
35
+ const question = domNode.getAttribute("data-lexical-poll-question");
36
+ const options = domNode.getAttribute("data-lexical-poll-options");
37
+ if (question !== null && options !== null) {
38
+ const node = $createPollNode(question, JSON.parse(options));
39
+ return { node };
40
+ }
41
+ return null;
42
+ }
43
+ var PollNode = class _PollNode extends DecoratorNode {
44
+ static getType() {
45
+ return "poll";
46
+ }
47
+ static clone(node) {
48
+ return new _PollNode(node.__question, node.__options, node.__key);
49
+ }
50
+ static importJSON(serializedNode) {
51
+ return $createPollNode(
52
+ serializedNode.question,
53
+ serializedNode.options
54
+ ).updateFromJSON(serializedNode);
55
+ }
56
+ constructor(question, options, key) {
57
+ super(key);
58
+ this.__question = question;
59
+ this.__options = options;
60
+ }
61
+ exportJSON() {
62
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
63
+ options: this.__options,
64
+ question: this.__question
65
+ });
66
+ }
67
+ setQuestion(newQuestion) {
68
+ const self = this.getWritable();
69
+ self.__question = newQuestion;
70
+ }
71
+ addOption(option) {
72
+ const self = this.getWritable();
73
+ const options = Array.from(self.__options);
74
+ options.push(option);
75
+ self.__options = options;
76
+ }
77
+ deleteOption(option) {
78
+ const self = this.getWritable();
79
+ const options = Array.from(self.__options);
80
+ const index = options.indexOf(option);
81
+ options.splice(index, 1);
82
+ self.__options = options;
83
+ }
84
+ setOptionText(option, text) {
85
+ const self = this.getWritable();
86
+ const clonedOption = cloneOption(option, text);
87
+ const options = Array.from(self.__options);
88
+ const index = options.indexOf(option);
89
+ options[index] = clonedOption;
90
+ self.__options = options;
91
+ }
92
+ toggleVote(option, clientID) {
93
+ const self = this.getWritable();
94
+ const newOptions = self.__options.map((opt) => {
95
+ if (opt.uid === option.uid) {
96
+ const newVotes = opt.votes.includes(clientID) ? opt.votes.filter((id) => id !== clientID) : [...opt.votes, clientID];
97
+ return __spreadProps(__spreadValues({}, opt), { votes: newVotes });
98
+ }
99
+ return __spreadValues({}, opt);
100
+ });
101
+ self.__options = newOptions;
102
+ this.markDirty();
103
+ }
104
+ static importDOM() {
105
+ return {
106
+ span: (domNode) => {
107
+ if (!domNode.hasAttribute("data-lexical-poll-question")) {
108
+ return null;
109
+ }
110
+ return {
111
+ conversion: $convertPollElement,
112
+ priority: 2
113
+ };
114
+ }
115
+ };
116
+ }
117
+ exportDOM() {
118
+ const element = document.createElement("span");
119
+ element.setAttribute("data-lexical-poll-question", this.__question);
120
+ element.setAttribute(
121
+ "data-lexical-poll-options",
122
+ JSON.stringify(this.__options)
123
+ );
124
+ return { element };
125
+ }
126
+ createDOM() {
127
+ const elem = document.createElement("span");
128
+ elem.style.display = "inline-block";
129
+ return elem;
130
+ }
131
+ updateDOM() {
132
+ return false;
133
+ }
134
+ decorate() {
135
+ return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(
136
+ PollComponent,
137
+ {
138
+ question: this.__question,
139
+ options: this.__options,
140
+ nodeKey: this.__key
141
+ }
142
+ ));
143
+ }
144
+ };
145
+ function $createPollNode(question, options) {
146
+ return new PollNode(question, options);
147
+ }
148
+ function $isPollNode(node) {
149
+ return node instanceof PollNode;
150
+ }
151
+
152
+ export {
153
+ createPollOption,
154
+ PollNode,
155
+ $createPollNode,
156
+ $isPollNode
157
+ };