@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,110 +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 './Modal.css';
12
-
13
- import {isDOMNode} from 'lexical';
14
- import * as React from 'react';
15
- import {ReactNode, useEffect, useRef} from 'react';
16
- import {createPortal} from 'react-dom';
17
-
18
- function PortalImpl({
19
- onClose,
20
- children,
21
- title,
22
- closeOnClickOutside,
23
- }: {
24
- children: ReactNode;
25
- closeOnClickOutside: boolean;
26
- onClose: () => void;
27
- title: string;
28
- }) {
29
- const modalRef = useRef<HTMLDivElement>(null);
30
-
31
- useEffect(() => {
32
- if (modalRef.current !== null) {
33
- modalRef.current.focus();
34
- }
35
- }, []);
36
-
37
- useEffect(() => {
38
- let modalOverlayElement: HTMLElement | null = null;
39
- const handler = (event: KeyboardEvent) => {
40
- if (event.key === 'Escape') {
41
- onClose();
42
- }
43
- };
44
- const clickOutsideHandler = (event: MouseEvent) => {
45
- const target = event.target;
46
- if (
47
- modalRef.current !== null &&
48
- isDOMNode(target) &&
49
- !modalRef.current.contains(target) &&
50
- closeOnClickOutside
51
- ) {
52
- onClose();
53
- }
54
- };
55
- const modelElement = modalRef.current;
56
- if (modelElement !== null) {
57
- modalOverlayElement = modelElement.parentElement;
58
- if (modalOverlayElement !== null) {
59
- modalOverlayElement.addEventListener('click', clickOutsideHandler);
60
- }
61
- }
62
-
63
- window.addEventListener('keydown', handler);
64
-
65
- return () => {
66
- window.removeEventListener('keydown', handler);
67
- if (modalOverlayElement !== null) {
68
- modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
69
- }
70
- };
71
- }, [closeOnClickOutside, onClose]);
72
-
73
- return (
74
- <div className="Modal__overlay" role="dialog">
75
- <div className="Modal__modal" tabIndex={-1} ref={modalRef}>
76
- <h2 className="Modal__title">{title}</h2>
77
- <button
78
- className="Modal__closeButton"
79
- aria-label="Close modal"
80
- type="button"
81
- onClick={onClose}>
82
- X
83
- </button>
84
- <div className="Modal__content">{children}</div>
85
- </div>
86
- </div>
87
- );
88
- }
89
-
90
- export default function Modal({
91
- onClose,
92
- children,
93
- title,
94
- closeOnClickOutside = false,
95
- }: {
96
- children: ReactNode;
97
- closeOnClickOutside?: boolean;
98
- onClose: () => void;
99
- title: string;
100
- }): JSX.Element {
101
- return createPortal(
102
- <PortalImpl
103
- onClose={onClose}
104
- title={title}
105
- closeOnClickOutside={closeOnClickOutside}>
106
- {children}
107
- </PortalImpl>,
108
- document.body,
109
- );
110
- }
@@ -1,29 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- const HoverCard = HoverCardPrimitive.Root
9
-
10
- const HoverCardTrigger = HoverCardPrimitive.Trigger
11
-
12
- const HoverCardContent = React.forwardRef<
13
- React.ElementRef<typeof HoverCardPrimitive.Content>,
14
- React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
15
- >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16
- <HoverCardPrimitive.Content
17
- ref={ref}
18
- align={align}
19
- sideOffset={sideOffset}
20
- className={cn(
21
- "z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
22
- className
23
- )}
24
- {...props}
25
- />
26
- ))
27
- HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
28
-
29
- export { HoverCard, HoverCardTrigger, HoverCardContent }
@@ -1,17 +0,0 @@
1
- import React from 'react'
2
-
3
- export default function ErrorImage() {
4
- return (
5
- <img
6
- src={"https://cdn.mos.cms.futurecdn.net/Wh46bS2Gw8vUC6iQh2wEd6-1020-80.png"}
7
- style={{
8
- height: 300,
9
- width: 300,
10
- }}
11
- draggable="false"
12
- />
13
- );
14
-
15
- }
16
-
17
-
@@ -1,240 +0,0 @@
1
- "use client";
2
-
3
- import type React from "react";
4
- import { useState, useRef } from "react";
5
- import {
6
- Upload,
7
- Loader2,
8
- X,
9
- Image,
10
- File,
11
- UploadCloudIcon,
12
- Video,
13
- } from "lucide-react";
14
- import { motion, AnimatePresence } from "framer-motion";
15
- import { Card, CardContent } from "@/components/ui/card";
16
- import { Progress } from "@/components/ui/progress";
17
- import { Button } from "@/components/ui/button";
18
- import { useEdgeStore } from "@/lib/edgestore";
19
-
20
- const FileUploadZone = ({
21
- InsertMedia,
22
- }: {
23
- InsertMedia: (files: { url: string; alt: string }[]) => void;
24
- }) => {
25
- const [draggedZone, setDraggedZone] = useState<number | null>(null);
26
- const [files, setFiles] = useState<{ url: string; alt: string }[]>([]);
27
- const [uploading, setUploading] = useState(false);
28
- const [progress, setProgress] = useState(0);
29
- const fileInputRef = useRef<HTMLInputElement>(null);
30
- const { edgestore } = useEdgeStore();
31
-
32
- const handleDragEnter = (index: number) => (e: React.DragEvent) => {
33
- e.preventDefault();
34
- setDraggedZone(index);
35
- };
36
-
37
- const handleDragLeave = (e: React.DragEvent) => {
38
- e.preventDefault();
39
- setDraggedZone(null);
40
- };
41
-
42
- // loading
43
- const upload = async (newFiles: File[]) => {
44
- setUploading(true);
45
- setProgress(0);
46
-
47
- // Store uploaded files
48
- let uploadedFiles: { url: string; alt: string }[] = [];
49
-
50
- for (let i = 0; i < newFiles.length; i++) {
51
- const file = newFiles[i];
52
-
53
- try {
54
- const response = await edgestore.publicFiles.upload({
55
- file,
56
- onProgressChange: (progress) => {
57
- setProgress(
58
- Math.round((progress / 100) * ((i + 1) / newFiles.length) * 100)
59
- );
60
- },
61
- });
62
-
63
- uploadedFiles.push({ url: response.url, alt: file.name });
64
- } catch (error) {
65
- console.error(`Error uploading ${file.name}:`, error);
66
- }
67
- }
68
-
69
- setFiles((prevFiles) => [...prevFiles, ...uploadedFiles]);
70
- setUploading(false);
71
- setProgress(100);
72
- };
73
-
74
- const handleDrop = () => async (e: React.DragEvent) => {
75
- e.preventDefault();
76
- setDraggedZone(null);
77
- const droppedFiles = Array.from(e.dataTransfer.files);
78
- if (droppedFiles.length > 0) {
79
- await upload(droppedFiles);
80
- }
81
- };
82
-
83
- const handleFileSelect = async (e: React.ChangeEvent<HTMLInputElement>) => {
84
- const selectedFiles = Array.from(e.target.files || []);
85
- if (selectedFiles.length > 0) {
86
- await upload(selectedFiles);
87
- }
88
- };
89
-
90
- const removeFile = (index: number) => {
91
- setFiles((prevFiles) => prevFiles.filter((_, i) => i !== index));
92
- };
93
-
94
- const zones = [
95
- {
96
- title: "Upload Images",
97
- subtitle: "Drop images here",
98
- icon: Image,
99
- gradient: "from-purple-400 via-pink-500 to-red-500",
100
- rotate: "-rotate-2",
101
- },
102
- {
103
- title: "Upload Videos",
104
- subtitle: "Drop videos here",
105
- icon: Video,
106
- gradient: "from-blue-400 via-teal-500 to-green-500",
107
- rotate: "",
108
- },
109
- {
110
- title: "Upload Files",
111
- subtitle: "Drop files here",
112
- icon: UploadCloudIcon,
113
- gradient: "from-yellow-400 via-orange-500 to-red-500",
114
- rotate: "rotate-3",
115
- },
116
- ];
117
-
118
- return (
119
- <Card className="mx-auto w-full bg-transparent border-none max-w-[300px] lg:max-w-[500px] overflow-hidden rounded-[1rem]">
120
- <CardContent className="p-6 py-7 cursor:pointer">
121
- <div className="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-6">
122
- {zones.map((zone, index) => (
123
- <div key={index} className={`relative ${zone.rotate}`}>
124
- <motion.div
125
- onDragEnter={handleDragEnter(index)}
126
- onDragOver={(e: { preventDefault: () => any }) =>
127
- e.preventDefault()
128
- }
129
- onDragLeave={handleDragLeave}
130
- onDrop={handleDrop}
131
- whileHover={{ y: -4, scale: 1.02 }}
132
- whileTap={{ scale: 0.98 }}
133
- className="group relative h-full"
134
- >
135
- <div
136
- className={`
137
- absolute inset-0 -z-10 rounded-xl bg-gradient-to-br ${
138
- zone.gradient
139
- }
140
- opacity-0 blur-md transition-opacity duration-300
141
- ${
142
- draggedZone === index
143
- ? "opacity-70"
144
- : "group-hover:opacity-70"
145
- }
146
- `}
147
- />
148
- <Card className="relative h-full rounded-[1rem] overflow-hidden border-2 border-dashed border-gray-200 dark:border-gray-800 transition-colors duration-300 group-hover:border-transparent">
149
- <CardContent className="flex h-full flex-col items-center justify-center p-6 text-center">
150
- <motion.div
151
- whileHover={{ scale: 1.1, rotate: 10 }}
152
- className="rounded-full bg-gray-100 dark:bg-gray-800 p-3 mb-4"
153
- >
154
- <zone.icon className="h-8 w-8 text-gray-500" />
155
- </motion.div>
156
- <h3 className="mb-1 text-sm font-medium">{zone.title}</h3>
157
- <p className="text-xs text-gray-500">{zone.subtitle}</p>
158
- </CardContent>
159
- </Card>
160
- </motion.div>
161
- </div>
162
- ))}
163
- </div>
164
-
165
- {(uploading || files.length > 0) && (
166
- <div className="mb-6">
167
- <Progress value={uploading ? progress : 100} className="h-2 mb-2" />
168
- <p className="text-sm text-gray-500 mb-2">
169
- {uploading
170
- ? `Uploading... ${progress}%`
171
- : `${files.length} file(s) uploaded`}
172
- </p>
173
- <AnimatePresence>
174
- {files.map((file, index) => (
175
- <motion.div
176
- key={`${file.alt}-${index}`}
177
- initial={{ opacity: 0, y: -10 }}
178
- animate={{ opacity: 1, y: 0 }}
179
- exit={{ opacity: 0, y: -10 }}
180
- className="flex items-center justify-between bg-gray-100 dark:bg-gray-800 rounded-[1rem] p-2 mb-2"
181
- >
182
- <span className="truncate max-w-[80%] text-sm text-gray-700 dark:text-gray-300 ml-2">
183
- {file.alt}
184
- </span>
185
- <Button
186
- variant="ghost"
187
- size="icon"
188
- onClick={() => removeFile(index)}
189
- className="h-6 w-6 p-0 hover:bg-gray-200 dark:hover:bg-gray-700"
190
- >
191
- <X className="h-4 w-4" />
192
- </Button>
193
- </motion.div>
194
- ))}
195
- </AnimatePresence>
196
- </div>
197
- )}
198
-
199
- <div className="text-center flex flex-col">
200
- <input
201
- type="file"
202
- ref={fileInputRef}
203
- onChange={handleFileSelect}
204
- className="hidden"
205
- multiple
206
- />
207
- <Button
208
- onClick={() => fileInputRef.current?.click()}
209
- disabled={uploading}
210
- className="rounded-[1rem] mt-5"
211
- >
212
- {uploading ? (
213
- <>
214
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
215
- Uploading...
216
- </>
217
- ) : (
218
- <>
219
- <Upload className="mr-2 h-4 w-4" />
220
- Choose Files
221
- </>
222
- )}
223
- </Button>
224
-
225
- {files.length > 0 && (
226
- <Button
227
- onClick={() => InsertMedia(files)}
228
- disabled={uploading}
229
- className="rounded-[1rem] mt-2"
230
- >
231
- Insert the {files.length == 1 ? "image" : "images"}
232
- </Button>
233
- )}
234
- </div>
235
- </CardContent>
236
- </Card>
237
- );
238
- };
239
-
240
- export default FileUploadZone;
@@ -1,297 +0,0 @@
1
- import * as React from "react";
2
- import { useRef } from "react";
3
- import { calculateZoomLevel } from "@lexical/utils";
4
- import { LexicalEditor } from "lexical";
5
-
6
- function clamp(value: number, min: number, max: number) {
7
- return Math.min(Math.max(value, min), max);
8
- }
9
-
10
- const Direction = {
11
- east: 1 << 0,
12
- north: 1 << 3,
13
- south: 1 << 1,
14
- west: 1 << 2,
15
- };
16
-
17
- export default function ImageResizer({
18
- onResizeStart,
19
- onResizeEnd,
20
- MediaRef,
21
- editor,
22
- }: {
23
- editor: LexicalEditor;
24
- MediaRef: { current: null | HTMLElement };
25
- onResizeEnd: (width: "inherit" | number, height: "inherit" | number) => void;
26
- onResizeStart: () => void;
27
- }): React.JSX.Element {
28
- const controlWrapperRef = useRef<HTMLDivElement>(null);
29
- const userSelect = useRef({
30
- priority: "",
31
- value: "default",
32
- });
33
- const positioningRef = useRef<{
34
- currentHeight: "inherit" | number;
35
- currentWidth: "inherit" | number;
36
- direction: number;
37
- isResizing: boolean;
38
- ratio: number;
39
- startHeight: number;
40
- startWidth: number;
41
- startX: number;
42
- startY: number;
43
- }>({
44
- currentHeight: 0,
45
- currentWidth: 0,
46
- direction: 0,
47
- isResizing: false,
48
- ratio: 0,
49
- startHeight: 0,
50
- startWidth: 0,
51
- startX: 0,
52
- startY: 0,
53
- });
54
-
55
- const editorRootElement = editor.getRootElement();
56
- // Find max width, accounting for editor padding.
57
- // document.getElementById("Editor")?.scrollHeight
58
-
59
- const maxWidthContainer = 950
60
- const maxHeightContainer =
61
- editorRootElement !== null
62
- ? editorRootElement.getBoundingClientRect().height - 20
63
- : 100;
64
-
65
- const minWidth = 100;
66
- const minHeight = 100;
67
-
68
- const setStartCursor = (direction: number) => {
69
- const ew = direction === Direction.east || direction === Direction.west;
70
- const ns = direction === Direction.north || direction === Direction.south;
71
- const nwse =
72
- (direction & Direction.north && direction & Direction.west) ||
73
- (direction & Direction.south && direction & Direction.east);
74
-
75
- const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
76
-
77
- if (editorRootElement !== null) {
78
- editorRootElement.style.setProperty(
79
- "cursor",
80
- `${cursorDir}-resize`,
81
- "important"
82
- );
83
- }
84
- if (document.body !== null) {
85
- document.body.style.setProperty(
86
- "cursor",
87
- `${cursorDir}-resize`,
88
- "important"
89
- );
90
- userSelect.current.value = document.body.style.getPropertyValue(
91
- "-webkit-user-select"
92
- );
93
- userSelect.current.priority = document.body.style.getPropertyPriority(
94
- "-webkit-user-select"
95
- );
96
- document.body.style.setProperty(
97
- "-webkit-user-select",
98
- `none`,
99
- "important"
100
- );
101
- }
102
- };
103
-
104
- const setEndCursor = () => {
105
- if (editorRootElement !== null) {
106
- editorRootElement.style.setProperty("cursor", "text");
107
- }
108
- if (document.body !== null) {
109
- document.body.style.setProperty("cursor", "default");
110
- document.body.style.setProperty(
111
- "-webkit-user-select",
112
- userSelect.current.value,
113
- userSelect.current.priority
114
- );
115
- }
116
- };
117
-
118
- const handlePointerDown = (
119
- event: React.PointerEvent<HTMLDivElement>,
120
- direction: number
121
- ) => {
122
- if (!editor.isEditable()) {
123
- return;
124
- }
125
-
126
- const image = MediaRef.current;
127
- const controlWrapper = controlWrapperRef.current;
128
-
129
- if (image !== null && controlWrapper !== null) {
130
- event.preventDefault();
131
- const { width, height } = image.getBoundingClientRect();
132
- const zoom = calculateZoomLevel(image);
133
- const positioning = positioningRef.current;
134
- positioning.startWidth = width;
135
- positioning.startHeight = height;
136
- positioning.ratio = width / height;
137
- positioning.currentWidth = width;
138
- positioning.currentHeight = height;
139
- positioning.startX = event.clientX / zoom;
140
- positioning.startY = event.clientY / zoom;
141
- positioning.isResizing = true;
142
- positioning.direction = direction;
143
-
144
- setStartCursor(direction);
145
- onResizeStart();
146
-
147
- controlWrapper.classList.add("resizing");
148
- image.classList.add("resizing");
149
-
150
- document.addEventListener("pointermove", handlePointerMove);
151
- document.addEventListener("pointerup", handlePointerUp);
152
- }
153
- };
154
-
155
- const handlePointerMove = (event: PointerEvent) => {
156
- const image = MediaRef.current;
157
- const positioning = positioningRef.current;
158
-
159
- const isHorizontal =
160
- positioning.direction & (Direction.east | Direction.west);
161
- const isVertical =
162
- positioning.direction & (Direction.south | Direction.north);
163
-
164
- if (image !== null && positioning.isResizing) {
165
- const zoom = calculateZoomLevel(image);
166
- // Corner cursor
167
- if (isHorizontal && isVertical) {
168
- let diff = Math.floor(positioning.startX - event.clientX / zoom);
169
- diff = positioning.direction & Direction.east ? -diff : diff;
170
-
171
- const width = clamp(
172
- positioning.startWidth + diff,
173
- minWidth,
174
- maxWidthContainer
175
- );
176
-
177
- const height = width / positioning.ratio;
178
- image.style.width = `${width}px`;
179
- image.style.height = `${height}px`;
180
- positioning.currentHeight = height;
181
- positioning.currentWidth = width;
182
- } else if (isVertical) {
183
- let diff = Math.floor(positioning.startY - event.clientY / zoom);
184
- diff = positioning.direction & Direction.south ? -diff : diff;
185
-
186
- const height = clamp(
187
- positioning.startHeight + diff,
188
- minHeight,
189
- maxHeightContainer
190
- );
191
-
192
- image.style.height = `${height}px`;
193
- positioning.currentHeight = height;
194
- } else {
195
- let diff = Math.floor(positioning.startX - event.clientX / zoom);
196
- diff = positioning.direction & Direction.east ? -diff : diff;
197
-
198
- const width = clamp(
199
- positioning.startWidth + diff,
200
- minWidth,
201
- maxWidthContainer
202
- );
203
-
204
- image.style.width = `${width}px`;
205
- positioning.currentWidth = width;
206
- }
207
- }
208
- };
209
-
210
- const handlePointerUp = () => {
211
- const image = MediaRef.current;
212
- const positioning = positioningRef.current;
213
- const controlWrapper = controlWrapperRef.current;
214
- if (image !== null && controlWrapper !== null && positioning.isResizing) {
215
- const width = positioning.currentWidth;
216
- const height = positioning.currentHeight;
217
- positioning.startWidth = 0;
218
- positioning.startHeight = 0;
219
- positioning.ratio = 0;
220
- positioning.startX = 0;
221
- positioning.startY = 0;
222
- positioning.currentWidth = 0;
223
- positioning.currentHeight = 0;
224
- positioning.isResizing = false;
225
-
226
- controlWrapper.classList.remove("resizing");
227
- image.classList.remove("resizing");
228
-
229
- setEndCursor();
230
- onResizeEnd(width, height);
231
-
232
- document.removeEventListener("pointermove", handlePointerMove);
233
- document.removeEventListener("pointerup", handlePointerUp);
234
- }
235
- };
236
-
237
- return (
238
- <div
239
- ref={controlWrapperRef}
240
- className="absolute inset-0 z-10"
241
- style={{
242
- width: MediaRef.current?.style.width,
243
- height: MediaRef.current?.style.height,
244
- }}
245
- >
246
- {/* Resizer Handles */}
247
- <div
248
- className="absolute top-0 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-n-resize"
249
- onPointerDown={(event) => {
250
- handlePointerDown(event, Direction.north);
251
- }}
252
- />
253
- <div
254
- className="absolute top-0 right-0 transform -translate-y-1/2 translate-x-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-ne-resize"
255
- onPointerDown={(event) => {
256
- handlePointerDown(event, Direction.north | Direction.east);
257
- }}
258
- />
259
- <div
260
- className="absolute top-1/2 right-0 transform translate-x-1/2 -translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-e-resize"
261
- onPointerDown={(event) => {
262
- handlePointerDown(event, Direction.east);
263
- }}
264
- />
265
- <div
266
- className="absolute bottom-0 right-0 transform translate-x-1/2 translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-se-resize"
267
- onPointerDown={(event) => {
268
- handlePointerDown(event, Direction.south | Direction.east);
269
- }}
270
- />
271
- <div
272
- className="absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-s-resize"
273
- onPointerDown={(event) => {
274
- handlePointerDown(event, Direction.south);
275
- }}
276
- />
277
- <div
278
- className="absolute bottom-0 left-0 transform -translate-x-1/2 translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-sw-resize"
279
- onPointerDown={(event) => {
280
- handlePointerDown(event, Direction.south | Direction.west);
281
- }}
282
- />
283
- <div
284
- className="absolute top-1/2 left-0 transform -translate-x-1/2 -translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-w-resize"
285
- onPointerDown={(event) => {
286
- handlePointerDown(event, Direction.west);
287
- }}
288
- />
289
- <div
290
- className="absolute top-0 left-0 transform -translate-x-1/2 -translate-y-1/2 w-2 h-2 bg-blue-500 rounded-full cursor-nw-resize"
291
- onPointerDown={(event) => {
292
- handlePointerDown(event, Direction.north | Direction.west);
293
- }}
294
- />
295
- </div>
296
- );
297
- }