@collabchron/notiq 0.3.0 → 1.0.1

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-YKYA4NB4.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 +67 -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,99 +0,0 @@
1
-
2
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
- import {
4
- TableCellNode,
5
- TableNode,
6
- TableRowNode,
7
- } from "@lexical/table";
8
- import { invariant } from "framer-motion";
9
- import { EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from "lexical";
10
- import {
11
- createContext,
12
- JSX,
13
- useContext,
14
- useEffect,
15
- useMemo,
16
- useState,
17
- } from "react";
18
-
19
- export type InsertTableCommandPayload = Readonly<{
20
- columns: string;
21
- rows: string;
22
- includeHeaders?: boolean;
23
- }>;
24
-
25
- export type CellContextShape = {
26
- cellEditorConfig: null | CellEditorConfig;
27
- cellEditorPlugins: null | JSX.Element | Array<JSX.Element>;
28
- set: (
29
- cellEditorConfig: null | CellEditorConfig,
30
- cellEditorPlugins: null | JSX.Element | Array<JSX.Element>
31
- ) => void;
32
- };
33
-
34
- export type CellEditorConfig = Readonly<{
35
- namespace: string;
36
- nodes?: ReadonlyArray<Klass<LexicalNode>>;
37
- onError: (error: Error, editor: LexicalEditor) => void;
38
- readOnly?: boolean;
39
- theme?: EditorThemeClasses;
40
- }>;
41
-
42
- export const CellContext = createContext<CellContextShape>({
43
- cellEditorConfig: null,
44
- cellEditorPlugins: null,
45
- set: () => {
46
- // Empty
47
- },
48
- });
49
-
50
- export function TableContext({ children }: { children: JSX.Element }) {
51
- const [contextValue, setContextValue] = useState<{
52
- cellEditorConfig: null | CellEditorConfig;
53
- cellEditorPlugins: null | JSX.Element | Array<JSX.Element>;
54
- }>({
55
- cellEditorConfig: null,
56
- cellEditorPlugins: null,
57
- });
58
- return (
59
- <CellContext.Provider
60
- value={useMemo(
61
- () => ({
62
- cellEditorConfig: contextValue.cellEditorConfig,
63
- cellEditorPlugins: contextValue.cellEditorPlugins,
64
- set: (cellEditorConfig, cellEditorPlugins) => {
65
- setContextValue({ cellEditorConfig, cellEditorPlugins });
66
- },
67
- }),
68
- [contextValue.cellEditorConfig, contextValue.cellEditorPlugins]
69
- )}
70
- >
71
- {children}
72
- </CellContext.Provider>
73
- );
74
- }
75
-
76
-
77
-
78
- export function TablePlugin({
79
- cellEditorConfig,
80
- children,
81
- }: {
82
- cellEditorConfig: CellEditorConfig;
83
- children: JSX.Element | Array<JSX.Element>;
84
- }): JSX.Element | null {
85
- const [editor] = useLexicalComposerContext();
86
- const cellContext = useContext(CellContext);
87
- useEffect(() => {
88
- if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {
89
- invariant(
90
- false,
91
- "TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor"
92
- );
93
- }
94
- }, [editor]);
95
- useEffect(() => {
96
- cellContext.set(cellEditorConfig, children);
97
- }, [cellContext, cellEditorConfig, children]);
98
- return null;
99
- }
@@ -1,522 +0,0 @@
1
- import React, { Dispatch, useCallback, useEffect, useState } from "react";
2
-
3
- import {
4
- $getNodeByKey,
5
- $getSelection,
6
- $isElementNode,
7
- $isLineBreakNode,
8
- $isRangeSelection,
9
- $isRootOrShadowRoot,
10
- CAN_REDO_COMMAND,
11
- CAN_UNDO_COMMAND,
12
- COMMAND_PRIORITY_CRITICAL,
13
- FORMAT_TEXT_COMMAND,
14
- LexicalEditor,
15
- NodeKey,
16
- REDO_COMMAND,
17
- SELECTION_CHANGE_COMMAND,
18
- UNDO_COMMAND,
19
- } from "lexical";
20
-
21
- import {
22
- useToolbarState,
23
- blockTypeToBlockName,
24
- } from "@/components/providers/ToolbarContext";
25
- import { cn } from "@/lib/utils";
26
-
27
- import { Bold, Code, Italic, Link, Mic, Redo, Redo2Icon, Underline, Undo, Undo2Icon } from "lucide-react";
28
-
29
- import { Separator } from "@/components/ui/separator";
30
- import { Button } from "@/components/ui/button";
31
- import {
32
- $findMatchingParent,
33
- $getNearestNodeOfType,
34
- $isEditorIsNestedEditor,
35
- mergeRegister,
36
- } from "@lexical/utils";
37
- import {
38
- $getSelectionStyleValueForProperty,
39
- $isParentElementRTL,
40
- } from "@lexical/selection";
41
- import { getSelectedNode } from "../../utils/getSelectedNode";
42
- import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
43
- import { $isTableNode, $isTableSelection } from "@lexical/table";
44
- import { $isListNode, ListNode } from "@lexical/list";
45
- import { $isHeadingNode } from "@lexical/rich-text";
46
- import { $isCodeNode, CODE_LANGUAGE_MAP } from "@lexical/code";
47
- import dynamic from "next/dynamic";
48
- import { Toggle } from "@/components/ui/toggle";
49
- import { SHORTCUTS } from "../ShortcutsPlugin/shortcuts";
50
- import { sanitizeUrl } from "../../utils/url";
51
- import CodeList from "@/components/ui/drop-downs/code"
52
- import { SPEECH_TO_TEXT_COMMAND, SUPPORT_SPEECH_RECOGNITION } from "../SpeechToTextPlugin";
53
- import { ModeToggle } from "@/components/theme/ModeToggle";
54
- const BlockFormatDropDown = dynamic(
55
- () => import("@/components/ui/drop-downs/block-format")
56
- );
57
- const FontDropDown = dynamic(
58
- () => import("@/components/ui/drop-downs/font")
59
- );
60
- const FontSize = dynamic(
61
- () => import("@/components/ui/drop-downs/font-size")
62
- );
63
- const Color = dynamic(() => import("@/components/ui/drop-downs/color"));
64
- const BackgroundColor = dynamic(() => import("@/components/ui/drop-downs/background-color"));
65
- const TextFormat = dynamic(
66
- () => import("@/components/ui/drop-downs/text-format")
67
- );
68
- const InsertNode = dynamic(
69
- () => import("@/components/ui/drop-downs/insert-node")
70
- );
71
- const TextAlign = dynamic(
72
- () => import("@/components/ui/drop-downs/text-align")
73
- );
74
- // import { type } from './../../../providers/ToolbarContext';
75
-
76
-
77
- const rootTypeToRootName = {
78
- root: 'Root',
79
- table: 'Table',
80
- };
81
- export default function index({
82
- editor,
83
- activeEditor,
84
- setActiveEditor,
85
- setIsLinkEditMode,
86
- }: {
87
- editor: LexicalEditor;
88
- activeEditor: LexicalEditor;
89
- setActiveEditor: Dispatch<LexicalEditor>;
90
- setIsLinkEditMode: Dispatch<boolean>;
91
- }) {
92
- const [isEditable, setIsEditable] = useState(() => editor.isEditable());
93
- const [isSpeechToText, setIsSpeechToText] = useState(false);
94
- const [selectedElementKey, setSelectedElementKey] = useState<NodeKey | null>(
95
- null
96
- );
97
- const { toolbarState, updateToolbarState } = useToolbarState();
98
-
99
- const $updateToolbar = useCallback(() => {
100
- const currentEditor = activeEditor || editor;
101
-
102
- if (!currentEditor) return;
103
-
104
- currentEditor.read(() => {
105
- const selection = $getSelection();
106
- if ($isRangeSelection(selection)) {
107
- if (activeEditor !== editor && $isEditorIsNestedEditor(activeEditor)) {
108
- const rootElement = activeEditor.getRootElement();
109
- updateToolbarState(
110
- "isImageCaption",
111
- !!rootElement?.parentElement?.classList.contains(
112
- "image-caption-container"
113
- )
114
- );
115
- } else {
116
- updateToolbarState("isImageCaption", false);
117
- }
118
-
119
- const anchorNode = selection.anchor.getNode();
120
- let element =
121
- anchorNode.getKey() === "root"
122
- ? anchorNode
123
- : $findMatchingParent(anchorNode, (e) => {
124
- const parent = e.getParent();
125
- return parent !== null && $isRootOrShadowRoot(parent);
126
- });
127
-
128
- if (element === null) {
129
- element = anchorNode.getTopLevelElementOrThrow();
130
- }
131
-
132
- const elementKey = element.getKey();
133
- const elementDOM = currentEditor.getElementByKey(elementKey);
134
-
135
- const node = getSelectedNode(selection);
136
- const parent = node.getParent();
137
- const isLink = $isLinkNode(parent) || $isLineBreakNode(node);
138
- updateToolbarState("isLink", isLink);
139
-
140
- const tableNode = $findMatchingParent(node, $isTableNode);
141
- if ($isTableNode(tableNode)) {
142
- updateToolbarState("rootType", "table");
143
- } else {
144
- updateToolbarState("rootType", "root");
145
- }
146
-
147
- if (elementDOM !== null) {
148
- setSelectedElementKey(elementKey);
149
- if ($isListNode(element)) {
150
- const parentList = $getNearestNodeOfType<ListNode>(anchorNode, ListNode);
151
- const type = parentList
152
- ? parentList.getListType()
153
- : element.getListType();
154
- updateToolbarState("blockType", type);
155
- } else {
156
- const type = $isHeadingNode(element)
157
- ? element.getTag()
158
- : element.getType();
159
- if (type in blockTypeToBlockName) {
160
- updateToolbarState(
161
- "blockType",
162
- type as keyof typeof blockTypeToBlockName
163
- );
164
- }
165
- if ($isCodeNode(element)) {
166
- const language =
167
- element.getLanguage() as keyof typeof CODE_LANGUAGE_MAP;
168
- updateToolbarState(
169
- "codeLanguage",
170
- language ? CODE_LANGUAGE_MAP[language] || language : ""
171
- );
172
- return;
173
- }
174
- }
175
- }
176
-
177
- updateToolbarState(
178
- "fontColor",
179
- $getSelectionStyleValueForProperty(selection, "color", "#000")
180
- );
181
- updateToolbarState(
182
- "bgColor",
183
- $getSelectionStyleValueForProperty(
184
- selection,
185
- "background-color",
186
- "#fff"
187
- )
188
- );
189
- updateToolbarState(
190
- "fontFamily",
191
- $getSelectionStyleValueForProperty(selection, "font-family", "Arial")
192
- );
193
-
194
- let matchingParent;
195
- if ($isLinkNode(parent)) {
196
- matchingParent = $findMatchingParent(
197
- node,
198
- (parentNode) => $isElementNode(parentNode) && !parentNode.isInline()
199
- );
200
- }
201
-
202
- updateToolbarState(
203
- "elementFormat",
204
- $isElementNode(matchingParent)
205
- ? matchingParent.getFormatType()
206
- : $isElementNode(node)
207
- ? node.getFormatType()
208
- : parent?.getFormatType() || "left"
209
- );
210
- }
211
-
212
- if ($isRangeSelection(selection) || $isTableSelection(selection)) {
213
- updateToolbarState("isBold", selection.hasFormat("bold"));
214
- updateToolbarState("isItalic", selection.hasFormat("italic"));
215
- updateToolbarState("isUnderline", selection.hasFormat("underline"));
216
- updateToolbarState("isStrikethrough", selection.hasFormat("strikethrough"));
217
- updateToolbarState("isSubscript", selection.hasFormat("subscript"));
218
- updateToolbarState("isSuperscript", selection.hasFormat("superscript"));
219
- updateToolbarState("isCode", selection.hasFormat("code"));
220
- updateToolbarState(
221
- "fontSize",
222
- $getSelectionStyleValueForProperty(selection, "font-size", "15px")
223
- );
224
- updateToolbarState("isLowercase", selection.hasFormat("lowercase"));
225
- updateToolbarState("isUppercase", selection.hasFormat("uppercase"));
226
- updateToolbarState("isCapitalize", selection.hasFormat("capitalize"));
227
- }
228
- });
229
- }, [activeEditor, editor, updateToolbarState]);
230
-
231
- useEffect(() => {
232
- return editor.registerCommand(
233
- SELECTION_CHANGE_COMMAND,
234
- (_payload, newEditor) => {
235
- setActiveEditor(newEditor);
236
- $updateToolbar();
237
- return false;
238
- },
239
- COMMAND_PRIORITY_CRITICAL
240
- );
241
- }, [editor, $updateToolbar, setActiveEditor]);
242
-
243
- useEffect(() => {
244
- activeEditor.getEditorState().read(() => {
245
- $updateToolbar();
246
- });
247
- }, [activeEditor, $updateToolbar]);
248
-
249
- useEffect(() => {
250
- return mergeRegister(
251
- editor.registerEditableListener((editable) => {
252
- setIsEditable(editable);
253
- }),
254
- activeEditor.registerUpdateListener(({ editorState }) => {
255
- editorState.read(() => {
256
- $updateToolbar();
257
- });
258
- }),
259
- activeEditor.registerCommand<boolean>(
260
- CAN_UNDO_COMMAND,
261
- (payload) => {
262
- updateToolbarState("canUndo", payload);
263
- return false;
264
- },
265
- COMMAND_PRIORITY_CRITICAL
266
- ),
267
- activeEditor.registerCommand<boolean>(
268
- CAN_REDO_COMMAND,
269
- (payload) => {
270
- updateToolbarState("canRedo", payload);
271
- return false;
272
- },
273
- COMMAND_PRIORITY_CRITICAL
274
- )
275
- );
276
- }, [$updateToolbar, activeEditor, editor, updateToolbarState]);
277
-
278
- const insertLink = useCallback(() => {
279
- if (!toolbarState.isLink) {
280
- setIsLinkEditMode(true);
281
- activeEditor.dispatchCommand(
282
- TOGGLE_LINK_COMMAND,
283
- sanitizeUrl("https://")
284
- );
285
- } else {
286
- setIsLinkEditMode(false);
287
- activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
288
- }
289
- }, [activeEditor, setIsLinkEditMode, toolbarState.isLink]);
290
- const onCodeLanguageSelect = useCallback(
291
- (value: string) => {
292
- activeEditor.update(() => {
293
- if (selectedElementKey !== null) {
294
- const node = $getNodeByKey(selectedElementKey);
295
- if ($isCodeNode(node)) {
296
- node.setLanguage(value);
297
- }
298
- }
299
- });
300
- },
301
- [activeEditor, selectedElementKey]
302
- );
303
-
304
-
305
- return (
306
- <nav
307
- className={cn(
308
- "z-[200] fixed top-0 left-0 w-full",
309
- )}
310
- >
311
- <div className="flex justify-center p-4">
312
- <div
313
- className={cn(
314
- "group flex flex-row items-center gap-x-2 dark:border dark:border-gray-500/20",
315
- "rounded-2xl h-14 px-4 py-2 shadow-md",
316
- "overflow-x-auto whitespace-nowrap max-w-full scrollbar-none",
317
- "[&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"
318
- )}
319
- >
320
- <div className="flex flex-row gap-x-2">
321
- <Button
322
- size={"Toolbar"}
323
- variant={"outline"}
324
- disabled={!toolbarState.canUndo || !isEditable}
325
- onClick={() => {
326
- activeEditor.dispatchCommand(UNDO_COMMAND, undefined);
327
- }}
328
- tip={false ? "Undo (⌘Z)" : "Undo (Ctrl+Z)"}
329
- type="button"
330
- aria-label="Undo"
331
- className="border-none"
332
- >
333
- <Undo2Icon className=" size-4" />
334
- </Button>
335
- <Button
336
- variant={"outline"}
337
- size={"Toolbar"}
338
- disabled={!toolbarState.canRedo || !isEditable}
339
- onClick={() => {
340
- activeEditor.dispatchCommand(REDO_COMMAND, undefined);
341
- }}
342
- tip={false ? "Redo (⇧⌘Z)" : "Redo (Ctrl+Y)"}
343
- type="button"
344
- className="toolbar-item border-none"
345
- aria-label="Redo"
346
- >
347
- <Redo2Icon className=" size-4" />
348
- </Button>
349
- </div>
350
- <Separator className="h-6 mx-2" orientation="vertical" />
351
- {toolbarState.blockType in blockTypeToBlockName &&
352
- activeEditor === editor && (
353
- <div className="flex flex-row gap-x-[5px] items-center">
354
- <BlockFormatDropDown
355
- disabled={!isEditable}
356
- blockType={toolbarState.blockType}
357
- editor={activeEditor}
358
- />
359
- <Separator orientation={"vertical"} />
360
- </div>
361
- )}
362
- <Separator className="h-6 mx-2" orientation="vertical" />
363
- {toolbarState.blockType == "code" ? (
364
- <CodeList
365
- onCodeLanguageSelect={onCodeLanguageSelect}
366
- codeLanguage={toolbarState.codeLanguage}
367
- disabled={!isEditable}
368
- />
369
- ) : (
370
- <div className="flex flex-row items-center">
371
- <FontDropDown
372
- disabled={!isEditable}
373
- style={{ fontFamily: toolbarState.fontFamily }}
374
- value={toolbarState.fontFamily}
375
- editor={activeEditor}
376
- />
377
- <Separator className="h-6 mx-2" orientation="vertical" />
378
- <FontSize
379
- selectionFontSize={toolbarState.fontSize.slice(0, -2)}
380
- editor={activeEditor}
381
- disabled={!isEditable}
382
- />
383
- <Separator className="h-6 mx-2" orientation="vertical" />
384
- <div className="flex flex-row gap-x-1">
385
- <Toggle
386
- disabled={!isEditable}
387
- variant={"outline"}
388
- size={"Toolbar"}
389
- pressed={toolbarState.isBold}
390
- onPressedChange={() => {
391
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
392
- }}
393
- tip={`Bold ${SHORTCUTS.BOLD}`}
394
- aria-label={`Format text as bold. Shortcut: ${SHORTCUTS.BOLD}`}
395
- >
396
- <Bold />
397
- </Toggle>
398
- <Toggle
399
- variant={"outline"}
400
- size={"Toolbar"}
401
- disabled={!isEditable}
402
- pressed={toolbarState.isItalic}
403
- onPressedChange={() => {
404
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "italic");
405
- }}
406
- tip={`Italic (${SHORTCUTS.ITALIC})`}
407
- type="button"
408
- aria-label={`Format text as italics. Shortcut: ${SHORTCUTS.ITALIC}`}
409
- >
410
- <Italic />
411
- </Toggle>
412
- <Toggle
413
- disabled={!isEditable}
414
- variant={"outline"}
415
- size={"Toolbar"}
416
- pressed={toolbarState.isUnderline}
417
- onPressedChange={() => {
418
- activeEditor.dispatchCommand(
419
- FORMAT_TEXT_COMMAND,
420
- "underline"
421
- );
422
- }}
423
- tip={`Underline (${SHORTCUTS.UNDERLINE})`}
424
- type="button"
425
- aria-label={`Format text to underlined. Shortcut: ${SHORTCUTS.UNDERLINE}`}
426
- >
427
- <Underline />
428
- </Toggle>
429
- <Toggle
430
- disabled={!isEditable}
431
- variant={"outline"}
432
- size={"Toolbar"}
433
- pressed={toolbarState.isCode}
434
- onPressedChange={() => {
435
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "code");
436
- }}
437
- tip={`Insert code block (${SHORTCUTS.INSERT_CODE_BLOCK})`}
438
- type="button"
439
- aria-label="Insert code block"
440
- >
441
- <Code />
442
- </Toggle>
443
- <Toggle
444
- variant={"outline"}
445
- size={"Toolbar"}
446
- disabled={!isEditable}
447
- onPressedChange={insertLink}
448
- pressed={toolbarState.isLink}
449
- aria-label="Insert link"
450
- tip={`Insert link (${SHORTCUTS.INSERT_LINK})`}
451
- type="button"
452
- >
453
- <Link />
454
- </Toggle>
455
- </div>
456
- <Separator className="h-6 mx-2" orientation="vertical" />
457
- <Color
458
- disabled={!isEditable}
459
- color={toolbarState.fontColor}
460
- bgColor={toolbarState.bgColor}
461
- editor={editor}
462
- />
463
- <BackgroundColor
464
- disabled={!isEditable}
465
- color={toolbarState.fontColor}
466
- bgColor={toolbarState.bgColor}
467
- editor={editor}
468
- />
469
- <Separator className="h-6 mx-2" orientation="vertical" />
470
- <TextFormat
471
- disabled={!isEditable}
472
- editor={editor}
473
- toolbarState={toolbarState}
474
- />
475
- <Separator className="h-6 mx-2" orientation="vertical" />
476
- <InsertNode disabled={!isEditable} editor={editor} />
477
- </div>
478
- )}
479
- <Separator className="h-6 mx-2" orientation="vertical" />
480
-
481
- <TextAlign
482
- disabled={!isEditable}
483
- value={toolbarState.elementFormat}
484
- editor={activeEditor}
485
- isRTL={toolbarState.isRTL}
486
- />
487
-
488
- {SUPPORT_SPEECH_RECOGNITION && (
489
- <Button
490
- variant={"outline"}
491
- size={"Toolbar"}
492
- type="button"
493
- onClick={() => {
494
- editor.dispatchCommand(SPEECH_TO_TEXT_COMMAND, !isSpeechToText);
495
- setIsSpeechToText(!isSpeechToText);
496
- }}
497
- className={`
498
- relative inline-flex items-center justify-center
499
- p-3 rounded-lg border-none font-medium
500
- transition-all duration-300 ease-in-out
501
- active:scale-95
502
- ${isSpeechToText
503
- ? "border-none animate-pulse bg-gray-800"
504
- : 'bg-transparent hover:bg-gray-900 cursor-pointer border-none shadow-sm hover:shadow-md'
505
- }
506
- `}
507
- title="Speech To Text"
508
- aria-label={`${isSpeechToText ? 'Disable' : 'Enable'} speech to text`}
509
- >
510
- <div className="relative z-10 flex items-center space-x-2">
511
- <Mic className={`w-4 h-4 transition-all duration-300 ${isSpeechToText ? 'animate-bounce' : ''
512
- }`} />
513
- </div>
514
- </Button>
515
- )}
516
-
517
- <ModeToggle />
518
- </div>
519
- </div>
520
- </nav>
521
- );
522
- }
@@ -1,35 +0,0 @@
1
-
2
-
3
- import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
4
- import {$insertNodeToNearestRoot} from '@lexical/utils';
5
- import {COMMAND_PRIORITY_EDITOR, createCommand, LexicalCommand} from 'lexical';
6
- import {JSX, useEffect} from 'react';
7
-
8
- import {$createTweetNode, TweetNode} from '../../nodes/TweetNode';
9
-
10
- export const INSERT_TWEET_COMMAND: LexicalCommand<string> = createCommand(
11
- 'INSERT_TWEET_COMMAND',
12
- );
13
-
14
- export default function TwitterPlugin(): JSX.Element | null {
15
- const [editor] = useLexicalComposerContext();
16
-
17
- useEffect(() => {
18
- if (!editor.hasNodes([TweetNode])) {
19
- throw new Error('TwitterPlugin: TweetNode not registered on editor');
20
- }
21
-
22
- return editor.registerCommand<string>(
23
- INSERT_TWEET_COMMAND,
24
- (payload) => {
25
- const tweetNode = $createTweetNode(payload);
26
- $insertNodeToNearestRoot(tweetNode);
27
-
28
- return true;
29
- },
30
- COMMAND_PRIORITY_EDITOR,
31
- );
32
- }, [editor]);
33
-
34
- return null;
35
- }