@collabchron/notiq 0.2.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 (188) hide show
  1. package/README.md +71 -0
  2. package/components.json +21 -0
  3. package/eslint.config.mjs +16 -0
  4. package/next.config.ts +12 -0
  5. package/package.json +108 -0
  6. package/postcss.config.mjs +5 -0
  7. package/public/file.svg +1 -0
  8. package/public/globe.svg +1 -0
  9. package/public/images/icons/plus.svg +10 -0
  10. package/public/next.svg +1 -0
  11. package/public/vercel.svg +1 -0
  12. package/public/window.svg +1 -0
  13. package/src/app/actions.ts +2 -0
  14. package/src/app/api/ai/route.ts +175 -0
  15. package/src/app/api/edgestore/[...edgestore]/route.ts +28 -0
  16. package/src/app/favicon.ico +0 -0
  17. package/src/app/globals.css +205 -0
  18. package/src/app/layout.tsx +38 -0
  19. package/src/app/page.tsx +12 -0
  20. package/src/components/editor/Core.tsx +220 -0
  21. package/src/components/editor/hooks/instructions-messages.ts +300 -0
  22. package/src/components/editor/hooks/use-mobile.ts +19 -0
  23. package/src/components/editor/hooks/useReport.ts +67 -0
  24. package/src/components/editor/hooks/useResizeObservert.ts +22 -0
  25. package/src/components/editor/index.tsx +39 -0
  26. package/src/components/editor/lexical-on-change.tsx +28 -0
  27. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +92 -0
  28. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +65 -0
  29. package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +105 -0
  30. package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +143 -0
  31. package/src/components/editor/nodes/EquationNode/EquationNode.tsx +170 -0
  32. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +228 -0
  33. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +137 -0
  34. package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +317 -0
  35. package/src/components/editor/nodes/ExcalidrawNode/index.tsx +204 -0
  36. package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +134 -0
  37. package/src/components/editor/nodes/Hint/HintComponet.tsx +221 -0
  38. package/src/components/editor/nodes/Hint/index.tsx +190 -0
  39. package/src/components/editor/nodes/ImageNode/index.tsx +328 -0
  40. package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +383 -0
  41. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +94 -0
  42. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +309 -0
  43. package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +146 -0
  44. package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +79 -0
  45. package/src/components/editor/nodes/PollNode/index.tsx +204 -0
  46. package/src/components/editor/nodes/Stepper/index.tsx +260 -0
  47. package/src/components/editor/nodes/TweetNode/index.tsx +214 -0
  48. package/src/components/editor/nodes/index.ts +81 -0
  49. package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +350 -0
  50. package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +56 -0
  51. package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +70 -0
  52. package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +192 -0
  53. package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +217 -0
  54. package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +26 -0
  55. package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +21 -0
  56. package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +76 -0
  57. package/src/components/editor/plugins/CollapsiblePlugin/index.ts +228 -0
  58. package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +44 -0
  59. package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +52 -0
  60. package/src/components/editor/plugins/EquationsPlugin/index.tsx +85 -0
  61. package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +98 -0
  62. package/src/components/editor/plugins/FigmaPlugin/index.tsx +42 -0
  63. package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +445 -0
  64. package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +275 -0
  65. package/src/components/editor/plugins/ImagesPlugin/index.tsx +222 -0
  66. package/src/components/editor/plugins/InlineImagePlugin/index.tsx +351 -0
  67. package/src/components/editor/plugins/LayoutPlugin/index.tsx +238 -0
  68. package/src/components/editor/plugins/LinkPlugin/index.tsx +36 -0
  69. package/src/components/editor/plugins/LinkWithMetaData/index.tsx +271 -0
  70. package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +11 -0
  71. package/src/components/editor/plugins/MarkdownTransformers/index.tsx +304 -0
  72. package/src/components/editor/plugins/PollPlugin/index.tsx +49 -0
  73. package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +180 -0
  74. package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +253 -0
  75. package/src/components/editor/plugins/SlashCommand/index.tsx +621 -0
  76. package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +127 -0
  77. package/src/components/editor/plugins/TabFocusPlugin/index.ts +58 -0
  78. package/src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx +759 -0
  79. package/src/components/editor/plugins/TableCellResizer/index.tsx +438 -0
  80. package/src/components/editor/plugins/TableHoverActionsPlugin/index.tsx +314 -0
  81. package/src/components/editor/plugins/TablePlugin/index.tsx +99 -0
  82. package/src/components/editor/plugins/ToolbarPlugin/index.tsx +522 -0
  83. package/src/components/editor/plugins/TwitterPlugin/index.ts +35 -0
  84. package/src/components/editor/plugins/YouTubeNode/index.tsx +179 -0
  85. package/src/components/editor/plugins/YouTubePlugin/index.ts +41 -0
  86. package/src/components/editor/themes/editor-theme.ts +113 -0
  87. package/src/components/editor/themes/theme.css +377 -0
  88. package/src/components/editor/utils/ai.ts +291 -0
  89. package/src/components/editor/utils/canUseDOM.ts +12 -0
  90. package/src/components/editor/utils/editorFormatting.ts +282 -0
  91. package/src/components/editor/utils/environment.ts +50 -0
  92. package/src/components/editor/utils/extract-data.ts +166 -0
  93. package/src/components/editor/utils/getAllLexicalChildren.ts +13 -0
  94. package/src/components/editor/utils/getDOMRangeRect.ts +27 -0
  95. package/src/components/editor/utils/getSelectedNode.ts +27 -0
  96. package/src/components/editor/utils/gif.ts +29 -0
  97. package/src/components/editor/utils/invariant.ts +15 -0
  98. package/src/components/editor/utils/setFloatingElemPosition.ts +51 -0
  99. package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +40 -0
  100. package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +51 -0
  101. package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +15 -0
  102. package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +114 -0
  103. package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +6 -0
  104. package/src/components/editor/utils/url.ts +109 -0
  105. package/src/components/editor/utils/useLayoutEffect.ts +13 -0
  106. package/src/components/providers/QueryProvider.tsx +15 -0
  107. package/src/components/providers/SharedHistoryContext.tsx +28 -0
  108. package/src/components/providers/ToolbarContext.tsx +123 -0
  109. package/src/components/providers/theme-provider.tsx +11 -0
  110. package/src/components/theme/ModeToggle.tsx +40 -0
  111. package/src/components/ui/FileInput.tsx +40 -0
  112. package/src/components/ui/Input.css +32 -0
  113. package/src/components/ui/Select.css +42 -0
  114. package/src/components/ui/Select.tsx +36 -0
  115. package/src/components/ui/TextInput.tsx +48 -0
  116. package/src/components/ui/ai/ai-button.tsx +574 -0
  117. package/src/components/ui/ai/border.tsx +99 -0
  118. package/src/components/ui/ai/placeholder-input-vanish.tsx +282 -0
  119. package/src/components/ui/button.tsx +89 -0
  120. package/src/components/ui/card.tsx +76 -0
  121. package/src/components/ui/checkbox.tsx +30 -0
  122. package/src/components/ui/command.tsx +153 -0
  123. package/src/components/ui/dialog/Dialog.css +25 -0
  124. package/src/components/ui/dialog/Dialog.tsx +34 -0
  125. package/src/components/ui/dialog.tsx +122 -0
  126. package/src/components/ui/drop-downs/background-color.tsx +183 -0
  127. package/src/components/ui/drop-downs/block-format.tsx +159 -0
  128. package/src/components/ui/drop-downs/code.tsx +42 -0
  129. package/src/components/ui/drop-downs/color.tsx +177 -0
  130. package/src/components/ui/drop-downs/font-size.tsx +138 -0
  131. package/src/components/ui/drop-downs/font.tsx +155 -0
  132. package/src/components/ui/drop-downs/index.tsx +122 -0
  133. package/src/components/ui/drop-downs/insert-node.tsx +213 -0
  134. package/src/components/ui/drop-downs/text-align.tsx +123 -0
  135. package/src/components/ui/drop-downs/text-format.tsx +104 -0
  136. package/src/components/ui/dropdown-menu.tsx +201 -0
  137. package/src/components/ui/equation/EquationEditor.css +38 -0
  138. package/src/components/ui/equation/EquationEditor.tsx +56 -0
  139. package/src/components/ui/equation/KatexEquationAlterer.css +41 -0
  140. package/src/components/ui/equation/KatexEquationAlterer.tsx +83 -0
  141. package/src/components/ui/equation/KatexRenderer.tsx +66 -0
  142. package/src/components/ui/excalidraw/ExcalidrawModal.css +64 -0
  143. package/src/components/ui/excalidraw/ExcalidrawModal.tsx +234 -0
  144. package/src/components/ui/excalidraw/Modal.css +62 -0
  145. package/src/components/ui/excalidraw/Modal.tsx +110 -0
  146. package/src/components/ui/hover-card.tsx +29 -0
  147. package/src/components/ui/image/error-image.tsx +17 -0
  148. package/src/components/ui/image/file-upload.tsx +240 -0
  149. package/src/components/ui/image/image-resizer.tsx +297 -0
  150. package/src/components/ui/image/image-toolbar.tsx +264 -0
  151. package/src/components/ui/image/index.tsx +408 -0
  152. package/src/components/ui/image/lazy-image.tsx +68 -0
  153. package/src/components/ui/image/lazy-video.tsx +71 -0
  154. package/src/components/ui/input.tsx +22 -0
  155. package/src/components/ui/models/custom-dialog.tsx +320 -0
  156. package/src/components/ui/models/insert-gif.tsx +90 -0
  157. package/src/components/ui/models/insert-image.tsx +52 -0
  158. package/src/components/ui/models/insert-poll.tsx +29 -0
  159. package/src/components/ui/models/insert-table.tsx +62 -0
  160. package/src/components/ui/models/use-model.tsx +91 -0
  161. package/src/components/ui/poll/poll-component.tsx +304 -0
  162. package/src/components/ui/popover.tsx +33 -0
  163. package/src/components/ui/progress.tsx +28 -0
  164. package/src/components/ui/scroll-area.tsx +48 -0
  165. package/src/components/ui/separator.tsx +31 -0
  166. package/src/components/ui/skeleton.tsx +15 -0
  167. package/src/components/ui/sonner.tsx +31 -0
  168. package/src/components/ui/stepper/step.tsx +179 -0
  169. package/src/components/ui/stepper/stepper.tsx +89 -0
  170. package/src/components/ui/textarea.tsx +22 -0
  171. package/src/components/ui/toggle.tsx +71 -0
  172. package/src/components/ui/tooltip.tsx +32 -0
  173. package/src/components/ui/write/text-format-floting-toolbar.tsx +346 -0
  174. package/src/lib/edgestore.ts +9 -0
  175. package/src/lib/pinecone-client.ts +0 -0
  176. package/src/lib/utils.ts +6 -0
  177. package/src/utils/docSerialization.ts +77 -0
  178. package/src/utils/emoji-list.ts +16615 -0
  179. package/src/utils/getDOMRangeRect.ts +27 -0
  180. package/src/utils/getSelectedNode.ts +27 -0
  181. package/src/utils/getThemeSelector.ts +25 -0
  182. package/src/utils/isMobileWidth.ts +7 -0
  183. package/src/utils/joinClasses.ts +13 -0
  184. package/src/utils/setFloatingElemPosition.ts +74 -0
  185. package/src/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
  186. package/src/utils/swipe.ts +127 -0
  187. package/src/utils/url.ts +38 -0
  188. package/tsconfig.json +27 -0
@@ -0,0 +1,66 @@
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 katex from 'katex';
12
+ import * as React from 'react';
13
+ import {useEffect, useRef} from 'react';
14
+
15
+ export default function KatexRenderer({
16
+ equation,
17
+ inline,
18
+ onDoubleClick,
19
+ }: Readonly<{
20
+ equation: string;
21
+ inline: boolean;
22
+ onDoubleClick: () => void;
23
+ }>): JSX.Element {
24
+ const katexElementRef = useRef(null);
25
+
26
+ useEffect(() => {
27
+ const katexElement = katexElementRef.current;
28
+
29
+ if (katexElement !== null) {
30
+ katex.render(equation, katexElement, {
31
+ displayMode: !inline, // true === block display //
32
+ errorColor: '#cc0000',
33
+ output: 'html',
34
+ strict: 'warn',
35
+ throwOnError: false,
36
+ trust: false,
37
+ });
38
+ }
39
+ }, [equation, inline]);
40
+
41
+ return (
42
+ // We use an empty image tag either side to ensure Android doesn't try and compose from the
43
+ // inner text from Katex. There didn't seem to be any other way of making this work,
44
+ // without having a physical space.
45
+ <>
46
+ <img
47
+ src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
48
+ width="0"
49
+ height="0"
50
+ alt=""
51
+ />
52
+ <span
53
+ role="button"
54
+ tabIndex={-1}
55
+ onDoubleClick={onDoubleClick}
56
+ ref={katexElementRef}
57
+ />
58
+ <img
59
+ src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
60
+ width="0"
61
+ height="0"
62
+ alt=""
63
+ />
64
+ </>
65
+ );
66
+ }
@@ -0,0 +1,64 @@
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
+
10
+ .ExcalidrawModal__overlay {
11
+ display: flex;
12
+ align-items: center;
13
+ position: fixed;
14
+ flex-direction: column;
15
+ top: 0px;
16
+ bottom: 0px;
17
+ left: 0px;
18
+ right: 0px;
19
+ flex-grow: 0px;
20
+ flex-shrink: 1px;
21
+ z-index: 100;
22
+ background-color: rgba(40, 40, 40, 0.6);
23
+ }
24
+ .ExcalidrawModal__actions {
25
+ text-align: end;
26
+ position: absolute;
27
+ right: 5px;
28
+ top: 5px;
29
+ z-index: 1;
30
+ }
31
+ .ExcalidrawModal__actions button {
32
+ background-color: #fff;
33
+ border-radius: 5px;
34
+ }
35
+ .ExcalidrawModal__row {
36
+ position: relative;
37
+ padding: 40px 5px 5px;
38
+ width: 70vw;
39
+ height: 70vh;
40
+ border-radius: 8px;
41
+ box-shadow:
42
+ 0 12px 28px 0 rgba(0, 0, 0, 0.2),
43
+ 0 2px 4px 0 rgba(0, 0, 0, 0.1),
44
+ inset 0 0 0 1px rgba(255, 255, 255, 0.5);
45
+ }
46
+ .ExcalidrawModal__row > div {
47
+ border-radius: 5px;
48
+ }
49
+ .ExcalidrawModal__modal {
50
+ position: relative;
51
+ z-index: 10;
52
+ top: 50px;
53
+ width: auto;
54
+ left: 0;
55
+ display: flex;
56
+ justify-content: center;
57
+ align-items: center;
58
+ border-radius: 8px;
59
+ background-color: #eee;
60
+ }
61
+ .ExcalidrawModal__discardModal {
62
+ margin-top: 60px;
63
+ text-align: center;
64
+ }
@@ -0,0 +1,234 @@
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 {
10
+ AppState,
11
+ BinaryFiles,
12
+ ExcalidrawImperativeAPI,
13
+ ExcalidrawInitialDataState,
14
+ } from '@excalidraw/excalidraw/types';
15
+ import type {JSX} from 'react';
16
+
17
+ import './ExcalidrawModal.css';
18
+
19
+ import {Excalidraw} from '@excalidraw/excalidraw';
20
+ import {isDOMNode} from 'lexical';
21
+ import * as React from 'react';
22
+ import {ReactPortal, useEffect, useLayoutEffect, useRef, useState} from 'react';
23
+ import {createPortal} from 'react-dom';
24
+ import Modal from './Modal';
25
+ import { Button } from '@/components/ui/button';
26
+
27
+
28
+
29
+ export type ExcalidrawInitialElements = ExcalidrawInitialDataState['elements'];
30
+
31
+ type Props = {
32
+ closeOnClickOutside?: boolean;
33
+ /**
34
+ * The initial set of elements to draw into the scene
35
+ */
36
+ initialElements: ExcalidrawInitialElements;
37
+ /**
38
+ * The initial set of elements to draw into the scene
39
+ */
40
+ initialAppState: AppState;
41
+ /**
42
+ * The initial set of elements to draw into the scene
43
+ */
44
+ initialFiles: BinaryFiles;
45
+ /**
46
+ * Controls the visibility of the modal
47
+ */
48
+ isShown?: boolean;
49
+ /**
50
+ * Callback when closing and discarding the new changes
51
+ */
52
+ onClose: () => void;
53
+ /**
54
+ * Completely remove Excalidraw component
55
+ */
56
+ onDelete: () => void;
57
+ /**
58
+ * Callback when the save button is clicked
59
+ */
60
+ onSave: (
61
+ elements: ExcalidrawInitialElements,
62
+ appState: Partial<AppState>,
63
+ files: BinaryFiles,
64
+ ) => void;
65
+ };
66
+
67
+ /**
68
+ * @explorer-desc
69
+ * A component which renders a modal with Excalidraw (a painting app)
70
+ * which can be used to export an editable image
71
+ */
72
+ export default function ExcalidrawModal({
73
+ closeOnClickOutside = false,
74
+ onSave,
75
+ initialElements,
76
+ initialAppState,
77
+ initialFiles,
78
+ isShown = false,
79
+ onDelete,
80
+ onClose,
81
+ }: Props): ReactPortal | null {
82
+ const excaliDrawModelRef = useRef<HTMLDivElement | null>(null);
83
+ const [excalidrawAPI, setExcalidrawAPI] =
84
+ useState<ExcalidrawImperativeAPI | null>(null);
85
+ const [discardModalOpen, setDiscardModalOpen] = useState(false);
86
+ const [elements, setElements] =
87
+ useState<ExcalidrawInitialElements>(initialElements);
88
+ const [files, setFiles] = useState<BinaryFiles>(initialFiles);
89
+
90
+ useEffect(() => {
91
+ excaliDrawModelRef.current?.focus();
92
+ }, []);
93
+
94
+ useEffect(() => {
95
+ let modalOverlayElement: HTMLElement | null = null;
96
+
97
+ const clickOutsideHandler = (event: MouseEvent) => {
98
+ const target = event.target;
99
+ if (
100
+ excaliDrawModelRef.current !== null &&
101
+ isDOMNode(target) &&
102
+ !excaliDrawModelRef.current.contains(target) &&
103
+ closeOnClickOutside
104
+ ) {
105
+ onDelete();
106
+ }
107
+ };
108
+
109
+ if (excaliDrawModelRef.current !== null) {
110
+ modalOverlayElement = excaliDrawModelRef.current?.parentElement;
111
+ modalOverlayElement?.addEventListener('click', clickOutsideHandler);
112
+ }
113
+
114
+ return () => {
115
+ modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
116
+ };
117
+ }, [closeOnClickOutside, onDelete]);
118
+
119
+ useLayoutEffect(() => {
120
+ const currentModalRef = excaliDrawModelRef.current;
121
+
122
+ const onKeyDown = (event: KeyboardEvent) => {
123
+ if (event.key === 'Escape') {
124
+ onDelete();
125
+ }
126
+ };
127
+
128
+ currentModalRef?.addEventListener('keydown', onKeyDown);
129
+
130
+ return () => {
131
+ currentModalRef?.removeEventListener('keydown', onKeyDown);
132
+ };
133
+ }, [elements, files, onDelete]);
134
+
135
+ const save = () => {
136
+ if (elements?.some((el) => !el.isDeleted)) {
137
+ const appState = excalidrawAPI?.getAppState();
138
+ // We only need a subset of the state
139
+ const partialState: Partial<AppState> = {
140
+ exportBackground: appState?.exportBackground,
141
+ exportScale: appState?.exportScale,
142
+ exportWithDarkMode: appState?.theme === 'dark',
143
+ isBindingEnabled: appState?.isBindingEnabled,
144
+ isLoading: appState?.isLoading,
145
+ name: appState?.name,
146
+ theme: appState?.theme,
147
+ viewBackgroundColor: appState?.viewBackgroundColor,
148
+ viewModeEnabled: appState?.viewModeEnabled,
149
+ zenModeEnabled: appState?.zenModeEnabled,
150
+ zoom: appState?.zoom,
151
+ };
152
+ onSave(elements, partialState, files);
153
+ } else {
154
+ // delete node if the scene is clear
155
+ onDelete();
156
+ }
157
+ };
158
+
159
+ const discard = () => {
160
+ setDiscardModalOpen(true);
161
+ };
162
+
163
+ function ShowDiscardDialog(): JSX.Element {
164
+ return (
165
+ <Modal
166
+ title="Discard"
167
+ onClose={() => {
168
+ setDiscardModalOpen(false);
169
+ }}
170
+ closeOnClickOutside={false}>
171
+ Are you sure you want to discard the changes?
172
+ <div className="ExcalidrawModal__discardModal">
173
+ <Button
174
+ onClick={() => {
175
+ setDiscardModalOpen(false);
176
+ onClose();
177
+ }}>
178
+ Discard
179
+ </Button>{' '}
180
+ <Button
181
+ onClick={() => {
182
+ setDiscardModalOpen(false);
183
+ }}>
184
+ Cancel
185
+ </Button>
186
+ </div>
187
+ </Modal>
188
+ );
189
+ }
190
+
191
+ if (isShown === false) {
192
+ return null;
193
+ }
194
+
195
+ const onChange = (
196
+ els: ExcalidrawInitialElements,
197
+ _: AppState,
198
+ fls: BinaryFiles,
199
+ ) => {
200
+ setElements(els);
201
+ setFiles(fls);
202
+ };
203
+
204
+ return createPortal(
205
+ <div className="ExcalidrawModal__overlay" role="dialog">
206
+ <div
207
+ className="ExcalidrawModal__modal"
208
+ ref={excaliDrawModelRef}
209
+ tabIndex={-1}>
210
+ <div className="ExcalidrawModal__row">
211
+ {discardModalOpen && <ShowDiscardDialog />}
212
+ <Excalidraw
213
+ onChange={onChange}
214
+ excalidrawAPI={setExcalidrawAPI}
215
+ initialData={{
216
+ appState: initialAppState || {isLoading: false},
217
+ elements: initialElements,
218
+ files: initialFiles,
219
+ }}
220
+ />
221
+ <div className="ExcalidrawModal__actions">
222
+ <button className="action-button" onClick={discard}>
223
+ Discard
224
+ </button>
225
+ <button className="action-button" onClick={save}>
226
+ Save
227
+ </button>
228
+ </div>
229
+ </div>
230
+ </div>
231
+ </div>,
232
+ document.body,
233
+ );
234
+ }
@@ -0,0 +1,62 @@
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
+
10
+ .Modal__overlay {
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ position: fixed;
15
+ flex-direction: column;
16
+ top: 0px;
17
+ bottom: 0px;
18
+ left: 0px;
19
+ right: 0px;
20
+ background-color: rgba(40, 40, 40, 0.6);
21
+ flex-grow: 0px;
22
+ flex-shrink: 1px;
23
+ z-index: 100;
24
+ }
25
+ .Modal__modal {
26
+ padding: 20px;
27
+ min-height: 100px;
28
+ min-width: 300px;
29
+ display: flex;
30
+ flex-grow: 0px;
31
+ background-color: #fff;
32
+ flex-direction: column;
33
+ position: relative;
34
+ box-shadow: 0 0 20px 0 #444;
35
+ border-radius: 10px;
36
+ }
37
+ .Modal__title {
38
+ color: #444;
39
+ margin: 0px;
40
+ padding-bottom: 10px;
41
+ border-bottom: 1px solid #ccc;
42
+ }
43
+ .Modal__closeButton {
44
+ border: 0px;
45
+ position: absolute;
46
+ right: 20px;
47
+ border-radius: 20px;
48
+ justify-content: center;
49
+ align-items: center;
50
+ display: flex;
51
+ width: 30px;
52
+ height: 30px;
53
+ text-align: center;
54
+ cursor: pointer;
55
+ background-color: #eee;
56
+ }
57
+ .Modal__closeButton:hover {
58
+ background-color: #ddd;
59
+ }
60
+ .Modal__content {
61
+ padding-top: 20px;
62
+ }
@@ -0,0 +1,110 @@
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
+ }
@@ -0,0 +1,29 @@
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 }
@@ -0,0 +1,17 @@
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
+