@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,217 +0,0 @@
1
- import {
2
- $isCodeNode,
3
- CodeNode,
4
- getLanguageFriendlyName,
5
- normalizeCodeLang,
6
- } from "@lexical/code";
7
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
8
- import {
9
- $getNearestNodeFromDOMNode,
10
- $getNodeByKey,
11
- isHTMLElement,
12
- NodeKey,
13
- } from "lexical";
14
- import { useEffect, useRef, useState } from "react";
15
- import * as React from "react";
16
- import { createPortal } from "react-dom";
17
-
18
- import { CopyButton } from "./components/CopyButton";
19
- import { canBePrettier, PrettierButton } from "./components/PrettierButton";
20
- import { useDebounce } from "./utils";
21
- import CodeList from "@/components/ui/drop-downs/code";
22
-
23
- const CODE_PADDING = 8;
24
-
25
- interface Position {
26
- top: string;
27
- right: string;
28
- }
29
-
30
- function CodeActionMenuContainer({
31
- anchorElem,
32
- }: {
33
- anchorElem: HTMLElement;
34
- }): React.JSX.Element {
35
- const [editor] = useLexicalComposerContext();
36
-
37
- const [lang, setLang] = useState("");
38
- const [isShown, setShown] = useState<boolean>(false);
39
- const [selectedElementKey, setSelectedElementKey] = useState<NodeKey | null>(
40
- null
41
- );
42
- const [shouldListenMouseMove, setShouldListenMouseMove] =
43
- useState<boolean>(false);
44
- const [position, setPosition] = useState<Position>({
45
- right: "0",
46
- top: "0",
47
- });
48
- const codeSetRef = useRef<Set<string>>(new Set());
49
- const codeDOMNodeRef = useRef<HTMLElement | null>(null);
50
-
51
- function getCodeDOMNode(): HTMLElement | null {
52
- return codeDOMNodeRef.current;
53
- }
54
-
55
- const debouncedOnMouseMove = useDebounce(
56
- (event: MouseEvent) => {
57
- const { codeDOMNode, isOutside } = getMouseInfo(event);
58
- if (isOutside) {
59
- setShown(false);
60
- return;
61
- }
62
-
63
- if (!codeDOMNode) {
64
- return;
65
- }
66
-
67
- codeDOMNodeRef.current = codeDOMNode;
68
-
69
- let codeNode: CodeNode | null = null;
70
- let _lang = "";
71
-
72
- editor.update(() => {
73
- const maybeCodeNode = $getNearestNodeFromDOMNode(codeDOMNode);
74
-
75
- if ($isCodeNode(maybeCodeNode)) {
76
- codeNode = maybeCodeNode;
77
- _lang = codeNode.getLanguage() || "";
78
- setSelectedElementKey(codeNode.getKey()); // Set the selectedElementKey
79
- }
80
- });
81
-
82
- if (codeNode) {
83
- const { y: editorElemY, right: editorElemRight } =
84
- anchorElem.getBoundingClientRect();
85
- const { y, right } = codeDOMNode.getBoundingClientRect();
86
- setLang(_lang);
87
- setShown(true);
88
- setPosition({
89
- right: `${editorElemRight - right + CODE_PADDING}px`,
90
- top: `${y - editorElemY}px`,
91
- });
92
- }
93
- },
94
- 1000,
95
- 500
96
- );
97
-
98
- useEffect(() => {
99
- if (!shouldListenMouseMove) {
100
- return;
101
- }
102
-
103
- document.addEventListener("mousemove", debouncedOnMouseMove);
104
-
105
- return () => {
106
- setShown(false);
107
- debouncedOnMouseMove.cancel();
108
- document.removeEventListener("mousemove", debouncedOnMouseMove);
109
- };
110
- }, [shouldListenMouseMove, debouncedOnMouseMove]);
111
-
112
- useEffect(() => {
113
- return editor.registerMutationListener(
114
- CodeNode,
115
- (mutations) => {
116
- editor.getEditorState().read(() => {
117
- for (const [key, type] of mutations) {
118
- switch (type) {
119
- case "created":
120
- codeSetRef.current.add(key);
121
- break;
122
-
123
- case "destroyed":
124
- codeSetRef.current.delete(key);
125
- break;
126
-
127
- default:
128
- break;
129
- }
130
- }
131
- });
132
- setShouldListenMouseMove(codeSetRef.current.size > 0);
133
- },
134
- { skipInitialization: false }
135
- );
136
- }, [editor]);
137
-
138
- const normalizedLang = normalizeCodeLang(lang);
139
- const codeFriendlyName = getLanguageFriendlyName(lang);
140
-
141
- const onCodeLanguageSelect = React.useCallback(
142
- (value: string) => {
143
- editor.update(() => {
144
- if (selectedElementKey !== null) {
145
- const node = $getNodeByKey(selectedElementKey);
146
- if ($isCodeNode(node)) {
147
- node.setLanguage(value);
148
- setLang(value);
149
- }
150
- }
151
- });
152
- },
153
- [editor, selectedElementKey]
154
- );
155
-
156
-
157
- return (
158
- <div>
159
- {isShown ? (
160
- <div
161
- className="code-action-menu-container flex flex-row items-center gap-x-2 p-2 absolute "
162
- style={{ ...position }}
163
- >
164
- <div>
165
- <CodeList
166
- codeLanguage={codeFriendlyName}
167
- disabled={!editor.isEditable()}
168
- onCodeLanguageSelect={onCodeLanguageSelect}
169
- />
170
- </div>
171
- <CopyButton editor={editor} getCodeDOMNode={getCodeDOMNode} />
172
- {canBePrettier(normalizedLang) ? (
173
- <PrettierButton
174
- editor={editor}
175
- getCodeDOMNode={getCodeDOMNode}
176
- lang={normalizedLang}
177
- />
178
- ) : null}
179
- </div>
180
- ) : null}
181
- </div>
182
- );
183
- }
184
-
185
- function getMouseInfo(event: MouseEvent): {
186
- codeDOMNode: HTMLElement | null;
187
- isOutside: boolean;
188
- } {
189
- const target = event.target;
190
-
191
- if (isHTMLElement(target)) {
192
- const codeDOMNode = target.closest<HTMLElement>(
193
- "code.line-code"
194
- );
195
- const isOutside = !(
196
- codeDOMNode ||
197
- target.closest<HTMLElement>("div.code-action-menu-container") ||
198
- target.closest<HTMLElement>("div.code-selector") ||
199
- target.closest<HTMLElement>("code.line-code")
200
- );
201
-
202
- return { codeDOMNode, isOutside };
203
- } else {
204
- return { codeDOMNode: null, isOutside: true };
205
- }
206
- }
207
-
208
- export default function CodeActionMenuPlugin({
209
- anchorElem = document.body,
210
- }: {
211
- anchorElem?: HTMLElement;
212
- }): React.ReactPortal | null {
213
- return createPortal(
214
- <CodeActionMenuContainer anchorElem={anchorElem} />,
215
- anchorElem
216
- );
217
- }
@@ -1,26 +0,0 @@
1
-
2
- import {debounce} from 'lodash-es';
3
- import {useMemo, useRef} from 'react';
4
-
5
- export function useDebounce<T extends (...args: never[]) => void>(
6
- fn: T,
7
- ms: number,
8
- maxWait?: number,
9
- ) {
10
- const funcRef = useRef<T | null>(null);
11
- funcRef.current = fn;
12
-
13
- return useMemo(
14
- () =>
15
- debounce(
16
- (...args: Parameters<T>) => {
17
- if (funcRef.current) {
18
- funcRef.current(...args);
19
- }
20
- },
21
- ms,
22
- {maxWait},
23
- ),
24
- [ms, maxWait],
25
- );
26
- }
@@ -1,21 +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 {registerCodeHighlighting} from '@lexical/code';
10
- import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
11
- import {useEffect} from 'react';
12
-
13
- export default function CodeHighlightPlugin(): JSX.Element | null {
14
- const [editor] = useLexicalComposerContext();
15
-
16
- useEffect(() => {
17
- return registerCodeHighlighting(editor);
18
- }, [editor]);
19
-
20
- return null;
21
- }
@@ -1,76 +0,0 @@
1
- .Collapsible__container {
2
- margin-bottom: 8px;
3
-
4
- }
5
-
6
- .Collapsible__title {
7
- cursor: pointer;
8
- padding: 5px 5px 5px 20px;
9
- position: relative;
10
- font-weight: bold;
11
- list-style: none;
12
- outline: none;
13
-
14
- }
15
-
16
-
17
- .Collapsible__title::marker,
18
- .Collapsible__title::-webkit-details-marker {
19
- display: none;
20
-
21
- }
22
-
23
-
24
-
25
-
26
-
27
- .dark .Collapsible__title:before {
28
- border-style: solid;
29
- border-color: transparent;
30
- border-width: 5px;
31
- border-left-color: white;
32
- display: block;
33
- content: '';
34
- position: absolute;
35
- left: 7px;
36
- top: 50%;
37
- transform: translateY(-50%);
38
- }
39
- .Collapsible__title:before {
40
- border-style: solid;
41
- border-color: transparent;
42
- border-width: 5px;
43
- border-left-color: #000;
44
- display: block;
45
- content: '';
46
- position: absolute;
47
- left: 7px;
48
- top: 50%;
49
- transform: translateY(-50%);
50
- }
51
-
52
- .dark .Collapsible__container[open] > .Collapsible__title:before {
53
- border-color: transparent;
54
- border-width: 6px 4px 0 4px;
55
- border-top-color: white;
56
-
57
-
58
- }
59
-
60
- .Collapsible__container[open] > .Collapsible__title:before {
61
- border-color: transparent;
62
- border-width: 6px 4px 0 4px;
63
- border-top-color: #000;
64
-
65
-
66
-
67
- }
68
-
69
- .Collapsible__content {
70
- padding: 0 5px 5px 20px;
71
- }
72
-
73
- .Collapsible__collapsed .Collapsible__content {
74
- display: none;
75
- user-select: none;
76
- }
@@ -1,228 +0,0 @@
1
- import "./Collapsible.css";
2
-
3
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
4
- import { $findMatchingParent, mergeRegister } from "@lexical/utils";
5
- import {
6
- $createParagraphNode,
7
- $getNodeByKey,
8
- $getPreviousSelection,
9
- $getSelection,
10
- $isElementNode,
11
- $isRangeSelection,
12
- $setSelection,
13
- COMMAND_PRIORITY_EDITOR,
14
- COMMAND_PRIORITY_LOW,
15
- createCommand,
16
- DELETE_CHARACTER_COMMAND,
17
- INSERT_PARAGRAPH_COMMAND,
18
- KEY_ARROW_DOWN_COMMAND,
19
- NodeKey
20
- } from "lexical";
21
- import { JSX, useEffect } from "react";
22
-
23
- import {
24
- $createCollapsibleContainerNode,
25
- $isCollapsibleContainerNode,
26
- CollapsibleContainerNode
27
- } from "../../nodes/CollapsibleNode/CollapsibleContainerNode";
28
- import {
29
- $createCollapsibleContentNode,
30
- $isCollapsibleContentNode,
31
- CollapsibleContentNode
32
- } from "../../nodes/CollapsibleNode/CollapsibleContentNode";
33
- import {
34
- $createCollapsibleTitleNode,
35
- $isCollapsibleTitleNode,
36
- CollapsibleTitleNode
37
- } from "../../nodes/CollapsibleNode/CollapsibleTitleNode";
38
-
39
- export const INSERT_COLLAPSIBLE_COMMAND = createCommand<void>();
40
- export const TOGGLE_COLLAPSIBLE_COMMAND = createCommand<NodeKey>();
41
-
42
- export default function CollapsiblePlugin(): JSX.Element | null {
43
- const [editor] = useLexicalComposerContext();
44
- useEffect(() => {
45
- if (
46
- !editor.hasNodes([
47
- CollapsibleContainerNode,
48
- CollapsibleTitleNode,
49
- CollapsibleContentNode
50
- ])
51
- ) {
52
- throw new Error(
53
- "CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor"
54
- );
55
- }
56
-
57
- return mergeRegister(
58
- // Structure enforcing transformers for each node type. In case nesting structure is not
59
- // "Container > Title + Content" it'll unwrap nodes and convert it back
60
- // to regular content.
61
- editor.registerNodeTransform(CollapsibleContentNode, (node) => {
62
- const parent = node.getParent();
63
- if (!$isCollapsibleContainerNode(parent)) {
64
- const children = node.getChildren();
65
- for (const child of children) {
66
- node.insertAfter(child);
67
- }
68
- node.remove();
69
- }
70
- }),
71
- editor.registerNodeTransform(CollapsibleTitleNode, (node) => {
72
- const parent = node.getParent();
73
- if (!$isCollapsibleContainerNode(parent)) {
74
- node.replace($createParagraphNode().append(...node.getChildren()));
75
- }
76
- }),
77
- editor.registerNodeTransform(CollapsibleContainerNode, (node) => {
78
- const children = node.getChildren();
79
- if (
80
- children.length !== 2 ||
81
- !$isCollapsibleTitleNode(children[0]) ||
82
- !$isCollapsibleContentNode(children[1])
83
- ) {
84
- for (const child of children) {
85
- node.insertAfter(child);
86
- }
87
- node.remove();
88
- }
89
- }),
90
- // This handles the case when container is collapsed and we delete its previous sibling
91
- // into it, it would cause collapsed content deleted (since it's display: none, and selection
92
- // swallows it when deletes single char). Instead we expand container, which is although
93
- // not perfect, but avoids bigger problem
94
- editor.registerCommand(
95
- DELETE_CHARACTER_COMMAND,
96
- () => {
97
- const selection = $getSelection();
98
- if (
99
- !$isRangeSelection(selection) ||
100
- !selection.isCollapsed() ||
101
- selection.anchor.offset !== 0
102
- ) {
103
- return false;
104
- }
105
-
106
- const anchorNode = selection.anchor.getNode();
107
- const topLevelElement = anchorNode.getTopLevelElement();
108
- if (topLevelElement === null) {
109
- return false;
110
- }
111
-
112
- const container = topLevelElement.getPreviousSibling();
113
- if (!$isCollapsibleContainerNode(container) || container.getOpen()) {
114
- return false;
115
- }
116
-
117
- container.setOpen(true);
118
- return true;
119
- },
120
- COMMAND_PRIORITY_LOW
121
- ),
122
- // When collapsible is the last child pressing down arrow will insert paragraph
123
- // below it to allow adding more content. It's similar what $insertBlockNode
124
- // (mainly for decorators), except it'll always be possible to continue adding
125
- // new content even if trailing paragraph is accidentally deleted
126
- editor.registerCommand(
127
- KEY_ARROW_DOWN_COMMAND,
128
- () => {
129
- const selection = $getSelection();
130
- if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
131
- return false;
132
- }
133
-
134
- const container = $findMatchingParent(
135
- selection.anchor.getNode(),
136
- $isCollapsibleContainerNode
137
- );
138
-
139
- if (container === null) {
140
- return false;
141
- }
142
-
143
- const parent = container.getParent();
144
- if (parent !== null && parent.getLastChild() === container) {
145
- parent.append($createParagraphNode());
146
- }
147
- return false;
148
- },
149
- COMMAND_PRIORITY_LOW
150
- ),
151
- // Handling CMD+Enter to toggle collapsible element collapsed state
152
- editor.registerCommand(
153
- INSERT_PARAGRAPH_COMMAND,
154
- () => {
155
- // @ts-ignore
156
- const windowEvent: KeyboardEvent | undefined = editor._window?.event;
157
-
158
- if (
159
- windowEvent &&
160
- (windowEvent.ctrlKey || windowEvent.metaKey) &&
161
- windowEvent.key === "Enter"
162
- ) {
163
- const selection = $getPreviousSelection();
164
- if ($isRangeSelection(selection) && selection.isCollapsed()) {
165
- const parent = $findMatchingParent(
166
- selection.anchor.getNode(),
167
- (node) => $isElementNode(node) && !node.isInline()
168
- );
169
-
170
- if ($isCollapsibleTitleNode(parent)) {
171
- const container = parent.getParent();
172
- if ($isCollapsibleContainerNode(container)) {
173
- container.toggleOpen();
174
- $setSelection(selection.clone());
175
- return true;
176
- }
177
- }
178
- }
179
- }
180
-
181
- return false;
182
- },
183
- COMMAND_PRIORITY_LOW
184
- ),
185
- editor.registerCommand(
186
- INSERT_COLLAPSIBLE_COMMAND,
187
- () => {
188
- editor.update(() => {
189
- const selection = $getSelection();
190
-
191
- if (!$isRangeSelection(selection)) {
192
- return;
193
- }
194
-
195
- const title = $createCollapsibleTitleNode();
196
- const content = $createCollapsibleContentNode().append(
197
- $createParagraphNode()
198
- );
199
- const container = $createCollapsibleContainerNode().append(
200
- title,
201
- content
202
- );
203
- selection.insertNodes([container]);
204
- title.selectStart();
205
- });
206
-
207
- return true;
208
- },
209
- COMMAND_PRIORITY_EDITOR
210
- ),
211
- editor.registerCommand(
212
- TOGGLE_COLLAPSIBLE_COMMAND,
213
- (key: NodeKey) => {
214
- editor.update(() => {
215
- const containerNode = $getNodeByKey(key);
216
- if ($isCollapsibleContainerNode(containerNode)) {
217
- containerNode.toggleOpen();
218
- }
219
- });
220
-
221
- return true;
222
- },
223
- COMMAND_PRIORITY_EDITOR
224
- )
225
- );
226
- }, [editor]);
227
- return null;
228
- }
@@ -1,44 +0,0 @@
1
-
2
- import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
3
- import {DRAG_DROP_PASTE} from '@lexical/rich-text';
4
- import {isMimeType, mediaFileReader} from '@lexical/utils';
5
- import {COMMAND_PRIORITY_LOW} from 'lexical';
6
- import {useEffect} from 'react';
7
-
8
- import {INSERT_IMAGE_COMMAND} from '../ImagesPlugin';
9
-
10
- const ACCEPTABLE_IMAGE_TYPES = [
11
- 'image/',
12
- 'image/heic',
13
- 'image/heif',
14
- 'image/gif',
15
- 'image/webp',
16
- ];
17
-
18
- export default function DragDropPaste(): null {
19
- const [editor] = useLexicalComposerContext();
20
- useEffect(() => {
21
- return editor.registerCommand(
22
- DRAG_DROP_PASTE,
23
- (files) => {
24
- (async () => {
25
- const filesResult = await mediaFileReader(
26
- files,
27
- [ACCEPTABLE_IMAGE_TYPES].flatMap((x) => x),
28
- );
29
- for (const {file, result} of filesResult) {
30
- if (isMimeType(file, ACCEPTABLE_IMAGE_TYPES)) {
31
- editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
32
- altText: file.name,
33
- src: result,
34
- });
35
- }
36
- }
37
- })();
38
- return true;
39
- },
40
- COMMAND_PRIORITY_LOW,
41
- );
42
- }, [editor]);
43
- return null;
44
- }
@@ -1,52 +0,0 @@
1
- import { cn } from '@/lib/utils';
2
- import {DraggableBlockPlugin_EXPERIMENTAL} from '@lexical/react/LexicalDraggableBlockPlugin';
3
- import { JSX, useRef} from 'react';
4
-
5
- const DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu';
6
-
7
- export default function DraggableBlockPlugin({
8
- anchorElem = document.body,
9
- className
10
- }: {
11
- anchorElem?: HTMLElement;
12
- className?:string
13
- }): JSX.Element {
14
- const menuRef = useRef<any>(null);
15
- const targetLineRef = useRef<any>(null);
16
-
17
- const isOnMenu = (element: HTMLElement): boolean => {
18
-
19
- return !!element.closest(`.${DRAGGABLE_BLOCK_MENU_CLASSNAME}`);
20
- };
21
-
22
-
23
- return (
24
- <DraggableBlockPlugin_EXPERIMENTAL
25
- anchorElem={anchorElem}
26
- menuRef={menuRef}
27
- targetLineRef={targetLineRef}
28
- menuComponent={
29
- <div ref={menuRef} className={
30
- cn("draggable-block-menu transition-all z-50 absolute top-0 -left-4",className)
31
- }>
32
- <svg
33
- xmlns="http://www.w3.org/2000/svg"
34
- className="w-4 cursor-move rounded-sm h-4 z-50"
35
- data-name="Layer 1"
36
- viewBox="0 0 24 24"
37
- fill="currentColor"
38
- >
39
- <path stroke="currentColor" d="M8.5 10a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm0 7a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm7-10a2 2 0 1 0-2-2 2 2 0 0 0 2 2Zm-7-4a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm7 14a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm0-7a2 2 0 1 0 2 2 2 2 0 0 0-2-2Z" />
40
- </svg>
41
- </div>
42
- }
43
- targetLineComponent={
44
- <div
45
- ref={targetLineRef}
46
- className="cursor-none bg-sky-600 h-1 absolute left-0 top-0 opacity-0 will-change-transform"
47
- />
48
- }
49
- isOnMenu={isOnMenu}
50
- />
51
- );
52
- }